mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_12-filter-mpath-work-with-nvme-devices.patch

cdbae0
 lib/device/dev-type.c      |  81 +++++++++++++++++++----
cdbae0
 lib/device/dev-type.h      |   2 +
cdbae0
 lib/device/device.h        |   1 +
cdbae0
 lib/filters/filter-mpath.c | 156 ++++++++++++++++++++++++++++++---------------
cdbae0
 4 files changed, 177 insertions(+), 63 deletions(-)
cdbae0
cdbae0
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
cdbae0
index 896821d..379afa8 100644
cdbae0
--- a/lib/device/dev-type.c
cdbae0
+++ b/lib/device/dev-type.c
cdbae0
@@ -21,6 +21,7 @@
cdbae0
 #include "lib/metadata/metadata.h"
cdbae0
 #include "lib/device/bcache.h"
cdbae0
 #include "lib/label/label.h"
cdbae0
+#include "lib/commands/toolcontext.h"
cdbae0
 
cdbae0
 #ifdef BLKID_WIPING_SUPPORT
cdbae0
 #include <blkid.h>
cdbae0
@@ -67,6 +68,31 @@ int dev_is_pmem(struct device *dev)
cdbae0
 	return is_pmem ? 1 : 0;
cdbae0
 }
cdbae0
 
cdbae0
+/*
cdbae0
+ * An nvme device has major number 259 (BLKEXT), minor number <minor>,
cdbae0
+ * and reading /sys/dev/block/259:<minor>/device/dev shows a character
cdbae0
+ * device cmajor:cminor where cmajor matches the major number of the
cdbae0
+ * nvme character device entry in /proc/devices.  Checking all of that
cdbae0
+ * is excessive and unnecessary compared to just comparing /dev/name*.
cdbae0
+ */
cdbae0
+
cdbae0
+int dev_is_nvme(struct dev_types *dt, struct device *dev)
cdbae0
+{
cdbae0
+	struct dm_str_list *strl;
cdbae0
+
cdbae0
+	if (dev->flags & DEV_IS_NVME)
cdbae0
+		return 1;
cdbae0
+
cdbae0
+	dm_list_iterate_items(strl, &dev->aliases) {
cdbae0
+		if (!strncmp(strl->str, "/dev/nvme", 9)) {
cdbae0
+			log_debug("Found nvme device %s", dev_name(dev));
cdbae0
+			dev->flags |= DEV_IS_NVME;
cdbae0
+			return 1;
cdbae0
+		}
cdbae0
+	}
cdbae0
+	return 0;
cdbae0
+}
cdbae0
+
cdbae0
 int dev_is_lv(struct device *dev)
cdbae0
 {
cdbae0
 	FILE *fp;
cdbae0
@@ -302,6 +328,9 @@ int dev_subsystem_part_major(struct dev_types *dt, struct device *dev)
cdbae0
 
cdbae0
 const char *dev_subsystem_name(struct dev_types *dt, struct device *dev)
cdbae0
 {
cdbae0
+	if (dev->flags & DEV_IS_NVME)
cdbae0
+		return "NVME";
cdbae0
+
cdbae0
 	if (MAJOR(dev->dev) == dt->device_mapper_major)
cdbae0
 		return "DM";
cdbae0
 
cdbae0
@@ -348,7 +377,6 @@ int major_is_scsi_device(struct dev_types *dt, int major)
cdbae0
 	return (dt->dev_type_array[major].flags & PARTITION_SCSI_DEVICE) ? 1 : 0;
cdbae0
 }
cdbae0
 
cdbae0
-
cdbae0
 static int _loop_is_with_partscan(struct device *dev)
cdbae0
 {
cdbae0
 	FILE *fp;
cdbae0
@@ -398,6 +426,28 @@ struct partition {
cdbae0
 	uint32_t nr_sects;
cdbae0
 } __attribute__((packed));
cdbae0
 
cdbae0
+static int _has_sys_partition(struct device *dev)
cdbae0
+{
cdbae0
+	char path[PATH_MAX];
cdbae0
+	struct stat info;
cdbae0
+	int major = (int) MAJOR(dev->dev);
cdbae0
+	int minor = (int) MINOR(dev->dev);
cdbae0
+
cdbae0
+	/* check if dev is a partition */
cdbae0
+	if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition",
cdbae0
+			dm_sysfs_dir(), major, minor) < 0) {
cdbae0
+		log_error("dm_snprintf partition failed");
cdbae0
+		return 0;
cdbae0
+	}
cdbae0
+
cdbae0
+	if (stat(path, &info) == -1) {
cdbae0
+		if (errno != ENOENT)
cdbae0
+			log_sys_error("stat", path);
cdbae0
+		return 0;
cdbae0
+	}
cdbae0
+	return 1;
cdbae0
+}
cdbae0
+
cdbae0
 static int _is_partitionable(struct dev_types *dt, struct device *dev)
cdbae0
 {
cdbae0
 	int parts = major_max_partitions(dt, MAJOR(dev->dev));
cdbae0
@@ -414,6 +464,13 @@ static int _is_partitionable(struct dev_types *dt, struct device *dev)
cdbae0
 	    _loop_is_with_partscan(dev))
cdbae0
 		return 1;
cdbae0
 
cdbae0
+	if (dev_is_nvme(dt, dev)) {
cdbae0
+		/* If this dev is already a partition then it's not partitionable. */
cdbae0
+		if (_has_sys_partition(dev))
cdbae0
+			return 0;
cdbae0
+		return 1;
cdbae0
+	}
cdbae0
+
cdbae0
 	if ((parts <= 1) || (MINOR(dev->dev) % parts))
cdbae0
 		return 0;
cdbae0
 
cdbae0
@@ -557,11 +614,18 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
cdbae0
 	char path[PATH_MAX];
cdbae0
 	char temp_path[PATH_MAX];
cdbae0
 	char buffer[64];
cdbae0
-	struct stat info;
cdbae0
 	FILE *fp = NULL;
cdbae0
 	int parts, residue, size, ret = 0;
cdbae0
 
cdbae0
 	/*
cdbae0
+	 * /dev/nvme devs don't use the major:minor numbering like
cdbae0
+	 * block dev types that have their own major number, so
cdbae0
+	 * the calculation based on minor number doesn't work.
cdbae0
+	 */
cdbae0
+	if (dev_is_nvme(dt, dev))
cdbae0
+		goto sys_partition;
cdbae0
+
cdbae0
+	/*
cdbae0
 	 * Try to get the primary dev out of the
cdbae0
 	 * list of known device types first.
cdbae0
 	 */
cdbae0
@@ -576,23 +640,14 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
cdbae0
 		goto out;
cdbae0
 	}
cdbae0
 
cdbae0
+ sys_partition:
cdbae0
 	/*
cdbae0
 	 * If we can't get the primary dev out of the list of known device
cdbae0
 	 * types, try to look at sysfs directly then. This is more complex
cdbae0
 	 * way and it also requires certain sysfs layout to be present
cdbae0
 	 * which might not be there in old kernels!
cdbae0
 	 */
cdbae0
-
cdbae0
-	/* check if dev is a partition */
cdbae0
-	if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition",
cdbae0
-			sysfs_dir, major, minor) < 0) {
cdbae0
-		log_error("dm_snprintf partition failed");
cdbae0
-		goto out;
cdbae0
-	}
cdbae0
-
cdbae0
-	if (stat(path, &info) == -1) {
cdbae0
-		if (errno != ENOENT)
cdbae0
-			log_sys_error("stat", path);
cdbae0
+	if (!_has_sys_partition(dev)) {
cdbae0
 		*result = dev->dev;
cdbae0
 		ret = 1;
cdbae0
 		goto out; /* dev is not a partition! */
cdbae0
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
cdbae0
index fdf7791..8b94b79 100644
cdbae0
--- a/lib/device/dev-type.h
cdbae0
+++ b/lib/device/dev-type.h
cdbae0
@@ -95,6 +95,8 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev);
cdbae0
 
cdbae0
 int dev_is_pmem(struct device *dev);
cdbae0
 
cdbae0
+int dev_is_nvme(struct dev_types *dt, struct device *dev);
cdbae0
+
cdbae0
 int dev_is_lv(struct device *dev);
cdbae0
 
cdbae0
 int get_fs_block_size(struct device *dev, uint32_t *fs_block_size);
cdbae0
diff --git a/lib/device/device.h b/lib/device/device.h
cdbae0
index a58bff8..816db31 100644
cdbae0
--- a/lib/device/device.h
cdbae0
+++ b/lib/device/device.h
cdbae0
@@ -38,6 +38,7 @@
cdbae0
 #define DEV_SCAN_FOUND_LABEL	0x00010000      /* label scan read dev and found label */
cdbae0
 #define DEV_IS_MD_COMPONENT	0x00020000	/* device is an md component */
cdbae0
 #define DEV_UDEV_INFO_MISSING   0x00040000	/* we have no udev info for this device */
cdbae0
+#define DEV_IS_NVME		0x00080000	/* set if dev is nvme */
cdbae0
 
cdbae0
 /*
cdbae0
  * Support for external device info.
cdbae0
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
cdbae0
index 85d1625..40e7df6 100644
cdbae0
--- a/lib/filters/filter-mpath.c
cdbae0
+++ b/lib/filters/filter-mpath.c
cdbae0
@@ -16,6 +16,7 @@
cdbae0
 #include "lib/misc/lib.h"
cdbae0
 #include "lib/filters/filter.h"
cdbae0
 #include "lib/activate/activate.h"
cdbae0
+#include "lib/commands/toolcontext.h"
cdbae0
 #ifdef UDEV_SYNC_SUPPORT
cdbae0
 #include <libudev.h>
cdbae0
 #include "lib/device/dev-ext-udev-constants.h"
cdbae0
@@ -27,7 +28,6 @@
cdbae0
 
cdbae0
 #define MPATH_PREFIX "mpath-"
cdbae0
 
cdbae0
-
cdbae0
 struct mpath_priv {
cdbae0
 	struct dm_pool *mem;
cdbae0
 	struct dev_filter f;
cdbae0
@@ -35,6 +35,9 @@ struct mpath_priv {
cdbae0
 	struct dm_hash_table *hash;
cdbae0
 };
cdbae0
 
cdbae0
+/*
cdbae0
+ * given "/dev/foo" return "foo"
cdbae0
+ */
cdbae0
 static const char *_get_sysfs_name(struct device *dev)
cdbae0
 {
cdbae0
 	const char *name;
cdbae0
@@ -53,6 +56,11 @@ static const char *_get_sysfs_name(struct device *dev)
cdbae0
 	return name;
cdbae0
 }
cdbae0
 
cdbae0
+/*
cdbae0
+ * given major:minor
cdbae0
+ * readlink translates /sys/dev/block/major:minor to /sys/.../foo
cdbae0
+ * from /sys/.../foo return "foo"
cdbae0
+ */
cdbae0
 static const char *_get_sysfs_name_by_devt(const char *sysfs_dir, dev_t devno,
cdbae0
 					  char *buf, size_t buf_size)
cdbae0
 {
cdbae0
@@ -102,27 +110,28 @@ static int _get_sysfs_string(const char *path, char *buffer, int max_size)
cdbae0
 	return r;
cdbae0
 }
cdbae0
 
cdbae0
-static int _get_sysfs_get_major_minor(const char *sysfs_dir, const char *kname, int *major, int *minor)
cdbae0
+static int _get_sysfs_dm_mpath(struct dev_types *dt, const char *sysfs_dir, const char *holder_name)
cdbae0
 {
cdbae0
-	char path[PATH_MAX], buffer[64];
cdbae0
+	char path[PATH_MAX];
cdbae0
+	char buffer[128];
cdbae0
 
cdbae0
-	if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev", sysfs_dir, kname) < 0) {
cdbae0
+	if (dm_snprintf(path, sizeof(path), "%sblock/%s/dm/uuid", sysfs_dir, holder_name) < 0) {
cdbae0
 		log_error("Sysfs path string is too long.");
cdbae0
 		return 0;
cdbae0
 	}
cdbae0
 
cdbae0
+	buffer[0] = '\0';
cdbae0
+
cdbae0
 	if (!_get_sysfs_string(path, buffer, sizeof(buffer)))
cdbae0
 		return_0;
cdbae0
 
cdbae0
-	if (sscanf(buffer, "%d:%d", major, minor) != 2) {
cdbae0
-		log_error("Failed to parse major minor from %s", buffer);
cdbae0
-		return 0;
cdbae0
-	}
cdbae0
+	if (!strncmp(buffer, MPATH_PREFIX, 6))
cdbae0
+		return 1;
cdbae0
 
cdbae0
-	return 1;
cdbae0
+	return 0;
cdbae0
 }
cdbae0
 
cdbae0
-static int _get_parent_mpath(const char *dir, char *name, int max_size)
cdbae0
+static int _get_holder_name(const char *dir, char *name, int max_size)
cdbae0
 {
cdbae0
 	struct dirent *d;
cdbae0
 	DIR *dr;
cdbae0
@@ -155,7 +164,7 @@ static int _get_parent_mpath(const char *dir, char *name, int max_size)
cdbae0
 }
cdbae0
 
cdbae0
 #ifdef UDEV_SYNC_SUPPORT
cdbae0
-static int _udev_dev_is_mpath(struct device *dev)
cdbae0
+static int _udev_dev_is_mpath_component(struct device *dev)
cdbae0
 {
cdbae0
 	const char *value;
cdbae0
 	struct dev_ext *ext;
cdbae0
@@ -174,95 +183,148 @@ static int _udev_dev_is_mpath(struct device *dev)
cdbae0
 	return 0;
cdbae0
 }
cdbae0
 #else
cdbae0
-static int _udev_dev_is_mpath(struct device *dev)
cdbae0
+static int _udev_dev_is_mpath_component(struct device *dev)
cdbae0
 {
cdbae0
 	return 0;
cdbae0
 }
cdbae0
 #endif
cdbae0
 
cdbae0
-static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
cdbae0
+static int _native_dev_is_mpath_component(struct cmd_context *cmd, struct dev_filter *f, struct device *dev)
cdbae0
 {
cdbae0
 	struct mpath_priv *mp = (struct mpath_priv *) f->private;
cdbae0
 	struct dev_types *dt = mp->dt;
cdbae0
-	const char *part_name, *name;
cdbae0
-	struct stat info;
cdbae0
-	char path[PATH_MAX], parent_name[PATH_MAX];
cdbae0
+	const char *part_name;
cdbae0
+	const char *name;               /* e.g. "sda" for "/dev/sda" */
cdbae0
+	char link_path[PATH_MAX];       /* some obscure, unpredictable sysfs path */
cdbae0
+	char holders_path[PATH_MAX];    /* e.g. "/sys/block/sda/holders/" */
cdbae0
+	char dm_dev_path[PATH_MAX];    /* e.g. "/dev/dm-1" */
cdbae0
+	char holder_name[128] = { 0 };  /* e.g. "dm-1" */
cdbae0
 	const char *sysfs_dir = dm_sysfs_dir();
cdbae0
-	int major = MAJOR(dev->dev);
cdbae0
-	int minor = MINOR(dev->dev);
cdbae0
+	int dev_major = MAJOR(dev->dev);
cdbae0
+	int dev_minor = MINOR(dev->dev);
cdbae0
+	int dm_dev_major;
cdbae0
+	int dm_dev_minor;
cdbae0
+	struct stat info;
cdbae0
 	dev_t primary_dev;
cdbae0
 	long look;
cdbae0
 
cdbae0
-	/* Limit this filter only to SCSI devices */
cdbae0
-	if (!major_is_scsi_device(dt, MAJOR(dev->dev)))
cdbae0
+	/* Limit this filter to SCSI or NVME devices */
cdbae0
+	if (!major_is_scsi_device(dt, dev_major) && !dev_is_nvme(dt, dev))
cdbae0
 		return 0;
cdbae0
 
cdbae0
 	switch (dev_get_primary_dev(dt, dev, &primary_dev)) {
cdbae0
+
cdbae0
 	case 2: /* The dev is partition. */
cdbae0
 		part_name = dev_name(dev); /* name of original dev for log_debug msg */
cdbae0
-		if (!(name = _get_sysfs_name_by_devt(sysfs_dir, primary_dev, parent_name, sizeof(parent_name))))
cdbae0
+
cdbae0
+		/* gets "foo" for "/dev/foo" where "/dev/foo" comes from major:minor */
cdbae0
+		if (!(name = _get_sysfs_name_by_devt(sysfs_dir, primary_dev, link_path, sizeof(link_path))))
cdbae0
 			return_0;
cdbae0
+
cdbae0
 		log_debug_devs("%s: Device is a partition, using primary "
cdbae0
 			       "device %s for mpath component detection",
cdbae0
 			       part_name, name);
cdbae0
 		break;
cdbae0
+
cdbae0
 	case 1: /* The dev is already a primary dev. Just continue with the dev. */
cdbae0
+
cdbae0
+		/* gets "foo" for "/dev/foo" */
cdbae0
 		if (!(name = _get_sysfs_name(dev)))
cdbae0
 			return_0;
cdbae0
 		break;
cdbae0
+
cdbae0
 	default: /* 0, error. */
cdbae0
-		log_warn("Failed to get primary device for %d:%d.", major, minor);
cdbae0
+		log_warn("Failed to get primary device for %d:%d.", dev_major, dev_minor);
cdbae0
 		return 0;
cdbae0
 	}
cdbae0
 
cdbae0
-	if (dm_snprintf(path, sizeof(path), "%s/block/%s/holders", sysfs_dir, name) < 0) {
cdbae0
+	if (dm_snprintf(holders_path, sizeof(holders_path), "%sblock/%s/holders", sysfs_dir, name) < 0) {
cdbae0
 		log_warn("Sysfs path to check mpath is too long.");
cdbae0
 		return 0;
cdbae0
 	}
cdbae0
 
cdbae0
 	/* also will filter out partitions */
cdbae0
-	if (stat(path, &info))
cdbae0
+	if (stat(holders_path, &info))
cdbae0
 		return 0;
cdbae0
 
cdbae0
 	if (!S_ISDIR(info.st_mode)) {
cdbae0
-		log_warn("Path %s is not a directory.", path);
cdbae0
+		log_warn("Path %s is not a directory.", holders_path);
cdbae0
 		return 0;
cdbae0
 	}
cdbae0
 
cdbae0
-	if (!_get_parent_mpath(path, parent_name, sizeof(parent_name)))
cdbae0
+	/*
cdbae0
+	 * If holders dir contains an entry such as "dm-1", then this sets
cdbae0
+	 * holder_name to "dm-1".
cdbae0
+	 *
cdbae0
+	 * If holders dir is empty, return 0 (this is generally where
cdbae0
+	 * devs that are not mpath components return.)
cdbae0
+	 */
cdbae0
+	if (!_get_holder_name(holders_path, holder_name, sizeof(holder_name)))
cdbae0
 		return 0;
cdbae0
 
cdbae0
-	if (!_get_sysfs_get_major_minor(sysfs_dir, parent_name, &major, &minor))
cdbae0
-		return_0;
cdbae0
+	if (dm_snprintf(dm_dev_path, sizeof(dm_dev_path), "%s/%s", cmd->dev_dir, holder_name) < 0) {
cdbae0
+		log_warn("dm device path to check mpath is too long.");
cdbae0
+		return 0;
cdbae0
+	}
cdbae0
 
cdbae0
-	if (major != dt->device_mapper_major)
cdbae0
+	/*
cdbae0
+	 * stat "/dev/dm-1" which is the holder of the dev we're checking
cdbae0
+	 * dm_dev_major:dm_dev_minor come from stat("/dev/dm-1")
cdbae0
+	 */
cdbae0
+	if (stat(dm_dev_path, &info)) {
cdbae0
+		log_debug("filter-mpath %s holder %s stat result %d",
cdbae0
+			  dev_name(dev), dm_dev_path, errno);
cdbae0
 		return 0;
cdbae0
+	}
cdbae0
+	dm_dev_major = (int)MAJOR(info.st_rdev);
cdbae0
+	dm_dev_minor = (int)MINOR(info.st_rdev);
cdbae0
+	
cdbae0
+	if (dm_dev_major != dt->device_mapper_major) {
cdbae0
+		log_debug_devs("filter-mpath %s holder %s %d:%d does not have dm major",
cdbae0
+			       dev_name(dev), dm_dev_path, dm_dev_major, dm_dev_minor);
cdbae0
+		return 0;
cdbae0
+	}
cdbae0
 
cdbae0
-	/* Avoid repeated detection of multipath device and use first checked result */
cdbae0
-	look = (long) dm_hash_lookup_binary(mp->hash, &minor, sizeof(minor));
cdbae0
+	/*
cdbae0
+	 * Save the result of checking that "/dev/dm-1" is an mpath device
cdbae0
+	 * to avoid repeating it for each path component.
cdbae0
+	 * The minor number of "/dev/dm-1" is added to the hash table with
cdbae0
+	 * const value 2 meaning that dm minor 1 (for /dev/dm-1) is a multipath dev
cdbae0
+	 * and const value 1 meaning that dm minor 1 is not a multipath dev.
cdbae0
+	 */
cdbae0
+	look = (long) dm_hash_lookup_binary(mp->hash, &dm_dev_minor, sizeof(dm_dev_minor));
cdbae0
 	if (look > 0) {
cdbae0
-		log_debug_devs("%s(%u:%u): already checked as %sbeing mpath.",
cdbae0
-			       parent_name, major, minor, (look > 1) ? "" : "not ");
cdbae0
+		log_debug_devs("filter-mpath %s holder %s %u:%u already checked as %sbeing mpath.",
cdbae0
+			       dev_name(dev), holder_name, dm_dev_major, dm_dev_minor, (look > 1) ? "" : "not ");
cdbae0
 		return (look > 1) ? 1 : 0;
cdbae0
 	}
cdbae0
 
cdbae0
-	if (lvm_dm_prefix_check(major, minor, MPATH_PREFIX)) {
cdbae0
-		(void) dm_hash_insert_binary(mp->hash, &minor, sizeof(minor), (void*)2);
cdbae0
+	/*
cdbae0
+	 * Returns 1 if /sys/block/<holder_name>/dm/uuid indicates that
cdbae0
+	 * <holder_name> is a dm device with dm uuid prefix mpath-.
cdbae0
+	 * When true, <holder_name> will be something like "dm-1".
cdbae0
+	 *
cdbae0
+	 * (Is a hash table worth it to avoid reading one sysfs file?)
cdbae0
+	 */
cdbae0
+	if (_get_sysfs_dm_mpath(dt, sysfs_dir, holder_name)) {
cdbae0
+		log_debug_devs("filter-mpath %s holder %s %u:%u ignore mpath component",
cdbae0
+			       dev_name(dev), holder_name, dm_dev_major, dm_dev_minor);
cdbae0
+		(void) dm_hash_insert_binary(mp->hash, &dm_dev_minor, sizeof(dm_dev_minor), (void*)2);
cdbae0
 		return 1;
cdbae0
 	}
cdbae0
 
cdbae0
-	(void) dm_hash_insert_binary(mp->hash, &minor, sizeof(minor), (void*)1);
cdbae0
+	(void) dm_hash_insert_binary(mp->hash, &dm_dev_minor, sizeof(dm_dev_minor), (void*)1);
cdbae0
 
cdbae0
 	return 0;
cdbae0
 }
cdbae0
 
cdbae0
-static int _dev_is_mpath(struct dev_filter *f, struct device *dev)
cdbae0
+static int _dev_is_mpath_component(struct cmd_context *cmd, struct dev_filter *f, struct device *dev)
cdbae0
 {
cdbae0
 	if (dev->ext.src == DEV_EXT_NONE)
cdbae0
-		return _native_dev_is_mpath(f, dev);
cdbae0
+		return _native_dev_is_mpath_component(cmd, f, dev);
cdbae0
 
cdbae0
 	if (dev->ext.src == DEV_EXT_UDEV)
cdbae0
-		return _udev_dev_is_mpath(dev);
cdbae0
+		return _udev_dev_is_mpath_component(dev);
cdbae0
 
cdbae0
 	log_error(INTERNAL_ERROR "Missing hook for mpath recognition "
cdbae0
 		  "using external device info source %s", dev_ext_name(dev));
cdbae0
@@ -272,11 +334,11 @@ static int _dev_is_mpath(struct dev_filter *f, struct device *dev)
cdbae0
 
cdbae0
 #define MSG_SKIPPING "%s: Skipping mpath component device"
cdbae0
 
cdbae0
-static int _ignore_mpath(struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name)
cdbae0
+static int _ignore_mpath_component(struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name)
cdbae0
 {
cdbae0
 	dev->filtered_flags &= ~DEV_FILTERED_MPATH_COMPONENT;
cdbae0
 
cdbae0
-	if (_dev_is_mpath(f, dev) == 1) {
cdbae0
+	if (_dev_is_mpath_component(cmd, f, dev) == 1) {
cdbae0
 		if (dev->ext.src == DEV_EXT_NONE)
cdbae0
 			log_debug_devs(MSG_SKIPPING, dev_name(dev));
cdbae0
 		else
cdbae0
@@ -303,8 +365,8 @@ static void _destroy(struct dev_filter *f)
cdbae0
 struct dev_filter *mpath_filter_create(struct dev_types *dt)
cdbae0
 {
cdbae0
 	const char *sysfs_dir = dm_sysfs_dir();
cdbae0
-	struct dm_pool *mem;
cdbae0
 	struct mpath_priv *mp;
cdbae0
+	struct dm_pool *mem;
cdbae0
 	struct dm_hash_table *hash;
cdbae0
 
cdbae0
 	if (!*sysfs_dir) {
cdbae0
@@ -328,19 +390,13 @@ struct dev_filter *mpath_filter_create(struct dev_types *dt)
cdbae0
 		goto bad;
cdbae0
 	}
cdbae0
 
cdbae0
-	if (!(mp = dm_pool_zalloc(mem, sizeof(*mp)))) {
cdbae0
-		log_error("mpath filter allocation failed.");
cdbae0
-		goto bad;
cdbae0
-	}
cdbae0
-
cdbae0
-	mp->f.passes_filter = _ignore_mpath;
cdbae0
+	mp->f.passes_filter = _ignore_mpath_component;
cdbae0
 	mp->f.destroy = _destroy;
cdbae0
 	mp->f.use_count = 0;
cdbae0
 	mp->f.private = mp;
cdbae0
 	mp->f.name = "mpath";
cdbae0
-
cdbae0
-	mp->mem = mem;
cdbae0
 	mp->dt = dt;
cdbae0
+	mp->mem = mem;
cdbae0
 	mp->hash = hash;
cdbae0
 
cdbae0
 	log_debug_devs("mpath filter initialised.");