Re: [PATCH 41/41] fs: Unify generic_file_fsync() with mmb methods

Christoph Hellwig <[email protected]> Mon, 23 Mar 2026 22:56:30 -0700
Newsgroups gmane.linux.block,gmane.linux.file-systems,gmane.comp.file-systems.ext4,gmane.linux.kernel.mm,gmane.linux.kernel.aio.general
Message-ID <[email protected]>
On Fri, Mar 20, 2026 at 02:41:36PM +0100, Jan Kara wrote:
> Taking inode lock when writing out the inode seems pointless in
> particular because there are lots of places (most notably sync(2) path)
> that don't do that so hardly anything can depend on it.

This is really something that needs to stand out clearly for bisecting
and documentation.  I.e. make this a patch on its own and preferably
before all the other refactoring that already is affected by moving
between the implementations at the beginning of the series.

> So let's remove __generic_file_fsync() and use
> generic_mmb_fsync_noflush() instead to reduce code duplication. Arguably
> this leaks a bit of buffer_head knowledge into fs/libfs.c which is not
> great but avoiding the duplication seems worth it.

You could just pass a callback to the generic version.  The cost of an
indirect call should not matter compared to the rest of the fsync code.
That would also be a nice thing before all the renaming, as that means
we could add the version with the callback first to unify the
implementations and then the file systems are switched away from
the buffers fsync variant to explicitly pass a callback, or to not
pass a callback when they currently get the default one.