"Darrick J. Wong" <djwong@xxxxxxxxxx> writes: > On Tue, Jun 11, 2024 at 04:15:02PM +0530, Ritesh Harjani wrote: >> >> Hi Darrick, >> >> Resuming my review from where I left off yesterday. > <snip> >> > +Writes >> > +~~~~~~ >> > + >> > +The ``iomap_file_buffered_write`` function writes an ``iocb`` to the >> > +pagecache. >> > +``IOMAP_WRITE`` or ``IOMAP_WRITE`` | ``IOMAP_NOWAIT`` will be passed as >> > +the ``flags`` argument to ``->iomap_begin``. >> > +Callers commonly take ``i_rwsem`` in either shared or exclusive mode. >> >> shared(e.g. aligned overwrites) > Ok, I see we were in buffered I/O section (Sorry, I misunderstood thinking this was for direct-io) > That's a matter of debate -- xfs locks out concurrent reads by taking > i_rwsem in exclusive mode, whereas (I think?) ext4 and most other > filesystems take it in shared mode and synchronizes readers and writers > with folio locks. Ext4 too takes inode lock in exclusive mode in case of buffered-write. It's the DIO writes/overwrites in ext4 which has special casing for shared/exclusive mode locking. But ext4 buffered-read does not take any inode lock (it uses generic_file_read_iter()). So the synchronization must happen via folio lock w.r.t buffered-writes. However, I am not sure if we have any filesystem taking VFS inode lock in shared more for buffered-writes. BTW - I really like all of the other updates that you made w.r.t the review comments. All of those looks more clear to me. (so not commenting on them individually). Thanks! -ritesh