]> sourceware.org Git - lvm2.git/commitdiff
hash: use individual hint sizes
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 7 Mar 2021 14:33:50 +0000 (15:33 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 8 Mar 2021 14:33:15 +0000 (15:33 +0100)
Use different 'hint' size for dm_hash_create() call - so
when debug info about hash is printed we can recognize which
hash was in use.

This patch doesn't change actual used size since that is always
rounded to be power of 2 and >=16 - so as such is only a
help to developer.

We could eventually use 'name' arg, but since this would have changed
API and this patchset will be routed to libdm & stable - we will
just use this small trick.

12 files changed:
device_mapper/libdm-deptree.c
device_mapper/libdm-report.c
lib/cache/lvmcache.c
lib/config/config.c
lib/device/dev-cache.c
lib/filters/filter-mpath.c
lib/filters/filter-persistent.c
lib/format_text/export.c
lib/format_text/format-text.c
lib/format_text/import_vsn1.c
lib/log/log.c
lib/metadata/vg.c

index 7045e1f264fa9f4a82fa3ac0be28563246d99f31..ede75ef77a4e938b194236befadb97524e5cc5b5 100644 (file)
@@ -380,13 +380,13 @@ struct dm_tree *dm_tree_create(void)
        dtree->mem = dmem;
        dtree->optional_uuid_suffixes = NULL;
 
-       if (!(dtree->devs = dm_hash_create(8))) {
+       if (!(dtree->devs = dm_hash_create(61))) {
                log_error("dtree hash creation failed");
                dm_pool_destroy(dtree->mem);
                return NULL;
        }
 
-       if (!(dtree->uuids = dm_hash_create(32))) {
+       if (!(dtree->uuids = dm_hash_create(31))) {
                log_error("dtree uuid hash creation failed");
                dm_hash_destroy(dtree->devs);
                dm_pool_destroy(dtree->mem);
index 1928354d3d90eb5ec4d8871010bc5db8a07ca353..f14aa8bc7ea6fc7039901fa9130e262f28f11f28 100644 (file)
@@ -2474,7 +2474,7 @@ dm_percent_t dm_make_percent(uint64_t numerator, uint64_t denominator)
 
 int dm_report_value_cache_set(struct dm_report *rh, const char *name, const void *data)
 {
-       if (!rh->value_cache && (!(rh->value_cache = dm_hash_create(64)))) {
+       if (!rh->value_cache && (!(rh->value_cache = dm_hash_create(63)))) {
                log_error("Failed to create cache for values used during reporting.");
                return 0;
        }
index b78262b654a1be2c727b7b0106b60fa1f41ab5df..d4acec509d0e74c7862308adec88da172096a626 100644 (file)
@@ -101,13 +101,13 @@ int lvmcache_init(struct cmd_context *cmd)
        dm_list_init(&_unused_duplicates);
        dm_list_init(&_prev_unused_duplicate_devs);
 
-       if (!(_vgname_hash = dm_hash_create(128)))
+       if (!(_vgname_hash = dm_hash_create(127)))
                return 0;
 
-       if (!(_vgid_hash = dm_hash_create(128)))
+       if (!(_vgid_hash = dm_hash_create(126)))
                return 0;
 
-       if (!(_pvid_hash = dm_hash_create(128)))
+       if (!(_pvid_hash = dm_hash_create(125)))
                return 0;
 
        return 1;
index 9725dece347620ffce6f9b261756cdb01c60f601..409555096795e7df66e7b292dd409f0c30ef6bc4 100644 (file)
@@ -1142,7 +1142,7 @@ int config_def_check(struct cft_check_handle *handle)
         * If section name is variable, use '#' as a substitute.
         */
        if (!handle->cmd->cft_def_hash) {
-               if (!(handle->cmd->cft_def_hash = dm_hash_create(64))) {
+               if (!(handle->cmd->cft_def_hash = dm_hash_create(60))) {
                        log_error("Failed to create configuration definition hash.");
                        r = 0; goto out;
                }
index 5632456bf12e78f1a23ea08f9dc5bf937ca0c156..cf6334564abdc61810d223bafbed63ec28da6eac 100644 (file)
@@ -1222,9 +1222,9 @@ int dev_cache_init(struct cmd_context *cmd)
        if (!(_cache.mem = dm_pool_create("dev_cache", 10 * 1024)))
                return_0;
 
-       if (!(_cache.names = dm_hash_create(128)) ||
-           !(_cache.vgid_index = dm_hash_create(32)) ||
-           !(_cache.lvid_index = dm_hash_create(32))) {
+       if (!(_cache.names = dm_hash_create(120)) ||
+           !(_cache.vgid_index = dm_hash_create(30)) ||
+           !(_cache.lvid_index = dm_hash_create(29))) {
                dm_pool_destroy(_cache.mem);
                _cache.mem = 0;
                return_0;
index 853a2c569c50252f5000bb05a99a8cb2f77a31a0..2022964585b2bb11f86bb5a0eda90a59e191d97d 100644 (file)
@@ -374,7 +374,7 @@ struct dev_filter *mpath_filter_create(struct dev_types *dt)
                return NULL;
        }
 
-       if (!(hash = dm_hash_create(128))) {
+       if (!(hash = dm_hash_create(110))) {
                log_error("mpath hash table creation failed.");
                return NULL;
        }
index 291f3932fbb082386511364a3277e32785d2c318..3f7007e4d5ae06fec8fef353f4a429658958b985 100644 (file)
@@ -58,7 +58,7 @@ static int _init_hash(struct pfilter *pf)
        if (pf->devices)
                dm_hash_destroy(pf->devices);
 
-       if (!(pf->devices = dm_hash_create(128)))
+       if (!(pf->devices = dm_hash_create(111)))
                return_0;
 
        return 1;
index 33844a2fd84aee92058054ee8efb5cf44bf401e5..7a95bdba4dfbc2d8b8e3253d58d2c1f4bbedd3d1 100644 (file)
@@ -960,7 +960,7 @@ static int _build_pv_names(struct formatter *f, struct volume_group *vg)
        if (!(f->mem = dm_pool_create("text pv_names", 512)))
                return_0;
 
-       if (!(f->pv_names = dm_hash_create(128)))
+       if (!(f->pv_names = dm_hash_create(115)))
                return_0;
 
        dm_list_iterate_items(pvl, &vg->pvs) {
index bf1b9b3a4c7341194332b3f8b3675287d5caa0c6..3ed6aa54a500f1ba489d263a82e2b7b4d34078c0 100644 (file)
@@ -2223,7 +2223,7 @@ static int _create_vg_text_instance(struct format_instance *fid,
                vg_name = fic->context.vg_ref.vg_name;
                vg_id = fic->context.vg_ref.vg_id;
 
-               if (!(fid->metadata_areas_index = dm_hash_create(128))) {
+               if (!(fid->metadata_areas_index = dm_hash_create(116))) {
                        log_error("Couldn't create metadata index for format "
                                  "instance of VG %s.", vg_name);
                        return 0;
index ee56502e10ffd48449c00331a17fa51870318a0c..ef25369a65ad567790e879016d6bcb00a4aec642 100644 (file)
@@ -1074,7 +1074,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
         * The pv hash memorises the pv section names -> pv
         * structures.
         */
-       if (!(pv_hash = dm_hash_create(64))) {
+       if (!(pv_hash = dm_hash_create(59))) {
                log_error("Couldn't create pv hash table.");
                goto bad;
        }
@@ -1083,7 +1083,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
         * The lv hash memorises the lv section names -> lv
         * structures.
         */
-       if (!(lv_hash = dm_hash_create(1024))) {
+       if (!(lv_hash = dm_hash_create(1023))) {
                log_error("Couldn't create lv hash table.");
                goto bad;
        }
index ebf26b4dec934d13f07253d70b58ab7d288083c5..cd676f2ae6ab156de4411686e326157f93614ef4 100644 (file)
@@ -576,7 +576,7 @@ static void _vprint_log(int level, const char *file, int line, int dm_errno_or_c
 
        if (log_once) {
                if (!_duplicated)
-                       _duplicated = dm_hash_create(128);
+                       _duplicated = dm_hash_create(117);
                if (_duplicated) {
                        if (dm_hash_lookup(_duplicated, message))
                                level = _LOG_NOTICE;
index e659579c253930bd9b1f80c32c1ed09b5e0cdb34..3f9ec8d350fbea0bd41b4c83700495444fff3dc8 100644 (file)
@@ -46,7 +46,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
        vg->vgmem = vgmem;
        vg->alloc = ALLOC_NORMAL;
 
-       if (!(vg->hostnames = dm_hash_create(16))) {
+       if (!(vg->hostnames = dm_hash_create(14))) {
                log_error("Failed to allocate VG hostname hashtable.");
                dm_pool_destroy(vgmem);
                return NULL;
This page took 0.054143 seconds and 5 git commands to generate.