1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2024-04-05 13:09:10 +02:00
parent 000f55a1a2
commit 203c8b3997
2 changed files with 8 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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,