From: Darrick J. Wong <djwong@xxxxxxxxxx>
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@xxxxxxxxxxxxxxx> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
---
misc/fuse2fs.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 318bfb55345b9b..cb5620c7e2ee33 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,