From 4fa50f30dd61783f5e545b8b0dbf446061bc363e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 13 Oct 2024 11:11:53 +0200 Subject: [PATCH] debug: for checking how find_lv works To see whether use of 'radix_tree' for every find_lv() call helps. As if we drop radix_tree after import, this code then may fallback to old slower find_lv_in_vg. --- lib/format_text/import_vsn1.c | 6 ++++++ lib/metadata/metadata.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index 58c645660..0bc22448f 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -1318,6 +1318,12 @@ static struct volume_group *_read_vg(struct cmd_context *cmd, vg->pv_names = NULL; /* PV names are no longer valid outside of _read_vg() */ } + if (0 && vg->lv_names) { + /* TODO: update also rename function to keep lv_names always valid and usable */ + radix_tree_destroy(vg->lv_names); + vg->lv_names = NULL; + } + /* * Finished. */ diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index ab15fda44..608d1cc9b 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1671,6 +1671,11 @@ struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg, struct logical_volume *find_lv(const struct volume_group *vg, const char *lv_name) { + if (!vg->lv_names) { + struct lv_list *lvl = find_lv_in_vg(vg, lv_name); + return lvl ? lvl->lv : NULL; + } + return radix_tree_lookup_ptr(vg->lv_names, lv_name, strlen(lv_name)); }