MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dbuf_remap_impl

Function dbuf_remap_impl

freebsd/contrib/openzfs/module/zfs/dbuf.c:4687–4736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4685}
4686
4687static void
4688dbuf_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.

Callers 1

dbuf_remapFunction · 0.85

Calls 12

dmu_objset_spaFunction · 0.85
dsl_pool_sync_contextFunction · 0.85
spa_get_dslFunction · 0.85
spa_remap_blkptrFunction · 0.85
spa_meta_objsetFunction · 0.85
dmu_objset_dsFunction · 0.85
dsl_deadlist_is_openFunction · 0.85
dsl_dir_is_cloneFunction · 0.85
spa_feature_is_enabledFunction · 0.85
bplist_appendFunction · 0.85
rw_enterFunction · 0.85
rw_exitFunction · 0.85

Tested by

no test coverage detected