Netdev List
 help / color / mirror / Atom feed
From: "Richard Weinberger (sigma star gmbh)" <rw@kernel.org>
To: linux-mtd@lists.infradead.org
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>
Subject: [PATCH 02/10] fuse: Add a public header for users outside of fs/fuse/
Date: Mon, 30 Nov 2026 09:26:25 +0100	[thread overview]
Message-ID: <20261130082634.2750846-3-rw@kernel.org> (raw)
In-Reply-To: <20261130082634.2750846-1-rw@kernel.org>

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


  parent reply	other threads:[~2026-11-30  8:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  8:26 [PATCH 0/10] MUSE: Userspace backed MTD v4 Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 01/10] fuse: Share cuse_parse_one() as fuse_kv_parse_one() Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` Richard Weinberger (sigma star gmbh) [this message]
2026-11-30  8:26 ` [PATCH 03/10] fuse: Add an interface for userspace backed devices Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 04/10] fuse: Convert CUSE to the " Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 05/10] fuse: Allow three output arguments per request Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 06/10] fuse: Add MUSE specific defines to FUSE interface Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 07/10] mtd: Add MTD_MUSE flag Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 08/10] mtd: Allow passing a custom mtdparts string to the cmdline parser Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 09/10] mtd: Implement MUSE - MTD in userspace Richard Weinberger (sigma star gmbh)
2026-11-30  8:26 ` [PATCH 10/10] MAINTAINERS: Add entry for MUSE Richard Weinberger (sigma star gmbh)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130082634.2750846-3-rw@kernel.org \
    --to=rw@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=edumazet@google.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miklos@szeredi.hu \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richard@nod.at \
    --cc=upstream+linux@sigma-star.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox