summaryrefslogtreecommitdiffstats
path: root/module/zfs/space_map.c
diff options
context:
space:
mode:
authorGeorge Wilson <[email protected]>2013-06-14 22:30:35 -0500
committerBrian Behlendorf <[email protected]>2013-06-19 16:22:39 -0700
commite51be06697762215dc3b679f8668987034a5a048 (patch)
tree84446c5dbac3de2f8f9bee1fe67bb41096a6dfc8 /module/zfs/space_map.c
parentc99c90015ece64746e20b74245caca41d1dbefe1 (diff)
Illumos #3552, #3564
3552 condensing one space map burns 3 seconds of CPU in spa_sync() thread 3564 spa_sync() spends 5-10% of its time in metaslab_sync() (when not condensing) Reviewed by: Adam Leventhal <[email protected]> Reviewed by: Dan Kimmel <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Approved by: Richard Lowe <[email protected]> References: illumos/illumos-gate@16a4a8074274d2d7cc408589cf6359f4a378c861 https://www.illumos.org/issues/3552 https://www.illumos.org/issues/3564 Ported-by: Tim Chase <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #1513
Diffstat (limited to 'module/zfs/space_map.c')
-rw-r--r--module/zfs/space_map.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/module/zfs/space_map.c b/module/zfs/space_map.c
index ab7cb7a9a..a031f3a20 100644
--- a/module/zfs/space_map.c
+++ b/module/zfs/space_map.c
@@ -107,6 +107,7 @@ space_map_add(space_map_t *sm, uint64_t start, uint64_t size)
int merge_before, merge_after;
ASSERT(MUTEX_HELD(sm->sm_lock));
+ VERIFY(!sm->sm_condensing);
VERIFY(size != 0);
VERIFY3U(start, >=, sm->sm_start);
VERIFY3U(end, <=, sm->sm_start + sm->sm_size);
@@ -175,6 +176,7 @@ space_map_remove(space_map_t *sm, uint64_t start, uint64_t size)
int left_over, right_over;
ASSERT(MUTEX_HELD(sm->sm_lock));
+ VERIFY(!sm->sm_condensing);
VERIFY(size != 0);
VERIFY(P2PHASE(start, 1ULL << sm->sm_shift) == 0);
VERIFY(P2PHASE(size, 1ULL << sm->sm_shift) == 0);
@@ -244,6 +246,20 @@ space_map_contains(space_map_t *sm, uint64_t start, uint64_t size)
}
void
+space_map_swap(space_map_t **msrc, space_map_t **mdst)
+{
+ space_map_t *sm;
+
+ ASSERT(MUTEX_HELD((*msrc)->sm_lock));
+ ASSERT0((*mdst)->sm_space);
+ ASSERT0(avl_numnodes(&(*mdst)->sm_root));
+
+ sm = *msrc;
+ *msrc = *mdst;
+ *mdst = sm;
+}
+
+void
space_map_vacate(space_map_t *sm, space_map_func_t *func, space_map_t *mdest)
{
space_seg_t *ss;
@@ -424,9 +440,9 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
space_map_obj_t *smo, objset_t *os, dmu_tx_t *tx)
{
spa_t *spa = dmu_objset_spa(os);
- void *cookie = NULL;
+ avl_tree_t *t = &sm->sm_root;
space_seg_t *ss;
- uint64_t bufsize, start, size, run_len, delta, sm_space;
+ uint64_t bufsize, start, size, run_len, total, sm_space, nodes;
uint64_t *entry, *entry_map, *entry_map_end;
ASSERT(MUTEX_HELD(sm->sm_lock));
@@ -455,13 +471,14 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
SM_DEBUG_SYNCPASS_ENCODE(spa_sync_pass(spa)) |
SM_DEBUG_TXG_ENCODE(dmu_tx_get_txg(tx));
- delta = 0;
+ total = 0;
+ nodes = avl_numnodes(&sm->sm_root);
sm_space = sm->sm_space;
- while ((ss = avl_destroy_nodes(&sm->sm_root, &cookie)) != NULL) {
+ for (ss = avl_first(t); ss != NULL; ss = AVL_NEXT(t, ss)) {
size = ss->ss_end - ss->ss_start;
start = (ss->ss_start - sm->sm_start) >> sm->sm_shift;
- delta += size;
+ total += size;
size >>= sm->sm_shift;
while (size) {
@@ -483,7 +500,6 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
start += run_len;
size -= run_len;
}
- kmem_cache_free(space_seg_cache, ss);
}
if (entry != entry_map) {
@@ -499,12 +515,11 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
* Ensure that the space_map's accounting wasn't changed
* while we were in the middle of writing it out.
*/
+ VERIFY3U(nodes, ==, avl_numnodes(&sm->sm_root));
VERIFY3U(sm->sm_space, ==, sm_space);
+ VERIFY3U(sm->sm_space, ==, total);
zio_buf_free(entry_map, bufsize);
-
- sm->sm_space -= delta;
- VERIFY0(sm->sm_space);
}
void