dnode.c (196703) | dnode.c (200726) |
---|---|
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 --- 401 unchanged lines hidden (view full) --- 410 dn->dn_next_bonuslen[tx->tx_txg & TXG_MASK] = dn->dn_bonuslen; 411 dn->dn_next_blksz[tx->tx_txg & TXG_MASK] = dn->dn_datablksz; 412} 413 414void 415dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, 416 dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx) 417{ | 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 --- 401 unchanged lines hidden (view full) --- 410 dn->dn_next_bonuslen[tx->tx_txg & TXG_MASK] = dn->dn_bonuslen; 411 dn->dn_next_blksz[tx->tx_txg & TXG_MASK] = dn->dn_datablksz; 412} 413 414void 415dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, 416 dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx) 417{ |
418 int i, nblkptr; 419 dmu_buf_impl_t *db = NULL; | 418 int nblkptr; |
420 421 ASSERT3U(blocksize, >=, SPA_MINBLOCKSIZE); 422 ASSERT3U(blocksize, <=, SPA_MAXBLOCKSIZE); 423 ASSERT3U(blocksize % SPA_MINBLOCKSIZE, ==, 0); 424 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT || dmu_tx_private_ok(tx)); 425 ASSERT(tx->tx_txg != 0); 426 ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) || 427 (bonustype != DMU_OT_NONE && bonuslen != 0)); 428 ASSERT3U(bonustype, <, DMU_OT_NUMTYPES); 429 ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN); 430 | 419 420 ASSERT3U(blocksize, >=, SPA_MINBLOCKSIZE); 421 ASSERT3U(blocksize, <=, SPA_MAXBLOCKSIZE); 422 ASSERT3U(blocksize % SPA_MINBLOCKSIZE, ==, 0); 423 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT || dmu_tx_private_ok(tx)); 424 ASSERT(tx->tx_txg != 0); 425 ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) || 426 (bonustype != DMU_OT_NONE && bonuslen != 0)); 427 ASSERT3U(bonustype, <, DMU_OT_NUMTYPES); 428 ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN); 429 |
431 for (i = 0; i < TXG_SIZE; i++) 432 ASSERT(!list_link_active(&dn->dn_dirty_link[i])); 433 | |
434 /* clean up any unreferenced dbufs */ 435 dnode_evict_dbufs(dn); | 430 /* clean up any unreferenced dbufs */ 431 dnode_evict_dbufs(dn); |
436 ASSERT3P(list_head(&dn->dn_dbufs), ==, NULL); | |
437 | 432 |
438 /* 439 * XXX I should really have a generation number to tell if we 440 * need to do this... 441 */ 442 if (blocksize != dn->dn_datablksz || 443 dn->dn_bonustype != bonustype || dn->dn_bonuslen != bonuslen) { 444 /* free all old data */ 445 dnode_free_range(dn, 0, -1ULL, tx); 446 } 447 448 nblkptr = 1 + ((DN_MAX_BONUSLEN - bonuslen) >> SPA_BLKPTRSHIFT); 449 450 /* change blocksize */ | |
451 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); | 433 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); |
452 if (blocksize != dn->dn_datablksz && 453 (!BP_IS_HOLE(&dn->dn_phys->dn_blkptr[0]) || 454 list_head(&dn->dn_dbufs) != NULL)) { 455 db = dbuf_hold(dn, 0, FTAG); 456 dbuf_new_size(db, blocksize, tx); 457 } 458 dnode_setdblksz(dn, blocksize); | |
459 dnode_setdirty(dn, tx); | 434 dnode_setdirty(dn, tx); |
460 dn->dn_next_bonuslen[tx->tx_txg&TXG_MASK] = bonuslen; 461 dn->dn_next_blksz[tx->tx_txg&TXG_MASK] = blocksize; | 435 if (dn->dn_datablksz != blocksize) { 436 /* change blocksize */ 437 ASSERT(dn->dn_maxblkid == 0 && 438 (BP_IS_HOLE(&dn->dn_phys->dn_blkptr[0]) || 439 dnode_block_freed(dn, 0))); 440 dnode_setdblksz(dn, blocksize); 441 dn->dn_next_blksz[tx->tx_txg&TXG_MASK] = blocksize; 442 } 443 if (dn->dn_bonuslen != bonuslen) 444 dn->dn_next_bonuslen[tx->tx_txg&TXG_MASK] = bonuslen; 445 nblkptr = 1 + ((DN_MAX_BONUSLEN - bonuslen) >> SPA_BLKPTRSHIFT); |
462 if (dn->dn_nblkptr != nblkptr) 463 dn->dn_next_nblkptr[tx->tx_txg&TXG_MASK] = nblkptr; 464 rw_exit(&dn->dn_struct_rwlock); | 446 if (dn->dn_nblkptr != nblkptr) 447 dn->dn_next_nblkptr[tx->tx_txg&TXG_MASK] = nblkptr; 448 rw_exit(&dn->dn_struct_rwlock); |
465 if (db) 466 dbuf_rele(db, FTAG); | |
467 468 /* change type */ 469 dn->dn_type = ot; 470 471 /* change bonus size and type */ 472 mutex_enter(&dn->dn_mtx); 473 dn->dn_bonustype = bonustype; 474 dn->dn_bonuslen = bonuslen; --- 707 unchanged lines hidden (view full) --- 1182 * set yet, but there shouldn't be anything dirty. 1183 */ 1184 if (dp == NULL) 1185 return (FALSE); 1186 1187 if (dn->dn_free_txg) 1188 return (TRUE); 1189 | 449 450 /* change type */ 451 dn->dn_type = ot; 452 453 /* change bonus size and type */ 454 mutex_enter(&dn->dn_mtx); 455 dn->dn_bonustype = bonustype; 456 dn->dn_bonuslen = bonuslen; --- 707 unchanged lines hidden (view full) --- 1164 * set yet, but there shouldn't be anything dirty. 1165 */ 1166 if (dp == NULL) 1167 return (FALSE); 1168 1169 if (dn->dn_free_txg) 1170 return (TRUE); 1171 |
1190 /* 1191 * If dn_datablkshift is not set, then there's only a single 1192 * block, in which case there will never be a free range so it 1193 * won't matter. 1194 */ | |
1195 range_tofind.fr_blkid = blkid; 1196 mutex_enter(&dn->dn_mtx); 1197 for (i = 0; i < TXG_SIZE; i++) { 1198 free_range_t *range_found; 1199 avl_index_t idx; 1200 1201 range_found = avl_find(&dn->dn_ranges[i], &range_tofind, &idx); 1202 if (range_found) { --- 242 unchanged lines hidden --- | 1172 range_tofind.fr_blkid = blkid; 1173 mutex_enter(&dn->dn_mtx); 1174 for (i = 0; i < TXG_SIZE; i++) { 1175 free_range_t *range_found; 1176 avl_index_t idx; 1177 1178 range_found = avl_find(&dn->dn_ranges[i], &range_tofind, &idx); 1179 if (range_found) { --- 242 unchanged lines hidden --- |