From 2a86f54b09312db58b662b1779557466a639567f Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 17 Nov 2016 11:39:43 +0000 Subject: [PATCH] libdm: separate dm_stats_populate() error cases There are two possible errors in _dm_stats_populate_region(): * No region struct in dms->regions[region_id] * Failure to parse data from @stats_print These have very different causes: the first occurs where a client program is populating one region at a time (region_id is a single region identifier), and has not previously called dm_stats_list() to dimension the region tables; this is an API usage error. The second occurs when either we read unparseable data from the kernel (kernel bug), or where various resource allocations fail. Separate these two cases out and log separate messages for each (allocation failures in the path already have their own distinct message), since the "failed to parse.." message in the un-listed handle case is confusing and misleading. --- libdm/libdm-stats.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 55e2a42b1..ad3e6249a 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -2241,7 +2241,11 @@ static int _dm_stats_populate_region(struct dm_stats *dms, uint64_t region_id, if (!_stats_bound(dms)) return_0; - if (!region || !_stats_parse_region(dms, resp, region, region->timescale)) { + if (!region) { + log_error("Cannot populate empty handle before dm_stats_list()."); + return 0; + } + if (!_stats_parse_region(dms, resp, region, region->timescale)) { log_error("Could not parse @stats_print message response."); return 0; } -- 2.43.5