From d362a59f9e2f31b35144c236960a40712b050035 Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Fri, 2 Aug 2013 16:30:34 -0400 Subject: [PATCH 4/4] dm stats: cleaned up docs a bit and other whitespace tweaks Also, added FIXME asking why we don't just have @stats_print and @stats_clear and eliminate @stats_print_clear? Would the user _always_ want to print the stats before clearing? --- Documentation/device-mapper/dm-statistics.txt | 15 +++++++-------- drivers/md/dm-stats.c | 9 +++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Documentation/device-mapper/dm-statistics.txt b/Documentation/device-mapper/dm-statistics.txt index 8edf8b1..143c10e 100644 --- a/Documentation/device-mapper/dm-statistics.txt +++ b/Documentation/device-mapper/dm-statistics.txt @@ -24,7 +24,7 @@ Messages "" - the number of sectors in each area "/" - the range is subdivided into the specified number - of areas + of areas @stats_create message creates new region and returns the region id. @stats_print @@ -35,7 +35,7 @@ line in this form: - counters Counters have the same meaning as /sys/block/*/stat or /proc/diskstats The counter of merged requests is always zero because merging has no -meaning in device mapper. +meaning in bio-based device mapper. @stats_print_clear @@ -46,18 +46,17 @@ all the counters except the in-flight i/o counters. @stats_delete region id returned from @stats_create -Deletes the range with the specified id. +Deletes the region with the specified id. Example ======= -Subdivide the logical volume vg1/lv into 100 pieces and start collecting +Subdivide the DM device 'vol' into 100 pieces and start collecting statistics on them: -dmsetup message vg1-lv 0 @stats_create - /100 +dmsetup message vol 0 @stats_create - /100 Print the statistics: -dmsetup message vg1-lv 0 @stats_print 0 +dmsetup message vol 0 @stats_print 0 Delete the statistics: -dmsetup message vg1-lv 0 @stats_delete 0 - +dmsetup message vol 0 @stats_delete 0 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 9b9ccd7..084fee3 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -465,22 +465,18 @@ static int message_stats_create(struct mapped_device *md, * If a buffer overflow happens after we created the region, * it's too late (the userspace would retry with a larger * buffer, but the region id that caused the overflow is already - * leaked). - * So we must detect buffer overflow in advance. + * leaked). So we must detect buffer overflow in advance. */ snprintf(result, maxlen, "%d", INT_MAX); if (dm_message_test_buffer_overflow(result, maxlen)) return 1; id = dm_stats_create(dm_get_stats(md), start, end, step, - dm_internal_suspend, dm_internal_resume, - md); - + dm_internal_suspend, dm_internal_resume, md); if (id < 0) return id; snprintf(result, maxlen, "%d", id); - return 1; } @@ -531,6 +527,7 @@ int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv, r = message_stats_delete(md, argc, argv); else if (!strcasecmp(argv[0], "@stats_print")) r = message_stats_print(md, argc, argv, false, result, maxlen); + /* FIXME: why not have @stats_print + @stats_clear ? */ else if (!strcasecmp(argv[0], "@stats_print_clear")) r = message_stats_print(md, argc, argv, true, result, maxlen); else -- 1.7.1