[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169814390.1428390.9380093122042614031.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 18:06:20 -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 4/4] libfuse: add syncfs support to the upper library
From: Darrick J. Wong <djwong@...nel.org>
Support syncfs in the upper level library.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
include/fuse.h | 5 +++++
lib/fuse.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/fuse.h b/include/fuse.h
index a10666b78eb1eb..3d36b49e1b3f67 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -918,6 +918,11 @@ struct fuse_operations {
* Shut down the filesystem
*/
int (*shutdownfs) (const char *path, uint64_t flags);
+
+ /*
+ * Flush the entire filesystem to disk.
+ */
+ int (*syncfs) (const char *path);
};
/** Extra context that may be needed by some filesystems
diff --git a/lib/fuse.c b/lib/fuse.c
index b8d4b4600077d7..d54fc9ea2004bd 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -3000,6 +3000,16 @@ static int fuse_fs_shutdownfs(struct fuse_fs *fs, const char *path,
return fs->op.shutdownfs(path, flags);
}
+static int fuse_fs_syncfs(struct fuse_fs *fs, const char *path)
+{
+ fuse_get_context()->private_data = fs->user_data;
+ if (!fs->op.syncfs)
+ return -ENOSYS;
+ if (fs->debug)
+ fuse_log(FUSE_LOG_DEBUG, "syncfs[%s]\n", path);
+ return fs->op.syncfs(path);
+}
+
static void fuse_lib_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
int valid, struct fuse_file_info *fi)
{
@@ -4933,6 +4943,26 @@ static void fuse_lib_shutdownfs(fuse_req_t req, fuse_ino_t ino, uint64_t flags)
reply_err(req, err);
}
+static void fuse_lib_syncfs(fuse_req_t req, fuse_ino_t ino)
+{
+ struct fuse *f = req_fuse_prepare(req);
+ struct fuse_intr_data d;
+ char *path;
+ int err;
+
+ err = get_path(f, ino, &path);
+ if (err) {
+ reply_err(req, err);
+ return;
+ }
+
+ fuse_prepare_interrupt(f, req, &d);
+ err = fuse_fs_syncfs(f->fs, path);
+ fuse_finish_interrupt(f, req, &d);
+ free_path(f, ino, path);
+ reply_err(req, err);
+}
+
static int clean_delay(struct fuse *f)
{
/*
@@ -5034,6 +5064,7 @@ static struct fuse_lowlevel_ops fuse_path_ops = {
#ifdef HAVE_STATX
.statx = fuse_lib_statx,
#endif
+ .syncfs = fuse_lib_syncfs,
.freezefs = fuse_lib_freezefs,
.unfreezefs = fuse_lib_unfreezefs,
.shutdownfs = fuse_lib_shutdownfs,
Powered by blists - more mailing lists