summaryrefslogtreecommitdiff
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorAbhi Das <adas@redhat.com>2023-11-10 13:10:08 +0100
committerAndreas Gruenbacher <agruenba@redhat.com>2023-12-18 14:24:33 +0100
commitdd00aaeb343255a8a30de671bd27bde79a47c8e5 (patch)
tree521dfaa2891b730c7d8260905c2bde3579102fd5 /fs/gfs2/inode.c
parentf9f229c1f75df2f1fe63b16615d184da4e90bb10 (diff)
gfs2: Use GL_NOBLOCK flag for non-blocking lookups
Add the GL_NOBLOCK flag to the locking requests in gfs2_permission() and gfs2_drevalidate() when called with the MAY_NOT_BLOCK flag and LOOKUP_RCU flag, respectively. This will cause the locking requests to be handled without sleeping if possible. We bail out with -ECHILD if we can't grant the glock immediately. Make sure not to dget() + dput() the parent dentry in gfs2_drevalidate() in LOOKUP_RCU mode; dput() is a sleeping operation. Signed-off-by: Abhi Das <adas@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 1b95db2c3aac..6bfc9383b7b8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1882,10 +1882,10 @@ int gfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
WARN_ON_ONCE(!may_not_block);
return -ECHILD;
}
- if (gfs2_glock_is_locked_by_me(gl) == NULL) {
- if (may_not_block)
- return -ECHILD;
- error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
+ if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
+ int noblock = may_not_block ? GL_NOBLOCK : 0;
+ error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED,
+ LM_FLAG_ANY | noblock, &i_gh);
if (error)
return error;
}