[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174553064980.1160461.9850792727586596449.stgit@frogsfrogsfrogs>
Date: Thu, 24 Apr 2025 14:41:34 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 03/16] fuse2fs: implement zero range
From: Darrick J. Wong <djwong@...nel.org>
Implement FALLOC_FL_ZERO_RANGE.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index e5f3cec083c0f5..4f3074261d0f53 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -123,6 +123,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */
# define FL_PUNCH_HOLE_FLAG (0)
#endif
+#ifdef FALLOC_FL_ZERO_RANGE
+# define FL_ZERO_RANGE_FLAG FALLOC_FL_ZERO_RANGE
+#else
+# define FL_ZERO_RANGE_FLAG (0)
+#endif
+
errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
#ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jbd-debug */
@@ -3619,6 +3625,16 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset,
return 0;
}
+static int zero_helper(struct fuse_file_info *fp, int mode, off_t offset,
+ off_t len)
+{
+ int ret = punch_helper(fp, mode | FL_KEEP_SIZE_FLAG, offset, len);
+
+ if (!ret)
+ ret = fallocate_helper(fp, mode, offset, len);
+ return ret;
+}
+
static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode,
off_t offset, off_t len,
struct fuse_file_info *fp)
@@ -3637,7 +3653,9 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode,
ret = -EROFS;
goto out;
}
- if (mode & FL_PUNCH_HOLE_FLAG)
+ if (mode & FL_ZERO_RANGE_FLAG)
+ ret = zero_helper(fp, mode, offset, len);
+ else if (mode & FL_PUNCH_HOLE_FLAG)
ret = punch_helper(fp, mode, offset, len);
else
ret = fallocate_helper(fp, mode, offset, len);
Powered by blists - more mailing lists