summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2014-10-20 18:58:45 +0000
committerdelphij <delphij@FreeBSD.org>2014-10-20 18:58:45 +0000
commitc02aa9ff18ddc7138b1999ff0eba11fc94bb5113 (patch)
treeccf0b87146fca00a2fbfc44d20ab7d50d850d41d /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
parente5880e7052e229fa5a3af2244aab73b440f0caff (diff)
downloadFreeBSD-src-c02aa9ff18ddc7138b1999ff0eba11fc94bb5113.zip
FreeBSD-src-c02aa9ff18ddc7138b1999ff0eba11fc94bb5113.tar.gz
MFC r272504: MFV r272494:
Make space_map_truncate() always do space_map_reallocate(). Without this, setting space_map_max_blksz would cause panic for existing pool, as dmu_objset_set_blocksize would fail if the object have multiple blocks. Illumos issues: 5164 space_map_max_blksz causes panic, does not work 5165 zdb fails assertion when run on pool with recently-enabled spacemap_histogram feature
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
index 2fe067b..dc15b3e 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
@@ -77,7 +77,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN,
/*
* Condensing a metaslab is not guaranteed to actually reduce the amount of
* space used on disk. In particular, a space map uses data in increments of
- * MAX(1 << ashift, SPACE_MAP_INITIAL_BLOCKSIZE), so a metaslab might use the
+ * MAX(1 << ashift, space_map_blksize), so a metaslab might use the
* same number of blocks after condensing. Since the goal of condensing is to
* reduce the number of IOPs required to read the space map, we only want to
* condense when we can be sure we will reduce the number of blocks used by the
@@ -1491,10 +1491,12 @@ metaslab_fragmentation(metaslab_t *msp)
uint64_t txg = spa_syncing_txg(spa);
vdev_t *vd = msp->ms_group->mg_vd;
- msp->ms_condense_wanted = B_TRUE;
- vdev_dirty(vd, VDD_METASLAB, msp, txg + 1);
- spa_dbgmsg(spa, "txg %llu, requesting force condense: "
- "msp %p, vd %p", txg, msp, vd);
+ if (spa_writeable(spa)) {
+ msp->ms_condense_wanted = B_TRUE;
+ vdev_dirty(vd, VDD_METASLAB, msp, txg + 1);
+ spa_dbgmsg(spa, "txg %llu, requesting force condense: "
+ "msp %p, vd %p", txg, msp, vd);
+ }
return (ZFS_FRAG_INVALID);
}
@@ -1938,6 +1940,15 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
mutex_enter(&msp->ms_lock);
+ /*
+ * Note: metaslab_condense() clears the space_map's histogram.
+ * Therefore we must verify and remove this histogram before
+ * condensing.
+ */
+ metaslab_group_histogram_verify(mg);
+ metaslab_class_histogram_verify(mg->mg_class);
+ metaslab_group_histogram_remove(mg, msp);
+
if (msp->ms_loaded && spa_sync_pass(spa) == 1 &&
metaslab_should_condense(msp)) {
metaslab_condense(msp, txg, tx);
@@ -1946,9 +1957,6 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
space_map_write(msp->ms_sm, *freetree, SM_FREE, tx);
}
- metaslab_group_histogram_verify(mg);
- metaslab_class_histogram_verify(mg->mg_class);
- metaslab_group_histogram_remove(mg, msp);
if (msp->ms_loaded) {
/*
* When the space map is loaded, we have an accruate
OpenPOWER on IntegriCloud