mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
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 <ahl@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Richard Lowe <richlowe@richlowe.net> References: illumos/illumos-gate@16a4a80742 https://www.illumos.org/issues/3552 https://www.illumos.org/issues/3564 Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1513
This commit is contained in:
committed by
Brian Behlendorf
parent
c99c90015e
commit
e51be06697
+24
-9
@@ -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);
|
||||
@@ -243,6 +245,20 @@ space_map_contains(space_map_t *sm, uint64_t start, uint64_t size)
|
||||
return (ss != NULL && ss->ss_start <= start && ss->ss_end >= end);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user