[PATCH 09/19] fuse2fs: don't zero bytes in punch hole

Darrick J. Wong
2026-04-29T14:54:59Z

When iomap is in use for the pagecache, it will take care of zeroing the
unaligned parts of punched out regions so we don't have to do it
ourselves.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fuse4fs/fuse4fs.c | 8 ++++++++
misc/fuse2fs.c | 9 +++++++++
2 files changed, 17 insertions(+)

diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index fa82fda99ff687..40713b0d0d5e37 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -5868,6 +5868,10 @@ static errcode_t fuse4fs_zero_middle(struct fuse4fs *ff, ext2_ino_t ino,
int retflags;
errcode_t err;

+ /* the kernel does this for us in iomap mode */
+ if (fuse4fs_iomap_enabled(ff))
+ return 0;
+
if (!*buf) {
err = ext2fs_get_mem(fs->blocksize, buf);
if (err)
@@ -5904,6 +5908,10 @@ static errcode_t fuse4fs_zero_edge(struct fuse4fs *ff, ext2_ino_t ino,
off_t residue;
errcode_t err;

+ /* the kernel does this for us in iomap mode */
+ if (fuse4fs_iomap_enabled(ff))
+ return 0;
+
residue = FUSE4FS_OFF_IN_FSB(ff, offset);
if (residue == 0)
return 0;
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 679406323df86f..a37851cdf30785 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -727,6 +727,7 @@ static inline int fuse2fs_iomap_enabled(const struct fuse2fs *ff)
}
#else
# define fuse2fs_iomap_enabled(...) (0)
+# define fuse2fs_iomap_enabled(...) (0)
#endif

static inline void fuse2fs_dump_extents(struct fuse2fs *ff, ext2_ino_t ino,
@@ -5104,6 +5105,10 @@ static errcode_t clean_block_middle(struct fuse2fs *ff, ext2_ino_t ino,
int retflags;
errcode_t err;

+ /* the kernel does this for us in iomap mode */
+ if (fuse2fs_iomap_enabled(ff))
+ return 0;
+
if (!*buf) {
err = ext2fs_get_mem(fs->blocksize, buf);
if (err)
@@ -5140,6 +5145,10 @@ static errcode_t clean_block_edge(struct fuse2fs *ff, ext2_ino_t ino,
off_t residue;
errcode_t err;

+ /* the kernel does this for us in iomap mode */
+ if (fuse2fs_iomap_enabled(ff))
+ return 0;
+
residue = FUSE2FS_OFF_IN_FSB(ff, offset);
if (residue == 0)
return 0;