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

5091 Commits

Author SHA1 Message Date
David Teigland
8b7a78c728 lvmcache: improve duplicate PV handling
Wait to compare and choose alternate duplicate devices until
after all devices are scanned.  During scanning, the first
duplicate dev is kept in lvmcache, and others are kept in a
new list (_found_duplicate_devs).

After all devices are scanned, compare all the duplicates
available for a given PVID and decide which is best.

If the dev used in lvmcache is changed, drop the old dev
from lvmcache entirely and rescan the replacement dev.
Previously the VG metadata from the old dev was kept in
lvmcache and only the dev was replaced.

A new config setting devices/allow_changes_with_duplicate_pvs
can be set to 0 which disallows modifying a VG or activating
LVs in it when the VG contains PVs with duplicate devices.
Set to 1 is the old behavior which allowed the VG to be
changed.

The logic for which of two devs is preferred has changed.
The primary goal is to choose a device that is currently
in use if the other isn't, e.g. by an active LV.

. prefer dev with fs mounted if the other doesn't, else
. prefer dev that is dm if the other isn't, else
. prefer dev in subsystem if the other isn't

If neither device is preferred by these rules, then don't
change devices in lvmcache, leaving the one that was found
first.

The previous logic for preferring a device was:

. prefer dev in subsystem if the other isn't, else
. prefer dev without holders if the other has holders, else
. prefer dev that is dm if the other isn't
2016-05-06 09:00:00 -05:00
David Teigland
67da017fd2 lvmetad: remove client side altdev code
This is no longer used since lvmetad no longer
keeps track of alternate devices for duplicate PVs,
but is simply disabled when duplicates appear.
2016-05-06 09:00:00 -05:00
David Teigland
9539ee8098 lvmetad: set disabled flag in lvmetad if duplicate PVs are found
When devices are being scanned, if duplicate PVs are seen,
tell lvmetad to set its disabled flag because of duplicate PVs.
2016-05-06 08:59:59 -05:00
Zdenek Kabelac
673d4f7453 cleanup: use unsigned with EPOCH printf format 2016-05-05 23:55:20 +02:00
Zdenek Kabelac
ed9162cd88 cleanup: enhance warning message
Add WARNING: for log_warn.
Show device name which is marked missing.
2016-05-05 23:55:18 +02:00
Zdenek Kabelac
f6575ec824 cleanup: just switch error path
Check for error case in if() like we normally do.
Let code continue on success.
2016-05-05 23:52:06 +02:00
Zdenek Kabelac
d1ecbfa52d lvcreate: improve --chunksize support for cached volume.
Support parsing --chunksize option also when converting.
Now user can use cache pool created with i.e. 32K chunksize,
while in caching user can select 512K blocks.
Tool is supposed to validate cache metadata size is big enough
to support such chunk size. Otherwise error is shown.
2016-05-05 23:50:10 +02:00
Zdenek Kabelac
d3b15674df lvcreate: check for lv type and created segtype
When creating LV - in some case we change created segment type
(ATM for cache and snapshot) and we then manipulate with
lv segment according to 'lp' segtype.
Fix this by checking for proper type before accessing segment members.

This makes command like:

lvcreate --type cache-pool -L10 vg/cpool
lvcreate -H -L10 --cachesettings migtation_threshold=10000  vg/cpool

to pass since now tool correctly selects default cache policy.
2016-05-05 23:34:35 +02:00
Zdenek Kabelac
d0111563c2 debug: enhance debug msg for cache 2016-05-05 23:34:35 +02:00
Zdenek Kabelac
fd79027cae cache: use target_present_version
Using new function.
Also add trace for error path.
2016-05-05 23:34:35 +02:00
Zdenek Kabelac
4d116d7a28 cleanup: gather version info with single check
As we already collect version info anyway, allow to use it through
a single call (can makes logs shorter and saves ioctl).
2016-05-05 23:34:30 +02:00
Zdenek Kabelac
def65507e6 cache: add cache_set_params function
Wrapping function to handle setup of various cache related params.
Reusable with lvcreate & lvconvert.
2016-05-05 23:30:49 +02:00
Zdenek Kabelac
ae805eea50 cache: add validate_lv_cache_chunk_size 2016-05-05 23:30:49 +02:00
Zdenek Kabelac
00dfca034c cache: function for min metadata size estimation
Move min code into reusable function.
2016-05-05 23:30:02 +02:00
Alasdair G Kergon
c76df666c9 raid: Use inherited tags when wiping rmeta.
If there's an activation volume_filter, it might not be possible
to activate the rmeta LVs to wipe them.  At least inherit any
LV tags from the parent LV while attempting this.
2016-04-29 19:49:21 +01:00
Alasdair G Kergon
e3efcdc9f5 datastruct: Add str_list_wipe. 2016-04-29 19:47:15 +01:00
David Teigland
263c1a4db5 lvmetad: improve warning after lvmetad message fails
Make it more consistent with the other similar warning.
2016-04-27 15:38:34 -05:00
David Teigland
3c53acb378 metadata: fix segfault when filters reject devices
Checking for devices uses is_missing_pv() to check
if there is a device for the PV.  is_missing_pv()
is based on the MISSING_PV flag, which does not
always correspond to !pv->dev.  When using lvmetad,
a command like:

pvs --config 'devices/filter=["a|/dev/sdb|", "r|.*|"]'

will cause a number of PVs to have NULL pv->dev, but
not the MISSING_PV flag.  So, NULL pv->dev needs to
also be checked.
2016-04-27 12:13:26 -05:00
Zdenek Kabelac
49f32e4859 cache: better support for alias check
To still support disabling of policies for test we need
better logic for alias detection introduced in
588455d03e.
2016-04-27 00:20:37 +02:00
Zdenek Kabelac
2a2efab0b1 cleanup: use log_debug_activation 2016-04-27 00:01:08 +02:00
Zdenek Kabelac
c81005dcc4 cleanup: smaller timeout
1s -> 0.5s
Also indent fix.
2016-04-26 23:59:20 +02:00
Zdenek Kabelac
84a5b19539 thin: zero and transaction_id also with thin volumes
Show trasaction_id when thin volume was created.
Also show zeroing state of thin-pool with thin volume (so user
doesn't need to lookup thin-pool).
2016-04-26 23:24:51 +02:00
Zdenek Kabelac
8b5967e1e3 cache: check for clean cache as separete function 2016-04-26 23:24:17 +02:00
Zdenek Kabelac
588455d03e cache: with cache target 1.9 mq is alias to smq
Avoid useless check for mq policy, it's loaded as smq
and aliased.
2016-04-26 23:24:05 +02:00
Zdenek Kabelac
aa91fe3d3c modprobe: check /sys/module entry first
Before executing modprobe for given module name, just check
if the module is not already present in /sys/module.

Useful when checking dm-cache-policy modules as we do not
having matching interface like for targets.
2016-04-26 23:23:03 +02:00
Peter Rajnoha
379874a2d0 cleanup: do not mention segment in warning message if device not found for a PV when checking used/assumed devs for an LV
[0] fedora/~ # pvs --config 'devices/filter=["a|/dev/sda|", "r|.*|"]'
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Couldn't find device for segment belonging to fedora/root while checking used and assumed devices.
  WARNING: Couldn't find device for segment belonging to fedora/swap while checking used and assumed devices.
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda          lvm2 ---  128.00m 128.00m
  [unknown]  fedora lvm2 a-m   19.49g      0

Probably not worth mentioning "segments" here, just state that devices
for an LV can't be all found during the check - it's less mysterious for
user then:

[0] fedora/~ # pvs --config 'devices/filter=["a|/dev/sda|", "r|.*|"]'
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Couldn't find all devices for LV fedora/root while checking used and assumed devices.
  WARNING: Couldn't find all devices for LV fedora/swap while checking used and assumed devices.
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda          lvm2 ---  128.00m 128.00m
  [unknown]  fedora lvm2 a-m   19.49g      0
2016-04-25 11:44:24 +02:00
Peter Rajnoha
9d976c0002 metadata: log warning instead of error if device not found while checking used and assumed devs
When checking assumed PVs against real devices used for LVs and if
there's no device assigned for an assumed PV (e.g. due to filters),
do log_warn instead of log_error and continue checking LV segments
and associated assumed PVs further, just like we do log_warn elsewhere
in this situation.

This way user will see the warning for each LV which couldn't be
checked completely against real PVs used. Before, we logged only
the very first occurence of missing device for an LV in a VG and we
returned from the function doing this check for all the LVs in VG
immediately which may be a bit misleading because it didn't tell
user about all the other LVs and whether they could be checked
or not.

For example, we have this setup:

[0] fedora/~ # pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda          lvm2 ---  128.00m 128.00m
  /dev/vda2  fedora lvm2 a--   19.49g      0

[0] fedora/~ # lvs -o+devices
  LV   VG     Attr       LSize   Devices
  root fedora -wi-ao----  19.00g /dev/vda2(0)
  swap fedora -wi-ao---- 500.00m /dev/vda2(4864)

Before this patch (only the very first LV in a VG is logged to have a
problem while checking used and assumed devices):

[0] fedora/~ # pvs --config 'devices/filter=["a|/dev/sda|", "r|.*|"]'
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  Couldn't find device for segment belonging to fedora/root while checking used and assumed devices.
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda          lvm2 ---  128.00m 128.00m
  [unknown]  fedora lvm2 a-m   19.49g      0

With this patch applied (all LVs where we hit problem while checking
used and assumed devices are logged and it's warning, not error):

[0] fedora/~ # pvs --config 'devices/filter=["a|/dev/sda|", "r|.*|"]'
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Device for PV Qcxpcy-XgtP-UD3s-PmG0-qLyE-Z0ho-DYsxoz not found or rejected by a filter.
  WARNING: Couldn't find device for segment belonging to fedora/root while checking used and assumed devices.
  WARNING: Couldn't find device for segment belonging to fedora/swap while checking used and assumed devices.
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda          lvm2 ---  128.00m 128.00m
  [unknown]  fedora lvm2 a-m   19.49g      0
2016-04-25 11:27:28 +02:00
Zdenek Kabelac
bc239f15eb coverity: ignore some dm_strncpy results
Using them only for debug so ignorable.
Also don't mark stack char buffer alignment, compiler already knows
what's the best here.
2016-04-22 14:15:36 +02:00
Zdenek Kabelac
d564d9f39c coverity: is_used_pv needs valid pv pointer 2016-04-22 14:15:36 +02:00
Zdenek Kabelac
4ddf5a11cf cache: fix previous change and correct ()
412f09ca33 missed parentheses.
2016-04-22 12:52:53 +02:00
Zdenek Kabelac
8c4b717f4d coverity: drop abadoing object
As mempool is destroyed on by caller don't bother for
mempool freeing here.
2016-04-22 01:13:35 +02:00
Zdenek Kabelac
0bf5518626 coverity: avoid using signed types for single bits 2016-04-22 01:12:34 +02:00
Zdenek Kabelac
412f09ca33 coverity: return non-null string with internal error
While we return internal error we should not let tool crash on NULL
access, so return valid string for such case.
2016-04-22 01:12:34 +02:00
Zdenek Kabelac
447daa9179 coverity: use wider type for whole expression
Coverity likes when the types are same through the whole expression.
And since dev_t is 64b - widen int type early.
2016-04-22 01:12:34 +02:00
Zdenek Kabelac
edcb3e65c6 coverity: drop unused header file 2016-04-22 01:12:34 +02:00
Zdenek Kabelac
99e96f3ce9 coverity: fix error paths
Patch 74e704bb44 missed to update
error path. Since now we just need to 'return_0' as 'dmt is NULL
and thus may not be destroyed.
2016-04-22 01:12:34 +02:00
Zdenek Kabelac
cbf99be43a coverity: fix memory access
Commit  52e0d0db44 introduced regression
as code may access   buf[0 - 1].

Reorder code to first remove '\n' and then check buffer size for
empty.
2016-04-22 01:11:57 +02:00
Zdenek Kabelac
556eba1835 cleanup: use kdev_t header in lvm tree
Reuse libdm header in lvm so we have single definition
of MAJOR/MINOR/MKDEV macros in use.
2016-04-22 00:23:28 +02:00
Zdenek Kabelac
9d4f9defc3 cleanup: simplify code
dm_strncpy() also check the size fits.
2016-04-22 00:22:02 +02:00
Alasdair G Kergon
01181a299e activate: Hide errors when snapshot merge delayed. 2016-04-21 22:14:10 +01:00
David Teigland
1134ab6324 lvmetad: warn about making changes while not using lvmetad
If lvmetad is running, and a command opts to not use it
(--config global/use_lvmetad=0), and the command changes
metadata, then the metadata change is not visible to
lvmetad.  Subsequent commands using lvmetad to change
metadata may cause corruption based on the invalid
lvmetad state.

Eventually we can set the disabled state in lvmetad
to prevent this problem, but for now print a warning
about the possibility.
2016-04-21 10:28:01 -05:00
David Teigland
6e6f8025ff lvmetad: fix compile without lvmetad
Last commit was missing stub function.
2016-04-21 10:06:47 -05:00
David Teigland
e44c4806db lvmetad: check pid for warning case
When command is not using lvmetad because
use_lvmetad=0 in the config, but the lvmetad
pidfile exists, print a warning (previously
this checked for the socket existing instead
of the pidfile existing.)
2016-04-21 09:50:59 -05:00
David Teigland
d00b70c789 lvmetad: check for socket in connect
We can connect if the socket is present, even
though the pidfile may not exist, since systemd
may start the process when the socket is opened.
2016-04-21 09:27:20 -05:00
Alasdair G Kergon
0778d2e985 display: Avoid internal snapshot LV names in msgs.
vg/snapshotN should not appear anywhere.

No code should be showing this, but it was noticed in some logs last
week and we can deal with it in display_lvname().
2016-04-21 00:30:17 +01:00
Zdenek Kabelac
2763b928de lvmetad: fix compilation without lvmetad# 2016-04-21 00:34:01 +02:00
Zdenek Kabelac
509b2e5247 debug: move misplaced log_debug
It should log action before taking it instead of only in error path.
2016-04-21 00:34:01 +02:00
David Teigland
5e9e43074a lvmetad: rework command connection setup and checking
The lvmetad connection is created within the
init_connections() path during command startup,
rather than via the old lvmetad_active() check.

The old lvmetad_active() checks are replaced
with lvmetad_used() which is a simple check that
tests if the command is using/connected to lvmetad.

The old lvmetad_set_active(cmd, 0) calls, which
stopped the command from using lvmetad (to revert to
disk scanning), are replaced with lvmetad_make_unused(cmd).
2016-04-19 14:00:02 -05:00
David Teigland
593900b795 lvmetad: use defines for disabled reason strings 2016-04-19 11:45:24 -05:00
David Teigland
1e380864e5 lvmetad: clear the disabled flag in lvmetad
After a device rescan that repopulates lvmetad,
if no reason for disabling lvmetad was seen
(lvm1 metadata or duplicate PVs), then clear
the disabled flag in lvmetad.  This allows
commands to resume using the lvmetad cache
after the cause for disabling it has been removed.
2016-04-19 09:41:18 -05:00