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

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