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

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.)
This commit is contained in:
Peter Rajnoha 2015-02-16 14:43:03 +01:00
parent 032c9178ca
commit 727c7ff85d
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
Enforce none external dev info for wiping during pvcreate to avoid races.
Add support for VG system_id to control host access to VGs.
Update vgextend to use process_each_vg.
Add --ignoreskippedcluster to pvchange.

View File

@ -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;
}