Blame SOURCES/0003-Allow-caching-symlinks-in-kernel-page-cache.-551.patch

00e543
From be7f19b21c84004c5a0705f040b957fd1c609e2e Mon Sep 17 00:00:00 2001
00e543
From: =?UTF-8?q?Etienne=20Dubl=C3=A9?= <etienne.duble@imag.fr>
00e543
Date: Sun, 20 Sep 2020 20:08:15 +0200
00e543
Subject: [PATCH 3/4] Allow caching symlinks in kernel page cache. (#551)
00e543
00e543
This commit defines a new capability called `FUSE_CAP_CACHE_SYMLINKS`.
00e543
It is off by default but you can now enable it by setting this flag in
00e543
in the `want` field of the `fuse_conn_info` structure.
00e543
00e543
When enabled, the kernel will save symlinks in its page cache,
00e543
by making use of the feature introduced in kernel 4.20:
00e543
https://github.com/torvalds/linux/commit/5571f1e65486be025f73fa6aa30fb03725d362a2
00e543
00e543
(cherry picked from commit ba3b225a126ebb3c6d4fe27c9f7c73aa4167001e)
00e543
Signed-off-by: Pavel Reichl <preichl@redhat.com>
00e543
---
00e543
 example/printcap.c    |  2 ++
00e543
 include/fuse_common.h | 13 +++++++++++++
00e543
 lib/fuse_lowlevel.c   |  4 ++++
00e543
 3 files changed, 19 insertions(+)
00e543
00e543
diff --git a/example/printcap.c b/example/printcap.c
00e543
index 77dea14..a66036f 100644
00e543
--- a/example/printcap.c
00e543
+++ b/example/printcap.c
00e543
@@ -77,6 +77,8 @@ static void pc_init(void *userdata,
00e543
 			printf("\tFUSE_CAP_PARALLEL_DIROPS\n");
00e543
 	if(conn->capable & FUSE_CAP_POSIX_ACL)
00e543
 			printf("\tFUSE_CAP_POSIX_ACL\n");
00e543
+	if(conn->capable & FUSE_CAP_CACHE_SYMLINKS)
00e543
+			printf("\tFUSE_CAP_CACHE_SYMLINKS\n");
00e543
 	fuse_session_exit(se);
00e543
 }
00e543
 
00e543
diff --git a/include/fuse_common.h b/include/fuse_common.h
00e543
index 83c9dee..a5a0ea5 100644
00e543
--- a/include/fuse_common.h
00e543
+++ b/include/fuse_common.h
00e543
@@ -316,6 +316,19 @@ struct fuse_loop_config {
00e543
  */
00e543
 #define FUSE_CAP_HANDLE_KILLPRIV         (1 << 20)
00e543
 
00e543
+/**
00e543
+ * Indicates that the kernel supports caching symlinks in its page cache.
00e543
+ *
00e543
+ * When this feature is enabled, symlink targets are saved in the page cache.
00e543
+ * You can invalidate a cached link by calling:
00e543
+ * `fuse_lowlevel_notify_inval_inode(se, ino, 0, 0);`
00e543
+ *
00e543
+ * This feature is disabled by default.
00e543
+ * If the kernel supports it (>= 4.20), you can enable this feature by
00e543
+ * setting this flag in the `want` field of the `fuse_conn_info` structure.
00e543
+ */
00e543
+#define FUSE_CAP_CACHE_SYMLINKS        (1 << 23)
00e543
+
00e543
 /**
00e543
  * Ioctl flags
00e543
  *
00e543
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
00e543
index 60195e0..43f785f 100644
00e543
--- a/lib/fuse_lowlevel.c
00e543
+++ b/lib/fuse_lowlevel.c
00e543
@@ -1882,6 +1882,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
00e543
 			se->conn.capable |= FUSE_CAP_POSIX_ACL;
00e543
 		if (arg->flags & FUSE_HANDLE_KILLPRIV)
00e543
 			se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV;
00e543
+		if (arg->flags & FUSE_CACHE_SYMLINKS)
00e543
+			se->conn.capable |= FUSE_CAP_CACHE_SYMLINKS;
00e543
 		if (!(arg->flags & FUSE_MAX_PAGES)) {
00e543
 			size_t max_bufsize =
00e543
 				FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
00e543
@@ -2002,6 +2004,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
00e543
 		outarg.flags |= FUSE_WRITEBACK_CACHE;
00e543
 	if (se->conn.want & FUSE_CAP_POSIX_ACL)
00e543
 		outarg.flags |= FUSE_POSIX_ACL;
00e543
+	if (se->conn.want & FUSE_CAP_CACHE_SYMLINKS)
00e543
+		outarg.flags |= FUSE_CACHE_SYMLINKS;
00e543
 	outarg.max_readahead = se->conn.max_readahead;
00e543
 	outarg.max_write = se->conn.max_write;
00e543
 	if (se->conn.proto_minor >= 13) {
00e543
-- 
00e543
2.36.1
00e543