[PATCH 15/16] fuse2fs: re-enable the block device pagecache for metadata IO

Darrick J. Wong
2025-05-22T00:14:46Z

Back in "fuse2fs: always use directio disk reads with fuse2fs", we
started using directio for all libext2fs disk IO to deal with cache
coherency issues between the unix io manager's disk cache, the block
device page cache, and the file data blocks being read and written to
disk by the kernel itself.

Now that we've turned off all regular file data block IO in libext2fs,
we don't need that and can go back to the old way, which is a lot
faster for metadata operations.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
misc/fuse2fs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index ba8c5f301625c6..f31aee5af5aad9 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -1128,8 +1128,12 @@ static void *op_init(struct fuse_conn_info *conn
* filesystem in directio mode to avoid cache coherency issues when
* reading file data. If we can't open the bdev in directio mode, we
* must not use iomap.
+ *
+ * If we know that the kernel can handle all regular file IO for us,
+ * then there is no cache coherency issue and we can use buffered reads
+ * for all IO, which will all be filesystem metadata.
*/
- if (iomap_enabled(ff))
+ if (iomap_enabled(ff) && !iomap_does_fileio(ff))
ff->directio = 1;
#endif