[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169814372.1428390.6057897053088282234.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 18:06:05 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: djwong@...nel.org, bschubert@....com
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
 bernd@...ernd.com, miklos@...redi.hu, joannelkoong@...il.com, neal@...pa.dev
Subject: [PATCH 3/4] libfuse: wire up FUSE_SYNCFS to the low level library
From: Darrick J. Wong <djwong@...nel.org>
Create hooks in the lowlevel library for syncfs.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
 include/fuse_lowlevel.h |   16 ++++++++++++++++
 lib/fuse_lowlevel.c     |   19 +++++++++++++++++++
 2 files changed, 35 insertions(+)
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index b37d1f03ab5d7f..f12f9b8226aa89 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -1457,6 +1457,22 @@ struct fuse_lowlevel_ops {
 	 * @param flags zero, currently
 	 */
 	void (*shutdownfs) (fuse_req_t req, fuse_ino_t ino, uint64_t flags);
+
+	/*
+	 * Flush the entire filesystem to disk.
+	 *
+	 * If this request is answered with an error code of ENOSYS, this is
+	 * treated as a permanent failure, i.e. all future syncfs() requests
+	 * will fail with the same error code without being sent to the
+	 * filesystem process.
+	 *
+	 * Valid replies:
+	 *   fuse_reply_err
+	 *
+	 * @param req request handle
+	 * @param ino the inode number
+	 */
+	void (*syncfs) (fuse_req_t req, fuse_ino_t ino);
 };
 
 /**
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 3ab4a532b4edbb..f58ffa36978ae7 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -2895,6 +2895,23 @@ static void do_shutdownfs(fuse_req_t req, const fuse_ino_t nodeid,
 	_do_shutdownfs(req, nodeid, inarg, NULL);
 }
 
+static void _do_syncfs(fuse_req_t req, const fuse_ino_t nodeid,
+		      const void *op_in, const void *in_payload)
+{
+	(void)op_in;
+	(void)in_payload;
+
+	if (req->se->op.syncfs)
+		req->se->op.syncfs(req, nodeid);
+	else
+		fuse_reply_err(req, ENOSYS);
+}
+
+static void do_syncfs(fuse_req_t req, const fuse_ino_t nodeid, const void *inarg)
+{
+	_do_syncfs(req, nodeid, inarg, NULL);
+}
+
 static bool want_flags_valid(uint64_t capable, uint64_t want)
 {
 	uint64_t unknown_flags = want & (~capable);
@@ -3824,6 +3841,7 @@ static struct {
 	[FUSE_COPY_FILE_RANGE_64] = { do_copy_file_range_64, "COPY_FILE_RANGE_64" },
 	[FUSE_LSEEK]	   = { do_lseek,       "LSEEK"	     },
 	[FUSE_STATX]	   = { do_statx,       "STATX"	     },
+	[FUSE_SYNCFS]	   = { do_syncfs,	"SYNCFS"     },
 	[FUSE_FREEZE_FS]   = { do_freezefs,	"FREEZE"     },
 	[FUSE_UNFREEZE_FS] = { do_unfreezefs,	"UNFREEZE"   },
 	[FUSE_SHUTDOWN_FS] = { do_shutdownfs,	"SHUTDOWN"   },
@@ -3887,6 +3905,7 @@ static struct {
 	[FUSE_COPY_FILE_RANGE_64]	= { _do_copy_file_range_64, "COPY_FILE_RANGE_64" },
 	[FUSE_LSEEK]		= { _do_lseek,		"LSEEK" },
 	[FUSE_STATX]		= { _do_statx,		"STATX" },
+	[FUSE_SYNCFS]		= { _do_syncfs,		"SYNCFS" },
 	[FUSE_FREEZE_FS]	= { _do_freezefs,	"FREEZE" },
 	[FUSE_UNFREEZE_FS]	= { _do_unfreezefs,	"UNFREEZE" },
 	[FUSE_SHUTDOWN_FS]	= { _do_shutdownfs,	"SHUTDOWN" },
Powered by blists - more mailing lists
 
