mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
lvmetad: check udev for mpath component several times if udev record not initialized yet
It's possible (mainly during boot) that udev has not finished processing the device and hence the udev database record for that device is still marked as uninitialized when we're trying to look at it as part of multipath component check in pvscan --cache code. So check several times with a short delay to wait for the udev db record to be initialized before giving up completely.
This commit is contained in:
parent
939f5310b9
commit
29d0317557
34
lib/cache/lvmetad.c
vendored
34
lib/cache/lvmetad.c
vendored
@ -2043,23 +2043,43 @@ out:
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
static int _dev_is_mpath_component(struct udev *udev_context, struct device *dev)
|
||||
{
|
||||
struct udev_device *udev_device;
|
||||
struct udev_device *udev_device = NULL;
|
||||
const char *value;
|
||||
int initialized = 0;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
if (!udev_context)
|
||||
return_0;
|
||||
|
||||
if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) {
|
||||
if (!udev_context) {
|
||||
log_debug("_dev_is_mpath_component: device %s: no udev context", dev_name(dev));
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!udev_device_get_is_initialized(udev_device)) {
|
||||
ret = 0;
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if (udev_device)
|
||||
udev_device_unref(udev_device);
|
||||
|
||||
if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) {
|
||||
log_debug("_dev_is_mpath_component: device %s: no udev device", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (udev_device_get_is_initialized(udev_device)) {
|
||||
initialized = 1;
|
||||
break;
|
||||
} else {
|
||||
log_debug("_dev_is_mpath_component: device %s: not initialized (%d)", dev_name(dev), i);
|
||||
initialized = 0;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
log_debug("_dev_is_mpath_component: device %s: not initialized even after waiting", dev_name(dev));
|
||||
goto_out;
|
||||
}
|
||||
|
||||
value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_BLKID_TYPE);
|
||||
|
||||
if (value && !strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_MPATH)) {
|
||||
log_debug("Dev %s is mpath component (%s)", dev_name(dev), value);
|
||||
ret = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user