From 200b05cec0b75ebd1c6860ca7b2233b390cc2024 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 28 Jun 2024 18:04:25 -0500 Subject: [PATCH] devices: simpler bcache invalidation of PVs on LVs When a PV is stacked on an LV, the PV needs to be dropped from bcache before the LV is processed. The LV can be found in dev-cache using its name rather than the devno. --- lib/device/dev-cache.c | 6 +----- lib/label/label.c | 13 ++----------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 8dc27697b..f4176b728 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -1366,17 +1366,13 @@ int dev_cache_update_dm_uuids(void) return 1; } - /* _cache.dm_devs entries are referenced by radix trees */ - - /* TODO: if _cache.dm_devs list is small, then skip the - overhead of radix trees and just do list searches on dm_devs */ - if (!(_cache.dm_devnos = radix_tree_create(NULL, NULL)) || !(_cache.dm_uuids = radix_tree_create(NULL, NULL))) { return_0; // FIXME } /* Insert every active DM device into radix trees */ + /* _cache.dm_devs entries are referenced by radix trees */ dm_list_iterate_items(dm_dev, _cache.dm_devs) { d = _shuffle_devno(dm_dev->devno); diff --git a/lib/label/label.c b/lib/label/label.c index 6fda88dc7..52ff9a395 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -1642,19 +1642,10 @@ void label_scan_invalidate(struct device *dev) void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv) { - struct lvinfo lvinfo; struct device *dev; - dev_t devt; - /* FIXME: use dev_cache_get_existing() with the lv name, - which allow us to skip the getting devno from lv_info. */ - - if (lv_info(cmd, lv, 0, &lvinfo, 0, 0) && lvinfo.exists) { - /* FIXME: Still unclear what is it supposed to find */ - devt = MKDEV(lvinfo.major, lvinfo.minor); - if ((dev = dev_cache_get_by_devt(cmd, devt))) - label_scan_invalidate(dev); - } + if ((dev = dev_cache_get_existing(cmd, display_lvname(lv), NULL))) + label_scan_invalidate(dev); } void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)