From 203c8b3997946eea7e739a6fc872fcb3728ca9d0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 5 Apr 2024 13:09:10 +0200 Subject: [PATCH] vdo: fix status message parsing When using message API for parsing VDO stats info, 0 was wrongly used for fallback for trying the old sysfs API. Switch to use ULLONG_MAX for values that could not have been obtained through the message call. Fixes lvdisplay info for freshly created VDO volume with 0 used data blocks. --- lib/activate/dev_manager.c | 7 ++++++- lib/metadata/vdo_manip.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 55c7ebfbd..5f13b3018 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -1935,6 +1935,9 @@ static int _dev_manager_vdo_pool_message_stats(struct dev_manager *dm, { "logicalBlocksUsed", &status->logical_blocks_used } }; + for (i = 0; i < DM_ARRAY_SIZE(vme); ++i) + *vme[i].val = ULLONG_MAX; + if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv)))) return_0; @@ -1957,9 +1960,11 @@ static int _dev_manager_vdo_pool_message_stats(struct dev_manager *dm, !(p = strchr(p, ':')) || ((*vme[i].val = strtoul(p + 1, NULL, 10)) == ULLONG_MAX) || errno) { log_debug("Cannot parse %s in VDO DM stats message.", vme[i].name); - *vme[i].val = 0; + *vme[i].val = ULLONG_MAX; goto out; } + if (*vme[i].val != ULLONG_MAX) + log_debug("VDO property %s = " FMTu64, vme[i].name, *vme[i].val); } } diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c index 9930d057d..6668fe45a 100644 --- a/lib/metadata/vdo_manip.c +++ b/lib/metadata/vdo_manip.c @@ -217,10 +217,10 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_ status->vdo = result.status; if ((result.status->operating_mode == DM_VDO_MODE_NORMAL) && - (status->data_blocks_used || + ((status->data_blocks_used != ULLONG_MAX) || _sysfs_get_kvdo_value(dm_name, dminfo, "statistics/data_blocks_used", &status->data_blocks_used)) && - (status->logical_blocks_used || + ((status->logical_blocks_used != ULLONG_MAX) || _sysfs_get_kvdo_value(dm_name, dminfo, "statistics/logical_blocks_used", &status->logical_blocks_used))) { status->usage = dm_make_percent(result.status->used_blocks,