multipathd: skip spurious event message for blacklisted paths
v4 cover multipathd: skip spurious event message for blacklisted paths
This patch-set prevents this error message on 'change' uevents of paths that are blacklisted:
sdb: spurious uevent, path not found
And in that case, replaces it with this _debug_ message (so it's not logged by default; only when requested):
sdb: spurious uevent, path is blacklisted
Patch 1/3 fixes a potential leak observed while doing that. Patch 2/3 minor refactors two blacklist/filter checks into
pathinfo() to clean-up a bit and fix a couple of bugs (reported by Ben and Hannes)
Patch 3/3 finally does what the patch-set is supposed to.
Changelog:
- v2: switch approach from using path_discover() to using alloc_path_with_pathinfo() (Benjamin Marzinski).
- v3: drop calls to udev_device_ref/unref() (Benjamin Marzinski) move filter_property() into pathinfo() (Benjamin Marzinski)
- v4: move filter_devnode() into pathinfo() (Hannes Reinecke) ensure equivalency between path_discover() and pathinfo() for multipathd behavior.
Mauricio Faria de Oliveira (3):
libmultipath: prevent memory leak in alloc_path_with_pathinfo() if
pp_ptr is NULL
libmultipath: move filter_property|devnode() from path_discover() into
pathinfo()
multipathd: skip spurious event message for blacklisted paths
libmultipath/blacklist.c | 4 ++++ libmultipath/discovery.c | 23 +++++++++++++++-------- multipathd/main.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/3 libmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL
In alloc_path_with_pathinfo(), if the 'pp_ptr' argument is NULL (which is acceptable and checked in the function in two places) the 'pp' pointer is lost as it is not referenced anywhere else; thus the memory allocated for it is leaked.
So, call free_path() in the case 'pp_ptr' is NULL too.
--- libmultipath/discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/discovery.c +1 -1
@@ -58,7 +58,7 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice, err =pathinfo (pp, conf, flag |DI_BLACKLIST ); } -if (err) +if (err || !pp_ptr)free_path (pp);else if (pp_ptr) *pp_ptr = pp;
Signature · 1 line
1.8.3.1
PATCH v4 2/3 libmultipath: move filter_property|devnode() from path_discover() into pathinfo()
In reply to Mauricio Faria de OliveiraThe udev property blacklisting is ignored on 'add' uevents because uev_add_path() calls pathinfo() directly - but the filter_property() check is only performed in path_discover().
So, move the call out from path_discover() into pathinfo(). While in there, do that for filter_devnode() too.
Since path_discover() always calls pathinfo() to return, either directly or via store_pathinfo(), the change is equivalent for callers of path_discover(), which turns out to be only path_discovery().
Interestingly, multipathd calls path_discovery() without DI_BLACKLIST and then calls filter_path() to remove paths. Thus, in order to guarantee equivalency (and prevent lots of more debug messages for discovery of devices that will be removed afterward), perform filter_property|devnode() without checking for DI_BLACKLIST; and make sure that filter_path() checks filter_property() (it already checks filter_devnode()).
Test-case:
# cat /etc/multipath.conf
blacklist {
property "ID_SERIAL"
}# multipathd -d -s -v3 & ... sdb: udev property ID_SERIAL blacklisted ...
# echo add > /sys/block/sdb/uevent
Before:
uevent 'add' from '/devices/.../block/sdb'
Forwarding 1 uevents
sdb: add path (uevent)
...
0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1: load table [0 4194304 multipath 1 retain_attached_hw_handler 0 1 1 service-time 0 1 1 8:16 1]
...
sdb [8:16]: path added to devmap 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1
After:
uevent 'add' from '/devices/.../block/sdb'
Forwarding 1 uevents
sdb: add path (uevent)
sdb: udev property ID_SERIAL blacklisted
--- libmultipath/blacklist.c | 4 ++++ libmultipath/discovery.c | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-)
libmultipath/blacklist.c +4 -0
@@ -327,6 +327,10 @@ _filter_path (struct config * conf, struct path * pp) {int r; + r =filter_property (conf, pp->udev); +if (r >0 ) +return r; + r =_filter_devnode (conf->blist_devnode, conf->elist_devnode,pp->dev);if (r >0 )return r;
libmultipath/discovery.c +14 -7
@@ -117,13 +117,6 @@ path_discover (vector pathvec, struct config * conf,if (!devname)return PATHINFO_FAILED ; -if (filter_property (conf, udevice) >0 ) -return PATHINFO_SKIPPED ; - -if (filter_devnode (conf->blist_devnode, conf->elist_devnode, - (char *)devname) >0 ) -return PATHINFO_SKIPPED ; - pp =find_path_by_dev (pathvec, (char *)devname);if (!pp) { return store_pathinfo(pathvec, conf,
@@ -1745,6 +1738,20 @@ int pathinfo(struct path *pp, struct config *conf, int mask)if (!pp)return PATHINFO_FAILED ; +/* +* For behavior backward-compatibility with multipathd, +* the blacklisting by filter_property|devnode() is not +* limited by DI_BLACKLIST and occurs before this debug +* message with the mask value. +*/ +if (pp->udev &&filter_property (conf, pp->udev) >0 ) +return PATHINFO_SKIPPED ; + +if (filter_devnode (conf->blist_devnode, + conf->elist_devnode, + pp->dev) >0 ) +return PATHINFO_SKIPPED ; +condlog (3 ,"%s: mask = 0x%x" , pp->dev, mask);/*
Signature · 1 line
1.8.3.1
PATCH v4 3/3 multipathd: skip spurious event message for blacklisted paths
In reply to Mauricio Faria de OliveiraCurrently, multipath still prints the 'spurious uevent, path not found' message if a path is blacklisted by something different than a devnode in the 'change' uevent handling. (uev_trigger() calls filter_devnode()).
Thus blacklisting by vendor/product, wwid, and udev property still get that message in the system log for paths that are explicitly marked to be ignored (since it's verbosity level 0).
This problem happens on common scenarios such as creating filesystems on a blacklisted device (e.g., mkfs.* /dev/sdX), which is usually run several times on test environments, and the error message may mislead the error checker/monitor tools with false negatives.
This patch resolves it by checking alloc_path_with_pathinfo()/pathinfo() for PATHINFO_SKIPPED with just enough device information flags for blacklist verification -- and it prints a debug message (verbosity level 3) instead of an error message since this case is not an error.
Even though this introduces a bit of overhead (to get the path info), it only happens in a corner case of an error path; so, not a problem.
Test-cases (on QEMU):
----------
Several versions of /etc/multipath.conf:
blacklist {
devnode "sdb"
}
blacklist {
property "ID_SERIAL"
}
blacklist {
wwid "0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1"
}
blacklist {
device {
vendor "QEMU"
}
}Either command can be used to generate a 'change' uevent:
# echo change > /sys/block/sdb/uevent
# mkfs.ext3 -F /dev/sdb
The output of multipathd is monitored with:
# multipathd -d -s ...
Without the patch, only the devnode blacklisting is silent; all other cases (property, wwid, device) print the message:
sdb: spurious uevent, path not found
With the patch applied, no message is printed by default (that is, verbosity level 2) in any case.
With verbosity level 3 (debug), the following messages are printed, according to the performed test-case:
uevent 'change' from '/devices/.../block/sdb'
Forwarding 1 uevents
< and either of >
sdb: device node name blacklisted
sdb: udev property ID_SERIAL blacklisted
sdb: spurious uevent, path is blacklisted
sdb: wwid 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1 blacklisted
sdb: spurious uevent, path is blacklisted
(null): (QEMU:QEMU HARDDISK) vendor/product blacklisted
sdb: spurious uevent, path is blacklisted
--- multipathd/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
multipathd/main.c +16 -1
@@ -1010,8 +1010,23 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } out:lock_cleanup_pop (vecs->lock); -if (!pp) +if (!pp) { +/* If the path is blacklisted, print a debug/non-default verbosity message. */ +if (uev->udev) { +int flag =DI_SYSFS |DI_WWID ; + + conf =get_multipath_config (); + retval =alloc_path_with_pathinfo (conf, uev->udev, flag,NULL ); +put_multipath_config (conf); + +if (retval ==PATHINFO_SKIPPED ) { +condlog (3 ,"%s: spurious uevent, path is blacklisted" , uev->kernel); +return 0 ; + } + } +condlog (0 ,"%s: spurious uevent, path not found" , uev->kernel); + }return retval; }
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerACK for the set.
-Ben
Quoted 39 lines · Mauricio Faria de Oliveira
This patch-set prevents this error message on 'change' uevents of paths that are blacklisted:
sdb: spurious uevent, path not found
And in that case, replaces it with this _debug_ message (so it's not logged by default; only when requested):
sdb: spurious uevent, path is blacklisted
Patch 1/3 fixes a potential leak observed while doing that. Patch 2/3 minor refactors two blacklist/filter checks into
pathinfo()to clean-up a bit and fix a couple of bugs (reported by Ben and Hannes)
Patch 3/3 finally does what the patch-set is supposed to.Changelog:
- v2: switch approach from usingpath_discover()to usingalloc_path_with_pathinfo()(Benjamin Marzinski).
- v3: drop calls to udev_device_ref/unref() (Benjamin Marzinski) movefilter_property()intopathinfo()(Benjamin Marzinski)
- v4: movefilter_devnode()intopathinfo()(Hannes Reinecke) ensure equivalency betweenpath_discover()andpathinfo()for multipathd behavior.Mauricio Faria de Oliveira (3):
libmultipath: prevent memory leak inalloc_path_with_pathinfo()if
pp_ptris NULL
libmultipath: move filter_property|devnode() frompath_discover()into
pathinfo()
multipathd: skip spurious event message for blacklisted pathslibmultipath/blacklist.c | 4 ++++ libmultipath/discovery.c | 23 +++++++++++++++-------- multipathd/main.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-)Signature · 1 line
1.8.3.1
This set is merged.
Thanks.
Quoted 45 lines · Benjamin Marzinski
ACK for the set.
-Ben
Quoted 39 lines · Mauricio Faria de Oliveira
This patch-set prevents this error message on 'change' uevents of paths that are blacklisted:
sdb: spurious uevent, path not found
And in that case, replaces it with this _debug_ message (so it's not logged by default; only when requested):
sdb: spurious uevent, path is blacklisted
Patch 1/3 fixes a potential leak observed while doing that. Patch 2/3 minor refactors two blacklist/filter checks into
pathinfo()to clean-up a bit and fix a couple of bugs (reported by Ben and Hannes)
Patch 3/3 finally does what the patch-set is supposed to.Changelog:
- v2: switch approach from usingpath_discover()to usingalloc_path_with_pathinfo()(Benjamin Marzinski).
- v3: drop calls to udev_device_ref/unref() (Benjamin Marzinski) movefilter_property()intopathinfo()(Benjamin Marzinski)
- v4: movefilter_devnode()intopathinfo()(Hannes Reinecke) ensure equivalency betweenpath_discover()andpathinfo()for multipathd behavior.Mauricio Faria de Oliveira (3):
libmultipath: prevent memory leak inalloc_path_with_pathinfo()if
pp_ptris NULL
libmultipath: move filter_property|devnode() frompath_discover()into
pathinfo()
multipathd: skip spurious event message for blacklisted pathslibmultipath/blacklist.c | 4 ++++ libmultipath/discovery.c | 23 +++++++++++++++-------- multipathd/main.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-)--
1.8.3.1