[PATCH 2/3] libmultipath: pathinfo: call filter_property only with DI_BLACKLIST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

With the previous change to call filter_property() after sysfs_pathinfo(),
it can't happen any more that filter_property() is called from pathinfo
with uid_attribute not set. This may cause pathinfo() to return failure
in some cases where it should actually proceed (e.g. when called from
"multipath -m" -> get_refwwid(). Therefore, don't call filter_property()
any more unless DI_BLACKLIST is set.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/discovery.c | 16 ++++++----------
 tests/test-lib.c         | 17 +++++++++--------
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index febcd0a..9be94cd 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -2255,8 +2255,8 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
 		 * uid_attribute is required for filter_property below,
 		 * and needs access to pp->hwe.
 		 */
-		if (!(mask & DI_SYSFS) && !pp->uid_attribute &&
-		    VECTOR_SIZE(pp->hwe) == 0)
+		if (!(mask & DI_SYSFS) && (mask & DI_BLACKLIST) &&
+		    !pp->uid_attribute && VECTOR_SIZE(pp->hwe) == 0)
 			mask |= DI_SYSFS;
 	}
 
@@ -2295,17 +2295,13 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
 		}
 	}
 
-	if (pp->udev) {
+	if (mask & DI_BLACKLIST && mask & DI_SYSFS) {
 		/* uid_attribute is required for filter_property() */
-		if (!pp->uid_attribute)
+		if (pp->udev && !pp->uid_attribute)
 			select_getuid(conf, pp);
 
-		if (filter_property(conf, pp->udev, 4, pp->uid_attribute) > 0)
-			return PATHINFO_SKIPPED;
-	}
-
-	if (mask & DI_BLACKLIST && mask & DI_SYSFS) {
-		if (filter_device(conf->blist_device, conf->elist_device,
+		if (filter_property(conf, pp->udev, 4, pp->uid_attribute) > 0 ||
+		    filter_device(conf->blist_device, conf->elist_device,
 				  pp->vendor_id, pp->product_id, pp->dev) > 0 ||
 		    filter_protocol(conf->blist_protocol, conf->elist_protocol,
 				    pp) > 0)
diff --git a/tests/test-lib.c b/tests/test-lib.c
index 960a766..f5542ed 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -260,14 +260,15 @@ void mock_pathinfo(int mask, const struct mocked_path *mp)
 	if (mask & DI_SYSFS)
 		mock_sysfs_pathinfo(mp);
 
-	/* filter_property */
-	will_return(__wrap_udev_device_get_sysname, mp->devnode);
-	if (mp->flags & BL_BY_PROPERTY) {
-		will_return(__wrap_udev_list_entry_get_name, "BAZ");
-		return;
-	} else
-		will_return(__wrap_udev_list_entry_get_name,
-			    "SCSI_IDENT_LUN_NAA_EXT");
+	if (mask & DI_BLACKLIST) {
+		will_return(__wrap_udev_device_get_sysname, mp->devnode);
+		if (mp->flags & BL_BY_PROPERTY) {
+			will_return(__wrap_udev_list_entry_get_name, "BAZ");
+			return;
+		} else
+			will_return(__wrap_udev_list_entry_get_name,
+				    "SCSI_IDENT_LUN_NAA_EXT");
+	}
 
 	if (mp->flags & BL_BY_DEVICE &&
 	    (mask & DI_BLACKLIST && mask & DI_SYSFS))
-- 
2.29.2


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux