diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index 0503d918a..c31219ed8 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -24,6 +24,10 @@ #include "lvm-signal.h" #include "lvmlockd.h" #include "str_list.h" +#ifdef UDEV_SYNC_SUPPORT +#include +#include "dev-ext-udev-constants.h" +#endif #include @@ -2036,6 +2040,44 @@ out: return vg_ret; } +#ifdef UDEV_SYNC_SUPPORT +static int _dev_is_mpath_component(struct udev *udev_context, struct device *dev) +{ + struct udev_device *udev_device; + const char *value; + int ret = 0; + + if (!udev_context) + return_0; + + if (!(udev_device = udev_device_new_from_devnum(udev_context, 'b', dev->dev))) { + return_0; + } + + if (!udev_device_get_is_initialized(udev_device)) { + ret = 0; + 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; + goto out; + } + + value = udev_device_get_property_value(udev_device, DEV_EXT_UDEV_MPATH_DEVICE_PATH); + if (value && !strcmp(value, "1")) { + log_debug("Dev %s is mpath component (device path)", dev_name(dev)); + ret = 1; + goto out; + } +out: + udev_device_unref(udev_device); + return ret; +} +#endif + int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev, struct dm_list *found_vgnames, struct dm_list *changed_vgnames) @@ -2051,6 +2093,15 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev, return 0; } +#ifdef UDEV_SYNC_SUPPORT + struct udev *udev_context = udev_get_library_context(); + + if (_dev_is_mpath_component(udev_context, dev)) { + log_debug("Ignore multipath component for pvscan."); + return 1; + } +#endif + if (!label_read(dev, &label, 0)) { log_print_unless_silent("No PV label found on %s.", dev_name(dev)); if (!lvmetad_pv_gone_by_dev(dev))