master - libdm: ensure dm_stats_get_area_start includes region offset
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77fae3d8522ffb...
Commit: 77fae3d8522ffb1077dcb0e2e9ebfba86cf19daf
Parent: 16ff2d927f6ce2f8c2ad8f7e6ec8fb52bd2a066c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 20:28:06 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
libdm: ensure dm_stats_get_area_start includes region offset
The dm_stats_get_area_start (and its '_current_' variant) methods
are expected to return the start sector of the area in the
containing device.
Make sure the call adds region->start to the returned value.
---
libdm/libdm-stats.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index ea4feef..51aba79 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1328,9 +1328,10 @@ uint64_t dm_stats_get_current_region_area_len(const struct dm_stats *dms,
uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
uint64_t region_id, uint64_t area_id)
{
+ struct dm_stats_region *region = &dms->regions[region_id];
if (!dms || !dms->regions)
return_0;
- *start = dms->regions[region_id].step * area_id;
+ *start = region->start + region->step * area_id;
return 1;
}
8 years, 9 months
master - dmsetup: add support for 'stats report --raw'
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=16ff2d927f6ce2...
Commit: 16ff2d927f6ce2f8c2ad8f7e6ec8fb52bd2a066c
Parent: fc7a27bc3d8c14ba696cf6893708d2715918d564
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 17:42:03 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
dmsetup: add support for 'stats report --raw'
Add a '--raw' switch to stats reports that causes us to report the
basic counter values rather than derived metrics for each visible
statistics region.
---
tools/dmsetup.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 66364ac..74e7806 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -191,6 +191,7 @@ enum {
NOUDEVSYNC_ARG,
OPTIONS_ARG,
PROGRAM_ID_ARG,
+ RAW_ARG,
READAHEAD_ARG,
REGION_ID_ARG,
RETRY_ARG,
@@ -3996,11 +3997,13 @@ static const char *default_report_options = "name,major,minor,attr,open,segments
static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
#define DEV_INFO_STATS "name,region_id"
-#define RD_STATS "reads,reads_merged,read_sectors,read_nsecs,total_rd_nsecs"
-#define WR_STATS "writes,writes_merged,write_sectors,write_nsecs,total_wr_nsecs"
-#define IO_STATS "in_progress,io_nsecs,weighted_io_nsecs"
+#define RD_COUNTERS "reads,reads_merged,read_sectors,read_nsecs,total_rd_nsecs"
+#define WR_COUNTERS "writes,writes_merged,write_sectors,write_nsecs,total_wr_nsecs"
+#define IO_COUNTERS "in_progress,io_nsecs,weighted_io_nsecs"
#define METRICS "rrqm,wrqm,rs,ws,rsize_sec,wsize_sec,arqsz,qusz,util,await,r_await,w_await"
+#define COUNTERS RD_COUNTERS "," WR_COUNTERS "," IO_COUNTERS
static const char *_stats_default_report_options = DEV_INFO_STATS ",area_id,area_start,area_len," METRICS;
+static const char *_stats_raw_report_options = DEV_INFO_STATS ",area_id,area_start,area_len," COUNTERS;
static const char *_stats_list_options = "name,region_id,region_start,region_len,area_len,area_count,program_id";
static int _report_init(const struct command *cmd, const char *subcommand)
@@ -4026,7 +4029,9 @@ static int _report_init(const struct command *cmd, const char *subcommand)
if (!strcmp(subcommand, "list"))
options = (char *) _stats_list_options;
else {
- options = (char *) _stats_default_report_options;
+ options = (char *) (!_switches[RAW_ARG])
+ ? _stats_default_report_options
+ : _stats_raw_report_options;
_report_type |= DR_STATS;
}
}
@@ -5430,6 +5435,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
{"noudevsync", 0, &ind, NOUDEVSYNC_ARG},
{"options", 1, &ind, OPTIONS_ARG},
{"programid", 1, &ind, PROGRAM_ID_ARG},
+ {"raw", 0, &ind, RAW_ARG},
{"readahead", 1, &ind, READAHEAD_ARG},
{"regionid", 1, &ind, REGION_ID_ARG},
{"retry", 0, &ind, RETRY_ARG},
@@ -5579,6 +5585,8 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
_switches[PROGRAM_ID_ARG]++;
_string_args[PROGRAM_ID_ARG] = optarg;
}
+ if (ind == RAW_ARG)
+ _switches[RAW_ARG]++;
if (ind == REGION_ID_ARG) {
_switches[REGION_ID_ARG]++;
_int_args[REGION_ID_ARG] = atoi(optarg);
8 years, 9 months
master - dmsetup: add prefixes for all report types
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fc7a27bc3d8c14...
Commit: fc7a27bc3d8c14ba696cf6893708d2715918d564
Parent: 666722324f870c7ef0fb03acb043a00567067188
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 21:14:29 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
dmsetup: add prefixes for all report types
Add prefixes to all dmsetup report types to allow the 'group_all'
option to be effective:
DR_NAME name_
DR_INFO info_
DR_DEPS deps_
DR_TREE tree_
DR_NAME splitname_
---
tools/dmsetup.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 7dd58b1..66364ac 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3877,11 +3877,11 @@ static void *_stats_get_obj(void *obj)
}
static const struct dm_report_object_type _report_types[] = {
- { DR_TASK, "Mapped Device Name", "", _task_get_obj },
- { DR_INFO, "Mapped Device Information", "", _info_get_obj },
- { DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj },
- { DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
- { DR_NAME, "Mapped Device Name Components", "", _split_name_get_obj },
+ { DR_TASK, "Mapped Device Name", "name_", _task_get_obj },
+ { DR_INFO, "Mapped Device Information", "info_", _info_get_obj },
+ { DR_DEPS, "Mapped Device Relationship Information", "deps_", _deps_get_obj },
+ { DR_TREE, "Mapped Device Relationship Information", "tree_", _tree_get_obj },
+ { DR_NAME, "Mapped Device Name Components", "splitname_", _split_name_get_obj },
{ DR_STATS, "Mapped Device Statistics","stats_", _stats_get_obj },
{ DR_STATS_META, "Mapped Device Statistics Region Information","stats_region_", _stats_get_obj },
{ 0, "", "", NULL }
8 years, 9 months
master - dmstats: add 'stat_' prefix to stats report columns
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=666722324f870c...
Commit: 666722324f870c7ef0fb03acb043a00567067188
Parent: bfb58b7e1c2d2142c0e4439d193a7ff5b07a3c67
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 17:10:47 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
dmstats: add 'stat_' prefix to stats report columns
---
tools/dmsetup.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index d386ca3..7dd58b1 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3882,8 +3882,8 @@ static const struct dm_report_object_type _report_types[] = {
{ DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj },
{ DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
{ DR_NAME, "Mapped Device Name Components", "", _split_name_get_obj },
- { DR_STATS, "Mapped Device Statistics","", _stats_get_obj },
- { DR_STATS_META, "Mapped Device Statistics Region Information","", _stats_get_obj },
+ { DR_STATS, "Mapped Device Statistics","stats_", _stats_get_obj },
+ { DR_STATS_META, "Mapped Device Statistics Region Information","stats_region_", _stats_get_obj },
{ 0, "", "", NULL }
};
@@ -4000,7 +4000,7 @@ static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
#define WR_STATS "writes,writes_merged,write_sectors,write_nsecs,total_wr_nsecs"
#define IO_STATS "in_progress,io_nsecs,weighted_io_nsecs"
#define METRICS "rrqm,wrqm,rs,ws,rsize_sec,wsize_sec,arqsz,qusz,util,await,r_await,w_await"
-static const char *_stats_default_report_options = DEV_INFO_STATS ",area_id," METRICS;
+static const char *_stats_default_report_options = DEV_INFO_STATS ",area_id,area_start,area_len," METRICS;
static const char *_stats_list_options = "name,region_id,region_start,region_len,area_len,area_count,program_id";
static int _report_init(const struct command *cmd, const char *subcommand)
8 years, 9 months
master - spec: Add cache-*.profile
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bfb58b7e1c2d21...
Commit: bfb58b7e1c2d2142c0e4439d193a7ff5b07a3c67
Parent: 8852b25fc7a676720abef99757ec073b882107a6
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Fri Aug 14 21:44:10 2015 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Aug 14 21:45:11 2015 +0200
spec: Add cache-*.profile
---
spec/packages.inc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/spec/packages.inc b/spec/packages.inc
index d781067..fc68335 100644
--- a/spec/packages.inc
+++ b/spec/packages.inc
@@ -164,6 +164,8 @@ fi
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/metadata_profile_template.profile
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/thin-generic.profile
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/thin-performance.profile
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/cache-mq.profile
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/cache-smq.profile
%dir %{_sysconfdir}/lvm/backup
%dir %{_sysconfdir}/lvm/cache
%dir %{_sysconfdir}/lvm/archive
8 years, 9 months
master - dmsetup: do not track moving average for interval estimate
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8852b25fc7a676...
Commit: 8852b25fc7a676720abef99757ec073b882107a6
Parent: 4d5b618d52f9f26537f8044bd4e6b139032c46c1
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 13:52:33 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 13:55:26 2015 +0100
dmsetup: do not track moving average for interval estimate
When run with full verbosity dmsetup or dmstats reports will
output a figure that tracks a moving average over a window of the
last two intervals:
Interval #3 time delta: 999991087ns
Interval #3 mean duration: 999907064ns, current err: -8913ns
End interval #3 duration: 999991087ns
Adjusted sample interval duration: 999991087ns
Due to the narrow window this is a very crude estimate and is only
of use to someone debugging or modifying the stats clock: remove
the value and the global variables used to track it.
Anyone with a particular use for this information can construct a
better mean by calculating the value of a greater number of
intervals.
---
tools/dmsetup.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 5472985..d386ca3 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -261,7 +261,6 @@ static struct dm_timestamp *_cycle_timestamp = NULL;
static uint64_t _interval = 0; /* configured interval in nsecs */
static uint64_t _new_interval = 0; /* flag top-of-interval */
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
-static double _mean_interval = 0.0; /* mean sample interval. */
static int _timer_fd = -1; /* timerfd file descriptor. */
/* Invalid fd value used to signal end-of-reporting. */
@@ -739,7 +738,6 @@ static int _update_interval_times(void)
/* Pretend we have the configured interval. */
delta_t = _interval;
- _mean_interval = (double) delta_t;
/* start the first cycle */
log_debug("Beginning first interval");
@@ -755,16 +753,11 @@ static int _update_interval_times(void)
_last_interval = delta_t;
_new_interval = 0;
- /* Track mean interval estimate. */
- _mean_interval = ((double) delta_t + _mean_interval) / 2.0;
-
/*
- * Log interval duration, mean duration and interval error.
+ * Log interval duration and current error.
*/
- log_debug("Interval #%-5"PRIu64" mean duration: %12.0fns, "
- "current err: "FMTi64"ns", interval_num,
- _mean_interval, ((int64_t)_last_interval
- - (int64_t)_interval));
+ log_debug("Interval #%-5"PRIu64" current err: %12"PRIi64"ns",
+ interval_num, ((int64_t)_last_interval - (int64_t)_interval));
log_debug("End interval #%-9"PRIu64" duration: %12"PRIu64"ns",
interval_num, _last_interval);
}
8 years, 9 months
master - WHATS_NEW_DM: recent commits (stats field split and timestamp headers)
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d5b618d52f9f2...
Commit: 4d5b618d52f9f26537f8044bd4e6b139032c46c1
Parent: e6724f0303b8dee0806ac799f0035d9f928441fc
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 13:20:20 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 13:43:12 2015 +0100
WHATS_NEW_DM: recent commits (stats field split and timestamp headers)
---
WHATS_NEW_DM | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f3b62b1..8e816a0 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,9 @@
Version 1.02.105 -
===================================
+ Fix 'stats list -o all' segfault
+ Separate statistics fields from region information fields
+ Add interval and interval_ns fields to DR_STATS reports.
+ Do not include internal glibc headers in libdm-timestamp.c (1.02.104)
Exit immediately if no device is supplied to dmsetup wipe_table.
Suppress dmsetup report headings when no data is output. (1.02.104)
Adjust dmsetup usage/help output selection to match command invoked.
8 years, 9 months
master - dmstats: make 'dmstats list' use common report infrastructure
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e6724f0303b8de...
Commit: e6724f0303b8dee0806ac799f0035d9f928441fc
Parent: 37dd26e322bc2fc3fa0fd7dd85d1972b08fca36c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Aug 13 23:03:46 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 13:43:12 2015 +0100
dmstats: make 'dmstats list' use common report infrastructure
Unlike 'info -c' and 'stats report' the 'dmstats list' subcommand
does its own report processing. This complicates the handling of
the DR_STATS and DR_STATS_META fields and leads to inconsistent
behaviour between the different commands. In particular it causes
'stats list' to segfault when using 'all' field options:
Segmentation fault (core dumped)
Delete _stats_list() entirely and adapt _stats_report so that it
can correctly format a DR_STATS_META-only report request.
This requires passing the subcommand into _report_init() where it
is used in addition to the command name to select the default set
of report fields for the 'list' and 'report' stats subcommands.
With this change both 'list' and 'report' dmstats report will use
the correct report object type and ensure that it is initialised
appropriately for the field selection in use.
---
tools/dmsetup.c | 147 ++++++++++++++++--------------------------------------
1 files changed, 44 insertions(+), 103 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index db2c3e4..5472985 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -252,9 +252,9 @@ static report_type_t _report_type;
static dev_name_t _dev_name_type;
static uint32_t _count = 1; /* count of repeating reports */
static struct dm_timestamp *_initial_timestamp = NULL;
-static int _stats_report_init = 0;
static uint64_t _disp_factor = 512; /* display sizes in sectors */
static char _disp_units = 's';
+const char *_program_id = DM_STATS_PROGRAM_ID; /* program_id used for reports. */
/* report timekeeping */
static struct dm_timestamp *_cycle_timestamp = NULL;
@@ -830,7 +830,7 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
dm_stats_bind_devno(obj.stats, info->major, info->minor);
- if (!(dm_stats_populate(obj.stats, DM_STATS_PROGRAM_ID, DM_STATS_REGIONS_ALL)))
+ if (!dm_stats_populate(obj.stats, _program_id, DM_STATS_REGIONS_ALL))
goto out;
/* Update timestamps and handle end-of-interval accounting. */
@@ -841,6 +841,21 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
dm_stats_set_sampling_interval_ns(obj.stats, _last_interval);
}
+ /* Only a dm_stats_list is needed for DR_STATS_META reports. */
+ if (!obj.stats && (_report_type & DR_STATS_META)) {
+ if (!(obj.stats = dm_stats_create(DM_STATS_PROGRAM_ID)))
+ goto_out;
+
+ dm_stats_bind_devno(obj.stats, info->major, info->minor);
+
+ if (!dm_stats_list(obj.stats, _program_id))
+ goto out;
+
+ /* No regions to report */
+ if (!dm_stats_get_nr_regions(obj.stats))
+ goto out;
+ }
+
/*
* Walk any statistics regions contained in the current
* reporting object: for objects with a NULL stats handle,
@@ -3995,7 +4010,7 @@ static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
static const char *_stats_default_report_options = DEV_INFO_STATS ",area_id," METRICS;
static const char *_stats_list_options = "name,region_id,region_start,region_len,area_len,area_count,program_id";
-static int _report_init(const struct command *cmd)
+static int _report_init(const struct command *cmd, const char *subcommand)
{
char *options = (char *) default_report_options;
char *opt_fields = NULL; /* optional fields from command line */
@@ -4014,8 +4029,13 @@ static int _report_init(const struct command *cmd)
}
if (cmd && !strcmp(cmd->name, "stats")) {
- options = (char *) _stats_default_report_options;
- _report_type |= (DR_STATS | DR_STATS_META);
+ _report_type |= DR_STATS_META;
+ if (!strcmp(subcommand, "list"))
+ options = (char *) _stats_list_options;
+ else {
+ options = (char *) _stats_default_report_options;
+ _report_type |= DR_STATS;
+ }
}
if (cmd && !strcmp(cmd->name, "list")) {
@@ -4642,91 +4662,6 @@ out:
return 0;
}
-static int _stats_list(CMD_ARGS)
-{
- struct dm_stats *dms;
- const char *name, *program_id = DM_STATS_PROGRAM_ID;
- struct dm_task *dmt = NULL;
- struct dm_info info;
- struct dmsetup_report_obj obj;
-
- if (names)
- name = names->name;
- else {
- if (!argc && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
- return _process_all(cmd, subcommand, argc, argv, 0, _stats_list);
- name = argv[0];
- }
-
- if (_switches[PROGRAM_ID_ARG])
- program_id = _string_args[PROGRAM_ID_ARG];
-
- if (_switches[ALL_PROGRAMS_ARG])
- program_id = "";
-
- if (_switches[OPTIONS_ARG] && !strcmp(_string_args[OPTIONS_ARG], "help"))
- /* field help already output from _report_init(). */
- return 1;
-
- if (!(dms = dm_stats_create(DM_STATS_PROGRAM_ID)))
- return_0;
-
- if (!_bind_stats_device(dms, name))
- goto_out;
-
- if (!dm_stats_list(dms, program_id)) {
- log_error("Could not list statistics regions.");
- goto out;
- }
-
- if (_report && !_stats_report_init) {
- dm_report_free(_report);
- _report_init(cmd);
- _stats_report_init = 1;
- }
-
- if (!dm_stats_get_nr_regions(dms)) {
- log_info("No statistics regions present.");
- goto none;
- }
-
- if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
- return 0;
-
- if (!_set_task_device(dmt, name, 0))
- goto out;
-
- if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
- goto out;
-
- if (!_task_run(dmt))
- goto out;
-
- if (!dm_task_get_info(dmt, &info))
- goto out;
-
- obj.task = dmt;
- obj.stats = dms;
- obj.info = &info;
-
- dm_stats_walk_do(obj.stats) {
- dm_report_object(_report, &obj);
- dm_stats_walk_next_region(obj.stats);
- } dm_stats_walk_while(obj.stats);
-
- dm_task_destroy(dmt);
-
-none:
- dm_stats_destroy(dms);
- return 1;
-
-out:
- if (dmt)
- dm_task_destroy(dmt);
- dm_stats_destroy(dms);
- return 0;
-}
-
static int _stats_print(CMD_ARGS)
{
struct dm_stats *dms;
@@ -4805,6 +4740,12 @@ static int _stats_report(CMD_ARGS)
struct dm_task *dmt;
char *name = NULL;
+ if (_switches[PROGRAM_ID_ARG])
+ _program_id = _string_args[PROGRAM_ID_ARG];
+
+ if (_switches[ALL_PROGRAMS_ARG])
+ _program_id = "";
+
if (names)
name = names->name;
else {
@@ -4869,7 +4810,7 @@ static struct command _stats_subcommands[] = {
{"clear", "--regionid <id> [<device>]", 0, -1, 1, 0, _stats_clear},
{"create", CREATE_OPTS "\n\t\t" ID_OPTS "[<device>]", 0, -1, 1, 0, _stats_create},
{"delete", "--regionid <id> <device>", 1, -1, 1, 0, _stats_delete},
- {"list", "[--programid <id>] [<device>]", 0, -1, 1, 0, _stats_list},
+ {"list", "[--programid <id>] [<device>]", 0, -1, 1, 0, _stats_report},
{"print", PRINT_OPTS "[<device>]", 0, -1, 1, 0, _stats_print},
{"report", REPORT_OPTS "[<device>]", 0, -1, 1, 0, _stats_report},
{"version", "", 0, -1, 1, 0, _version},
@@ -5025,7 +4966,7 @@ static int _stats_help(CMD_ARGS)
_report = NULL;
}
- (void) _report_init(cmd);
+ (void) _report_init(cmd, "help");
if (_report) {
dm_report_free(_report);
_report = NULL;
@@ -5048,7 +4989,7 @@ static int _dmsetup_help(CMD_ARGS)
dm_report_free(_report);
_report = NULL;
}
- (void) _report_init(cmd);
+ (void) _report_init(cmd, "");
if (_report) {
dm_report_free(_report);
_report = NULL;
@@ -5964,7 +5905,16 @@ unknown:
goto out;
#endif
- if (_switches[COLS_ARG] && !_report_init(cmd))
+ /*
+ * Extract subcommand?
+ * dmsetup <command> <subcommand> [args...]
+ */
+ if (cmd->has_subcommands) {
+ subcommand = argv[0];
+ argc--, argv++;
+ }
+
+ if (_switches[COLS_ARG] && !_report_init(cmd, subcommand))
goto out;
if (_switches[COUNT_ARG])
@@ -5981,15 +5931,6 @@ unknown:
}
}
- /*
- * Extract subcommand?
- * dmsetup <command> <subcommand> [args...]
- */
- if (cmd->has_subcommands) {
- subcommand = argv[0];
- argc--, argv++;
- }
-
/* Start interval timer. */
if (_count > 1)
if (!_start_timer())
8 years, 9 months
master - dmstats: separate stats meta fields into their own report type
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=37dd26e322bc2f...
Commit: 37dd26e322bc2fc3fa0fd7dd85d1972b08fca36c
Parent: f10ad95c3678f51c26ed55216f4337e78c992375
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Aug 13 21:14:57 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 13:43:03 2015 +0100
dmstats: separate stats meta fields into their own report type
Although statistics and meta fields (region and area properties) share
the same object type the state of the handle they expect differs: meta
only expects a dm_stats_list() operation to have been performed whereas
statistics require a fully populated handle.
Distinguish between these requirements by separating the fields into
two distinct report types:
DR_STATS = 32,
DR_STATS_META = 64
The new category is described as "Mapped Device Statistics Region
Information" in the help text.
---
tools/dmsetup.c | 102 ++++++++++++++++++++++++++++--------------------------
1 files changed, 53 insertions(+), 49 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 68ca7e0..db2c3e4 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -222,7 +222,8 @@ typedef enum {
DR_DEPS = 4,
DR_TREE = 8, /* Complete dependency tree required */
DR_NAME = 16,
- DR_STATS = 32,
+ DR_STATS = 32, /* Requires populated stats handle. */
+ DR_STATS_META = 64, /* Requires listed stats handle. */
} report_type_t;
typedef enum {
@@ -3376,39 +3377,6 @@ static int _dm_stats_aux_data_disp(struct dm_report *rh,
return dm_report_field_string(rh, field, (const char * const*) &aux_data);
}
-static int _dm_stats_sample_interval_ns_disp(struct dm_report *rh,
- struct dm_pool *mem __attribute__((unused)),
- struct dm_report_field *field, const void *data,
- void *private __attribute__((unused)))
-{
- /* FIXME: use internal interval estimate when supported by libdm */
- return dm_report_field_uint64(rh, field, &_last_interval);
-}
-
-static int _dm_stats_sample_interval_disp(struct dm_report *rh,
- struct dm_pool *mem __attribute__((unused)),
- struct dm_report_field *field, const void *data,
- void *private __attribute__((unused)))
-{
- char buf[64];
- char *repstr;
- double *sortval;
-
- if (!(sortval = dm_pool_alloc(mem, sizeof(*sortval))))
- return_0;
-
- *sortval = (double)_last_interval / (double) NSEC_PER_SEC;
-
- if (!dm_snprintf(buf, sizeof(buf), "%2.6f", *sortval))
- return_0;
-
- if (!(repstr = dm_pool_strdup(mem, buf)))
- return_0;
-
- dm_report_field_set_value(field, repstr, sortval);
- return 1;
-}
-
static int _dm_stats_rrqm_disp(struct dm_report *rh,
struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field, const void *data,
@@ -3837,6 +3805,39 @@ static int _dm_stats_util_disp(struct dm_report *rh,
return 1;
}
+static int _dm_stats_sample_interval_ns_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute__((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private __attribute__((unused)))
+{
+ /* FIXME: use internal interval estimate when supported by libdm */
+ return dm_report_field_uint64(rh, field, &_last_interval);
+}
+
+static int _dm_stats_sample_interval_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute__((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private __attribute__((unused)))
+{
+ char buf[64];
+ char *repstr;
+ double *sortval;
+
+ if (!(sortval = dm_pool_alloc(mem, sizeof(*sortval))))
+ return_0;
+
+ *sortval = (double)_last_interval / (double) NSEC_PER_SEC;
+
+ if (!dm_snprintf(buf, sizeof(buf), "%2.6f", *sortval))
+ return_0;
+
+ if (!(repstr = dm_pool_strdup(mem, buf)))
+ return_0;
+
+ dm_report_field_set_value(field, repstr, sortval);
+ return 1;
+}
+
static void *_task_get_obj(void *obj)
{
return ((struct dmsetup_report_obj *)obj)->task;
@@ -3874,6 +3875,7 @@ static const struct dm_report_object_type _report_types[] = {
{ DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
{ DR_NAME, "Mapped Device Name Components", "", _split_name_get_obj },
{ DR_STATS, "Mapped Device Statistics","", _stats_get_obj },
+ { DR_STATS_META, "Mapped Device Statistics Region Information","", _stats_get_obj },
{ 0, "", "", NULL }
};
@@ -3940,19 +3942,6 @@ FIELD_F(STATS, NUM, "WtIoNsec", 8, dm_stats_weighted_io_nsecs, "weighted_io_nsec
FIELD_F(STATS, NUM, "TotalRdNsec", 8, dm_stats_total_read_nsecs, "total_rd_nsecs", "Total time spent reading.")
FIELD_F(STATS, NUM, "TotalWrNsec", 8, dm_stats_total_write_nsecs, "total_wr_nsecs", "Total time spent writing.")
-/* Stats report meta-fields */
-FIELD_F(STATS, NUM, "RgID", 5, dm_stats_region_id, "region_id", "Region ID.")
-FIELD_F(STATS, SIZ, "RStart", 5, dm_stats_region_start, "region_start", "Region start.")
-FIELD_F(STATS, SIZ, "RSize", 5, dm_stats_region_len, "region_len", "Region length.")
-FIELD_F(STATS, NUM, "ArID", 5, dm_stats_area_id, "area_id", "Area ID.")
-FIELD_F(STATS, SIZ, "AStrt", 5, dm_stats_area_start, "area_start", "Area start.")
-FIELD_F(STATS, SIZ, "ASize", 5, dm_stats_area_len, "area_len", "Area length.")
-FIELD_F(STATS, NUM, "#Areas", 6, dm_stats_area_count, "area_count", "Area count.")
-FIELD_F(STATS, STR, "ProgID", 6, dm_stats_program_id, "program_id", "Program ID.")
-FIELD_F(STATS, STR, "AuxDat", 6, dm_stats_aux_data, "aux_data", "Auxiliary data.")
-FIELD_F(STATS, NUM, "IntervalNSec", 10, dm_stats_sample_interval_ns, "interval_ns", "Sampling interval in nanoseconds.")
-FIELD_F(STATS, NUM, "Interval", 8, dm_stats_sample_interval, "interval", "Sampling interval.")
-
/* Stats derived metrics */
FIELD_F(STATS, NUM, "RRqM/s", 8, dm_stats_rrqm, "rrqm", "Read requests merged per second.")
FIELD_F(STATS, NUM, "WRqM/s", 8, dm_stats_wrqm, "wrqm", "Write requests merged per second.")
@@ -3969,6 +3958,21 @@ FIELD_F(STATS, NUM, "TPut", 5, dm_stats_tput, "tput", "Throughput.")
FIELD_F(STATS, NUM, "SvcTm", 5, dm_stats_svctm, "svctm", "Service time.")
FIELD_F(STATS, NUM, "Util%", 10, dm_stats_util, "util", "Utilization.")
+/* Stats interval duration estimates */
+FIELD_F(STATS, NUM, "IntervalNSec", 10, dm_stats_sample_interval_ns, "interval_ns", "Sampling interval in nanoseconds.")
+FIELD_F(STATS, NUM, "Interval", 8, dm_stats_sample_interval, "interval", "Sampling interval.")
+
+/* Stats report meta-fields */
+FIELD_F(STATS_META, NUM, "RgID", 5, dm_stats_region_id, "region_id", "Region ID.")
+FIELD_F(STATS_META, SIZ, "RStart", 5, dm_stats_region_start, "region_start", "Region start.")
+FIELD_F(STATS_META, SIZ, "RSize", 5, dm_stats_region_len, "region_len", "Region length.")
+FIELD_F(STATS_META, NUM, "ArID", 5, dm_stats_area_id, "area_id", "Area ID.")
+FIELD_F(STATS_META, SIZ, "AStrt", 5, dm_stats_area_start, "area_start", "Area start.")
+FIELD_F(STATS_META, SIZ, "ASize", 5, dm_stats_area_len, "area_len", "Area length.")
+FIELD_F(STATS_META, NUM, "#Areas", 6, dm_stats_area_count, "area_count", "Area count.")
+FIELD_F(STATS_META, STR, "ProgID", 6, dm_stats_program_id, "program_id", "Program ID.")
+FIELD_F(STATS_META, STR, "AuxDat", 6, dm_stats_aux_data, "aux_data", "Auxiliary data.")
+
{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
@@ -4011,12 +4015,12 @@ static int _report_init(const struct command *cmd)
if (cmd && !strcmp(cmd->name, "stats")) {
options = (char *) _stats_default_report_options;
- _report_type |= DR_STATS;
+ _report_type |= (DR_STATS | DR_STATS_META);
}
if (cmd && !strcmp(cmd->name, "list")) {
options = (char *) _stats_list_options;
- _report_type |= DR_STATS;
+ _report_type |= DR_STATS_META;
}
/* emulate old dmsetup behaviour */
8 years, 9 months
master - dmstats: cleanup _do_stats_create_regions()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f10ad95c3678f5...
Commit: f10ad95c3678f51c26ed55216f4337e78c992375
Parent: 9b3dc725060a243b7b6d849de9bafbdf3e9f5140
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Aug 13 20:54:21 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 13:36:52 2015 +0100
dmstats: cleanup _do_stats_create_regions()
Make the use of the this_start and this_len variables easier to
follow and clarify the use of zero start and len arguments to
request a whole-device region.
---
tools/dmsetup.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 6e75e28..68ca7e0 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4381,7 +4381,9 @@ static uint64_t _nr_areas_from_step(uint64_t len, int64_t step)
/*
* Create a single region starting at start and spanning len sectors,
* or, if the segments argument is no-zero create one region for each
- * segment present in the mapped device.
+ * segment present in the mapped device. Passing zero for segments,
+ * start, and length will create a single segment spanning the whole
+ * device.
*/
static int _do_stats_create_regions(struct dm_stats *dms,
const char *name, uint64_t start,
@@ -4390,7 +4392,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
const char *program_id,
const char *aux_data)
{
- uint64_t this_start = start, this_len = len, region_id = UINT64_C(0);
+ uint64_t this_start, this_len, region_id = UINT64_C(0);
char *target_type, *params; /* unused */
struct dm_task *dmt;
struct dm_info info;
@@ -4439,8 +4441,8 @@ static int _do_stats_create_regions(struct dm_stats *dms,
* --start/--length arguments, or 0/0 for a default
* whole-device region).
*/
- this_start = (segments) ? segment_start : this_start;
- this_len = (segments) ? segment_len : this_len;
+ this_start = (segments) ? segment_start : start;
+ this_len = (segments) ? segment_len : len;
if (!dm_stats_create_region(dms, ®ion_id,
this_start, this_len, step,
program_id, aux_data)) {
8 years, 9 months