]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: fix clean_block_middle when punching byte 0 of a block
authorDarrick J. Wong <djwong@kernel.org>
Thu, 31 Jul 2025 14:43:50 +0000 (10:43 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 31 Jul 2025 14:43:50 +0000 (10:43 -0400)
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 <djwong@kernel.org>
misc/fuse2fs.c

index bff303a10e718614833e951769244270867d3808..6155dff6645ff68e8491002b00e2a8c5c3db5439 100644 (file)
@@ -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)