Skip to contentSkip to conversation

gfs2: add missing __rcu annotation to i_gl in incore.h

PATCH Applied Adrian Garcia Casado 2 participants 3 messages Jun 30 – Jul 24 1 message not in the archive GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: add missing __rcu annotation to i_gl in incore.h

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.

Fix this by adding the __rcu annotation to i_gl in struct gfs2_inode.

---

fs/gfs2/incore.h +1 -1
index 6146577..16df753 100644
@@ -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;
maintainer Applied
#1 lore raw
Quoted 9 lines · Adrian Garcia Casado

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.

Quoted 1 line

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

Quoted 9 lines

---

fs/gfs2/incore.h +0 -0
index 6146577..16df753 100644

fs/gfs2/incore.h struct gfs2_inode { · line 398

Quoted 8 lines
fs/gfs2/incore.h +1 -1
@@ -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

#3 lore raw
In reply to a message not in the archive
Quoted 3 lines · Adrián García Casado

Hi Andreas,

Thanks for applying the patch!

No, I'm not applying that patch. As I said, it's not really fixing anything, it's only trading two errors against 200 warnings.

Quoted 9 lines

For the record, I have successfully boot-tested the patched v7.2-rc4+ kernel on bare-metal x86_64 (Debian 13 native on an ASUS Vivobook).

To stress-test the kernel stability under load, I ran some heavy workloads:
- A standalone loopback mount of GFS2 (using lock_nolock) with I/O stress tests (100+ concurrent files).
- A full multi-threaded compilation of the PCSX2 emulator (using CMake and Ninja) with all CPU cores sustained at 100% load.

Quoted 6 lines

The system behaved completely stable with no deadlocks, hangs, or OOM.

Best regards,
Adrian

Andreas

Quoted 48 lines · Andreas Gruenbacher
Quoted 47 lines
Quoted 9 lines · Adrian Garcia Casado

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.

Quoted 1 line

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

Quoted 9 lines

---

fs/gfs2/incore.h +0 -0
index 6146577..16df753 100644

fs/gfs2/incore.h struct gfs2_inode { · line 398

Quoted 8 lines
fs/gfs2/incore.h +1 -1
@@ -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