dnode_sync.c (263397) | dnode_sync.c (265740) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Copyright (c) 2013 by Delphix. All rights reserved. | 24 * Copyright (c) 2012, 2014 by Delphix. All rights reserved. |
25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/dbuf.h> 29#include <sys/dnode.h> 30#include <sys/dmu.h> 31#include <sys/dmu_tx.h> 32#include <sys/dmu_objset.h> 33#include <sys/dsl_dataset.h> 34#include <sys/spa.h> | 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/dbuf.h> 29#include <sys/dnode.h> 30#include <sys/dmu.h> 31#include <sys/dmu_tx.h> 32#include <sys/dmu_objset.h> 33#include <sys/dsl_dataset.h> 34#include <sys/spa.h> |
35#include <sys/range_tree.h> |
|
35#include <sys/zfeature.h> 36 37static void 38dnode_increase_indirection(dnode_t *dn, dmu_tx_t *tx) 39{ 40 dmu_buf_impl_t *db; 41 int txgoff = tx->tx_txg & TXG_MASK; 42 int nblkptr = dn->dn_phys->dn_nblkptr; --- 270 unchanged lines hidden (view full) --- 313 arc_buf_freeze(db->db_buf); 314} 315 316/* 317 * Traverse the indicated range of the provided file 318 * and "free" all the blocks contained there. 319 */ 320static void | 36#include <sys/zfeature.h> 37 38static void 39dnode_increase_indirection(dnode_t *dn, dmu_tx_t *tx) 40{ 41 dmu_buf_impl_t *db; 42 int txgoff = tx->tx_txg & TXG_MASK; 43 int nblkptr = dn->dn_phys->dn_nblkptr; --- 270 unchanged lines hidden (view full) --- 314 arc_buf_freeze(db->db_buf); 315} 316 317/* 318 * Traverse the indicated range of the provided file 319 * and "free" all the blocks contained there. 320 */ 321static void |
321dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, | 322dnode_sync_free_range_impl(dnode_t *dn, uint64_t blkid, uint64_t nblks, |
322 dmu_tx_t *tx) 323{ 324 blkptr_t *bp = dn->dn_phys->dn_blkptr; 325 int dnlevel = dn->dn_phys->dn_nlevels; 326 boolean_t trunc = B_FALSE; 327 328 if (blkid > dn->dn_phys->dn_maxblkid) 329 return; --- 41 unchanged lines hidden (view full) --- 371 uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * 372 (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT); 373 ASSERT(off < dn->dn_phys->dn_maxblkid || 374 dn->dn_phys->dn_maxblkid == 0 || 375 dnode_next_offset(dn, 0, &off, 1, 1, 0) != 0); 376 } 377} 378 | 323 dmu_tx_t *tx) 324{ 325 blkptr_t *bp = dn->dn_phys->dn_blkptr; 326 int dnlevel = dn->dn_phys->dn_nlevels; 327 boolean_t trunc = B_FALSE; 328 329 if (blkid > dn->dn_phys->dn_maxblkid) 330 return; --- 41 unchanged lines hidden (view full) --- 372 uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * 373 (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT); 374 ASSERT(off < dn->dn_phys->dn_maxblkid || 375 dn->dn_phys->dn_maxblkid == 0 || 376 dnode_next_offset(dn, 0, &off, 1, 1, 0) != 0); 377 } 378} 379 |
380typedef struct dnode_sync_free_range_arg { 381 dnode_t *dsfra_dnode; 382 dmu_tx_t *dsfra_tx; 383} dnode_sync_free_range_arg_t; 384 385static void 386dnode_sync_free_range(void *arg, uint64_t blkid, uint64_t nblks) 387{ 388 dnode_sync_free_range_arg_t *dsfra = arg; 389 dnode_t *dn = dsfra->dsfra_dnode; 390 391 mutex_exit(&dn->dn_mtx); 392 dnode_sync_free_range_impl(dn, blkid, nblks, dsfra->dsfra_tx); 393 mutex_enter(&dn->dn_mtx); 394} 395 |
|
379/* 380 * Try to kick all the dnode's dbufs out of the cache... 381 */ 382void 383dnode_evict_dbufs(dnode_t *dn) 384{ 385 int progress; 386 int pass = 0; --- 144 unchanged lines hidden (view full) --- 531} 532 533/* 534 * Write out the dnode's dirty buffers. 535 */ 536void 537dnode_sync(dnode_t *dn, dmu_tx_t *tx) 538{ | 396/* 397 * Try to kick all the dnode's dbufs out of the cache... 398 */ 399void 400dnode_evict_dbufs(dnode_t *dn) 401{ 402 int progress; 403 int pass = 0; --- 144 unchanged lines hidden (view full) --- 548} 549 550/* 551 * Write out the dnode's dirty buffers. 552 */ 553void 554dnode_sync(dnode_t *dn, dmu_tx_t *tx) 555{ |
539 free_range_t *rp; | |
540 dnode_phys_t *dnp = dn->dn_phys; 541 int txgoff = tx->tx_txg & TXG_MASK; 542 list_t *list = &dn->dn_dirty_records[txgoff]; 543 static const dnode_phys_t zerodn = { 0 }; 544 boolean_t kill_spill = B_FALSE; 545 546 ASSERT(dmu_tx_is_syncing(tx)); 547 ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg); --- 41 unchanged lines hidden (view full) --- 589 dn->dn_next_type[txgoff] = 0; 590 } 591 592 if (dn->dn_next_blksz[txgoff] != 0) { 593 ASSERT(P2PHASE(dn->dn_next_blksz[txgoff], 594 SPA_MINBLOCKSIZE) == 0); 595 ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[0]) || 596 dn->dn_maxblkid == 0 || list_head(list) != NULL || | 556 dnode_phys_t *dnp = dn->dn_phys; 557 int txgoff = tx->tx_txg & TXG_MASK; 558 list_t *list = &dn->dn_dirty_records[txgoff]; 559 static const dnode_phys_t zerodn = { 0 }; 560 boolean_t kill_spill = B_FALSE; 561 562 ASSERT(dmu_tx_is_syncing(tx)); 563 ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg); --- 41 unchanged lines hidden (view full) --- 605 dn->dn_next_type[txgoff] = 0; 606 } 607 608 if (dn->dn_next_blksz[txgoff] != 0) { 609 ASSERT(P2PHASE(dn->dn_next_blksz[txgoff], 610 SPA_MINBLOCKSIZE) == 0); 611 ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[0]) || 612 dn->dn_maxblkid == 0 || list_head(list) != NULL || |
597 avl_last(&dn->dn_ranges[txgoff]) || | |
598 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT == | 613 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT == |
599 dnp->dn_datablkszsec); | 614 dnp->dn_datablkszsec || 615 range_tree_space(dn->dn_free_ranges[txgoff]) != 0); |
600 dnp->dn_datablkszsec = 601 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT; 602 dn->dn_next_blksz[txgoff] = 0; 603 } 604 605 if (dn->dn_next_bonuslen[txgoff] != 0) { 606 if (dn->dn_next_bonuslen[txgoff] == DN_ZERO_BONUSLEN) 607 dnp->dn_bonuslen = 0; --- 42 unchanged lines hidden (view full) --- 650 if (kill_spill) { 651 free_blocks(dn, &dn->dn_phys->dn_spill, 1, tx); 652 mutex_enter(&dn->dn_mtx); 653 dnp->dn_flags &= ~DNODE_FLAG_SPILL_BLKPTR; 654 mutex_exit(&dn->dn_mtx); 655 } 656 657 /* process all the "freed" ranges in the file */ | 616 dnp->dn_datablkszsec = 617 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT; 618 dn->dn_next_blksz[txgoff] = 0; 619 } 620 621 if (dn->dn_next_bonuslen[txgoff] != 0) { 622 if (dn->dn_next_bonuslen[txgoff] == DN_ZERO_BONUSLEN) 623 dnp->dn_bonuslen = 0; --- 42 unchanged lines hidden (view full) --- 666 if (kill_spill) { 667 free_blocks(dn, &dn->dn_phys->dn_spill, 1, tx); 668 mutex_enter(&dn->dn_mtx); 669 dnp->dn_flags &= ~DNODE_FLAG_SPILL_BLKPTR; 670 mutex_exit(&dn->dn_mtx); 671 } 672 673 /* process all the "freed" ranges in the file */ |
658 while (rp = avl_last(&dn->dn_ranges[txgoff])) { 659 dnode_sync_free_range(dn, rp->fr_blkid, rp->fr_nblks, tx); 660 /* grab the mutex so we don't race with dnode_block_freed() */ | 674 if (dn->dn_free_ranges[txgoff] != NULL) { 675 dnode_sync_free_range_arg_t dsfra; 676 dsfra.dsfra_dnode = dn; 677 dsfra.dsfra_tx = tx; |
661 mutex_enter(&dn->dn_mtx); | 678 mutex_enter(&dn->dn_mtx); |
662 avl_remove(&dn->dn_ranges[txgoff], rp); | 679 range_tree_vacate(dn->dn_free_ranges[txgoff], 680 dnode_sync_free_range, &dsfra); 681 range_tree_destroy(dn->dn_free_ranges[txgoff]); 682 dn->dn_free_ranges[txgoff] = NULL; |
663 mutex_exit(&dn->dn_mtx); | 683 mutex_exit(&dn->dn_mtx); |
664 kmem_free(rp, sizeof (free_range_t)); | |
665 } 666 667 if (freeing_dnode) { 668 dnode_sync_free(dn, tx); 669 return; 670 } 671 672 if (dn->dn_next_nblkptr[txgoff]) { --- 41 unchanged lines hidden --- | 684 } 685 686 if (freeing_dnode) { 687 dnode_sync_free(dn, tx); 688 return; 689 } 690 691 if (dn->dn_next_nblkptr[txgoff]) { --- 41 unchanged lines hidden --- |