Re: [PATCH 1/1] docs/vfs: update references to i_mutex to i_rwsem
From: Jan Kara <jack@suse.cz>
Date: 2025-06-16 10:10:47
Also in:
linux-fsdevel, lkml
On Sun 15-06-25 21:16:53, Junxuan Liao wrote:
VFS has switched to i_rwsem for ten years now (9902af79c01a: parallel lookups actual switch to rwsem), but the VFS documentation and comments still has references to i_mutex. Signed-off-by: Junxuan Liao <redacted>
Thanks. This cleanup is long overdue :).
quoted hunk ↗ jump to hunk
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst index fd32a9a17bfb..a09c4aab9b5b 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst@@ -759,7 +759,7 @@ dirty_folio to write data into the address_space, and writepages to writeback data to storage. Adding and removing pages to/from an address_space is protected by the -inode's i_mutex. +inode's i_rwsem.
It is not your fault but this sentence is not actually true. i_rwsem is held exlusively when removing pages from an address space. However i_rwsem is often not held at all when adding pages to an address space. mapping->invalidate_lock is used for that.
quoted hunk ↗ jump to hunk
diff --git a/fs/attr.c b/fs/attr.c index 9caf63d20d03..3a3881d3147f 100644 --- a/fs/attr.c +++ b/fs/attr.c@@ -230,7 +230,7 @@ EXPORT_SYMBOL(setattr_prepare); * @inode: the inode to be truncated * @offset: the new size to assign to the inode * - * inode_newsize_ok must be called with i_mutex held. + * inode_newsize_ok must be called with i_rwsem held.
I guess we can add "exclusively" here. Otherwise the changes look good to me. Honza -- Jan Kara [off-list ref] SUSE Labs, CR