public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev, Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Miklos Szeredi <mszeredi@redhat.com>
Subject: [PATCH 4/5] gfs2: Enable non-blocking lookup in gfs2_permission
Date: Sat,  1 Nov 2025 08:09:18 +0000	[thread overview]
Message-ID: <20251101080919.1290117-5-agruenba@redhat.com> (raw)
In-Reply-To: <20251101080919.1290117-1-agruenba@redhat.com>

Under MAY_NOT_BLOCK, we consider the cached permissions "good enough" if
the glock still appears to be held.

Reviewed-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 3d87ecd277a1..af38676a408f 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1955,14 +1955,14 @@ int gfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
 	gfs2_holder_mark_uninitialized(&i_gh);
 	ip = GFS2_I(inode);
 	gl = rcu_dereference_check(ip->i_gl, !may_not_block);
-	if (unlikely(!gl)) {
-		/* inode is getting torn down, must be RCU mode */
-		WARN_ON_ONCE(!may_not_block);
-		return -ECHILD;
-        }
-	if (gfs2_glock_is_locked_by_me(gl) == NULL) {
-		if (may_not_block)
+	if (may_not_block) {
+		/* Is the inode getting torn down? */
+		if (unlikely(!gl))
 			return -ECHILD;
+		if (gl->gl_state == LM_ST_UNLOCKED ||
+		    test_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags))
+			return -ECHILD;
+	} else if (gfs2_glock_is_locked_by_me(gl) == NULL) {
 		error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
 		if (error)
 			return error;
-- 
2.51.0


  parent reply	other threads:[~2025-11-01  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-01  8:09 [PATCH 0/5] gfs2 non-blocking lookup Andreas Gruenbacher
2025-11-01  8:09 ` [PATCH 1/5] gfs2: No d_revalidate op for "lock_nolock" mounts Andreas Gruenbacher
2025-11-01  8:09 ` [PATCH 2/5] gfs2: Get rid of had_lock in gfs2_drevalidate Andreas Gruenbacher
2025-11-01  8:09 ` [PATCH 3/5] gfs2: Use unique tokens for gfs2_revalidate Andreas Gruenbacher
2025-11-01  8:09 ` Andreas Gruenbacher [this message]
2025-11-01  8:09 ` [PATCH 5/5] Revert "gfs2: Add GL_NOBLOCK flag" Andreas Gruenbacher
2025-11-17 12:16 ` [PATCH 0/5] gfs2 non-blocking lookup 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=20251101080919.1290117-5-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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