Print this page
3955 ztest failure: assertion refcount_count(&tx->tx_space_written) + delta <= tx->tx_space_towrite
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>


 431         /*
 432          * The struct_rwlock protects us against dn_nlevels
 433          * changing, in case (against all odds) we manage to dirty &
 434          * sync out the changes after we check for being dirty.
 435          * Also, dbuf_hold_impl() wants us to have the struct_rwlock.
 436          */
 437         rw_enter(&dn->dn_struct_rwlock, RW_READER);
 438         epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
 439         if (dn->dn_maxblkid == 0) {
 440                 if (off == 0 && len >= dn->dn_datablksz) {
 441                         blkid = 0;
 442                         nblks = 1;
 443                 } else {
 444                         rw_exit(&dn->dn_struct_rwlock);
 445                         return;
 446                 }
 447         } else {
 448                 blkid = off >> dn->dn_datablkshift;
 449                 nblks = (len + dn->dn_datablksz - 1) >> dn->dn_datablkshift;
 450 
 451                 if (blkid >= dn->dn_maxblkid) {
 452                         rw_exit(&dn->dn_struct_rwlock);
 453                         return;
 454                 }
 455                 if (blkid + nblks > dn->dn_maxblkid)
 456                         nblks = dn->dn_maxblkid - blkid;
 457 
 458         }
 459         l0span = nblks;    /* save for later use to calc level > 1 overhead */
 460         if (dn->dn_nlevels == 1) {
 461                 int i;
 462                 for (i = 0; i < nblks; i++) {
 463                         blkptr_t *bp = dn->dn_phys->dn_blkptr;
 464                         ASSERT3U(blkid + i, <, dn->dn_nblkptr);
 465                         bp += blkid + i;
 466                         if (dsl_dataset_block_freeable(ds, bp, bp->blk_birth)) {
 467                                 dprintf_bp(bp, "can free old%s", "");
 468                                 space += bp_get_dsize(spa, bp);
 469                         }
 470                         unref += BP_GET_ASIZE(bp);
 471                 }
 472                 nl1blks = 1;
 473                 nblks = 0;
 474         }
 475 
 476         lastblk = blkid + nblks - 1;




 431         /*
 432          * The struct_rwlock protects us against dn_nlevels
 433          * changing, in case (against all odds) we manage to dirty &
 434          * sync out the changes after we check for being dirty.
 435          * Also, dbuf_hold_impl() wants us to have the struct_rwlock.
 436          */
 437         rw_enter(&dn->dn_struct_rwlock, RW_READER);
 438         epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
 439         if (dn->dn_maxblkid == 0) {
 440                 if (off == 0 && len >= dn->dn_datablksz) {
 441                         blkid = 0;
 442                         nblks = 1;
 443                 } else {
 444                         rw_exit(&dn->dn_struct_rwlock);
 445                         return;
 446                 }
 447         } else {
 448                 blkid = off >> dn->dn_datablkshift;
 449                 nblks = (len + dn->dn_datablksz - 1) >> dn->dn_datablkshift;
 450 
 451                 if (blkid > dn->dn_maxblkid) {
 452                         rw_exit(&dn->dn_struct_rwlock);
 453                         return;
 454                 }
 455                 if (blkid + nblks > dn->dn_maxblkid)
 456                         nblks = dn->dn_maxblkid - blkid + 1;
 457 
 458         }
 459         l0span = nblks;    /* save for later use to calc level > 1 overhead */
 460         if (dn->dn_nlevels == 1) {
 461                 int i;
 462                 for (i = 0; i < nblks; i++) {
 463                         blkptr_t *bp = dn->dn_phys->dn_blkptr;
 464                         ASSERT3U(blkid + i, <, dn->dn_nblkptr);
 465                         bp += blkid + i;
 466                         if (dsl_dataset_block_freeable(ds, bp, bp->blk_birth)) {
 467                                 dprintf_bp(bp, "can free old%s", "");
 468                                 space += bp_get_dsize(spa, bp);
 469                         }
 470                         unref += BP_GET_ASIZE(bp);
 471                 }
 472                 nl1blks = 1;
 473                 nblks = 0;
 474         }
 475 
 476         lastblk = blkid + nblks - 1;