From: Darrick J. Wong <djwong@xxxxxxxxxx> When iomap is in use for the page cache, the kernel will take care of all the file data block IO for us, including zeroing of punched ranges and post-EOF bytes. fuse2fs only needs to do IO for inline data. Therefore, set the NOBLOCKIO ext2_file flag so that libext2fs will not do any regular file IO to or from disk blocks at all. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- misc/fuse2fs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 45eec59d85faf4..989f9f17cae0a9 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3059,9 +3059,14 @@ static int truncate_helper(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size) ext2_file_t file; __u64 old_isize; errcode_t err; + int flags = EXT2_FILE_WRITE; int ret = 0; - err = ext2fs_file_open(fs, ino, EXT2_FILE_WRITE, &file); + /* the kernel handles all eof zeroing for us in iomap mode */ + if (fuse2fs_iomap_does_fileio(ff)) + flags |= EXT2_FILE_NOBLOCKIO; + + err = ext2fs_file_open(fs, ino, flags, &file); if (err) return translate_error(fs, ino, err); @@ -3181,6 +3186,9 @@ static int __op_open(struct fuse2fs *ff, const char *path, file->open_flags |= EXT2_FILE_WRITE; break; } + /* the kernel handles all block IO for us in iomap mode */ + if (fuse2fs_iomap_does_fileio(ff)) + file->open_flags |= EXT2_FILE_NOBLOCKIO; if (fp->flags & O_APPEND) { /* the kernel doesn't allow truncation of an append-only file */ if (fp->flags & O_TRUNC) {