Skip to contentSkip to conversation

master - dmsetup: fix stats report command output

PATCH Bryn Reeves 1 participant 1 message Nov 1, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=925aaf0b874fd92aec1b34f42d23987f65205ff9
Commit:        925aaf0b874fd92aec1b34f42d23987f65205ff9
Parent:        19f2105b87773047854ef172de8fc48da110b2fa
Author:        Bryn M. Reeves <[email protected]>
AuthorDate:    Thu Nov 1 16:49:05 2018 +0000
Committer:     Bryn M. Reeves <[email protected]>
CommitterDate: Thu Nov 1 17:00:06 2018 +0000

dmsetup: fix stats report command output

Since the stats handle is neither bound nor listed before the attempt to call dm_stats_get_nr_regions(), it will always return
zero: this prevents reporting of any dmstats regions on any device.

Remove the dm_stats_get_nr_regions() check and instead rely on the correct return status from dm_stats_populate() which only returns 0 in the case that there are regions to inspect (and which logs a specific error for all other cases).

---
 libdm/dm-tools/dmsetup.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
libdm/dm-tools/dmsetup.c +3 -7
index 835fdcd..93714ac 100644
@@ -914,17 +914,13 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
 		if (!(obj.stats = dm_stats_create(DM_STATS_PROGRAM_ID)))
 			goto_out;
 
-		if (!dm_stats_get_nr_regions(obj.stats)) {
-			log_debug("Skipping %s with no regions.", dm_task_get_name(dmt));
+		dm_stats_bind_devno(obj.stats, info->major, info->minor);
+
+		if (!dm_stats_populate(obj.stats, _program_id, DM_STATS_REGIONS_ALL)) {
 			r = 1;
 			goto out;
 		}
 
-		dm_stats_bind_devno(obj.stats, info->major, info->minor);
-
-		if (!dm_stats_populate(obj.stats, _program_id, DM_STATS_REGIONS_ALL))
-			goto_out;
-
 		/* Update timestamps and handle end-of-interval accounting. */
 		_update_interval_times();