diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-16 14:43:03 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-02-16 15:07:00 +0100 |
commit | 727c7ff85d448743f751bc5218e73c41314ed5f1 (patch) | |
tree | b1af49681809be041a88c33d498fc9901ee98d1d /lib | |
parent | 032c9178ca72aef93bfef6e4952bb98d3373b642 (diff) | |
download | lvm2-727c7ff85d448743f751bc5218e73c41314ed5f1.tar.gz |
pvcreate: switch to "none" dev-ext source during pvcreate
pvcreate code path executes signature wiping if there are any signatures
found on device to prepare the device for PV. When the signature is wiped,
the WATCH udev rule triggers the event which then updates udev database
with fresh info, clearing the old record about previous signature.
However, when we're using udev db as dev-ext source, we'd need to wait
for this WATCH-triggered event. But we can't synchronize against such
events (at least not at this moment). Without this sync, if the code
continues, the device could still be marked as containing the old
signature if reading udev db. This may end up even with the device
to be still filtered, though the signature is already wiped.
This problem is then exposed as (an example with md components):
$ mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb --run
$ mdadm -S /dev/md0
$ pvcreate -y /dev/sda
Wiping linux_raid_member signature on /dev/sda.
/dev/sda: Couldn't find device. Check your filters?
$ echo $?
5
So we need to temporarily switch off "udev" dev-ext source here
in this part of pvcreate code until we find a way how to sync
with WATCH events.
(This problem does not occur with signature wiping which we do
on newly created LVs since we already handle this properly with
our udev flags - the LV_NOSCAN/LV_TEMPORARY flag. But we can't use
this technique for non-dm devices to keep WATCH rule under control.)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/metadata/metadata.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 138fdaff1..55e64769a 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1423,6 +1423,20 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name, int r = 0; int scan_needed = 0; int filter_refresh_needed = 0; + dev_ext_t dev_ext_src = external_device_info_source(); + + if (dev_ext_src == DEV_EXT_UDEV) + /* + * wipe_known_signatures called later fires WATCH event + * to update udev database. But at the moment, we have + * no way to synchronize with such event - we may end + * up still seeing the old info in udev db and pvcreate + * can fail to proceed because of the device still + * being filtered (because of the stale info in udev db). + * Disable udev dev-ext source temporarily here for + * this reason. + */ + init_external_device_info_source(DEV_EXT_NONE); /* FIXME Check partition type is LVM unless --force is given */ @@ -1512,6 +1526,7 @@ out: } free_pv_fid(pv); + init_external_device_info_source(dev_ext_src); return r; } |