Skip to content

Commit 074d730

Browse files
author
Andreas Gruenbacher
committed
gfs2: Silence "suspicious RCU usage in gfs2_permission" warning
Commit 0abd155 added rcu_dereference() for dereferencing ip->i_gl in gfs2_permission. This now causes lockdep to complain when gfs2_permission is called in non-RCU context: WARNING: suspicious RCU usage in gfs2_permission Switch to rcu_dereference_check() and check for the MAY_NOT_BLOCK flag to shut up lockdep when we know that dereferencing ip->i_gl is safe. Fixes: 0abd155 ("gfs2: fix an oops in gfs2_permission") Reported-by: [email protected] Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent d6fc6c9 commit 074d730

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/gfs2/inode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,21 +1867,22 @@ static const char *gfs2_get_link(struct dentry *dentry,
18671867
int gfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
18681868
int mask)
18691869
{
1870+
int may_not_block = mask & MAY_NOT_BLOCK;
18701871
struct gfs2_inode *ip;
18711872
struct gfs2_holder i_gh;
18721873
struct gfs2_glock *gl;
18731874
int error;
18741875

18751876
gfs2_holder_mark_uninitialized(&i_gh);
18761877
ip = GFS2_I(inode);
1877-
gl = rcu_dereference(ip->i_gl);
1878+
gl = rcu_dereference_check(ip->i_gl, !may_not_block);
18781879
if (unlikely(!gl)) {
18791880
/* inode is getting torn down, must be RCU mode */
1880-
WARN_ON_ONCE(!(mask & MAY_NOT_BLOCK));
1881+
WARN_ON_ONCE(!may_not_block);
18811882
return -ECHILD;
18821883
}
18831884
if (gfs2_glock_is_locked_by_me(gl) == NULL) {
1884-
if (mask & MAY_NOT_BLOCK)
1885+
if (may_not_block)
18851886
return -ECHILD;
18861887
error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
18871888
if (error)

0 commit comments

Comments
 (0)