fuse: Invalidate the page cache after FOPEN_DIRECT_IO write

generic_file_direct_write() also does this and has a large
comment about.

Reproducer here is xfstest's generic/209, which is exactly to
have competing DIO write and cached IO read.

Signed-off-by: Bernd Schubert <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
This commit is contained in:
Bernd Schubert authored and Miklos Szeredi committed 2025-11-13 14:54:05 +01:00
1 parent 47781ee71f
commit b359af8275
1 file changed
+9
+9
View File
@@ -1693,6 +1693,15 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
if (res > 0)
*ppos = pos;
if (res > 0 && write && fopen_direct_io) {
/*
* As in generic_file_direct_write(), invalidate after the
* write, to invalidate read-ahead cache that may have competed
* with the write.
*/
invalidate_inode_pages2_range(mapping, idx_from, idx_to);
}
return res > 0 ? res : err;
}
EXPORT_SYMBOL_GPL(fuse_direct_io);