device-mapper-multipath/0120-libmultipath-pathinfo-...

89 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 2 Feb 2021 19:55:28 +0100
Subject: [PATCH] libmultipath: pathinfo: call filter_property only with
DI_BLACKLIST
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.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
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 febcd0ae..9be94cd1 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 960a7665..f5542ed0 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.17.2