summaryrefslogtreecommitdiff
path: root/lib/raid
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-06-16 10:48:38 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2017-06-16 17:04:01 +0200
commitb7c9ec8a24a0271e55ea5aa0c9f6525011d0fa0c (patch)
treeac11698200b5e8d77453cc5a7c92f7857ad8ec4b /lib/raid
parent59d646167f8f47fbef3231469675f52d90432205 (diff)
downloadlvm2-b7c9ec8a24a0271e55ea5aa0c9f6525011d0fa0c.tar.gz
cleanup: use 'dm_get_status_raid'
Use single 'dm' call to parse raid status. (Avoiding multiple parsers - even when we know it's slighly less efficient).
Diffstat (limited to 'lib/raid')
-rw-r--r--lib/raid/raid.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 969007cbd..c5cfb0f80 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -358,36 +358,21 @@ static int _raid_target_percent(void **target_state,
uint64_t *total_numerator,
uint64_t *total_denominator)
{
- int i;
- uint64_t numerator, denominator;
- char *pos = params;
- /*
- * Status line:
- * <raid_type> <#devs> <status_chars> <synced>/<total>
- * Example:
- * raid1 2 AA 1024000/1024000
- */
- for (i = 0; i < 3; i++) {
- pos = strstr(pos, " ");
- if (pos)
- pos++;
- else
- break;
- }
- if (!pos || (sscanf(pos, FMTu64 "/" FMTu64 "%n", &numerator, &denominator, &i) != 2) ||
- !denominator) {
- log_error("Failed to parse %s status fraction: %s",
- (seg) ? seg->segtype->name : "segment", params);
- return 0;
- }
+ struct dm_status_raid *sr;
+
+ if (!dm_get_status_raid(mem, params, &sr))
+ return_0;
- *total_numerator += numerator;
- *total_denominator += denominator;
+ *total_numerator += sr->insync_regions;
+ *total_denominator += sr->total_regions;
if (seg)
- seg->extents_copied = (uint64_t) seg->area_len * dm_make_percent(numerator, denominator) / DM_PERCENT_100;
+ seg->extents_copied = (uint64_t) seg->area_len
+ * dm_make_percent(sr->insync_regions , sr->total_regions) / DM_PERCENT_100;
+
+ *percent = dm_make_percent(sr->insync_regions, sr->total_regions);
- *percent = dm_make_percent(numerator, denominator);
+ dm_pool_free(mem, sr);
return 1;
}