From 5551e4a1e93a3a1b0db9c24016423f231a66657d Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 1 Jul 2024 10:50:53 -0500 Subject: [PATCH] devices: update dm uuid cache naming replace "dm uuid" with "dm devs" in case it begins caching more than dm uuids. --- lib/activate/dev_manager.c | 12 ++++++------ lib/device/dev-cache.c | 18 +++++++++--------- lib/device/dev-cache.h | 6 +++--- lib/label/label.c | 2 +- lib/locking/locking.c | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 6651827e4..2fa4ce316 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -766,7 +766,7 @@ int dm_device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_ int only_error_or_zero_target = 1; int r = 0; - if (dev_cache_use_dm_uuid_cache() && + if (dev_cache_use_dm_devs_cache() && /* With cache we can avoid status calls for unusable UUIDs */ (dm_dev = dev_cache_get_dm_dev_by_devno(cmd, dev->dev)) && !_is_usable_uuid(dev, dm_dev->name, dm_dev->uuid, check.check_reserved, check.check_lv, is_lv)) @@ -897,7 +897,7 @@ int devno_dm_uuid(struct cmd_context *cmd, int major, int minor, const char *uuid; int r = 0; - if (dev_cache_use_dm_uuid_cache()) { + if (dev_cache_use_dm_devs_cache()) { if ((dm_dev = dev_cache_get_dm_dev_by_devno(cmd, MKDEV(major, minor)))) { dm_strncpy(uuid_buf, dm_dev->uuid, uuid_buf_size); return 1; @@ -1085,7 +1085,7 @@ int dev_manager_info(struct cmd_context *cmd, dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid)); - if (dev_cache_use_dm_uuid_cache() && + if (dev_cache_use_dm_devs_cache() && !dev_cache_get_dm_dev_by_uuid(cmd, dlid) && !dev_cache_get_dm_dev_by_uuid(cmd, old_style_dlid)) { log_debug("Cached as inactive %s.", name); @@ -2459,7 +2459,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, if (!(dlid = build_dm_uuid(dm->track_pending_delete ? dm->cmd->pending_delete_mem : dm->mem, lv, layer))) return_0; - if (dev_cache_use_dm_uuid_cache()) { + if (dev_cache_use_dm_devs_cache()) { if (!(dm_dev = dev_cache_get_dm_dev_by_uuid(dm->cmd, dlid))) { log_debug("Cached as not present %s.", name); return 1; @@ -2614,7 +2614,7 @@ static int _pool_callback(struct dm_tree_node *node, } } - dev_cache_destroy_dm_uuids(); + dev_cache_destroy_dm_devs(); log_debug("Running check command on %s", mpath); @@ -3998,7 +3998,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv, /* Drop any cache before DM table manipulation within locked section * TODO: check if it makes sense to manage cache within lock */ - dev_cache_destroy_dm_uuids(); + dev_cache_destroy_dm_devs(); dtree = _create_partial_dtree(dm, lv, laopts->origin_only); diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 8dc27697b..c89280e1f 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -59,7 +59,7 @@ static struct { struct radix_tree *devices; struct dm_regex *preferred_names_matcher; const char *dev_dir; - int use_dm_uuid_cache; + int use_dm_devs_cache; size_t dev_dir_len; int has_scanned; @@ -1327,14 +1327,14 @@ out: return r; } -int dev_cache_use_dm_uuid_cache(void) +int dev_cache_use_dm_devs_cache(void) { - return _cache.use_dm_uuid_cache; + return _cache.use_dm_devs_cache; } -void dev_cache_destroy_dm_uuids(void) +void dev_cache_destroy_dm_devs(void) { - _cache.use_dm_uuid_cache = 0; + _cache.use_dm_devs_cache = 0; if (_cache.dm_devnos) { radix_tree_destroy(_cache.dm_devnos); @@ -1349,13 +1349,13 @@ void dev_cache_destroy_dm_uuids(void) dm_device_list_destroy(&_cache.dm_devs); } -int dev_cache_update_dm_uuids(void) +int dev_cache_update_dm_devs(void) { struct dm_active_device *dm_dev; unsigned devs_features; uint32_t d; - dev_cache_destroy_dm_uuids(); + dev_cache_destroy_dm_devs(); if (!get_dm_active_devices(NULL, &_cache.dm_devs, &devs_features)) return 1; @@ -1391,7 +1391,7 @@ int dev_cache_update_dm_uuids(void) //radix_tree_dump(_cache.dm_devnos, stdout); //radix_tree_dump(_cache.dm_uuids, stdout); - _cache.use_dm_uuid_cache = 1; + _cache.use_dm_devs_cache = 1; return 1; } @@ -1523,7 +1523,7 @@ int dev_cache_exit(void) vt.num_open); } - dev_cache_destroy_dm_uuids(); + dev_cache_destroy_dm_devs(); if (_cache.mem) dm_pool_destroy(_cache.mem); diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 0f56ba702..a68ba757e 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -37,9 +37,9 @@ struct dev_filter { struct dm_list *dev_cache_get_dev_list_for_vgid(const char *vgid); struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid); -int dev_cache_use_dm_uuid_cache(void); -int dev_cache_update_dm_uuids(void); -void dev_cache_destroy_dm_uuids(void); +int dev_cache_use_dm_devs_cache(void); +int dev_cache_update_dm_devs(void); +void dev_cache_destroy_dm_devs(void); const struct dm_active_device * dev_cache_get_dm_dev_by_devno(struct cmd_context *cmd, dev_t devno); const struct dm_active_device * diff --git a/lib/label/label.c b/lib/label/label.c index 6fda88dc7..5e09eeff2 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -1263,7 +1263,7 @@ int label_scan(struct cmd_context *cmd) * here, before processing the hints file, so that the dm uuid checks * in hint processing can benefit from the dm uuid cache.) */ - if (!dev_cache_update_dm_uuids()) + if (!dev_cache_update_dm_devs()) return_0; /* diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 3a38c4109..1b4f579b9 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -330,7 +330,7 @@ int vg_write_lock_held(void) int sync_local_dev_names(struct cmd_context* cmd) { - dev_cache_destroy_dm_uuids(); + dev_cache_destroy_dm_devs(); memlock_unlock(cmd); fs_unlock(); return 1;