* 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. */
| 752 | * for synchronizing writes to the space map. |
| 753 | */ |
| 754 | void |
| 755 | space_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 | |
| 793 | static int |
| 794 | space_map_open_impl(space_map_t *sm) |
no test coverage detected