summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2016-09-05 11:33:08 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-09-05 12:43:11 +0200
commit29d03175574580424b634ac677336dbf8d14d9dd (patch)
tree19736bb08628eef73b8e2ff68406d46735b589da
parent939f5310b9e58a560247c44cbd8a8f8af86aae7c (diff)
downloadlvm2-29d03175574580424b634ac677336dbf8d14d9dd.tar.gz
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.
-rw-r--r--lib/cache/lvmetad.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index c31219ed8..a7d330c4a 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -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)
+ if (!udev_context) {
+ log_debug("_dev_is_mpath_component: device %s: no udev context", dev_name(dev));
return_0;
+ }
- if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) {
- return_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 (!udev_device_get_is_initialized(udev_device)) {
- ret = 0;
+ 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;