]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: disable fallocate/zero range on indirect files
authorDarrick J. Wong <djwong@kernel.org>
Thu, 14 Aug 2025 00:14:21 +0000 (17:14 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 21 Aug 2025 00:00:54 +0000 (17:00 -0700)
Indirect mapped files can't have unwritten extents, so we can't do
unwritten preallocation or zero-range because both depend on unwritten
extents.

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 318bfb55345b9b130083552b4e8e41413599aa51..cb5620c7e2ee334dcf64abda19a38cb8a254c1fd 100644 (file)
@@ -4137,6 +4137,10 @@ static int fallocate_helper(struct fuse_file_info *fp, int mode, off_t offset,
                return err;
        fsize = EXT2_I_SIZE(&inode);
 
+       /* Indirect files do not support unwritten extents */
+       if (!(inode.i_flags & EXT4_EXTENTS_FL))
+               return -EOPNOTSUPP;
+
        /* Allocate a bunch of blocks */
        flags = (mode & FL_KEEP_SIZE_FLAG ? 0 :
                        EXT2_FALLOCATE_INIT_BEYOND_EOF);
@@ -4279,6 +4283,14 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset,
        if (err)
                return translate_error(fs, fh->ino, err);
 
+       /*
+        * Indirect files do not support unwritten extents, which means we
+        * can't support zero range.  Punch goes first in zero-range, which
+        * is why the check is here.
+        */
+       if ((mode & FL_ZERO_RANGE_FLAG) && !(inode.i_flags & EXT4_EXTENTS_FL))
+               return -EOPNOTSUPP;
+
        /* Zero everything before the first block and after the last block */
        if (FUSE2FS_B_TO_FSBT(ff, offset) == FUSE2FS_B_TO_FSBT(ff, offset + len))
                err = clean_block_middle(ff, fh->ino, &inode, offset,