]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/vdev_removal.c
Get rid of space_map_update() for ms_synced_length
[mirror_zfs.git] / module / zfs / vdev_removal.c
index 70620499756c871d3a87f0766e248209564364f7..ff39a0a26d6a1a1d9c79f92ce293d3fa668a219e 100644 (file)
@@ -291,15 +291,8 @@ vdev_remove_initiate_sync(void *arg, dmu_tx_t *tx)
                if (ms->ms_sm == NULL)
                        continue;
 
-               /*
-                * Sync tasks happen before metaslab_sync(), therefore
-                * smp_alloc and sm_alloc must be the same.
-                */
-               ASSERT3U(space_map_allocated(ms->ms_sm), ==,
-                   ms->ms_sm->sm_phys->smp_alloc);
-
                spa->spa_removing_phys.sr_to_copy +=
-                   space_map_allocated(ms->ms_sm);
+                   metaslab_allocated_space(ms);
 
                /*
                 * Space which we are freeing this txg does not need to
@@ -1443,22 +1436,8 @@ spa_vdev_remove_thread(void *arg)
                 * appropriate action (see free_from_removing_vdev()).
                 */
                if (msp->ms_sm != NULL) {
-                       space_map_t *sm = NULL;
-
-                       /*
-                        * We have to open a new space map here, because
-                        * ms_sm's sm_length and sm_alloc may not reflect
-                        * what's in the object contents, if we are in between
-                        * metaslab_sync() and metaslab_sync_done().
-                        */
-                       VERIFY0(space_map_open(&sm,
-                           spa->spa_dsl_pool->dp_meta_objset,
-                           msp->ms_sm->sm_object, msp->ms_sm->sm_start,
-                           msp->ms_sm->sm_size, msp->ms_sm->sm_shift));
-                       space_map_update(sm);
-                       VERIFY0(space_map_load(sm, svr->svr_allocd_segs,
-                           SM_ALLOC));
-                       space_map_close(sm);
+                       VERIFY0(space_map_load(msp->ms_sm,
+                           svr->svr_allocd_segs, SM_ALLOC));
 
                        range_tree_walk(msp->ms_freeing,
                            range_tree_remove, svr->svr_allocd_segs);
@@ -1681,16 +1660,6 @@ spa_vdev_remove_cancel_sync(void *arg, dmu_tx_t *tx)
                ASSERT0(range_tree_space(msp->ms_freed));
 
                if (msp->ms_sm != NULL) {
-                       /*
-                        * Assert that the in-core spacemap has the same
-                        * length as the on-disk one, so we can use the
-                        * existing in-core spacemap to load it from disk.
-                        */
-                       ASSERT3U(msp->ms_sm->sm_alloc, ==,
-                           msp->ms_sm->sm_phys->smp_alloc);
-                       ASSERT3U(msp->ms_sm->sm_length, ==,
-                           msp->ms_sm->sm_phys->smp_objsize);
-
                        mutex_enter(&svr->svr_lock);
                        VERIFY0(space_map_load(msp->ms_sm,
                            svr->svr_allocd_segs, SM_ALLOC));
@@ -1789,9 +1758,6 @@ spa_vdev_remove_cancel(spa_t *spa)
        return (spa_vdev_remove_cancel_impl(spa));
 }
 
-/*
- * Called every sync pass of every txg if there's a svr.
- */
 void
 svr_sync(spa_t *spa, dmu_tx_t *tx)
 {