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

Function bpobj_enqueue_subobj

freebsd/contrib/openzfs/module/zfs/bpobj.c:646–781  ·  view source on GitHub ↗

* Logically add subobj's contents to the parent bpobj. * * In the most general case, this is accomplished in constant time by adding * a reference to subobj. This case is used when enqueuing a large subobj: * +--------------+ +--------------+ * | bpobj |----------------------->| subobj list | * +----+----+----+----+----+ +-----+-----+--+--+ * | b

Source from the content-addressed store, hash-verified

644 * +----+----+----+----+---------+----+
645 */
646void
647bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
648{
649 bpobj_t subbpo;
650 uint64_t used, comp, uncomp, subsubobjs;
651 boolean_t copy_subsub = B_TRUE;
652 boolean_t copy_bps = B_TRUE;
653
654 ASSERT(bpobj_is_open(bpo));
655 ASSERT(subobj != 0);
656 ASSERT(bpo->bpo_havesubobj);
657 ASSERT(bpo->bpo_havecomp);
658 ASSERT(bpo->bpo_object != dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj);
659
660 if (subobj == dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj) {
661 bpobj_decr_empty(bpo->bpo_os, tx);
662 return;
663 }
664
665 VERIFY3U(0, ==, bpobj_open(&subbpo, bpo->bpo_os, subobj));
666 VERIFY3U(0, ==, bpobj_space(&subbpo, &used, &comp, &uncomp));
667
668 if (bpobj_is_empty(&subbpo)) {
669 /* No point in having an empty subobj. */
670 bpobj_close(&subbpo);
671 bpobj_free(bpo->bpo_os, subobj, tx);
672 return;
673 }
674
675 mutex_enter(&bpo->bpo_lock);
676 dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
677
678 dmu_object_info_t doi;
679
680 if (bpo->bpo_phys->bpo_subobjs != 0) {
681 ASSERT0(dmu_object_info(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
682 &doi));
683 ASSERT3U(doi.doi_type, ==, DMU_OT_BPOBJ_SUBOBJ);
684 }
685
686 /*
687 * If subobj has only one block of subobjs, then move subobj's
688 * subobjs to bpo's subobj list directly. This reduces recursion in
689 * bpobj_iterate due to nested subobjs.
690 */
691 subsubobjs = subbpo.bpo_phys->bpo_subobjs;
692 if (subsubobjs != 0) {
693 VERIFY0(dmu_object_info(bpo->bpo_os, subsubobjs, &doi));
694 if (doi.doi_max_offset > doi.doi_data_block_size) {
695 copy_subsub = B_FALSE;
696 }
697 }
698
699 /*
700 * If, in addition to having only one block of subobj's, subobj has
701 * only one block of bp's, then move subobj's bp's to bpo's bp list
702 * directly. This reduces recursion in bpobj_iterate due to nested
703 * subobjs.

Callers 2

dle_enqueue_subobjFunction · 0.85
dsl_deadlist_move_bpobjFunction · 0.85

Calls 15

bpobj_is_openFunction · 0.85
dmu_objset_poolFunction · 0.85
bpobj_decr_emptyFunction · 0.85
bpobj_openFunction · 0.85
bpobj_spaceFunction · 0.85
bpobj_is_emptyFunction · 0.85
bpobj_closeFunction · 0.85
bpobj_freeFunction · 0.85
mutex_enterFunction · 0.85
dmu_buf_will_dirtyFunction · 0.85
dmu_buf_holdFunction · 0.85
dmu_object_allocFunction · 0.85

Tested by

no test coverage detected