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

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