From: Cykang <cykang4830@gmail.com>
To: dm-devel@lists.linux.dev
Cc: Benjamin Marzinski <bmarzins@redhat.com>,
Martin Wilck <mwilck@suse.com>, Cykang <cykang4830@gmail.com>
Subject: [PATCH] libmpathpersist: fix self-preemption when key has no active reservation
Date: Sat, 11 Jul 2026 11:31:07 +0800 [thread overview]
Message-ID: <20260711033107.2318-1-cykang4830@gmail.com> (raw)
According to the SCSI-3 Persistent Reservations specification, when a
self-preemption is performed with a key that does not currently hold
an active reservation, the operation should be treated as an unregister
and should not fail.
The current code in do_mpath_persistent_reserve_out() does not check
whether the preempting key has a reservation before invoking the
self-preemption path. It unconditionally calls preempt_self() and
re-registers the key on the local paths, even when the key has no
reservation. This violates the SCSI-3 PR spec and can lead to
incorrect reservation states.
This patch moves the self-preemption check inside the conditional
block so that it only executes when the key matches, but does not
bypass the general preemption path for keys without a reservation.
With this change, the code will fall through to the common PR_OUT
handling (e.g., MPATH_PROUT_RES_SA or CLEAR_SA) when the key is not
reserved, allowing the storage target to properly process the
operation as an unregister.
Signed-off-by: Cykang <cykang4830@gmail.com>
---
libmpathpersist/mpath_persist_int.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c
index 3091c5c2..2ee7fe68 100644
--- a/libmpathpersist/mpath_persist_int.c
+++ b/libmpathpersist/mpath_persist_int.c
@@ -960,14 +960,15 @@ int do_mpath_persistent_reserve_out(vector curmp, vector pathvec, int fd,
ret = preempt_all(mpp, rq_servact, rq_scope,
rq_type, noisy);
break;
+ }
+ /* if we are preempting ourself */
+ if (memcmp(paramp->sa_key, paramp->key, 8) == 0) {
+ ret = preempt_self(mpp, rq_servact, rq_scope, rq_type,
+ noisy, PREE_WORK_NONE);
+ break;
}
}
- /* if we are preempting ourself */
- if (memcmp(paramp->sa_key, paramp->key, 8) == 0) {
- ret = preempt_self(mpp, rq_servact, rq_scope, rq_type,
- noisy, PREE_WORK_NONE);
- break;
- }
+
/* fallthrough */
case MPATH_PROUT_RES_SA:
case MPATH_PROUT_CLEAR_SA: {
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-07-11 3:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260711033107.2318-1-cykang4830@gmail.com \
--to=cykang4830@gmail.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=mwilck@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox