summaryrefslogtreecommitdiffstats
path: root/fs/fuse/passthrough.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2024-02-09 16:57:17 +0200
committerMiklos Szeredi <mszeredi@redhat.com>2024-02-23 17:36:32 +0100
commit7dc4e97a4f9a55bae6ed6ab3f96c92921259d59f (patch)
tree2232613c737e5709577dc4790ac884cb8d1a3891 /fs/fuse/passthrough.c
parentaed918310ea2542059eeab6c74defca95c30f77b (diff)
downloadlinux-stable-7dc4e97a4f9a55bae6ed6ab3f96c92921259d59f.tar.gz
linux-stable-7dc4e97a4f9a55bae6ed6ab3f96c92921259d59f.tar.bz2
linux-stable-7dc4e97a4f9a55bae6ed6ab3f96c92921259d59f.zip
fuse: introduce FUSE_PASSTHROUGH capability
FUSE_PASSTHROUGH capability to passthrough FUSE operations to backing files will be made available with kernel config CONFIG_FUSE_PASSTHROUGH. When requesting FUSE_PASSTHROUGH, userspace needs to specify the max_stack_depth that is allowed for FUSE on top of backing files. Introduce the flag FOPEN_PASSTHROUGH and backing_id to fuse_open_out argument that can be used when replying to OPEN request, to setup passthrough of io operations on the fuse inode to a backing file. Introduce a refcounted fuse_backing object that will be used to associate an open backing file with a fuse inode. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/passthrough.c')
-rw-r--r--fs/fuse/passthrough.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
new file mode 100644
index 000000000000..e8639c0a9ac6
--- /dev/null
+++ b/fs/fuse/passthrough.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * FUSE passthrough to backing file.
+ *
+ * Copyright (c) 2023 CTERA Networks.
+ */
+
+#include "fuse_i.h"
+
+#include <linux/file.h>
+
+struct fuse_backing *fuse_backing_get(struct fuse_backing *fb)
+{
+ if (fb && refcount_inc_not_zero(&fb->count))
+ return fb;
+ return NULL;
+}
+
+static void fuse_backing_free(struct fuse_backing *fb)
+{
+ if (fb->file)
+ fput(fb->file);
+ kfree_rcu(fb, rcu);
+}
+
+void fuse_backing_put(struct fuse_backing *fb)
+{
+ if (fb && refcount_dec_and_test(&fb->count))
+ fuse_backing_free(fb);
+}