| 4685 | } |
| 4686 | |
| 4687 | static void |
| 4688 | dbuf_remap_impl(dnode_t *dn, blkptr_t *bp, krwlock_t *rw, dmu_tx_t *tx) |
| 4689 | { |
| 4690 | blkptr_t bp_copy = *bp; |
| 4691 | spa_t *spa = dmu_objset_spa(dn->dn_objset); |
| 4692 | dbuf_remap_impl_callback_arg_t drica; |
| 4693 | |
| 4694 | ASSERT(dsl_pool_sync_context(spa_get_dsl(spa))); |
| 4695 | |
| 4696 | drica.drica_os = dn->dn_objset; |
| 4697 | drica.drica_blk_birth = bp->blk_birth; |
| 4698 | drica.drica_tx = tx; |
| 4699 | if (spa_remap_blkptr(spa, &bp_copy, dbuf_remap_impl_callback, |
| 4700 | &drica)) { |
| 4701 | /* |
| 4702 | * If the blkptr being remapped is tracked by a livelist, |
| 4703 | * then we need to make sure the livelist reflects the update. |
| 4704 | * First, cancel out the old blkptr by appending a 'FREE' |
| 4705 | * entry. Next, add an 'ALLOC' to track the new version. This |
| 4706 | * way we avoid trying to free an inaccurate blkptr at delete. |
| 4707 | * Note that embedded blkptrs are not tracked in livelists. |
| 4708 | */ |
| 4709 | if (dn->dn_objset != spa_meta_objset(spa)) { |
| 4710 | dsl_dataset_t *ds = dmu_objset_ds(dn->dn_objset); |
| 4711 | if (dsl_deadlist_is_open(&ds->ds_dir->dd_livelist) && |
| 4712 | bp->blk_birth > ds->ds_dir->dd_origin_txg) { |
| 4713 | ASSERT(!BP_IS_EMBEDDED(bp)); |
| 4714 | ASSERT(dsl_dir_is_clone(ds->ds_dir)); |
| 4715 | ASSERT(spa_feature_is_enabled(spa, |
| 4716 | SPA_FEATURE_LIVELIST)); |
| 4717 | bplist_append(&ds->ds_dir->dd_pending_frees, |
| 4718 | bp); |
| 4719 | bplist_append(&ds->ds_dir->dd_pending_allocs, |
| 4720 | &bp_copy); |
| 4721 | } |
| 4722 | } |
| 4723 | |
| 4724 | /* |
| 4725 | * The db_rwlock prevents dbuf_read_impl() from |
| 4726 | * dereferencing the BP while we are changing it. To |
| 4727 | * avoid lock contention, only grab it when we are actually |
| 4728 | * changing the BP. |
| 4729 | */ |
| 4730 | if (rw != NULL) |
| 4731 | rw_enter(rw, RW_WRITER); |
| 4732 | *bp = bp_copy; |
| 4733 | if (rw != NULL) |
| 4734 | rw_exit(rw); |
| 4735 | } |
| 4736 | } |
| 4737 | |
| 4738 | /* |
| 4739 | * Remap any existing BP's to concrete vdevs, if possible. |
no test coverage detected