public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 03/13] gfs2: run_queue cleanup
Date: Fri, 23 Jan 2026 16:30:53 +0100	[thread overview]
Message-ID: <20260123153105.797382-4-agruenba@redhat.com> (raw)
In-Reply-To: <20260123153105.797382-1-agruenba@redhat.com>

In run_queue(), instead of always setting the GLF_LOCK flag, only set it
when the flag is actually needed.  This avoids having to undo the flag
setting later.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/glock.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index f358448d7b3d..776179933315 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -753,13 +753,10 @@ __acquires(&gl->gl_lockref.lock)
 
 	if (test_bit(GLF_LOCK, &gl->gl_flags))
 		return;
-	set_bit(GLF_LOCK, &gl->gl_flags);
 
 	/*
-	 * The GLF_DEMOTE_IN_PROGRESS flag is only set intermittently during
-	 * locking operations.  We have just started a locking operation by
-	 * setting the GLF_LOCK flag, so the GLF_DEMOTE_IN_PROGRESS flag must
-	 * be cleared.
+	 * The GLF_DEMOTE_IN_PROGRESS flag must only be set when the GLF_LOCK
+	 * flag is set as well.
 	 */
 	GLOCK_BUG_ON(gl, test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags));
 
@@ -770,12 +767,13 @@ __acquires(&gl->gl_lockref.lock)
 		}
 
 		if (find_first_holder(gl))
-			goto out_unlock;
+			return;
 		if (nonblock)
 			goto out_sched;
 		set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
 		GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
 		gl->gl_target = gl->gl_demote_state;
+		set_bit(GLF_LOCK, &gl->gl_flags);
 		do_xmote(gl, NULL, gl->gl_target);
 		return;
 	}
@@ -783,26 +781,22 @@ __acquires(&gl->gl_lockref.lock)
 promote:
 	do_promote(gl);
 	if (find_first_holder(gl))
-		goto out_unlock;
+		return;
 	gh = find_first_waiter(gl);
 	if (!gh)
-		goto out_unlock;
+		return;
 	if (nonblock)
 		goto out_sched;
 	gl->gl_target = gh->gh_state;
 	if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
 		do_error(gl, 0); /* Fail queued try locks */
+	set_bit(GLF_LOCK, &gl->gl_flags);
 	do_xmote(gl, gh, gl->gl_target);
 	return;
 
 out_sched:
-	clear_bit(GLF_LOCK, &gl->gl_flags);
 	gl->gl_lockref.count++;
 	gfs2_glock_queue_work(gl, 0);
-	return;
-
-out_unlock:
-	clear_bit(GLF_LOCK, &gl->gl_flags);
 }
 
 /**
-- 
2.52.0


  parent reply	other threads:[~2026-01-23 15:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-23 15:30 [PATCH 00/13] gfs2 patches on for-next Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 01/13] gfs2: glock cancelation flag fix Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 02/13] gfs2: Retries missing in gfs2_{rename,exchange} Andreas Gruenbacher
2026-01-23 15:30 ` Andreas Gruenbacher [this message]
2026-01-23 15:30 ` [PATCH 04/13] gfs2: Do not cancel internal demote requests Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 05/13] Revert "gfs2: Fix use of bio_chain" Andreas Gruenbacher
2026-01-26 14:25   ` Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 06/13] gfs2: Rename gfs2_log_submit_{bio -> write} Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 07/13] gfs2: Initialize bio->bi_opf early Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 08/13] gfs2: gfs2_chain_bio start sector fix Andreas Gruenbacher
2026-01-23 15:30 ` [PATCH 09/13] gfs2: Fix gfs2_log_get_bio argument type Andreas Gruenbacher
2026-01-23 15:31 ` [PATCH 10/13] gfs: Use fixed GL_GLOCK_MIN_HOLD time Andreas Gruenbacher
2026-01-23 15:31 ` [PATCH 11/13] gfs2: gfs2_glock_hold cleanup Andreas Gruenbacher
2026-01-23 15:31 ` [PATCH 12/13] gfs2: Introduce glock_{type,number,sbd} helpers Andreas Gruenbacher
2026-01-23 15:31 ` [PATCH 13/13] gfs2: Fix slab-use-after-free in qd_put Andreas Gruenbacher

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=20260123153105.797382-4-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    /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