[PATCH 08/10] fuse2fs: enable syncfs

Darrick J. Wong
2026-04-29T15:00:42Z

Enable syncfs calls in fuse2fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fuse4fs/fuse4fs.c | 32 ++++++++++++++++++++++++++++++++
misc/fuse2fs.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)

diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 8a9ada8905983d..51958d6677288c 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -6563,7 +6563,38 @@ static void op_shutdownfs(fuse_req_t req, fuse_ino_t ino, uint64_t flags)
int ret;

ret = ioctl_shutdown(ff, ctxt, NULL, NULL, 0);
+ fuse_reply_err(req, -ret);
+}

+static void op_syncfs(fuse_req_t req, fuse_ino_t ino)
+{
+ struct fuse4fs *ff = fuse4fs_get(req);
+ ext2_filsys fs;
+ errcode_t err;
+ int ret = 0;
+
+ FUSE4FS_CHECK_CONTEXT(req);
+ fs = fuse4fs_start(ff);
+
+ if (ff->opstate == F4OP_WRITABLE) {
+ if (fs->super->s_error_count)
+ fs->super->s_state |= EXT2_ERROR_FS;
+ ext2fs_mark_super_dirty(fs);
+ err = ext2fs_set_gdt_csum(fs);
+ if (err) {
+ ret = translate_error(fs, 0, err);
+ goto out_unlock;
+ }
+
+ err = ext2fs_flush2(fs, 0);
+ if (err) {
+ ret = translate_error(fs, 0, err);
+ goto out_unlock;
+ }
+ }
+
+out_unlock:
+ fuse4fs_finish(ff, ret);
fuse_reply_err(req, -ret);
}
#endif
@@ -7874,6 +7905,7 @@ static struct fuse_lowlevel_ops fs_ops = {
.freezefs = op_freezefs,
.unfreezefs = op_unfreezefs,
.shutdownfs = op_shutdownfs,
+ .syncfs = op_syncfs,
#endif
#ifdef HAVE_FUSE_IOMAP
.iomap_begin = op_iomap_begin,
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index e790f6c2b59ecd..026c547618b5cd 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -5851,6 +5851,39 @@ static int op_shutdownfs(const char *path, uint64_t flags)

return ioctl_shutdown(ff, NULL, NULL);
}
+
+static int op_syncfs(const char *path)
+{
+ struct fuse2fs *ff = fuse2fs_get();
+ ext2_filsys fs;
+ errcode_t err;
+ int ret = 0;
+
+ FUSE2FS_CHECK_CONTEXT(ff);
+ dbg_printf(ff, "%s: path=%s\n", __func__, path);
+ fs = fuse2fs_start(ff);
+
+ if (ff->opstate == F2OP_WRITABLE) {
+ if (fs->super->s_error_count)
+ fs->super->s_state |= EXT2_ERROR_FS;
+ ext2fs_mark_super_dirty(fs);
+ err = ext2fs_set_gdt_csum(fs);
+ if (err) {
+ ret = translate_error(fs, 0, err);
+ goto out_unlock;
+ }
+
+ err = ext2fs_flush2(fs, 0);
+ if (err) {
+ ret = translate_error(fs, 0, err);
+ goto out_unlock;
+ }
+ }
+
+out_unlock:
+ fuse2fs_finish(ff, ret);
+ return ret;
+}
#endif

#ifdef HAVE_FUSE_IOMAP
@@ -7140,6 +7173,7 @@ static struct fuse_operations fs_ops = {
.freezefs = op_freezefs,
.unfreezefs = op_unfreezefs,
.shutdownfs = op_shutdownfs,
+ .syncfs = op_syncfs,
#endif
#ifdef HAVE_FUSE_IOMAP
.iomap_begin = op_iomap_begin,