]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
filelock: use a consume fence in locks_inode_context()
authorMateusz Guzik <mjguzik@gmail.com>
Wed, 3 Dec 2025 09:48:36 +0000 (10:48 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Dec 2025 13:33:38 +0000 (14:33 +0100)
Matches the idiom of storing a pointer with a release fence and safely
getting the content with a consume fence after.

Eliminates an actual fence on some archs.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://patch.msgid.link/20251203094837.290654-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/filelock.h

index 54b824c05299261e6bd6acc4175cb277ea35b35d..dc15f542768016ec786b5d137506a677b8102cff 100644 (file)
@@ -241,7 +241,10 @@ bool locks_owner_has_blockers(struct file_lock_context *flctx,
 static inline struct file_lock_context *
 locks_inode_context(const struct inode *inode)
 {
-       return smp_load_acquire(&inode->i_flctx);
+       /*
+        * Paired with the fence in locks_get_lock_context().
+        */
+       return READ_ONCE(inode->i_flctx);
 }
 
 #else /* !CONFIG_FILE_LOCKING */