From c19dfe11a57566ed2adf7a465bc3bdca32752363 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 20 Oct 2024 20:48:56 +0200 Subject: [PATCH] debug: use just LV name for debug message Since we detect 'debug' level after calling 'log_debug()' - all the arguments are evaluated, so in this case display_lvname() was preparing a string that is not used in case debugging is not enabled. So since these string are on 'hot-path' and it's already known which VG is being worked on, in these few cases just use lv->name. --- lib/format_text/import_vsn1.c | 2 +- lib/metadata/lv_manip.c | 5 ++--- tools/toollib.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index a649f1b97..e18a0b621 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -629,7 +629,7 @@ static int _read_lvnames(struct cmd_context *cmd, if (!(lv->name = dm_pool_strdup(mem, lvn->key))) return_0; - log_debug_metadata("Importing logical volume %s.", display_lvname(lv)); + log_debug_metadata("Importing logical volume %s.", lv->name); if (!(lvn = lvn->child)) { log_error("Empty logical volume section for %s.", diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 0ec82bb31..ebc2239fc 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -868,7 +868,7 @@ int add_seg_to_segs_using_this_lv(struct logical_volume *lv, } log_very_verbose("Adding %s:" FMTu32 " as an user of %s.", - display_lvname(seg->lv), seg->le, display_lvname(lv)); + seg->lv->name, seg->le, lv->name); if (!(sl = dm_pool_zalloc(lv->vg->vgmem, sizeof(*sl)))) { log_error("Failed to allocate segment list."); @@ -1303,8 +1303,7 @@ int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num, uint64_t status) { log_very_verbose("Stack %s:" FMTu32 "[" FMTu32 "] on LV %s:" FMTu32 ".", - display_lvname(seg->lv), seg->le, area_num, - display_lvname(lv), le); + seg->lv->name, seg->le, area_num, lv->name, le); if (area_num >= seg->area_count) { log_error(INTERNAL_ERROR "Try to set to high area number (%u >= %u) for LV %s.", diff --git a/tools/toollib.c b/tools/toollib.c index 07d9ce714..dcb6c8f4f 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -3506,7 +3506,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, if (!process_lv) continue; - log_very_verbose("Adding %s to the list of LVs to be processed.", display_lvname(lvl->lv)); + log_very_verbose("Adding %s to the list of LVs to be processed.", lvl->lv->name); if (!(final_lvl = dm_pool_zalloc(cmd->mem, sizeof(struct lv_list)))) { log_error("Failed to allocate final LV list item.");