Skip to contentSkip to conversation

libmultipath: export path_discover()

PATCH In review Mauricio Faria de Oliveira 2 participants 5 messages Dec 10, 2016 – Dec 13, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libmultipath: export path_discover()

In order to call path_discover() from multipathd (for the next patch), make it visible to other units (header declaration, static modifier).

---
 libmultipath/discovery.c | 2 +-
 libmultipath/discovery.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
libmultipath/discovery.c +1 -1
index 7b5b434..865b53b 100644
@@ -106,7 +106,7 @@ out:
 	return err;
 }
 
-static int
+int
 path_discover (vector pathvec, struct config * conf,
 	       struct udev_device *udevice, int flag)
 {
libmultipath/discovery.h +2 -0
index 3039268..34a41d4 100644
@@ -31,6 +31,8 @@
 struct config;
 
 int path_discovery (vector pathvec, int flag);
+int path_discover (vector pathvec, struct config * conf,
+		   struct udev_device *udevice, int flag);
 
 int do_tur (char *);
 int path_offline (struct path *);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 multipathd: skip spurious event message for blacklisted paths

Currently, 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 device vendor/product and wwid still renders that message in the system log -- since it's verbosity level 0 -- for paths that are explicitly marked to be ignored.

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 this problem by calling/checking path_discover() 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 it introduces a bit of overhead to get the path info, it is only exercised in the error/non-default path -- so not a problem.

Test-case (on QEMU):

/etc/multipath.conf:

  blacklist {
      device {
          vendor "QEMU"
       }
  }
  # multipathd -d &
  ...
  Dec 10 08:06:27 | sda: (QEMU:QEMU HARDDISK) vendor/product blacklisted
  ...
  # mkfs.ext3 -F /dev/sda
  ...
  Dec 10 08:07:05 | sda: spurious uevent, path not found

With the patch applied, no message is printed by default. It's still possible to get the event logged for debug with '-v3':

  Dec 10 09:08:51 | sda: spurious uevent, path blacklisted
---
 multipathd/main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
multipathd/main.c +21 -1
index d6f081f..364fecb 100644
@@ -1010,8 +1010,28 @@ 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_BLACKLIST | DI_SYSFS | DI_WWID;
+			struct udev_device *udevice;
+
+			udevice = udev_device_ref(uev->udev);
+			conf = get_multipath_config();
+
+			retval = path_discover(NULL, conf, udevice, flag);
+
+			put_multipath_config(conf);
+			udev_device_unref(uev->udev);
+
+			if (retval == PATHINFO_SKIPPED) {
+				condlog(3, "%s: spurious uevent, path blacklisted", uev->kernel);
+				return 0;
+			}
+		}
+
 		condlog(0, "%s: spurious uevent, path not found", uev->kernel);
+	}
 
 	return retval;
 }
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] multipathd: skip spurious event message for blacklisted paths

Why don't we just call pathinfo here? I see that you set the pathvec to NULL so that you don't actually store the path, but this sure does a lot of unnecessary work before failing. AFAICT, just calling pathinfo with DI_BLACKLIST already gets you what you need (it checks both the device and wwid blacklists). Am I missing something here?

-Ben

Quoted 93 lines · Mauricio Faria de Oliveira

Currently, 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 device vendor/product and wwid still renders that message in the system log -- since it's verbosity level 0 -- for paths that are explicitly marked to be ignored.

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 this problem by calling/checking path_discover() 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 it introduces a bit of overhead to get the path info, it is only exercised in the error/non-default path -- so not a problem.

Test-case (on QEMU):

/etc/multipath.conf:

  blacklist {
      device {
          vendor "QEMU"
       }
  }
  # multipathd -d &
  ...
  Dec 10 08:06:27 | sda: (QEMU:QEMU HARDDISK) vendor/product blacklisted
  ...
  # mkfs.ext3 -F /dev/sda
  ...
  Dec 10 08:07:05 | sda: spurious uevent, path not found

With the patch applied, no message is printed by default. It's still possible to get the event logged for debug with '-v3':

  Dec 10 09:08:51 | sda: spurious uevent, path blacklisted
---
 multipathd/main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
multipathd/main.c +21 -1
index d6f081f..364fecb 100644
@@ -1010,8 +1010,28 @@ 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_BLACKLIST | DI_SYSFS | DI_WWID;
+			struct udev_device *udevice;
+
+			udevice = udev_device_ref(uev->udev);
+			conf = get_multipath_config();
+
+			retval = path_discover(NULL, conf, udevice, flag);
+
+			put_multipath_config(conf);
+			udev_device_unref(uev->udev);
+
+			if (retval == PATHINFO_SKIPPED) {
+				condlog(3, "%s: spurious uevent, path blacklisted", uev->kernel);
+				return 0;
+			}
+		}
+
 		condlog(0, "%s: spurious uevent, path not found", uev->kernel);
+	}
 
 	return retval;
 }
Signature · 6 lines
2.7.4

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#3 lore raw

Re: [PATCH 2/2] multipathd: skip spurious event message for blacklisted paths

Ben,

Thanks for reviewing,

Quoted 5 lines · Benjamin Marzinski

Why don't we just call pathinfo here? I see that you set the pathvec to NULL so that you don't actually store the path, but this sure does a lot of unnecessary work before failing. AFAICT, just calling pathinfo with DI_BLACKLIST already gets you what you need (it checks both the device and wwid blacklists). Am I missing something here?

path_discover() also calls filter_property() and filter_devnode(), so more blacklisting methods are covered.

(filter_devnode() is also checked by uev_trigger(), but I wanted to reuse the existing code to keep the patch simple.)

And afaik there is not a lot more being done in path_discover()

Quoted 1 line

store_pathinfo() > path_info() vs the direct path_info() call;

There /is/ some overhead, you're right, but since this is only in the error path of this corner case, it seemed to be not a big deal.

Signature · 2 lines
Mauricio Faria de Oliveira
IBM Linux Technology Center
#4 lore raw

Re: [PATCH 2/2] multipathd: skip spurious event message for blacklisted paths

Ben,

Quoted 7 lines · Mauricio Faria de Oliveira
Quoted 5 lines · Benjamin Marzinski

Why don't we just call pathinfo here? I see that you set the pathvec to NULL so that you don't actually store the path, but this sure does a lot of unnecessary work before failing. AFAICT, just calling pathinfo with DI_BLACKLIST already gets you what you need (it checks both the device and wwid blacklists). Am I missing something here?

Quoted 5 lines

path_discover() also calls filter_property() and filter_devnode(), so more blacklisting methods are covered.

(filter_devnode() is also checked by uev_trigger(), but I wanted to reuse the existing code to keep the patch simple.)

I found a better way to do this which should also honor your point about the unnecessary work/overhead; PATCH v2 on the way.

Signature · 2 lines
Mauricio Faria de Oliveira
IBM Linux Technology Center