1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

318 Commits

Author SHA1 Message Date
Bryn M. Reeves
da49d4d54e dmstats: fix bounds leak in _do_stats_create_regions() (Coverity) 2016-07-18 18:48:34 +01:00
Bryn M. Reeves
d2bf6742f8 dmstats: check uuid, major, and alldevices before argc (Coverity)
The --uuid, --major and --alldevices arguments were incorrectly tested
after confirming argc is > 0, in a branch that only executes if argc
== 0 (i.e. they were unreachable).

Move all device checks before the test for argc and log an appropriate
error before returning.
2016-07-18 18:48:34 +01:00
Bryn M. Reeves
da146ae9b9 dmstats: free bounds string in _stats_create_file() (Coverity) 2016-07-18 18:48:34 +01:00
Bryn M. Reeves
6a77a40501 dmstats: accept multiple arguments to --filemap
Make the --filemap switch take no arguments and instead accept one
or more files on the command line to be mapped and placed into
groups.

This allows --filemap to be used with a glob:

  # dmstats create --filemap *
  rhel5.10-1.qcow2: Created new group with 87 region(s) as group ID 1564.
  rhel5.10.qcow2: Created new group with 8 region(s) as group ID 1651.
  rhel7.0-1.qcow2: Created new group with 11 region(s) as group ID 1659.
  rhel7.0.qcow2: Created new group with 1454 region(s) as group ID 1670.
  vm.img: Created new group with 2 region(s) as group ID 3124.
2016-07-08 22:05:36 +01:00
Bryn M. Reeves
5cd39f1dc4 dmstats: use canonical path when reporting errors
When a 'dmstats create --filemap' operation fails (e.g. during
open(2), close(2), or dm_stats_create_regions_from_fd()), use the
canonical version of the path. This avoids cryptic/confusing error
messages when symbolic links exist in the path argument given:

  # findmnt /var/lib/libvirt/images -otarget,source
  TARGET                  SOURCE
  /var/lib/libvirt/images /dev/mapper/vg_hex-lv_images

  # readlink /var/lib/libvirt/images/my.img
  /boot/my.img

  # dmstats create --filemap /var/lib/libvirt/images/my.img
  Cannot map file: not a device-mapper device.
  Could not create regions from file /var/lib/libvirt/images/my.img
  Command failed

Using the canonical path the error is immediately obvious:

  # dmstats create --filemap /var/lib/libvirt/images/my.img
  Cannot map file: not a device-mapper device.
  Could not create regions from file /boot/my.img
  Command failed
2016-07-08 17:27:52 +01:00
Bryn M. Reeves
bd1f4987eb dmstats: group regions by default with --segments
Grouping is also useful in combination with --segments: creating a
group allows both individual segment data and data for the device
as a whole to be presented in the same report.

Support grouping for 'create --segments' in the same manner as for
'create --filemap'; group regions by default, applying an optional
alias specified with --alias, unless the user specifies --nogroup.
2016-07-08 17:27:52 +01:00
Bryn M. Reeves
bce1bc4ca3 dmstats: allow --bounds with 'create --filemap' 2016-07-08 17:27:52 +01:00
Bryn M. Reeves
7ebe630b69 dmstats: add create --filemap
Add a new option to the create command to create regions that map the
extents of a file:

  # dmstats create --filemap /path/to/file
  /path/to/file: Created new group with 10 region(s) as group ID 0.

When performing a --filemap no device argument is required (and
supplying one results in error) since the device to bind to is implied
by the file path and is obtained directly from an fstat().

Grouping may be optionally disabled by the --nogroup switch: in this
case the command will report each region individually:

  # dmstats create --nogroup --filemap /path/to/file
  /path/to/file: Created new region with 1 area as region ID 0.
  /path/to/file: Created new region with 1 area as region ID 1.
  /path/to/file: Created new region with 1 area as region ID 2.

When grouping regions the group alias is automatically set to the
basename (as returned by dm_basename()) of the provided file.

This can be overridden to a user-defined value at the command line by
use of the --alias option.

If grouping is disabled no alias can be set.

Use of offset and subdivision options (--start, --length, --segments,
--areas, --areasize).

Setting aux_data and histograms for groups is possible but is not
currently implemented.
2016-07-08 14:34:41 +01:00
Bryn M. Reeves
005adb0a0a dmstats: ensure dm_stats_delete_region() return is checked 2016-07-08 12:26:34 +01:00
Bryn M. Reeves
1faa208067 dmstats: simplify nr_areas calculation (CWE-561)
Eliminate dead conditional (step cannot be zero).

Fixes commit 988ca74.
2016-07-06 09:59:45 +01:00
Bryn M. Reeves
21b946dfb7 dmstats: fix 'obj_type' field width
The header for 'obj_type' was changed from 'Object Type' to
'ObjType': update the minimum field width to match this change.
2016-07-06 09:37:59 +01:00
Bryn M. Reeves
e9c6fd3cff dmstats: fix <backtrace> in _display_info_cols()
Remove a false <backtrace> in _display_info_cols(): it is not an
error if there are no regions to display.

Fixes commit e6724f03.
2016-07-05 19:53:17 +01:00
Bryn M. Reeves
cf0fa3d693 dmstats: rename --auxdata to --userdata 2016-07-05 19:53:17 +01:00
Bryn M. Reeves
14b74c360f dmstats: rename 'aux_data' to 'user_data'
Make it clear that the "aux data" presented in reports is the user
data stored in the field (and does not include any library-internal
state such as group descriptors) by renaming the field to user_data
and changing the heading to "UserData".
2016-07-05 19:53:17 +01:00
Bryn M. Reeves
2b0dd0b051 dmstats: replace --statstype with separate object switches
Replace --statstype=area,region,group with a separate switch for
each object type: --area, --region, --group. Omitting any object
type switch will use the defaults for the current command (regions
and groups for list, and regions, groups and areas for verbose list).
2016-07-05 19:53:17 +01:00
Bryn M. Reeves
b926511b4b dmstats: add 'statsname' and 'obj_type' to default stats fields 2016-07-05 19:53:17 +01:00
Bryn M. Reeves
0b05e4a874 dmstats: rename 'type' field to 'obj_type'
Rename the field and remove whitespace from the column heading:

  "Object Type" -> "ObjType"
2016-07-05 19:53:17 +01:00
Bryn M. Reeves
c014425b6f dmstats: use 'statsname' and 'groupid' in default fields
Replace the 'name' field with 'statsname' in order to report alias
names for groups, and include the 'group_id' field between statsname
and the 'region_id' field to make it clear to the user when groups
are in use.
2016-07-05 19:53:17 +01:00
Bryn M. Reeves
b0964acadf dmstats: convert 'delete' to dm_stats_foreach_region() 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
01cc11d9f8 dmstats: convert 'print' to dm_stats_foreach_region() 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
2047b8e565 dmstats: convert 'clear' to dm_stats_foreach_region() 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
cf6c1665f1 dmstats: fix region deletion message
Make the use of 64-bit format macros consistent with other usage
and end the message with a '.'.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
e554e375ae dmstats: accept --groupid for 'dmstats delete'
Allow deletion of a group and all the regions it contains with a
single 'dmstats delete' command.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
837e7e513b dmstats: allow --statstype to override report defults 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
a2bf3c6ee8 dmstats: report a list of members as a group's region_id
Instead of '-' print the member list in range notation (as stored
in aux_data).
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
ca0a4cecec dmstats: report groups and region summaries
Walk avaiable groups and regions (in addition to areas) and report
aggregate statistics and properties.

A new switch is added to filter the type of obects inclued in the
report:

  --statstype={all,area,region,group}

The type of the current row is also available in a new
DR_STATS_META field 'type'.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
8b179e09a4 dmstats: do not walk regions if deleting a single id 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
402d840aa7 dmstats: add stats_name field
To allow the names used to describe statistics report objects to
change (for e.g to support groups and region and group aliases)
introduce a new "stats_name" field that evaluates to the correct
name for the object being reported.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
b55daa28e8 dmstats: add group alias support 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
0761863e28 dmstats: add 'group' and 'ungroup' commands
Add a pair of commands to create and delete stats groups:

  dmstats group --regions REGIONS

  dmstats ungroup --groupid ID

REGIONS specifies a list of regions to be included in the group.
Regions are specified as a comma separated list in order of
increasing region ID. Ranges may be specified as a hypen separated
pair of values giving the first and last member of the range.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
b4cbc8f283 dmstats: add group_id report field type 2016-07-05 19:53:16 +01:00
Bryn M. Reeves
52be93c54b dmsetup: fix timestamp leak
With a single report (--count=1) no timerfd is set up and the cycle
and current timestamps should be freed during the single call to
_update_interval_times().
2016-07-04 12:16:51 +01:00
Bryn M. Reeves
62dce13c7a dmstats: fix RgStart and RgSize field widths 2016-07-04 12:16:51 +01:00
Zdenek Kabelac
a9634e993a coverity: check cmd pointer exists
Since in _report_init() we check few times for cmd != NULL
keep it consistent and Coverity happier.
2016-02-23 21:40:16 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Zdenek Kabelac
6c331f3061 dmsetup: one missed dms 2015-11-09 17:04:10 +01:00
Zdenek Kabelac
84a9546869 dmsetup: cleanup warn for older compilers
Older gcc somehow thinks there is a path of using
subcommand uninitilized.

So make it more obvious there is no such one.
2015-11-09 12:21:17 +01:00
Zdenek Kabelac
c542c18d2a cleanup: drop unneded assign
Coverity doesn't really like to see subcommand being assigned NULL,
so drop it.
2015-11-09 10:22:51 +01:00
Zdenek Kabelac
297d6773af dmsetup: add missing checks for dm_stats_create() ret value
Coverity likes to see a check for dms not being NULL, so
add those missing ones...
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
e90c5d2060 dmsetup: check for NULL from dm_task_get_ioctl_timestamp
Coverity: ensure NULL is not passed to dm_timestamp_delta().
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
f9c8cefd06 dmsetup: improve help text
Document more options.
2015-09-18 17:45:45 +02:00
Zdenek Kabelac
791e76ff70 dmsetup: use noflush with force removal
When user specifies '--force' with remove/remove_all/wipe_table
use '--noflush --nolockfs' resume flags, so the operation
will not block when device underneath is blocked.
2015-09-18 17:45:45 +02:00
Bryn M. Reeves
a26523330e dmsetup: fix bounds leak in _do_stats_create_regions()
If we fail to create the DM_DEVICE_TABLE dm_task destroy the bounds
object before returning.
2015-09-07 11:14:28 +01:00
Alasdair G Kergon
fb12308416 style: Standardise some error paths. 2015-09-05 23:56:30 +01:00
Bryn M. Reeves
cebbb0feaf dmstats: replace histogram command with switch
Replace the histogram stats subcommand with a --histogram switch
to enable histogram related fields for both list and report output.

To avoid overloading the existing --histogram rename it to --bounds:
this is also a better description of the option.
2015-09-03 23:39:11 +01:00
Bryn M. Reeves
49b5022993 dmstats: support --noheadings for histogram fields 2015-09-03 22:04:11 +01:00
Bryn M. Reeves
84d88cb2cf dmstats: add --notimesuffix switch
Add a switch to disable the printing of time unit suffixes in
histogram bounds descriptions.
2015-09-03 22:04:10 +01:00
Bryn M. Reeves
031cd2bb0d dmstats: improve stats column names
Improve the names and labels of stats reports columns, ensure that
the minimum field widths allow unambiguos labels to be shown and
update the man page descriptions of these fields.
2015-09-02 21:03:03 +01:00
Bryn M. Reeves
3c0fc6f0da dmstats: add histogram support
Add support to dmstats to create and report histograms.

Add a --histogram switch to 'create' that accepts a string
description of bin boundaries and DR_STATS and DR_STATS_META fields
to report bin configuration and absolute and relative histogram
values:

  hist_bins
  hist_bounds
  hist_ranges
  hist_count
  hist_count_bounds
  hist_count_ranges
  hist_percent
  hist_percent_bounds
  hist_percent_ranges

A new 'histogram' subcommand displays a report that emphasizes
histogram data as either counters or percentage values.
2015-09-02 21:02:12 +01:00
Bryn M. Reeves
a0cf3d47f1 libdm: add latency histogram support
Add support for creating, parsing, and reporting dm-stats latency
histograms on kernels that support precise_timestamps.

Histograms are specified as a series of time values that give the
boundaries of the bins into which I/O counts accumulate (with
implicit lower and upper bounds on the first and last bins).

A new type, struct dm_histogram, is introduced to represent
histogram values and bin boundaries.

The boundary values may be given as either a string of values (with
optional unit suffixes) or as a zero terminated array of uint64_t
values expressing boundary times in nanoseconds.

A new bounds argument is added to dm_stats_create_region() which
accepts a pointer to a struct dm_histogram initialised with bounds
values.

Histogram data associated with a region is parsed during a call to
dm_stats_populate() and used to build a table of histogram values
that are pointed to from the containing area's counter set. The
histogram for a specified area may then be obtained and interogated
for values and properties.

This relies on kernel support to provide the boundary values in
a @stats_list response: this will be present in 4.3 and 4.2-stable. A
check for a minimum driver version of 4.33.0 is implemented to ensure
that this is present (4.32.0 has the necessary precise_timestamps and
histogram features but is unable to report these via @stats_list).

Access methods are provided to retrieve histogram values and bounds
as well as simple string representations of the counts and bin
boundaries.  Methods are also available to return the total count
for a histogram and the relative value (as a dm_percent_t) of a
specified bin.
2015-09-02 20:48:59 +01:00