[PATCH dlm/next 5/5] dlm: more debug info on invalid lock requests

Alexander Aring
2024-11-13T16:46:59Z

Recently there was an issue coming up about an invalid lkb state when a
convert was triggered. After investigation an recovery issue was the
root of the problem. However we only saw it because QUECVT flag was
being set that was leading DLM to return with -EINVAL on such invalid
state. To cover also such case without QUECVT is set we introduce more
conditions that are required to be checked before initial a DLM lock
conversion.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lock.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 1e809f591d1a..7217cc566175 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -2830,6 +2830,11 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
if (test_bit(DLM_IFL_MSTCPY_BIT, &lkb->lkb_iflags))
goto out;

+ /* sanity check to do a conversion on a invalid lkb state */
+ if (lkb->lkb_grmode == DLM_LOCK_IV ||
+ lkb->lkb_status != DLM_LKSTS_GRANTED)
+ goto out;
+
if (args->flags & DLM_LKF_QUECVT &&
!__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1])
goto out;
@@ -2852,14 +2857,16 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
case -EINVAL:
/* annoy the user because dlm usage is wrong */
WARN_ON(1);
- log_error(ls, "%s %d %x %x %x %d %d", __func__,
+ log_error(ls, "%s %d %x %x %x %d %d %d %d", __func__,
rv, lkb->lkb_id, dlm_iflags_val(lkb), args->flags,
- lkb->lkb_status, lkb->lkb_wait_type);
+ lkb->lkb_status, lkb->lkb_wait_type,
+ lkb->lkb_rqmode, lkb->lkb_grmode);
break;
default:
- log_debug(ls, "%s %d %x %x %x %d %d", __func__,
+ log_debug(ls, "%s %d %x %x %x %d %d %d %d", __func__,
rv, lkb->lkb_id, dlm_iflags_val(lkb), args->flags,
- lkb->lkb_status, lkb->lkb_wait_type);
+ lkb->lkb_status, lkb->lkb_wait_type,
+ lkb->lkb_rqmode, lkb->lkb_grmode);
break;
}

--
2.43.0