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

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