]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gfs2: Fix request cancelation bug
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 5 Feb 2025 16:16:38 +0000 (17:16 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 10 Mar 2025 17:15:38 +0000 (18:15 +0100)
In finish_xmote(), when a locking request is canceled, the corresponding
holder is moved to the tail of the holders list instead of being
dequeued immediately.  When there is only a single holder, the canceled
locking request is then immediately repeated.  This makes no sense; it
looks like another remnant of LM_FLAG_PRIORITY support.

Instead, dequeue canceled holders and proceed with the next holder in
finish_xmote().  We can then easily detect in gfs2_glock_dq() when a
holder has been canceled.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c

index 5d4d7b7f3af3dbd48bcc9177668bbb9c292ccbad..4d152e0e585ce8feddf83b688d3ccd20b6b9355e 100644 (file)
@@ -607,14 +607,19 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
                if (gh && (ret & LM_OUT_CANCELED))
                        gfs2_holder_wake(gh);
                if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) {
-                       /* move to back of queue and try next entry */
                        if (ret & LM_OUT_CANCELED) {
-                               list_move_tail(&gh->gh_list, &gl->gl_holders);
+                               list_del_init(&gh->gh_list);
+                               trace_gfs2_glock_queue(gh, 0);
+                               gl->gl_target = gl->gl_state;
                                gh = find_first_waiter(gl);
-                               gl->gl_target = gh->gh_state;
-                               if (do_promote(gl))
-                                       goto out;
-                               goto retry;
+                               if (gh) {
+                                       gl->gl_target = gh->gh_state;
+                                       if (do_promote(gl))
+                                               goto out;
+                                       do_xmote(gl, gh, gl->gl_target);
+                                       return;
+                               }
+                               goto out;
                        }
                        /* Some error or failed "try lock" - report it */
                        if ((ret & LM_OUT_ERROR) ||
@@ -627,7 +632,6 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
                switch(state) {
                /* Unlocked due to conversion deadlock, try again */
                case LM_ST_UNLOCKED:
-retry:
                        do_xmote(gl, gh, gl->gl_target);
                        break;
                /* Conversion fails, unlock and try again */
@@ -1672,6 +1676,8 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
                gl->gl_name.ln_sbd->sd_lockstruct.ls_ops->lm_cancel(gl);
                wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE);
                spin_lock(&gl->gl_lockref.lock);
+               if (!gfs2_holder_queued(gh))
+                       goto out;
        }
 
        /*