Blame SOURCES/0019-mpathpersist-fail-commands-when-no-usable-paths-exis.patch

68b27c
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
68b27c
From: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
Date: Thu, 15 Jul 2021 17:09:05 -0500
68b27c
Subject: [PATCH] mpathpersist: fail commands when no usable paths exist
68b27c
68b27c
"mpathpersist -oCK <reservation_key> <device>" will return success if it
68b27c
is run on devices with no usable paths, but nothing is actually done.
68b27c
The -L command will fail, but it should give up sooner, and with a more
68b27c
helpful error message.
68b27c
68b27c
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
---
68b27c
 libmpathpersist/mpath_persist.c | 8 +++++++-
68b27c
 1 file changed, 7 insertions(+), 1 deletion(-)
68b27c
68b27c
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
68b27c
index 190e9707..26710e79 100644
68b27c
--- a/libmpathpersist/mpath_persist.c
68b27c
+++ b/libmpathpersist/mpath_persist.c
68b27c
@@ -604,7 +604,8 @@ int mpath_prout_common(struct multipath *mpp,int rq_servact, int rq_scope,
68b27c
 			return ret ;
68b27c
 		}
68b27c
 	}
68b27c
-	return MPATH_PR_SUCCESS;
68b27c
+	condlog (0, "%s: no path available", mpp->wwid);
68b27c
+	return MPATH_PR_DMMP_ERROR;
68b27c
 }
68b27c
 
68b27c
 int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
68b27c
@@ -663,6 +664,11 @@ int mpath_prout_rel(struct multipath *mpp,int rq_servact, int rq_scope,
68b27c
 
68b27c
 	active_pathcount = count_active_paths(mpp);
68b27c
 
68b27c
+	if (active_pathcount == 0) {
68b27c
+		condlog (0, "%s: no path available", mpp->wwid);
68b27c
+		return MPATH_PR_DMMP_ERROR;
68b27c
+	}
68b27c
+
68b27c
 	struct threadinfo thread[active_pathcount];
68b27c
 	memset(thread, 0, sizeof(thread));
68b27c
 	for (i = 0; i < active_pathcount; i++){