Re: [PATCH] gfs2: add missing __rcu annotation to i_gl in incore.h
From: Andreas Gruenbacher
Date: Fri Jul 24 2026 - 12:00:26 EST
On Tue, Jun 30, 2026 at 12:03 PM Adrian Garcia Casado
<adriangarciacasado42@xxxxxxxxx> wrote:
> In gfs2_inode_lookup() and other parts of the GFS2 filesystem,
> ip->i_gl is accessed and dereferenced via RCU helpers like
> rcu_dereference_check() and rcu_access_pointer(). However, the
> actual i_gl pointer in struct gfs2_inode was never annotated
> with __rcu in incore.h.
>
> This missing annotation causes Sparse to throw multiple
> "incompatible types in comparison expression (different address spaces)"
> warnings and compilation-blocking errors under strict static analysis builds.
Indeed, there are two sparse errors related to i_gl.
> Fix this by adding the __rcu annotation to i_gl in struct gfs2_inode.
With this fix, I get about 200 sparse warnings instead of the two
errors. So thanks for pointing out that there are errors, but without
fixing any of the underlying problems, this patch isn't very useful.
Andreas
> Signed-off-by: Adrian Garcia Casado <adriangarciacasado42@xxxxxxxxx>
> Tested-by: Adrian Garcia Casado <adriangarciacasado42@xxxxxxxxx>
> ---
>
> diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
> index 6146577..16df753 100644
> --- a/fs/gfs2/incore.h
> +++ b/fs/gfs2/incore.h
> @@ -392,7 +392,7 @@ struct gfs2_inode {
> u64 i_generation;
> u64 i_eattr;
> unsigned long i_flags; /* GIF_... */
> - struct gfs2_glock *i_gl;
> + struct gfs2_glock __rcu *i_gl;
> struct gfs2_holder i_iopen_gh;
> struct gfs2_qadata *i_qadata; /* quota allocation data */
> struct gfs2_holder i_rgd_gh;
Applied, thanks.
Andreas