diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2014-09-03 15:47:52 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2014-12-02 14:59:13 +0100 |
commit | 632c558308c82f997cbc6fc4ca630da49239af67 (patch) | |
tree | 828bee0e29c849a523b49e0f088e92ae301e349b | |
parent | 4e01857d7dc5c278bb5277cc4473cf63dfd2e072 (diff) | |
download | lvm2-632c558308c82f997cbc6fc4ca630da49239af67.tar.gz |
filter-md: use new 'udev' device status source to get MD component status
MD components are marked in udev db as:
ID_FS_TYPE="linux_raid_member"
-rw-r--r-- | lib/device/dev-md.c | 44 | ||||
-rw-r--r-- | lib/filters/filter-md.c | 5 |
2 files changed, 47 insertions, 2 deletions
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c index 76e30939d..aacbf1027 100644 --- a/lib/device/dev-md.c +++ b/lib/device/dev-md.c @@ -16,6 +16,9 @@ #include "lib.h" #include "dev-type.h" #include "xlate.h" +#ifdef UDEV_SYNC_SUPPORT +#include <libudev.h> /* for MD detection using udev db records */ +#endif #ifdef __linux__ @@ -81,10 +84,27 @@ static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version) return sb_offset; } +#ifdef UDEV_SYNC_SUPPORT +static int _udev_dev_is_md(struct device *dev) +{ + const char *value; + + if (!(value = udev_device_get_property_value((struct udev_device *)dev->aux_status.handle, "ID_FS_TYPE"))) + return 0; + + return !strcmp(value, "linux_raid_member"); +} +#else +static int _udev_dev_is_md(struct device *dev) +{ + return 0; +} +#endif + /* * Returns -1 on error */ -int dev_is_md(struct device *dev, uint64_t *offset_found) +static int _native_dev_is_md(struct device *dev, uint64_t *offset_found) { int ret = 1; md_minor_version_t minor; @@ -129,6 +149,28 @@ out: return ret; } +int dev_is_md(struct device *dev, uint64_t *offset_found) +{ + + /* + * If non-native device status source is selected, use it + * only if offset_found is not requested as this + * information is not in udev db. + */ + if (dev_aux_status_use_native(&dev->aux_status, dev_name(dev)) || offset_found) + return _native_dev_is_md(dev, offset_found); + + if (dev->aux_status.source == DEV_AUX_STATUS_SRC_UDEV) + return _udev_dev_is_md(dev); + + log_error(INTERNAL_ERROR "Missing hook for MD device recognition " + "using auxiliary device status source %s", + dev_aux_status_source_name(dev->aux_status.source)); + + return -1; + +} + static int _md_sysfs_attribute_snprintf(char *path, size_t size, struct dev_types *dt, struct device *blkdev, diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c index fe79f3da5..c56cf5cab 100644 --- a/lib/filters/filter-md.c +++ b/lib/filters/filter-md.c @@ -29,7 +29,10 @@ static int _ignore_md(struct dev_filter *f __attribute__((unused)), ret = dev_is_md(dev, NULL); if (ret == 1) { - log_debug_devs("%s: Skipping md component device", dev_name(dev)); + log_debug_devs("%s: Skipping md component device [aux:%s/%p]", + dev_name(dev), + dev_aux_status_source_name_used(&dev->aux_status), + dev->aux_status.handle); return 0; } |