From: Darrick J. Wong Date: Thu, 14 Aug 2025 00:14:21 +0000 (-0700) Subject: fuse2fs: disable fallocate/zero range on indirect files X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b646a80722c0a1412377f854d75538f9a022f949;p=thirdparty%2Fe2fsprogs.git fuse2fs: disable fallocate/zero range on indirect files 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: # 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 318bfb55..cb5620c7 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -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,