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

15232 Commits

Author SHA1 Message Date
Martin Wilck
7a7b8a7778 udev: keep systemd vars on change event in 69-dm-lvm-metad.rules for systemd reload
The current logic that avoids setting SYSTEMD_ALIAS and SYSTEMD_WANTS
on "change" events is flawed in the default "systemd background job"
configuration. For systemd, it's important that device properties don't
change spuriously.

If an "add" event starts lvm2-pvscan@.service for a device, and a
"change" event follows, removing SYSTEMD_ALIAS and SYSTEMD_WANTS from the
udev db, information about unit dependencies between the device and the
pvscan service can be lost in systemd, in particular if the daemon
configuration is reloaded.

Steps to reproduce problem:

- create a device with an LVM PV
- remove device
- add device (generates "add" and "change" uevents for the device)
  (at this point SYSTEMD_ALIAS and SYSTEMD_WANTS are clear in udev db)
- systemctl daemon-reload
  (systemd reloads udev db)
- vgchange -a n
- remove device

=> the lvm2-pvscan@.service for the device is still active although the
device is gone.

- add device again

=> the PV is not detected, because systemd sees the lvm2-pvscan@.service
as active and thus doesn't restart it.

The original purpose of this logic was to avoid volumes being scanned
over and over again. With systemd background jobs, that isn't necessary,
because systemd will not restart the job as long as it's active.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2018-04-17 11:38:12 +02:00
Martin Wilck
99bfbbf229 udev: explicit pvscan rule in 69-dm-lvm-metad.rules
Make the distinction between the cases with and without systemd
background jobs explicit in 69-dm-lvm-metad.rules rather than
substituting the rule from the Makefile. At this stage,
this improves only readibility, at the cost of one GOTO statement.

This patch introduces no functional change to the udev rules.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2018-04-17 11:32:52 +02:00
Heinz Mauelshagen
bc286910ec test: add lvcreate-raid-volume_list
Test that no (Sub)LV remnants persist if the volume group is
not listed in configuration variable activation/volume_list,
hence not activatable thus causing initialization of rmeta
SubLVs to fail.

Related: rhbz1161347
2018-04-06 15:26:38 +02:00
Zdenek Kabelac
3a48fb47b7 tests: shellcheck misc
Few more minor complains from ShellCheck.
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
1507956383 tests: shellcheck split assing
Keep possibly error unmasked by assign
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
397b7891ff tests: shellcheck liter 2018-03-23 17:25:00 +01:00
Zdenek Kabelac
410c992744 tests: shellcheck use grep -E
Replace egrep with grep -E
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
14abe1e87b tests: shellcheck prevention check
Always make sure variable is set to something else the /dev/*
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
cafcc5813a fsadm: shellcheck prefer explicit escaping
Backslash is literal in "\t". Prefer explicit escaping: "\\t".
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
fe69731d31 tests: handle setting better
When using 'make check...  LVM_TEST_AUX_TRACE=0'  make it behaving
like other supported VARS in use so it's like disabled.
2018-03-23 17:25:00 +01:00
Zdenek Kabelac
30975a3328 libdm: enhance mounted fs detection
btrfs is using fake major:minor device numbers.
try to be smarter and detect used node via DM device name.

This shortens delays, where i.e. lvm2 is asked to deactivate
volume with mounted btrfs as such operation is not retryed
and user is informed about device being in use.
2018-03-23 17:24:58 +01:00
Zdenek Kabelac
8c02cc9e8f tests: update no tool test
Correct testing with format 1 and mq policy.

Add testing of 'smq'

Fix testing with clvmd - where logged message is part of clvmd log
and we can only check command status.
2018-03-19 12:08:04 +01:00
Zdenek Kabelac
4e0c0417ce cleanup: typo fix 2018-03-19 12:05:57 +01:00
Zdenek Kabelac
8d7ece126b cache: disallow to combine format 2 with mq
Only policy 'smq' is meant to be used with format version 2.
Code used to let pass 'mq' policy also with format 2. But 'mq'
is obsoloted wth smq and kernel currently matches it. But this
is incompatible with older original mq logic - so disallow creation
of this rather useless combination.
2018-03-19 12:02:08 +01:00
Zdenek Kabelac
08487a3098 tests: use 4k extents
Use 4K chunks since some older kernels are not capable
to create striped volumes with smaller size.

TODO: lvm2 should detect this ahead and avoid kernel
reporting "Invalid chunk".
2018-03-18 00:30:43 +01:00
Zdenek Kabelac
e5b40e0488 tests: check activation of cache without cache_check 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
9e7b00a3b9 tests: test striped COW LV 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
c82ab92d04 cleanup: use zalloc
Replace malloc() + memset()   with zalloc().
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
5c40e81a7e cleanup: use direct initializer 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
f4383a70ba coverity: drop unused local static var 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
aa75e181be coverity: drop unneeded header files 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
b4c69320fc coverity: move declaration out of the loop
Move declaration of count counter outside the while loop.
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
f2d0eefa77 coverity: make use of defined variable
Since we declare 'r', let's use the value for something.
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
26c58027fb coverity: validate descriptor
Since this function is called with 'fd == -1', but Coverity can't see
this path can't be visited with this argument, add explicit check for
valid descriptor.
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
f331eb1c0d coverity: ensure lock_type is not NULL 2018-03-17 23:33:58 +01:00
Zdenek Kabelac
fd6661dfcf coverity: add missing error check for str_list_add
Validate success.
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
d727382275 lvconvert: accept striped LV as snapshot COW LV
Restore back acceptance of striped LV to be valid COW LV.
2018-03-17 23:33:58 +01:00
Zdenek Kabelac
67fbe980a7 raid: fix version check of target
Comparision missed to check patch level for matching minor version.
Howerver since all checked patchlevels were 0 - the fix doesn't change result.
2018-03-17 23:30:14 +01:00
Zdenek Kabelac
689af32313 pools: skip checks when tools are missing
If the tools for checking thin_pool or cache metadata are missing,
issue rather just a WARNING, but let the operation of activation
continue.

This has the advantage, the if user is missing those tools,
but he already started to use thinpool or cacheing, he can
access these volumes with a WARNING.

Also if the user is using too old tools i.e. for CacheV2 format
dmpd tool 0.7 is required - provide informative WARNING and
skip failure from older tool version which can't understand
new format V2.
2018-03-17 23:29:11 +01:00
Heinz Mauelshagen
d68d71013f lvcreate: remove RaidLV on creation failure
In case a newly created RaidLV is blacklisted using config
\"activation { volume list = [ ... ] }\" (i.e. its SubLVs stay inactive),
the metadata SubLVs can't get wiped thus failing the creation.

As a result, the RaidLV together with its SubLVs
is left behind in an inconsistent state.

Fix by removing the RaidLV and provide a hint about volume_list reasoning.

Resolves: rhbz1161347
2018-03-16 15:57:53 +01:00
Zdenek Kabelac
9553dc7761 activation: separate prioritized counter
While prioritized_section() based on raised priority works
nicely for standard lvm comman - separate counter is actually needed
when it's used in daemons like clvmd/dmeventd  where priority
stays raised all the time.
2018-03-15 12:30:45 +01:00
Zdenek Kabelac
f6f8f0c7fd tests: skip test when not enough space
Make the test skipped instead of failing when there was not
enough space.
2018-03-15 11:01:04 +01:00
Zdenek Kabelac
bed869a8a0 tests: use DM_DEBUG_WITH_LINE_NUMBERS
Use src:line also for debugging of tools like dmsetup.
2018-03-15 11:01:04 +01:00
Zdenek Kabelac
750fc2e876 tests: fix running tests on systems without udevd
Variable was unbound on systems without running udevd.
2018-03-15 11:01:04 +01:00
Zdenek Kabelac
285413b502 cleanup: missing dots and indent 2018-03-15 11:01:04 +01:00
Zdenek Kabelac
d794444715 activation: check for prioritized_section
Detect we are in prioritezed section instead of critical one,
since these operation were supposed to NOT be happining during
whole set of operation.

This patch fixes verification of udev operations.
2018-03-15 11:01:04 +01:00
Zdenek Kabelac
6365f011b0 locking: introduce prioritized_section
Introduce prioritized_section() as a closer match to previous logic
of critical_section() that has been held over longer sequence of
ioctl commands - essentially it's matching operation on a single
cookie.

While 'critical_section()' now corresponds to locked memory - we hold
this memory only between suspend/resume thus notion of 'cookie' was
lost.

This patch restores some logic unintentionaly lost with dropping
memory locking for just activation/deactivation calls.
2018-03-15 10:59:42 +01:00
Zdenek Kabelac
043f58452a libdm-stats: fix error messages
When function dm_stats_populate() returns 0 it's an error and needs
log_error() message -  function can't have 'success' returning 0 or
error without reasons.
2018-03-15 10:56:31 +01:00
Zdenek Kabelac
a082ce2613 dmstatus: check nr_regions ahead of find call
Prevent call of dm_stats_populate(), when there has been no
stats region detected for a DM device.
Such skip is evaluated as 'correct' visit of stats call and
not causing 'dmstats' command failure.
2018-03-15 10:54:19 +01:00
Zdenek Kabelac
4c925692f5 dmsetup: loop output table as verbose
Resulting loop table line was streamed to 'stderr' stream - assuming this
was not a feature when user used '-v' for more verbose output
and properly show it via  'log_verbose()' on 'stdout'.
2018-03-15 10:50:30 +01:00
Zdenek Kabelac
70ad633638 devcache: add reason and always log_error
With these read errors it's useful to know the reason.
Also avoid to log error just once so we know exactly
how many times we did failing read.

On the other hand reduce repeated log_error() on code 'backtrace'
path and change severity of message to just log_debug() so the
actual read error is printed once for one read.
2018-03-15 10:50:28 +01:00
Zdenek Kabelac
2b3b486a37 libdm: support for DM_DEBUG_WITH_LINE_NUMBERS
For any libdm tool using default debugging function allow
to show source filename and code line number when this
functionality is available.
2018-03-15 10:49:24 +01:00
Marian Csontos
eae54b67d8 test: Skip tests which require too much RAM
- Tests for RAID reshape under load require too much RAM
2018-03-13 13:42:45 +01:00
Zdenek Kabelac
90512910e5 tests: try unfreezeing raids
With problematic kernels raid devices can be occasionaly left with
'frozen' status - try to 'unfreeze' them with idle message on teardown.

Also replace couple greps with 'built-in' dmsetup --select feature.

Note: dmsetup --select  currently reports 'No devices found' on stdout
and return success - looks like a bug to fix.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
b1ace8ce19 dmsetup: indent 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
e9cadbe105 cleanup: matching signess 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
49a8c786d5 dmsetup: report close as debug
Since close() failures are not causing command errors,
issue error via debug log stream only.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
06c1f71897 dmsetup: use dm_snprintf 2018-03-13 12:58:57 +01:00
Zdenek Kabelac
3f351466f7 dmsetup: update _display_info
Handle error code.
2018-03-13 12:58:57 +01:00
Zdenek Kabelac
7ac7cc0ac8 dmsetup: update messages 2018-03-13 12:58:57 +01:00