From: Darrick J. Wong Date: Thu, 31 Jul 2025 14:43:50 +0000 (-0400) Subject: fuse2fs: fix clean_block_middle when punching byte 0 of a block X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b44c01c1f9d800a56bb7a01a53e4f318c08d9f2;p=thirdparty%2Fe2fsprogs.git fuse2fs: fix clean_block_middle when punching byte 0 of a block In non-iomap mode, generic/008 tries to fzero the first byte of a block and fails: --- a/tests/generic/008.out 2025-07-15 14:45:14.937058680 -0700 +++ b/tests/generic/008.out.bad 2025-07-16 11:43:42.427989360 -0700 @@ -4,8 +4,7 @@ XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 1024/1024 bytes at offset 1024 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -00000000: 00 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 .AAAAAAAAAAAAAAA -00000010: 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 AAAAAAAAAAAAAAAA +00000000: 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 AAAAAAAAAAAAAAAA * 00000400: 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 BBBBBBBBBBBBBBBB * Here we can clearly see that the first byte of the block has not been zeroed, even though that's what the caller wanted us to do. This is due to an incorrect check of the residue variable that was most likely copy pasted from clean_block_edge years ago. Cc: linux-ext4@vger.kernel.org # v1.43 Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs") Signed-off-by: Darrick J. Wong --- diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index bff303a1..6155dff6 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -4007,14 +4007,10 @@ static errcode_t clean_block_middle(struct fuse2fs *ff, ext2_ino_t ino, { ext2_filsys fs = ff->fs; blk64_t blk; - off_t residue; + off_t residue = FUSE2FS_OFF_IN_FSB(ff, offset); int retflags; errcode_t err; - residue = FUSE2FS_OFF_IN_FSB(ff, offset); - if (residue == 0) - return 0; - if (!*buf) { err = ext2fs_get_mem(fs->blocksize, buf); if (err)