aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Chen <hselin.chen@gmail.com>2019-11-27 01:36:30 -0800
committerNikolaus Rath <Nikolaus@rath.org>2019-11-27 09:36:30 +0000
commitada08d50a647adb37c77f2106e7adc0db6ab93d5 (patch)
treec577291626b68ff962c6cc65820435861f5f8a56
parent4520a97286e53977d15825111365d46b99d5a836 (diff)
downloadlibfuse-ada08d50a647adb37c77f2106e7adc0db6ab93d5.tar.gz
Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474)
-rw-r--r--ChangeLog.rst6
-rw-r--r--example/printcap.c2
-rw-r--r--include/fuse_common.h23
-rw-r--r--lib/fuse_lowlevel.c4
4 files changed, 35 insertions, 0 deletions
diff --git a/ChangeLog.rst b/ChangeLog.rst
index a99f11d..57bd743 100644
--- a/ChangeLog.rst
+++ b/ChangeLog.rst
@@ -1,3 +1,9 @@
+Unreleased Changes
+==========================
+
+* Added support for FUSE_EXPLICIT_INVAL_DATA to enable
+ only invalidate cached pages on explicit request.
+
libfuse 3.8.0 (2019-11-03)
==========================
diff --git a/example/printcap.c b/example/printcap.c
index 580f52c..904542f 100644
--- a/example/printcap.c
+++ b/example/printcap.c
@@ -79,6 +79,8 @@ static void pc_init(void *userdata,
printf("\tFUSE_CAP_POSIX_ACL\n");
if(conn->capable & FUSE_CAP_NO_OPENDIR_SUPPORT)
printf("\tFUSE_CAP_NO_OPENDIR_SUPPORT\n");
+ if(conn->capable & FUSE_CAP_EXPLICIT_INVAL_DATA)
+ printf("\tFUSE_CAP_EXPLICIT_INVAL_DATA\n");
fuse_session_exit(se);
}
diff --git a/include/fuse_common.h b/include/fuse_common.h
index 2d686b2..77d4bfe 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -359,6 +359,29 @@ struct fuse_loop_config {
#define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
/**
+ * Indicates support for invalidating cached pages only on explicit request.
+ *
+ * If this flag is set in the `capable` field of the `fuse_conn_info` structure,
+ * then the FUSE kernel module supports invalidating cached pages only on
+ * explicit request by the filesystem through fuse_lowlevel_notify_inval_inode()
+ * or fuse_invalidate_path().
+ *
+ * By setting this flag in the `want` field of the `fuse_conn_info` structure,
+ * the filesystem is responsible for invalidating cached pages through explicit
+ * requests to the kernel.
+ *
+ * Note that setting this flag does not prevent the cached pages from being
+ * flushed by OS itself and/or through user actions.
+ *
+ * Note that if both FUSE_CAP_EXPLICIT_INVAL_DATA and FUSE_CAP_AUTO_INVAL_DATA
+ * are set in the `capable` field of the `fuse_conn_info` structure then
+ * FUSE_CAP_AUTO_INVAL_DATA takes precedence.
+ *
+ * This feature is disabled by default.
+ */
+#define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
+
+/**
* Ioctl flags
*
* FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index f2d7038..6eb949f 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -1965,6 +1965,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV;
if (arg->flags & FUSE_NO_OPENDIR_SUPPORT)
se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT;
+ if (arg->flags & FUSE_EXPLICIT_INVAL_DATA)
+ se->conn.capable |= FUSE_CAP_EXPLICIT_INVAL_DATA;
if (!(arg->flags & FUSE_MAX_PAGES)) {
size_t max_bufsize =
FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
@@ -2085,6 +2087,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
outarg.flags |= FUSE_WRITEBACK_CACHE;
if (se->conn.want & FUSE_CAP_POSIX_ACL)
outarg.flags |= FUSE_POSIX_ACL;
+ if (se->conn.want & FUSE_CAP_EXPLICIT_INVAL_DATA)
+ outarg.flags |= FUSE_EXPLICIT_INVAL_DATA;
outarg.max_readahead = se->conn.max_readahead;
outarg.max_write = se->conn.max_write;
if (se->conn.proto_minor >= 13) {