gfs2: only apply DLM_LKF_VALBLK if sb_lvbptr is not NULL
authorAlexander Aring <aahringo@redhat.com>
Mon, 7 Apr 2025 18:45:38 +0000 (14:45 -0400)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 21 Apr 2025 16:20:36 +0000 (18:20 +0200)
Currently, gfs2 always sets the DLM_LKF_VALBLK flag to enable lvb
handling even when sb_lvbptr is NULL.  This currently causes no problems
because DLM ignores the DLM_LKF_VALBLK flag when sb_lvbptr is NULL, but
it does violate the DLM API.  Fix that by only setting DLM_LKF_VALBLK
when sb_lvbptr is not NULL.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/lock_dlm.c

index 2c9172dd41e7ee8cb91e75ca2cb6dfa5e35a6e29..7cb9d216d8bb9075ad91d3293db229116c415aed 100644 (file)
@@ -328,6 +328,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
 {
        struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
        struct lm_lockstruct *ls = &sdp->sd_lockstruct;
+       uint32_t flags = 0;
        int error;
 
        BUG_ON(!__lockref_is_dead(&gl->gl_lockref));
@@ -352,7 +353,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
         * When the lockspace is released, all remaining glocks will be
         * unlocked automatically.  This is more efficient than unlocking them
         * individually, but when the lock is held in DLM_LOCK_EX or
-        * DLM_LOCK_PW mode, the lock value block (LVB) will be lost.
+        * DLM_LOCK_PW mode, the lock value block (LVB) would be lost.
         */
 
        if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
@@ -361,8 +362,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
                return;
        }
 
+       if (gl->gl_lksb.sb_lvbptr)
+               flags |= DLM_LKF_VALBLK;
+
 again:
-       error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK,
+       error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, flags,
                           NULL, gl);
        if (error == -EBUSY) {
                msleep(20);