[dm-devel] [PATCH 13/31] libmultipath: add DI_NOIO flag for pathinfo

Martin Wilck mwilck at suse.com
Sat Sep 2 22:38:42 UTC 2017


This flag can used to avoid any IO on the device itself. Useful
for getting the path state without the risk of hanging or running
into IO errors.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 libmultipath/discovery.c | 8 ++++++++
 libmultipath/discovery.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 3a912d76..0ff2faa7 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1926,6 +1926,14 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
 	path_state = path_offline(pp);
 	if (path_state == PATH_REMOVED)
 		goto blank;
+	else if (mask & DI_NOIO) {
+		/*
+		 * Avoid any IO on the device itself.
+		 * Behave like DI_CHECKER in the "path unavailable" case.
+		 */
+		pp->chkrstate = pp->state = path_state;
+		return PATHINFO_OK;
+	}
 
 	/*
 	 * fetch info not available through sysfs
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 51c23d6f..65352881 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -62,6 +62,7 @@ enum discovery_mode {
 	__DI_PRIO,
 	__DI_WWID,
 	__DI_BLACKLIST,
+	__DI_NOIO,
 };
 
 #define DI_SYSFS	(1 << __DI_SYSFS)
@@ -70,6 +71,7 @@ enum discovery_mode {
 #define DI_PRIO		(1 << __DI_PRIO)
 #define DI_WWID		(1 << __DI_WWID)
 #define DI_BLACKLIST	(1 << __DI_BLACKLIST)
+#define DI_NOIO		(1 << __DI_NOIO) /* Avoid IO on the device */
 
 #define DI_ALL		(DI_SYSFS  | DI_SERIAL | DI_CHECKER | DI_PRIO | \
 			 DI_WWID)
-- 
2.14.0




More information about the dm-devel mailing list