public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, aahringo@redhat.com
Subject: [PATCH dlm/next 1/3] dlm: fix recover_conversion() if grmode is unknown
Date: Mon,  4 Nov 2024 17:04:15 -0500	[thread overview]
Message-ID: <20241104220417.3883898-1-aahringo@redhat.com> (raw)

When a pending PR -> CW conversion is interrupted by a fence. While a
fence happened the master lock node of the pending PR -> CW conversion
was removed from the lockspace an recovery try to solve lock
dependencies. A new master node will be elected and the original granted
mode of the PR -> CW conversion cannot be determined anymore. In this
case recovery will set lkb_grmode to lkb_rqmode, but this will leave the
lkb in a invalid conversion state. Later on recovery will grant the
recovered lock state and it can't move out the lkb out of the conversion
queue to move it into the granted queue as the grmode is equal the
rqmode. At the end the lkb ends in an invalid state with grmode set to
DLM_LOCK_IV that can't handle future conversions.

To avoid this case we need to set the grmode to something different than
the rqmode. In the particular case we only run into PR <-> CW conversion.
If the rqmode is PR the grmode should be CW and vice versa to signal a
valid conversion on the conversion queue.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/recover.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c
index 2e1169c81c6e..7f748b21f1fb 100644
--- a/fs/dlm/recover.c
+++ b/fs/dlm/recover.c
@@ -831,11 +831,31 @@ static void recover_conversion(struct dlm_rsb *r)
 		if (lkb->lkb_grmode != DLM_LOCK_IV)
 			continue;
 		if (grmode == -1) {
-			log_debug(ls, "recover_conversion %x set gr to rq %d",
+			/* the information of rqmode was never lost, but
+			 * grmode was lost. The lkb is on the convertqueue
+			 * and requires that lkb_grmode is different than
+			 * lkb_rqmode to be granted later by
+			 * dlm_recover_grant(). The real grmode is unknown
+			 * but as the rqmode is either PR or CW we just
+			 * set grmode as the conversion queue indicates
+			 * contention because the lock mode was incompatible.
+			 */
+			switch (lkb->lkb_rqmode) {
+			case DLM_LOCK_PR:
+				lkb->lkb_grmode = DLM_LOCK_CW;
+				break;
+			case DLM_LOCK_CW:
+				lkb->lkb_grmode = DLM_LOCK_PR;
+				break;
+			default:
+				WARN_ON(1);
+				break;
+			}
+
+			log_debug(ls, "%s %x set gr to rq %d", __func__,
 				  lkb->lkb_id, lkb->lkb_rqmode);
-			lkb->lkb_grmode = lkb->lkb_rqmode;
 		} else {
-			log_debug(ls, "recover_conversion %x set gr %d",
+			log_debug(ls, "%s %x set gr %d", __func__,
 				  lkb->lkb_id, grmode);
 			lkb->lkb_grmode = grmode;
 		}
-- 
2.43.0


             reply	other threads:[~2024-11-04 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 22:04 Alexander Aring [this message]
2024-11-04 22:04 ` [PATCH dlm/next 2/3] dlm: add grmode sanity checks and debug info Alexander Aring
2024-11-04 22:04 ` [PATCH dlm/next 3/3] dlm: log_limit() recover_conversion() handling Alexander Aring

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=20241104220417.3883898-1-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=teigland@redhat.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