mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
3329 spa_sync() spends 10-20% of its time in spa_free_sync_cb() 3330 space_seg_t should have its own kmem_cache 3331 deferred frees should happen after sync_pass 1 3335 make SYNC_PASS_* constants tunable Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: Eric Schrock <eric.schrock@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Dan McDonald <danmcd@nexenta.com> Approved by: Eric Schrock <eric.schrock@delphix.com> References: illumos/illumos-gate@01f55e48fb https://www.illumos.org/issues/3329 https://www.illumos.org/issues/3330 https://www.illumos.org/issues/3331 https://www.illumos.org/issues/3335 Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
committed by
Brian Behlendorf
parent
5853fe790d
commit
55d85d5a8c
+34
-8
@@ -29,6 +29,23 @@
|
||||
#include <sys/zio.h>
|
||||
#include <sys/space_map.h>
|
||||
|
||||
static kmem_cache_t *space_seg_cache;
|
||||
|
||||
void
|
||||
space_map_init(void)
|
||||
{
|
||||
ASSERT(space_seg_cache == NULL);
|
||||
space_seg_cache = kmem_cache_create("space_seg_cache",
|
||||
sizeof (space_seg_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
space_map_fini(void)
|
||||
{
|
||||
kmem_cache_destroy(space_seg_cache);
|
||||
space_seg_cache = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Space map routines.
|
||||
* NOTE: caller is responsible for all locking.
|
||||
@@ -121,7 +138,7 @@ space_map_add(space_map_t *sm, uint64_t start, uint64_t size)
|
||||
avl_remove(sm->sm_pp_root, ss_after);
|
||||
}
|
||||
ss_after->ss_start = ss_before->ss_start;
|
||||
kmem_free(ss_before, sizeof (*ss_before));
|
||||
kmem_cache_free(space_seg_cache, ss_before);
|
||||
ss = ss_after;
|
||||
} else if (merge_before) {
|
||||
ss_before->ss_end = end;
|
||||
@@ -134,7 +151,7 @@ space_map_add(space_map_t *sm, uint64_t start, uint64_t size)
|
||||
avl_remove(sm->sm_pp_root, ss_after);
|
||||
ss = ss_after;
|
||||
} else {
|
||||
ss = kmem_alloc(sizeof (*ss), KM_PUSHPAGE);
|
||||
ss = kmem_cache_alloc(space_seg_cache, KM_PUSHPAGE);
|
||||
ss->ss_start = start;
|
||||
ss->ss_end = end;
|
||||
avl_insert(&sm->sm_root, ss, where);
|
||||
@@ -181,7 +198,7 @@ space_map_remove(space_map_t *sm, uint64_t start, uint64_t size)
|
||||
avl_remove(sm->sm_pp_root, ss);
|
||||
|
||||
if (left_over && right_over) {
|
||||
newseg = kmem_alloc(sizeof (*newseg), KM_PUSHPAGE);
|
||||
newseg = kmem_cache_alloc(space_seg_cache, KM_PUSHPAGE);
|
||||
newseg->ss_start = end;
|
||||
newseg->ss_end = ss->ss_end;
|
||||
ss->ss_end = start;
|
||||
@@ -194,7 +211,7 @@ space_map_remove(space_map_t *sm, uint64_t start, uint64_t size)
|
||||
ss->ss_start = end;
|
||||
} else {
|
||||
avl_remove(&sm->sm_root, ss);
|
||||
kmem_free(ss, sizeof (*ss));
|
||||
kmem_cache_free(space_seg_cache, ss);
|
||||
ss = NULL;
|
||||
}
|
||||
|
||||
@@ -234,7 +251,7 @@ space_map_vacate(space_map_t *sm, space_map_func_t *func, space_map_t *mdest)
|
||||
while ((ss = avl_destroy_nodes(&sm->sm_root, &cookie)) != NULL) {
|
||||
if (func != NULL)
|
||||
func(mdest, ss->ss_start, ss->ss_end - ss->ss_start);
|
||||
kmem_free(ss, sizeof (*ss));
|
||||
kmem_cache_free(space_seg_cache, ss);
|
||||
}
|
||||
sm->sm_space = 0;
|
||||
}
|
||||
@@ -406,7 +423,7 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
|
||||
spa_t *spa = dmu_objset_spa(os);
|
||||
void *cookie = NULL;
|
||||
space_seg_t *ss;
|
||||
uint64_t bufsize, start, size, run_len;
|
||||
uint64_t bufsize, start, size, run_len, delta, sm_space;
|
||||
uint64_t *entry, *entry_map, *entry_map_end;
|
||||
|
||||
ASSERT(MUTEX_HELD(sm->sm_lock));
|
||||
@@ -435,11 +452,13 @@ 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;
|
||||
sm_space = sm->sm_space;
|
||||
while ((ss = avl_destroy_nodes(&sm->sm_root, &cookie)) != NULL) {
|
||||
size = ss->ss_end - ss->ss_start;
|
||||
start = (ss->ss_start - sm->sm_start) >> sm->sm_shift;
|
||||
|
||||
sm->sm_space -= size;
|
||||
delta += size;
|
||||
size >>= sm->sm_shift;
|
||||
|
||||
while (size) {
|
||||
@@ -461,7 +480,7 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
|
||||
start += run_len;
|
||||
size -= run_len;
|
||||
}
|
||||
kmem_free(ss, sizeof (*ss));
|
||||
kmem_cache_free(space_seg_cache, ss);
|
||||
}
|
||||
|
||||
if (entry != entry_map) {
|
||||
@@ -473,8 +492,15 @@ space_map_sync(space_map_t *sm, uint8_t maptype,
|
||||
smo->smo_objsize += size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the space_map's accounting wasn't changed
|
||||
* while we were in the middle of writing it out.
|
||||
*/
|
||||
VERIFY3U(sm->sm_space, ==, sm_space);
|
||||
|
||||
zio_buf_free(entry_map, bufsize);
|
||||
|
||||
sm->sm_space -= delta;
|
||||
VERIFY3U(sm->sm_space, ==, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user