summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2016-09-05 12:13:10 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-09-05 12:55:25 +0200
commit5d323c37f3e0324e2599cb98dbb2969cffa41805 (patch)
tree107dbf91897afb34af12d383a92f96032a521d47
parent29d03175574580424b634ac677336dbf8d14d9dd (diff)
downloadlvm2-dev-dct-pvscan-multipath.tar.gz
refactor: move and rename _dev_is_mpath_component in lvmetad.c to udev_dev_is_mpath_component in dev-type.cdev-dct-pvscan-multipath
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/cache/lvmetad.c64
-rw-r--r--lib/device/dev-type.c66
-rw-r--r--lib/device/dev-type.h1
4 files changed, 69 insertions, 63 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 3f7eaf1c5..4cee0e48e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.165 -
===================================
+ Use udev db to check for mpath components before running pvscan for lvmetad.
Use lsblk -s and lsblk -O in lvmdump only if these options are supported.
Fix number of stripes shown in lvcreate raid10 message when too many.
Do not monitor cache-pool metadata when LV is just being cleared.
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a7d330c4a..94cc67dbf 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -2040,64 +2040,6 @@ 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 = NULL;
- const char *value;
- int initialized = 0;
- int i;
- int ret = 0;
-
- if (!udev_context) {
- log_debug("_dev_is_mpath_component: device %s: no udev context", dev_name(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 (!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;
- 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)
@@ -2113,14 +2055,10 @@ 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)) {
+ if (udev_dev_is_mpath_component(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));
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 0246c09bf..07c634688 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -976,3 +976,69 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
return 1;
}
#endif
+
+#ifdef UDEV_SYNC_SUPPORT
+int udev_dev_is_mpath_component(struct device *dev)
+{
+ struct udev *udev_context = udev_get_library_context();
+ struct udev_device *udev_device = NULL;
+ const char *value;
+ int initialized = 0;
+ int i;
+ int ret = 0;
+
+ if (!udev_context) {
+ log_debug("udev_dev_is_mpath_component: device %s: no udev context", dev_name(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("udev_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("udev_dev_is_mpath_component: device %s: not initialized (%d)", dev_name(dev), i);
+ initialized = 0;
+ }
+ usleep(100000);
+ }
+
+ if (!initialized) {
+ log_debug("udev_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;
+ 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 (%s)", dev_name(dev), DEV_EXT_UDEV_MPATH_DEVICE_PATH);
+ ret = 1;
+ goto out;
+ }
+out:
+ udev_device_unref(udev_device);
+ return ret;
+}
+#else
+
+int udev_dev_is_mpath_component(struct device *dev)
+{
+ return 0;
+}
+
+#endif
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index 267b79f6c..33622fe94 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -59,6 +59,7 @@ int dev_is_md(struct device *dev, uint64_t *sb);
int dev_is_swap(struct device *dev, uint64_t *signature);
int dev_is_luks(struct device *dev, uint64_t *signature);
int dasd_is_cdl_formatted(struct device *dev);
+int udev_dev_is_mpath_component(struct device *dev);
/* Signature wiping. */
#define TYPE_LVM1_MEMBER 0x001