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

Function space_map_write

freebsd/contrib/openzfs/module/zfs/space_map.c:754–791  ·  view source on GitHub ↗

* Note: This function manipulates the state of the given space map but * does not hold any locks implicitly. Thus the caller is responsible * for synchronizing writes to the space map. */

Source from the content-addressed store, hash-verified

752 * for synchronizing writes to the space map.
753 */
754void
755space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
756 uint64_t vdev_id, dmu_tx_t *tx)
757{
758 ASSERT(dsl_pool_sync_context(dmu_objset_pool(sm->sm_os)));
759 VERIFY3U(space_map_object(sm), !=, 0);
760
761 dmu_buf_will_dirty(sm->sm_dbuf, tx);
762
763 /*
764 * This field is no longer necessary since the in-core space map
765 * now contains the object number but is maintained for backwards
766 * compatibility.
767 */
768 sm->sm_phys->smp_object = sm->sm_object;
769
770 if (range_tree_is_empty(rt)) {
771 VERIFY3U(sm->sm_object, ==, sm->sm_phys->smp_object);
772 return;
773 }
774
775 if (maptype == SM_ALLOC)
776 sm->sm_phys->smp_alloc += range_tree_space(rt);
777 else
778 sm->sm_phys->smp_alloc -= range_tree_space(rt);
779
780 uint64_t nodes = zfs_btree_numnodes(&rt->rt_root);
781 uint64_t rt_space = range_tree_space(rt);
782
783 space_map_write_impl(sm, rt, maptype, vdev_id, tx);
784
785 /*
786 * Ensure that the space_map's accounting wasn't changed
787 * while we were in the middle of writing it out.
788 */
789 VERIFY3U(nodes, ==, zfs_btree_numnodes(&rt->rt_root));
790 VERIFY3U(range_tree_space(rt), ==, rt_space);
791}
792
793static int
794space_map_open_impl(space_map_t *sm)

Callers 5

metaslab_condenseFunction · 0.85
metaslab_flushFunction · 0.85
metaslab_syncFunction · 0.85
vdev_dtl_syncFunction · 0.85

Calls 8

dsl_pool_sync_contextFunction · 0.85
dmu_objset_poolFunction · 0.85
space_map_objectFunction · 0.85
dmu_buf_will_dirtyFunction · 0.85
range_tree_is_emptyFunction · 0.85
range_tree_spaceFunction · 0.85
zfs_btree_numnodesFunction · 0.85
space_map_write_implFunction · 0.85

Tested by

no test coverage detected