summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2021-10-24 14:01:23 +0300
committerAmir Goldstein <amir73il@gmail.com>2022-01-03 14:55:34 +0200
commit1b498ac9b341e086562f54cc49bf035e19a94e1d (patch)
tree51745ff21733bd4a3dc3328df272f57404b60f4b
parent48ae2e72b39b6a31cb2194f6f11786b7ca06aac6 (diff)
downloadfuse-1b498ac9b341e086562f54cc49bf035e19a94e1d.tar.gz
Add support for FOPEN_NOFLUSH flag
Allow requesting from kernel to avoid flush on close at file open time. If kernel does not support FOPEN_NOFLUSH flag, the request will be ignored. For passthrough_hp example, request to avoid flush on close when writeback cache is disabled and file is opened O_RDONLY. Signed-off-by: Amir Goldstein <amir73il@gmail.com>
-rw-r--r--ChangeLog.rst5
-rw-r--r--example/passthrough_hp.cc1
-rw-r--r--include/fuse_common.h6
-rw-r--r--include/fuse_kernel.h2
-rw-r--r--lib/fuse_lowlevel.c2
5 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog.rst b/ChangeLog.rst
index 521c163..96f4fb7 100644
--- a/ChangeLog.rst
+++ b/ChangeLog.rst
@@ -1,3 +1,8 @@
+Unreleased Changes
+==================
+
+* Add support for flag FOPEN_NOFLUSH for avoiding flush on close.
+
libfuse 3.10.5 (2021-09-06)
===========================
diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc
index 872fc73..e15f893 100644
--- a/example/passthrough_hp.cc
+++ b/example/passthrough_hp.cc
@@ -856,6 +856,7 @@ static void sfs_open(fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi) {
lock_guard<mutex> g {inode.m};
inode.nopen++;
fi->keep_cache = (fs.timeout != 0);
+ fi->noflush = (fs.timeout == 0 && (fi->flags & O_ACCMODE) == O_RDONLY);
fi->fh = fd;
fuse_reply_open(req, fi);
}
diff --git a/include/fuse_common.h b/include/fuse_common.h
index ea4bdb0..d7481be 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -83,8 +83,12 @@ struct fuse_file_info {
nothing when set by open()). */
unsigned int cache_readdir : 1;
+ /** Can be filled in by open, to indicate that flush is not needed
+ on close. */
+ unsigned int noflush : 1;
+
/** Padding. Reserved for future use*/
- unsigned int padding : 25;
+ unsigned int padding : 24;
unsigned int padding2 : 32;
/** File handle id. May be filled in by filesystem in create,
diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h
index 018a00a..48f2000 100644
--- a/include/fuse_kernel.h
+++ b/include/fuse_kernel.h
@@ -238,12 +238,14 @@ struct fuse_file_lock {
* FOPEN_NONSEEKABLE: the file is not seekable
* FOPEN_CACHE_DIR: allow caching this directory
* FOPEN_STREAM: the file is stream-like (no file position at all)
+ * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
*/
#define FOPEN_DIRECT_IO (1 << 0)
#define FOPEN_KEEP_CACHE (1 << 1)
#define FOPEN_NONSEEKABLE (1 << 2)
#define FOPEN_CACHE_DIR (1 << 3)
#define FOPEN_STREAM (1 << 4)
+#define FOPEN_NOFLUSH (1 << 5)
/**
* INIT request/reply flags
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index d227688..b5638fc 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -395,6 +395,8 @@ static void fill_open(struct fuse_open_out *arg,
arg->open_flags |= FOPEN_CACHE_DIR;
if (f->nonseekable)
arg->open_flags |= FOPEN_NONSEEKABLE;
+ if (f->noflush)
+ arg->open_flags |= FOPEN_NOFLUSH;
}
int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)