Re: [PATCH v2] docs/vfs: update references to i_mutex to i_rwsem

From: Jan Kara
Date: Mon Jun 23 2025 - 07:09:55 EST


On Sun 22-06-25 23:01:32, 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 <ljx@xxxxxxxxxxx>

One comment below. Christian, can you please fix it up? Otherwise feel free
to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index fd32a9a17bfb..dd9da7e04a99 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -758,8 +758,9 @@ process is more complicated and uses write_begin/write_end or
> 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.
> +Removing pages from an address_space requires holding the inode's i_rwsem
> +exclusively, while adding pages to the address_space requires holding the
> +inode's i_mapping->invalidate_lock exclusively.

I wasn't probably precise enough in my previous comment. This paragraph
should be:

Removing pages from an address_space requires holding the inode's i_rwsem
exclusively and i_mapping->invalidate_lock exclusively. Adding pages to the
address_space requires either holding inode's i_rwsem exclusively or
i_mapping->invalidate_lock in shared mode.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR