1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2021-03-07 15:33:50 +01:00
parent 78c7ae7cd2
commit 2d64ffaee5
12 changed files with 18 additions and 18 deletions

View 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);

View 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;
}

View 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;

View 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;
}

View 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;

View 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;
}

View 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;

View 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) {

View 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;

View 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;
}

View 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;

View 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;