149 lines
4.4 KiB
Diff
149 lines
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Date: Fri, 25 Jul 2025 23:58:46 -0400
|
|
Subject: [PATCH] multipathd: wrap setting and unsetting prflag
|
|
|
|
When prflag is unset, prhold and sa_flags should also be unset. A future
|
|
patch will add another variable to be set when prflag is set. Wrap all
|
|
these actions in set_pr() and unset_pr().
|
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Reviewed-by: Martin Wilck <mwilck@suse.com>
|
|
---
|
|
multipathd/cli_handlers.c | 10 ++++------
|
|
multipathd/main.c | 34 ++++++++++++++++++++--------------
|
|
multipathd/main.h | 2 ++
|
|
3 files changed, 26 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
|
|
index 94d0b63f..ee2764b9 100644
|
|
--- a/multipathd/cli_handlers.c
|
|
+++ b/multipathd/cli_handlers.c
|
|
@@ -1280,7 +1280,7 @@ cli_setprstatus(void * v, struct strbuf *reply, void * data)
|
|
return -ENODEV;
|
|
|
|
if (mpp->prflag != PR_SET) {
|
|
- mpp->prflag = PR_SET;
|
|
+ set_pr(mpp);
|
|
condlog(2, "%s: prflag set", param);
|
|
}
|
|
|
|
@@ -1301,12 +1301,10 @@ cli_unsetprstatus(void * v, struct strbuf *reply, void * data)
|
|
return -ENODEV;
|
|
|
|
if (mpp->prflag != PR_UNSET) {
|
|
- mpp->prflag = PR_UNSET;
|
|
condlog(2, "%s: prflag unset", param);
|
|
- }
|
|
- if (mpp->prhold != PR_UNSET) {
|
|
- mpp->prhold = PR_UNSET;
|
|
- condlog(2, "%s: prhold unset (by clearing prflag)", param);
|
|
+ if (mpp->prhold != PR_UNSET)
|
|
+ condlog(2, "%s: prhold unset (by clearing prflag)", param);
|
|
+ unset_pr(mpp);
|
|
}
|
|
|
|
return 0;
|
|
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
index bc42f2fa..e29ab2b8 100644
|
|
--- a/multipathd/main.c
|
|
+++ b/multipathd/main.c
|
|
@@ -3944,10 +3944,6 @@ static void check_prhold(struct multipath *mpp, struct path *pp)
|
|
struct prin_resp resp = {{{.prgeneration = 0}}};
|
|
int status;
|
|
|
|
- if (mpp->prflag == PR_UNSET) {
|
|
- mpp->prhold = PR_UNSET;
|
|
- return;
|
|
- }
|
|
if (mpp->prflag != PR_SET || mpp->prhold != PR_UNKNOWN)
|
|
return;
|
|
|
|
@@ -3966,6 +3962,18 @@ static void check_prhold(struct multipath *mpp, struct path *pp)
|
|
mpp->prhold = PR_SET;
|
|
}
|
|
|
|
+void set_pr(struct multipath *mpp)
|
|
+{
|
|
+ mpp->prflag = PR_SET;
|
|
+}
|
|
+
|
|
+void unset_pr(struct multipath *mpp)
|
|
+{
|
|
+ mpp->prflag = PR_UNSET;
|
|
+ mpp->prhold = PR_UNSET;
|
|
+ mpp->sa_flags = 0;
|
|
+}
|
|
+
|
|
static int update_map_pr(struct multipath *mpp, struct path *pp)
|
|
{
|
|
struct prin_resp resp;
|
|
@@ -3979,7 +3987,7 @@ static int update_map_pr(struct multipath *mpp, struct path *pp)
|
|
|
|
if (!get_be64(mpp->reservation_key)) {
|
|
/* Nothing to do. Assuming pr mgmt feature is disabled*/
|
|
- mpp->prflag = PR_UNSET;
|
|
+ unset_pr(mpp);
|
|
condlog(was_set ? 2 : 4,
|
|
"%s: reservation_key not set in multipath.conf",
|
|
mpp->alias);
|
|
@@ -3991,12 +3999,11 @@ static int update_map_pr(struct multipath *mpp, struct path *pp)
|
|
ret = prin_do_scsi_ioctl(pp->dev, MPATH_PRIN_RKEY_SA, &resp, 0);
|
|
if (ret != MPATH_PR_SUCCESS) {
|
|
if (ret == MPATH_PR_ILLEGAL_REQ)
|
|
- mpp->prflag = PR_UNSET;
|
|
+ unset_pr(mpp);
|
|
condlog(0, "%s : pr in read keys service action failed Error=%d",
|
|
mpp->alias, ret);
|
|
return ret;
|
|
}
|
|
- mpp->prflag = PR_UNSET;
|
|
|
|
condlog(4, "%s: Multipath reservation_key: 0x%" PRIx64 " ", mpp->alias,
|
|
get_be64(mpp->reservation_key));
|
|
@@ -4017,11 +4024,13 @@ static int update_map_pr(struct multipath *mpp, struct path *pp)
|
|
}
|
|
|
|
if (isFound) {
|
|
- mpp->prflag = PR_SET;
|
|
+ set_pr(mpp);
|
|
condlog(was_set ? 3 : 2, "%s: key found. prflag set.", mpp->alias);
|
|
- } else
|
|
+ } else {
|
|
+ unset_pr(mpp);
|
|
condlog(was_set ? 1 : 3, "%s: key not found. prflag unset.",
|
|
mpp->alias);
|
|
+ }
|
|
|
|
return MPATH_PR_SUCCESS;
|
|
}
|
|
@@ -4033,15 +4042,12 @@ static void mpath_pr_event_handle(struct path *pp)
|
|
struct prout_param_descriptor param;
|
|
|
|
if (pp->bus != SYSFS_BUS_SCSI) {
|
|
- mpp->prflag = PR_UNSET;
|
|
+ unset_pr(mpp);
|
|
return;
|
|
}
|
|
|
|
- if (update_map_pr(mpp, pp) != MPATH_PR_SUCCESS) {
|
|
- if (mpp->prflag == PR_UNSET)
|
|
- mpp->prhold = PR_UNSET;
|
|
+ if (update_map_pr(mpp, pp) != MPATH_PR_SUCCESS)
|
|
return;
|
|
- }
|
|
|
|
check_prhold(mpp, pp);
|
|
|
|
diff --git a/multipathd/main.h b/multipathd/main.h
|
|
index 4fcd6402..c9b3e0fd 100644
|
|
--- a/multipathd/main.h
|
|
+++ b/multipathd/main.h
|
|
@@ -52,4 +52,6 @@ bool check_path_wwid_change(struct path *pp);
|
|
int finish_path_init(struct path *pp, struct vectors * vecs);
|
|
int resize_map(struct multipath *mpp, unsigned long long size,
|
|
struct vectors *vecs);
|
|
+void set_pr(struct multipath *mpp);
|
|
+void unset_pr(struct multipath *mpp);
|
|
#endif /* MAIN_H */
|