🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24479

[PATCH 02/10] fuse: Add a public header for users outside of fs/fuse/

#24479
From: "Richard Weinberger (sigma star ...
Date: Mon, 30 Nov 2026 08:26
279 lines
15552 bytes
From: Richard Weinberger <richard@nod.at>

A driver which implements a userspace backed device on top of the FUSE
transport does not have to live in fs/fuse/. So far such a driver would
need fuse_i.h, and with it every internal data structure of FUSE.

Add <net/fuse.h> and move the bare minimum to it: the request arguments
(struct fuse_args), the device file operations, fuse_dev_release(),
fuse_dev_put(), reference counting of struct fuse_conn, and
fuse_kv_parse_one(). struct fuse_conn and struct fuse_dev are opaque to
users of this header.

No functional change, the private headers include the new one.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 MAINTAINERS          |  1 +
 fs/fuse/args.h       | 44 +----------------------
 fs/fuse/dev.h        | 12 +------
 fs/fuse/fuse_dev_i.h |  3 +-
 fs/fuse/fuse_i.h     |  9 -----
 include/net/fuse.h   | 85 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 89 insertions(+), 65 deletions(-)
 create mode 100644 include/net/fuse.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 84cb98ef4c49..6626e026deea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11039,6 +11039,7 @@ W:	https://github.com/libfuse/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git
 F:	Documentation/filesystems/fuse/*
 F:	fs/fuse/
+F:	include/net/fuse.h
 F:	include/uapi/linux/fuse.h
 F:	tools/testing/selftests/filesystems/fuse/
 
diff --git a/fs/fuse/args.h b/fs/fuse/args.h
index 36ef0c6d5999..d9c4fb1a19b3 100644
--- a/fs/fuse/args.h
+++ b/fs/fuse/args.h
@@ -4,52 +4,10 @@
 #define _FS_FUSE_ARGS_H
 
 #include <linux/types.h>
+#include <net/fuse.h>
 
 struct fuse_mount;
 
-/** One input argument of a request */
-struct fuse_in_arg {
-	unsigned size;
-	const void *value;
-};
-
-/** One output argument of a request */
-struct fuse_arg {
-	unsigned size;
-	void *value;
-};
-
-struct fuse_args {
-	u64 nodeid;
-	u32 opcode;
-	u32 uid;
-	u32 gid;
-	u32 pid;
-	u8 in_numargs;
-	u8 out_numargs;
-	u8 ext_idx;
-	bool force:1;
-	bool noreply:1;
-	bool nocreds:1;
-	bool in_pages:1;
-	bool out_pages:1;
-	bool user_pages:1;
-	bool out_argvar:1;
-	bool page_zeroing:1;
-	bool may_block:1;
-	bool is_ext:1;
-	bool is_pinned:1;
-	bool invalidate_vmap:1;
-	bool abort_on_kill:1;
-	/* server requested io-uring zero-copy for this op */
-	bool zero_copy:1;
-	struct fuse_in_arg in_args[4];
-	struct fuse_arg out_args[2];
-	void (*end)(struct fuse_args *args, int error);
-	/* Used for kvec iter backed by vmalloc address */
-	void *vmap_base;
-};
-
 /** FUSE folio descriptor */
 struct fuse_folio_desc {
 	unsigned int length;
diff --git a/fs/fuse/dev.h b/fs/fuse/dev.h
index dbffd5bed2f5..3e4838b32c79 100644
--- a/fs/fuse/dev.h
+++ b/fs/fuse/dev.h
@@ -4,6 +4,7 @@
 #define _FS_FUSE_DEV_H
 
 #include <linux/cleanup.h>
+#include <net/fuse.h>
 
 /** Maximum number of outstanding background requests */
 #define FUSE_DEFAULT_MAX_BACKGROUND 12
@@ -59,7 +60,6 @@ void fuse_dev_cleanup(void);
 
 void fuse_dev_install(struct fuse_dev *fud, struct fuse_chan *fch);
 bool fuse_dev_verify(struct fuse_dev *fud, struct fuse_chan *fch);
-void fuse_dev_put(struct fuse_dev *fud);
 bool fuse_dev_is_installed(struct fuse_dev *fud);
 bool fuse_dev_is_sync_init(struct fuse_dev *fud);
 struct fuse_dev *fuse_dev_grab(struct file *file);
@@ -70,16 +70,6 @@ void fuse_init_server_timeout(struct fuse_chan *fch, unsigned int timeout);
 void fuse_chan_abort(struct fuse_chan *fch, bool abort_with_err);
 void fuse_chan_wait_aborted(struct fuse_chan *fch);
 
-/**
- * Acquire reference to fuse_conn
- */
-struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
-
-/**
- * Release reference to fuse_conn
- */
-void fuse_conn_put(struct fuse_conn *fc);
-
 dev_t fuse_conn_get_id(struct fuse_conn *fc);
 
 void fuse_end_polls(struct fuse_conn *fc);
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index a8eba46a3e51..82621b8d41e6 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -12,6 +12,7 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <linux/fs.h>
+#include <net/fuse.h>
 
 /* Ordinary requests have even IDs, while interrupts IDs are odd */
 #define FUSE_INT_REQ_BIT (1ULL << 0)
@@ -411,8 +412,6 @@ u64 fuse_get_unique(struct fuse_iqueue *fiq);
 struct fuse_dev *fuse_dev_alloc_install(struct fuse_chan *fch);
 struct fuse_dev *fuse_dev_alloc(void);
 
-int fuse_dev_release(struct inode *inode, struct file *file);
-
 struct list_head *fuse_pqueue_alloc(void);
 
 /*
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index b6153db7e76a..8bceab59c1ca 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -365,8 +365,6 @@ union fuse_file_args {
 	struct fuse_release_args release_args;
 };
 
-#define FUSE_ARGS(args) struct fuse_args args = {}
-
 /** The request IO state (for asynchronous processing) */
 struct fuse_io_priv {
 	struct kref refcnt;
@@ -959,9 +957,6 @@ static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket)
 	rcu_read_unlock();
 }
 
-/** Device operations */
-extern const struct file_operations fuse_dev_operations;
-
 extern const struct dentry_operations fuse_dentry_operations;
 
 /*
@@ -1410,8 +1405,4 @@ int fuse_ext_map_mmap(struct file *file, struct vm_area_struct *vma);
 bool fuse_ext_map_is_dax(struct fuse_backing *fb);
 int fuse_ext_map_populate(struct fuse_conn *fc, struct fuse_notify_backing_map_out *arg,
 			  struct fuse_extent *ext);
-
-/* helper.c */
-int fuse_kv_parse_one(char **pp, char *end, char **keyp, char **valp);
-
 #endif /* _FS_FUSE_I_H */
diff --git a/include/net/fuse.h b/include/net/fuse.h
new file mode 100644
index 000000000000..206193f4653a
--- /dev/null
+++ b/include/net/fuse.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * FUSE transport interface for users outside of fs/fuse/.
+ *
+ * This is the bare minimum a driver needs to implement a device which is
+ * backed by a userspace server.
+ */
+
+#ifndef _NET_FUSE_H
+#define _NET_FUSE_H
+
+#include <linux/types.h>
+
+struct file;
+struct file_operations;
+struct fuse_conn;
+struct fuse_dev;
+struct inode;
+struct user_namespace;
+
+/** One input argument of a request */
+struct fuse_in_arg {
+	unsigned size;
+	const void *value;
+};
+
+/** One output argument of a request */
+struct fuse_arg {
+	unsigned size;
+	void *value;
+};
+
+struct fuse_args {
+	u64 nodeid;
+	u32 opcode;
+	u32 uid;
+	u32 gid;
+	u32 pid;
+	u8 in_numargs;
+	u8 out_numargs;
+	u8 ext_idx;
+	bool force:1;
+	bool noreply:1;
+	bool nocreds:1;
+	bool in_pages:1;
+	bool out_pages:1;
+	bool user_pages:1;
+	bool out_argvar:1;
+	bool page_zeroing:1;
+	bool may_block:1;
+	bool is_ext:1;
+	bool is_pinned:1;
+	bool invalidate_vmap:1;
+	bool abort_on_kill:1;
+	/* server requested io-uring zero-copy for this op */
+	bool zero_copy:1;
+	struct fuse_in_arg in_args[4];
+	struct fuse_arg out_args[2];
+	void (*end)(struct fuse_args *args, int error);
+	/* Used for kvec iter backed by vmalloc address */
+	void *vmap_base;
+};
+
+#define FUSE_ARGS(args) struct fuse_args args = {}
+
+/** Device operations */
+extern const struct file_operations fuse_dev_operations;
+
+int fuse_dev_release(struct inode *inode, struct file *file);
+void fuse_dev_put(struct fuse_dev *fud);
+
+/**
+ * Acquire reference to fuse_conn
+ */
+struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
+
+/**
+ * Release reference to fuse_conn
+ */
+void fuse_conn_put(struct fuse_conn *fc);
+
+/* Helpers for userspace backed devices, see fs/fuse/helper.c */
+int fuse_kv_parse_one(char **pp, char *end, char **keyp, char **valp);
+
+#endif /* _NET_FUSE_H */
-- 
2.55.0
Technical Details
Message-ID: <20261130082634.2750846-3-rw@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374009-linux-kernel-netdev=dewy.ru
References: <20261130082634.2750846-1-rw@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374009-linux-kernel-netdev=dewy.ru
From: rw@kernel.org ("Richard Weinberger (sigma star gmbh)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH 02/10] fuse: Add a public header for users outside of fs/fuse/
Date: Mon, 30 Nov 2026 09:26:25 +0100
Organization: Usenet Network
Message-ID: <20261130082634.2750846-3-rw@kernel.org>
References: <20261130082634.2750846-1-rw@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1375918"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pq9+G91hqOOxxg7/9bCAi8fMAZc= sha256:VqeilU+dLZL870WcG/a3Xhh+yHuMr8RhxuIUefyve7c=
	sha1:uG5PgbrkqPJ8dpUwLuBxx0WR+mw= sha256:wm8rqOlAl2O7MKVWij+2iIb8YHqdQ81p8PpBYHLNg58=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 8353D125FCF; Mon, 30 Nov 2026 11:27:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id fZq_ZA11JF8j;
	Mon, 30 Nov 2026 11:27:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374009-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8991A125FCC; Mon, 30 Nov 2026 11:26:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 8FAA624F5C; Mon, 30 Nov 2026 08:26:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796027215;
	b=hqXM0wTe74J0BGi0Er53PpNqk1b8KjWyo25RfkOR6O6NbDgOHNp0rY0m9H2eMeQ9rO3N
	 k1U8GJCA6QYjFlNDB3DafAJUoMMbxIFQ2LuyVtJsDWRKHTZxnT9aXolXWtEFal5lIsccf
	 iklDnNFAlRTS1Wy7FqOLMZ2wDUZ+KX5/qmV2Dt4ZcBE7yQGSzkBufIf3Run5q2ENU8edt
	 Tt5i4lU6mQjMQVEKs/d4vqCXjF3SY8nFiR2vuTO2l41RYdZEZZ8wuQhFnA0mwLMHKqTwE
	 WWLX67QRFqn7VfrHP/LCp0p3p1VrRx2gnUc3qQ//sAhJRJa6Q05clxBQEjIO51WUu2A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796027215;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=1pPilO8dbKfXXHxRsJlkYs9xA3UcmmEgCMUG0tYLQXI=;
	b=zMMeDV8jVcBCWYrGcBtyL9op18aLxINZSCUNEJRfH0Qa1FLKt/7p4mK6RxVHcnObWs4w
	 UYgqyBO2R1shUUPDX1bKU04vfrCsYJQ1UAvF19rq//FE2HwOyWFFlmC7ybnSjOvX94Bhv
	 I2hGVPqRG5ixRPbRajJIddzru9sRr5+AyvsWQuImvSCtuWOUQLgiGz1XcfQbuorpDuvj9
	 qaYdYz2YtN2v8TenUVzXiel2H8iszZj82vLJtY6WY8KbGgsRaU3RwRaJ/CNfTD1IUch4x
	 /HazxobyHE3eSIO0CgMlEkYr4EZ436choYdghgPqfkIKitGhufWRlsMThhh1kSI1ueQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mu1DEEz8;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 65DBB606A32F;
	Mon, 30 Nov 2026 08:26:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mu1DEEz8
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796027214;
	b=ti45Mo20k/ystNKM+bd1gGpK5YGNQdA0C7UD40lM7CRqi1F+Dlhyqmqne3SqvZIUcZPL
	 E2JPYDgRBS/WRAUdATn+1CbbUZEOVPy2nmLxWDdUvrZ/Zzxku3q9yZS8rUxyfGPEQYp/9
	 3wT7hUrGxzA92cCpB6zE0Z9DRWSZ2qAXyEutB2GhJv6XS+2aJecFU3HIaFVdPTXKk27o3
	 jnSsiTwKZF45jRXmChGvvdbnDjfUn7d8NSwxv2R8s7zLN+LUGNJD/0Tw8bu2oNNo6HXxs
	 7EzhCmM/gVvrrZQmfxhH+N6F/iiaWUbuhrXutJ9WfnJ2tFbPJddHYRiUYW+XwVBc9dw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796027214;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=1pPilO8dbKfXXHxRsJlkYs9xA3UcmmEgCMUG0tYLQXI=;
	b=meWTHVI2tKcFh3p0z7EcHMFbt8fYAT4fAsKvlvGUdCM4VUdJIzaKhqb2VtaaZSpsC67R
	 AHGOFcID+b2JkOYi/Il+NB+DmjKNU7Ccomme4pooTXlY+hr3T4vjxq8YgPTMWy1IYJLAJ
	 P3O1D8sSEARM1waE6NRJJ5s4QTff8tDlauwDTKEOnwluq8JhukAysDZEywwGtGb8BHujT
	 tac8F0aO7AtG+M5HlHMT3oY4b0C7SMI7jQIbt5XRkAtP+DM98bl9Ww5UW47tk1Zj+WSBm
	 97gFaM+i5aFQsCiz7bAeXOzqwi17CunKq7w0kFaK+/CGaf5JKCRZvsFolijP3Ptq2BQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mu1DEEz8;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84EC9606A31C;
	Mon, 30 Nov 2026 08:26:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE7451F00897;
	Mon, 30 Nov 2026 08:26:49 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796027213;
	bh=1pPilO8dbKfXXHxRsJlkYs9xA3UcmmEgCMUG0tYLQXI=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=mu1DEEz8TPkiSJ2fndmflZBtsanwDPG6CsFuYeO1U3oLnM6fiHuQs+SHuuJYHlscC
	 RYERA0yzZmOrI1ZosDcPBbgTEQPK/5LZntZspmFwIketLnCbqLORkZ9abkACoqTSXd
	 fFPxAZgBxMFFF2y2GcpGHV9uo8EY4H1WiYy1yg5Ur9TWF0GV2Ye5PnVA2z5HfNBaaL
	 ZtIhLrnFI04ak7EmxbYrSWNHFK83wTtEfICGTzXSQ38W/9AfU0rXFxaNnisZi4qczB
	 +FG49aiPv0dzm15X1rdmUj/XC2yDwPvteNx5sFdtHpME3pJwtMYC05yU4+MayXW55q
	 I9Au2GhZd+0oQ==
X-Cc: fuse-devel@lists.linux.dev,
	netdev@vger.kernel.org,
	horms@kernel.org,
	pabeni@redhat.com,
	kuba@kernel.org,
	edumazet@google.com,
	davem@davemloft.net,
	miklos@szeredi.hu,
	vigneshr@ti.com,
	miquel.raynal@bootlin.com,
	david.oberhollenzer@sigma-star.at,
	upstream+linux@sigma-star.at,
	Richard Weinberger <richard@nod.at>
X-Mailer: git-send-email 2.55.0
X-In-Reply-To: <20261130082634.2750846-1-rw@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list