main - hash: use individual hint sizes
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2d64ffaee521222e64b5c0bdfec367617e503f05 Commit: 2d64ffaee521222e64b5c0bdfec367617e503f05 Parent: 78c7ae7cd2dab7abf9ece9bec37979fa3b33c978 Author: Zdenek Kabelac <[email protected]> AuthorDate: Sun Mar 7 15:33:50 2021 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Mar 8 15:33:15 2021 +0100
hash: use individual hint sizes
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.
--- device_mapper/libdm-deptree.c | 4 ++-- device_mapper/libdm-report.c | 2 +- lib/cache/lvmcache.c | 6 +++--- lib/config/config.c | 2 +- lib/device/dev-cache.c | 6 +++--- lib/filters/filter-mpath.c | 2 +- lib/filters/filter-persistent.c | 2 +- lib/format_text/export.c | 2 +- lib/format_text/format-text.c | 2 +- lib/format_text/import_vsn1.c | 4 ++-- lib/log/log.c | 2 +- lib/metadata/vg.c | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-)
device_mapper/libdm-deptree.c +2 -2
@@ -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);
device_mapper/libdm-report.c +1 -1
@@ -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 ; }
lib/cache/lvmcache.c +3 -3
@@ -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 ;
lib/config/config.c +1 -1
@@ -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; }
lib/device/dev-cache.c +3 -3
@@ -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;
lib/filters/filter-mpath.c +1 -1
@@ -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 ; }
lib/filters/filter-persistent.c +1 -1
@@ -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 ;
lib/format_text/export.c +1 -1
@@ -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) {
lib/format_text/format-text.c +1 -1
@@ -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 ;
lib/format_text/import_vsn1.c +2 -2
@@ -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; }
lib/log/log.c +1 -1
@@ -576,7 +576,7 @@ static void _vprint_log(int level, const char *file, int line, int dm_errno_or_cif (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;
lib/metadata/vg.c +1 -1
@@ -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 ;