From 5f26c05bf21cc876741df20d07f37f6bd2929a10 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 1 Jul 2024 10:58:23 -0500 Subject: [PATCH] Revert "devices: simpler bcache invalidation of PVs on LVs" This reverts commit 200b05cec0b75ebd1c6860ca7b2233b390cc2024. Doesn't work to depend on lv name. --- lib/device/dev-cache.c | 6 +++++- lib/label/label.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index f4176b728..8dc27697b 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -1366,13 +1366,17 @@ 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 52ff9a395..6fda88dc7 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -1642,10 +1642,19 @@ 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; - if ((dev = dev_cache_get_existing(cmd, display_lvname(lv), NULL))) - label_scan_invalidate(dev); + /* 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); + } } void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)