1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

12771 Commits

Author SHA1 Message Date
Bryn M. Reeves
cda1622fef libdm: allow deleting regions with dm_stats_delete_group()
Add a flag to dm_stats_delete_group() to allow optional deletion
of all regions belonging to the group being removed.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
f1f2df7bc0 libdm: add stats group and region iterators and properties
Add support do dm_stats_walk*() to walk over the set of
available groups using the cursor embedded in the dm_stats
handle, and to obtain the type of the object at the current
stats cursor location. A set of flags is introduced to
control which objects are visited:

    DM_STATS_WALK_AREA
    DM_STATS_WALK_REGION
    DM_STATS_WALK_GROUP
    DM_STATS_WALK_ALL

A final flag suppresses visits to regions that contain only a
single area - since the aggregate of such a region is idential
to the area it contains this allows these duplicates to be
filtered out:

    DM_STATS_WALK_SKIP_SINGLE_AREA

If flags are not initialised before beginning a walk the default
set matches the behaviour of previous versions of the library.

Also accept group identifiers as immediate arguments to the
counter, metric, and property functions by adding control
flags to the region and area identifiers passed in.

Region and area properties are mapped to their equivalents for
the group (for example: group size is reported as the sum of
all regions contained in the group). Counter and metric values
are aggregated for the region or group.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
62050760aa libdm: use defined constants for buffer sizes
Introduce constants for the buffer sizes that libdm-stats uses:
one for messages sent to the kernel, one for rows of response data
returned, and a pair for the "start+len" range and histogram bounds
strings.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
2cb9794da2 libdm: add statistics groups
Add a grouping facility to the libdm-stats library that allows the
user to bind several regions together as a group. Groups may be
used to aggregate data from several regions for reporting, or to
select and sort among large sets of regions.

A textual descriptor ("group tag") is associated with each group
and is stored in the first group member's aux_data field. The
tag contains the group member list and an optional alias for the
group, allowing the user to assign meaningful names to groups of
regions.

These descriptors are parsed in @stats_list message responses and
populate the resulting region and area tables with the group
structure.

Groups with overlapping regions are permitted but since this will
result in some events being counted more than once a warning is
printed in this case.

Nested and overlapping groups are not currently supported and
attempting to create these configurations results in error.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
4cd3dcbbc2 libdm: rename 'region' to 'skip_region' in _stats_walk_next
In libdm-stats.c 'region' usually refers to a 'struct region*'.
Rename the argument to _stats_walk_start to avoid confusion.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
82e5766062 libdm: add enum based counter and metric calls
Add a new enum based interface for accessing counter and metric
values that uses a single function for each:

uint64_t dm_stats_get_counter(const struct dm_stats *dms,
                              dm_stats_counter_t counter
                              uint64_t region_id, uint64_t area_id);

int dm_stats_get_metric(const struct dm_stats *dms, int metric,
                        uint64_t region_id, uint64_t area_id,
                        double *value);

This simplifies the implementation of value aggregation for
groups of regions. The named function interface now calls the
enum interface internally so that all new functionality is
available regardless of the method used to retrieve values.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
69f808ac8d libdm: cache dm name in stats handle
Cache the device-mapper name of a bound device in the dm_stats
handle.

This will be used by stats groups to report a device name or
user defined alias for groups.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
4a66f02f88 libdm: rename dm_stats name, devno and uuid members
The device-mapper name, device numbers and uuid stored in the
dm_stats handle are used only to bind the handle to a specific
device in order to issue ioctls.

Rename them to "bind_*" to reflect this usage in preparation
for caching the device-mapper name of the bound device in the
dm_stats handle.

This will be used to allow optional aliases to be set for
dmstats groups.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
81fad9e853 libdm: add dm_bitset_parse_list()
Add a function to parse a list of integer values and ranges into
a dm_bitset representation. Individual values signify that that bit
is set in the resulting mask and ranges are given as a pair of
start and end values, M-N, such that M and N are the first and
last members of the range (inclusive).

The implementation is based on the kernel's __bitmap_parselist()
that is used for cpumasks and other set configuration passed in
string form from user space.
2016-07-05 19:53:16 +01:00
Bryn M. Reeves
d382e66035 libdm: fix histogram pool user-after-free (CWE-825) 2016-07-05 19:53:15 +01:00
Heinz Mauelshagen
4420d41fea vgsplit: fix moving RAID LVs to split off VG and check for LVs not to skip moving with other LV types 2016-07-05 19:49:44 +01:00
Zdenek Kabelac
e5d1f3d6c5 tests: using mkfs config file
Use more predictable local config when creating ext4.
2016-07-04 17:41:10 +02:00
Zdenek Kabelac
2063d6bb06 tests: add line for mixing dmeventd with log
TODO: it might be better to log dmeventd messages with test output
just like we do with clvmd - maybe we will switch to this one
instead of extra  DMEVENTD log file in future....
2016-07-04 17:41:09 +02:00
Zdenek Kabelac
b91390c211 tests: add mke2fs.conf
Add config for mkfs to get more predicatable results
when using mkfs across variety of distributions.

In future maybe use this per all tests as default.
For now user has to specify in a test MKE2FS_CONFIG envvar to use it.
2016-07-04 17:40:25 +02:00
Zdenek Kabelac
2981d1e798 tests: try to force remove higher minor first
When force removing thin-pool we loose 'real' access to hidden device,
and if such pool is in suspended state, any thin volume cannot be
dropped. It likely should be also checked by dmsetup, but meanwhile
apply simple logic -  try to force remove first all higher minors first
with assumption we first create thin-pool and then thin volume
and there are usually not being released lower dm numbers to
get the order wrong.
2016-07-04 17:40:24 +02:00
Zdenek Kabelac
c0a505b0bb cleanup: drop unused header files 2016-07-04 17:40:24 +02:00
Zdenek Kabelac
adc1fe4b3f dmeventd: improved logged messages from thin plugin
Show better names in logged messages.
2016-07-04 17:40:24 +02: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
Bryn M. Reeves
f27e95b25a docs: remove obsolete note from dmstats.8.in 2016-07-04 12:16:50 +01:00
Alasdair G Kergon
d8c2677ab9 raid0: Add raid0_meta segment type. 2016-07-01 22:20:54 +01:00
David Teigland
1df9822224 lvconvert: improve arg checks in new operation routing code
Use defines for segment types, and test args directly
instead of indirectly.
2016-07-01 11:24:41 -05:00
Zdenek Kabelac
b0d8a524a2 tests: test foreign users of thin-pool
Note: dmeventd should not need any notification and automatically
try to resize again when there is some metadata change.
2016-07-01 00:44:49 +02:00
Zdenek Kabelac
37a33d7414 cleanup: warns from older gcc 2016-07-01 00:44:48 +02:00
Zdenek Kabelac
3fd4584886 cleanup: lvchange uses display_lvname
Convert messages to report vg/lv name consistently.

Also drop unneeded 'info_obtaned' variable since the
obtained info is not reused in any code path.
2016-07-01 00:44:48 +02:00
Zdenek Kabelac
b9d3e8c8a8 cleanup: drop unused assignments
In all code paths we set a value for these variables, so drop
their initial unused assign.
2016-07-01 00:44:48 +02:00
Zdenek Kabelac
1e3411aa37 cleanup: add extra test for argc==0
Cleaup some compiler warning about posibility to allocate 0 size.
2016-07-01 00:44:48 +02:00
Zdenek Kabelac
458918b319 thin: fix link validation for unused thin-pool
This patch fixes link validation for used thin-pool.
Udev rules correctly creates symlinks only for unused new thin-pool.
Such thin-pool can be used by foreing apps (like Docker) thus
has  /dev/vg/lv link.
However when thin-pool becomes used by thinLV - this link is no
longer exposed to user - but internal verfication missed this
and caused messages like this to be printed upon 'vgchange -ay':

The link /dev/vg/pool should have been created by udev but it was not
found. Falling back to direct link creation.

And same with 'vgchange -an':
The link /dev/vg/pool should have been removed by udev but it is still
present. Falling back to direct link removal.

This patch ensures only unused thin-pool has this link.
2016-07-01 00:44:46 +02:00
Zdenek Kabelac
2f638e07e8 dmeventd: thin plugin umount over 95%
Run umount code only when either thin data or metadata are
above 95% - so if there are resize failures with 60%.
system fill keep running.

Also umount will only be tried with lvm2 LVs.
Foreign users are ATM unsuppored.
2016-07-01 00:43:45 +02:00
David Teigland
103c188681 lvconvert: add comments describing conversions 2016-06-30 17:08:50 -05:00
Alasdair G Kergon
aed8bc8ae7 macros: Use is_power_of_2. 2016-06-30 17:59:44 +01:00
David Teigland
a8e39530ef lvconvert: add missing alias for a thin-pool conversion
The case of converting a cache volume to a thin pool missed
recognizing the --thinpool alias for --type thin-pool.
2016-06-30 10:09:54 -05:00
David Teigland
802ed9d459 lvconvert: remove unused code
This code became unused with the previous commit 2282f5.
2016-06-29 16:59:32 -05:00
David Teigland
2282f53ac7 lvconvert: rework routing of operations
Add new logic to identify each unique operation and route
it to the correct function to perform it.  The functions
that perform the conversions remain unchanged.

This new code checks every allowed combination of LV type
and requested operation, and for each valid combination
calls the function that performs that conversion.

The first stage of option validation which checks for
incompatible combinations of command line options, is done
done before process_each is called.  This is unchanged.
(This new code will allow that first stage validation to
be simplified in a future commit.)

The second stage of checking options against the specific
LV type is done by this new code.  For each valid combination
of operation + LV type, the new code calls an existing
function that implements it.

With this in place, the ad hoc checks for valid combinations
of LV types and operations can be removed from the existing
code in a future commit.

(The #if 0 is used to keep the patch clean, and the
disabled code will be removed by a following patch.)
2016-06-29 16:55:27 -05:00
Peter Rajnoha
eac0706761 libdm: do not issue 'Failed to create directory' message for failure in dm_create_dir
There are detailed messages inside _create_dir_recursive that
dm_create_dir calls (except EROFS which where the message is not
generated, like anywhere else in the code).
2016-06-29 15:58:18 +02:00
Alasdair G Kergon
686acce23f lvconvert: Conversions between striped and raid0. 2016-06-28 23:44:15 +01:00
Tony Asleson
6f216692b4 lvmdbustest: Comment out refresh check for LV create
When we test Vg.LvCreateRaid some of the hidden LVs volume type go from
'I' to 'i' between the time it takes us to create the LV and
the time it takes to call into refresh to verify the service is up to date.
This is a fairly rare occurance.
2016-06-28 13:36:32 -05:00
Tony Asleson
1d3532d0a7 lvmdbusd: Add --nojson command line option
Add ability to not use the JSON output even if available.
2016-06-28 13:32:39 -05:00
Tony Asleson
e6e5c3d3ec lvmdbusd: Remove WARNING for 'lvm help'
We call 'lvm help' to find out if fullreport is supported.  Lvm
dumps help to stderr.  Common code prints a warning if we exit
with 0, but have something in stderr so we are skipping the warning
message.
2016-06-28 12:54:48 -05:00
Tony Asleson
7c5a08521b lvmdbusd: Remove unneeded comment 2016-06-28 12:45:55 -05:00
Tony Asleson
9e3ad37828 lvmdbusd: Clean up ws 2016-06-28 12:45:28 -05:00
Tony Asleson
c11003c860 lvmdbusd: Remove unused imports and function parameter 2016-06-28 12:44:45 -05:00
Tony Asleson
dd5d865020 lvmdbusd: Fix hang when lvm compiled with 'enable-notify-dbus'
The following operations would hang if lvm was compiled with
'enable-notify-dbus' and the client specified -1 for the timeout:

* LV snapshot merge
* VG move
* LV move

This was caused because the implementation of these three dbus methods is
different.  Most of the dbus method calls are executed by gathering information
needed to fulfill it, placing that information on a thread safe queue and
returning.  The results later to be returned to the client with callbacks.
With this approach we can process an arbitrary number of commands without any
of them blocking other dbus commands.  However, the 3 dbus methods listed
above did not utilize this functionality because they were implemented with a
separate thread that handles the fork & exec of lvm.  This is done because these
operations can be very slow to complete.  However, because of this the lvm
command that we were waiting on is trying to call back into the dbus service to
notify it that something changed.  Because the code was blocking the process
that handles the incoming dbus activity the lvm command blocked.  We were stuck
until the client timed-out the connection, which then causes the service to
unblock and continue.  If the client did not have a timeout, we would have been
hung indefinitely.

The fix is to always utilize the worker queue on all dbus methods.  We need to
ensure that lvm is tested with 'enable-notify-dbus' enabled and disabled.
2016-06-28 12:09:28 -05:00
Tony Asleson
5274c2f11b lvmdbusd: request.py, initialize _job to None
_job is a job object, not a boolean so initialize it to None instead.
2016-06-28 12:09:28 -05:00
Tony Asleson
4f26eae40f lvmdbusd: Correct pv_seg_start -> pvseg_start
Code was using the incorrect column names for pvseg_start which only
became apparent when utilizing the JSON.
2016-06-28 12:09:28 -05:00
Tony Asleson
0aadd6b0fb lvmdbusd: Correct command line args for JSON
Use the updated syntax.
2016-06-28 12:09:28 -05:00
Tony Asleson
4b337b20d4 lvmdbusd: Remove sorting in db layer
When using the JSON this does not yield a totally sorted list as we don't
have a complete set of LVs, so remove this sort.
2016-06-28 12:09:28 -05:00
Tony Asleson
e514284c65 lvmdbusd: Add hidden in for json too 2016-06-28 12:09:28 -05:00
Tony Asleson
ec45be9976 lvmdbusd: Initial support for json output 2016-06-28 12:09:28 -05:00
Alasdair G Kergon
79446ffad7 raid: Infrastructure for raid takeover. 2016-06-28 02:42:30 +01:00