1317 {
1318 dmu_buf_impl_t *db, *db_next;
1319 int err;
1320
1321 if (size == 0)
1322 size = SPA_MINBLOCKSIZE;
1323 if (size > SPA_MAXBLOCKSIZE)
1324 size = SPA_MAXBLOCKSIZE;
1325 else
1326 size = P2ROUNDUP(size, SPA_MINBLOCKSIZE);
1327
1328 if (ibs == dn->dn_indblkshift)
1329 ibs = 0;
1330
1331 if (size >> SPA_MINBLOCKSHIFT == dn->dn_datablkszsec && ibs == 0)
1332 return (0);
1333
1334 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
1335
1336 /* Check for any allocated blocks beyond the first */
1337 if (dn->dn_phys->dn_maxblkid != 0)
1338 goto fail;
1339
1340 mutex_enter(&dn->dn_dbufs_mtx);
1341 for (db = list_head(&dn->dn_dbufs); db; db = db_next) {
1342 db_next = list_next(&dn->dn_dbufs, db);
1343
1344 if (db->db_blkid != 0 && db->db_blkid != DMU_BONUS_BLKID &&
1345 db->db_blkid != DMU_SPILL_BLKID) {
1346 mutex_exit(&dn->dn_dbufs_mtx);
1347 goto fail;
1348 }
1349 }
1350 mutex_exit(&dn->dn_dbufs_mtx);
1351
1352 if (ibs && dn->dn_nlevels != 1)
1353 goto fail;
1354
1355 /* resize the old block */
1356 err = dbuf_hold_impl(dn, 0, 0, TRUE, FTAG, &db);
1357 if (err == 0)
|
1317 {
1318 dmu_buf_impl_t *db, *db_next;
1319 int err;
1320
1321 if (size == 0)
1322 size = SPA_MINBLOCKSIZE;
1323 if (size > SPA_MAXBLOCKSIZE)
1324 size = SPA_MAXBLOCKSIZE;
1325 else
1326 size = P2ROUNDUP(size, SPA_MINBLOCKSIZE);
1327
1328 if (ibs == dn->dn_indblkshift)
1329 ibs = 0;
1330
1331 if (size >> SPA_MINBLOCKSHIFT == dn->dn_datablkszsec && ibs == 0)
1332 return (0);
1333
1334 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
1335
1336 /* Check for any allocated blocks beyond the first */
1337 if (dn->dn_maxblkid != 0)
1338 goto fail;
1339
1340 mutex_enter(&dn->dn_dbufs_mtx);
1341 for (db = list_head(&dn->dn_dbufs); db; db = db_next) {
1342 db_next = list_next(&dn->dn_dbufs, db);
1343
1344 if (db->db_blkid != 0 && db->db_blkid != DMU_BONUS_BLKID &&
1345 db->db_blkid != DMU_SPILL_BLKID) {
1346 mutex_exit(&dn->dn_dbufs_mtx);
1347 goto fail;
1348 }
1349 }
1350 mutex_exit(&dn->dn_dbufs_mtx);
1351
1352 if (ibs && dn->dn_nlevels != 1)
1353 goto fail;
1354
1355 /* resize the old block */
1356 err = dbuf_hold_impl(dn, 0, 0, TRUE, FTAG, &db);
1357 if (err == 0)
|