OpenZFS 7843 - get_clones_stat() is suboptimal for lots of clones

Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>

OpenZFS-issue: https://www.illumos.org/issues/7843
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/4d519e7
Closes #5868
This commit is contained in:
Brian Behlendorf 2017-03-07 09:47:40 -08:00 committed by GitHub
parent 3c9e0d673e
commit e2fcb56275
1 changed files with 12 additions and 1 deletions

View File

@ -1753,10 +1753,21 @@ get_clones_stat(dsl_dataset_t *ds, nvlist_t *nv)
zap_cursor_t zc; zap_cursor_t zc;
zap_attribute_t za; zap_attribute_t za;
nvlist_t *propval = fnvlist_alloc(); nvlist_t *propval = fnvlist_alloc();
nvlist_t *val = fnvlist_alloc(); nvlist_t *val;
ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool)); ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool));
/*
* We use nvlist_alloc() instead of fnvlist_alloc() because the
* latter would allocate the list with NV_UNIQUE_NAME flag.
* As a result, every time a clone name is appended to the list
* it would be (linearly) searched for for a duplicate name.
* We already know that all clone names must be unique and we
* want avoid the quadratic complexity of double-checking that
* because we can have a large number of clones.
*/
VERIFY0(nvlist_alloc(&val, 0, KM_SLEEP));
/* /*
* There may be missing entries in ds_next_clones_obj * There may be missing entries in ds_next_clones_obj
* due to a bug in a previous version of the code. * due to a bug in a previous version of the code.