Re: [PATCH 12/41] fs: Drop sync_mapping_buffers() from __generic_file_fsync()

Christoph Hellwig
2026-03-24T13:17:29Z

On Tue, Mar 24, 2026 at 01:34:57PM +0100, Jan Kara wrote:
> I'm fine with simple_fsync() name for the helper with the trivial behavior
> of writing out the mapping and the inode. Code wise this will look somewhat
> different given what you've suggested for the last patch.

Yeah, the pitfalls of going sequentially through the series :)

But sketching this out I'm not even sure all this makes sense any more.
Maybe instad of the allback we should just have a helper for checking the
inode state like:

static inline bool inode_need_fsync(struct inode *inode, bool datasync)
{
enum inode_state_flags_enum state = inode_state_read_once(inode);

if (!(state & I_DIRTY_ALL))
return false;
if (datasync && !(state & I_DIRTY_DATASYNC))
retun false;
return true;
}

and otherwise just open code the calls int the two implementations
without any callbacks, as it feels cleaner to avoid the entanglement.

This helper might also be useful for other fs-specific implementations
later on.