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 06/10] fuse: Add MUSE specific defines to FUSE interface
Date: Mon, 30 Nov 2026 09:26:29 +0100 [thread overview]
Message-ID: <20261130082634.2750846-7-rw@kernel.org> (raw)
In-Reply-To: <20261130082634.2750846-1-rw@kernel.org>
From: Richard Weinberger <richard@nod.at>
Raise the FUSE API minor version to 48 and add all MUSE specific
operations and data structures.
MUSE_INIT: Initialize a new connection and install the MTD
MUSE_ERASE: Erase a range of the MTD
MUSE_READ: Read in-band and/or out-of-band data
MUSE_WRITE: Write in-band and/or out-of-band data
MUSE_MARKBAD: Mark a block as bad
MUSE_ISBAD: Check whether a block is bad
MUSE_SYNC: Flush all cached data
The requests and their replies are documented next to the definitions.
The keys of the MTD description a server passes to MUSE_INIT are
documented in drivers/mtd/muse.c.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
include/uapi/linux/fuse.h | 249 +++++++++++++++++++++++++++++++++++++-
1 file changed, 248 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index cb9e9554f0ef..a80e50a32c98 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -258,6 +258,10 @@
* - add FUSE_NOTIFY_BACKING_MAP, fuse_notify_backing_map_out, fuse_extent
* - add FUSE_BACKING_MAP_CREATE, FUSE_BACKING_MAP_CYCLIC
* - extend the meaning of FUSE_HAS_INODE_DAX and FUSE_ATTR_DAX
+ *
+ * 7.48
+ * - add support for MUSE: MUSE_INIT, MUSE_ERASE, MUSE_READ, MUSE_WRITE,
+ * MUSE_MARKBAD, MUSE_ISBAD and MUSE_SYNC
*/
#ifndef _LINUX_FUSE_H
@@ -293,7 +297,7 @@
#define FUSE_KERNEL_VERSION 7
/** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 47
+#define FUSE_KERNEL_MINOR_VERSION 48
/** The node ID of the root inode */
#define FUSE_ROOT_ID 1
@@ -708,6 +712,15 @@ enum fuse_opcode {
/* CUSE specific operations */
CUSE_INIT = 4096,
+ /* MUSE specific operations */
+ MUSE_INIT = 8192,
+ MUSE_ERASE = 8193,
+ MUSE_READ = 8194,
+ MUSE_WRITE = 8195,
+ MUSE_MARKBAD = 8196,
+ MUSE_ISBAD = 8197,
+ MUSE_SYNC = 8198,
+
/* Reserved opcodes: helpful to detect structure endian-ness */
CUSE_INIT_BSWAP_RESERVED = 1048576, /* CUSE_INIT << 8 */
FUSE_INIT_BSWAP_RESERVED = 436207616, /* FUSE_INIT << 24 */
@@ -1450,4 +1463,238 @@ struct fuse_uring_cmd_req {
};
};
+/*
+ * MUSE: MTD in userspace
+ *
+ * A MUSE server opens /dev/muse and serves the requests it reads from it,
+ * like a FUSE or CUSE server does. The first request is MUSE_INIT, the reply
+ * to it describes an MTD which the kernel then creates. From then on the
+ * kernel forwards the operations on that MTD to the server. The MTD is
+ * removed when the server closes the device and the MTD has no more users.
+ *
+ * Requests and replies start with struct fuse_in_header and struct
+ * fuse_out_header. The nodeid is always FUSE_ROOT_ID. Replying with an
+ * error in struct fuse_out_header makes the operation on the MTD fail with
+ * that error.
+ *
+ * MUSE_INIT: create the MTD
+ * in: struct muse_init_in
+ * out: struct muse_init_out, followed by the description of the MTD
+ * MUSE_ERASE: erase a range of the MTD
+ * in: struct muse_erase_in
+ * out: nothing
+ * MUSE_READ: read in-band and/or out-of-band data
+ * in: struct muse_read_in
+ * out: struct muse_read_out, followed by the data
+ * MUSE_WRITE: write in-band and/or out-of-band data
+ * in: struct muse_write_in, followed by the data
+ * out: struct muse_write_out
+ * MUSE_MARKBAD: mark an erase block as bad, only sent for NAND type MTDs
+ * in: struct muse_markbad_in
+ * out: nothing
+ * MUSE_ISBAD: ask whether an erase block is bad, only sent for NAND type MTDs
+ * in: struct muse_isbad_in
+ * out: struct muse_isbad_out
+ * MUSE_SYNC: write all cached data to the storage, an error is ignored
+ * in: nothing
+ * out: nothing
+ */
+
+/**
+ * define MUSE_INIT_INFO_MAX - Maximum size of the description of the MTD
+ *
+ * The reply to MUSE_INIT carries the description of the MTD right after
+ * struct muse_init_out, as a sequence of "KEY=VALUE" strings, each of them
+ * terminated by a NUL byte. This is the format CUSE_INIT uses. Numbers are
+ * decimal. Known keys are documented in drivers/mtd/muse.c
+ */
+#define MUSE_INIT_INFO_MAX 4096
+
+/**
+ * struct muse_init_in - MUSE_INIT request
+ * @fuse_major: major version of the protocol the kernel speaks,
+ * FUSE_KERNEL_VERSION
+ * @fuse_minor: minor version of the protocol the kernel speaks,
+ * FUSE_KERNEL_MINOR_VERSION
+ */
+struct muse_init_in {
+ uint32_t fuse_major;
+ uint32_t fuse_minor;
+};
+
+/**
+ * struct muse_init_out - MUSE_INIT reply
+ * @fuse_major: major version of the protocol the server speaks, has to be
+ * the one of the kernel
+ * @fuse_minor: minor version of the protocol the server speaks, at least 48
+ * @max_read: maximum number of bytes, in-band and out-of-band data together,
+ * the server returns in one MUSE_READ reply
+ * @max_write: maximum number of bytes, in-band and out-of-band data
+ * together, the server takes in one MUSE_WRITE request
+ *
+ * The kernel splits larger reads and writes into multiple requests. It uses
+ * a limit of at least 4096 bytes, and both limits have to allow for a
+ * request of WRITEBUFSIZE bytes of in-band data together with OOBSIZE bytes
+ * of out-of-band data.
+ *
+ * The description of the MTD follows this structure, see MUSE_INIT_INFO_MAX.
+ */
+struct muse_init_out {
+ uint32_t fuse_major;
+ uint32_t fuse_minor;
+ uint32_t max_read;
+ uint32_t max_write;
+};
+
+/**
+ * struct muse_erase_in - MUSE_ERASE request
+ * @addr: address on the MTD where the range to erase starts
+ * @len: length of the range in bytes
+ *
+ * The range is within the MTD. It is up to the server to reject a range
+ * which does not consist of whole erase blocks.
+ */
+struct muse_erase_in {
+ uint64_t addr;
+ uint64_t len;
+};
+
+/*
+ * MUSE_READ and MUSE_WRITE request flags
+ *
+ * MUSE_IO_INBAND: the request has in-band data, len is not 0
+ * MUSE_IO_OOB_AUTO: the request has out-of-band data, ooblen is not 0. It
+ * addresses only the free bytes of the out-of-band area,
+ * OOBAVAIL bytes per page, the server places them
+ * MUSE_IO_OOB_PLACE: the request has out-of-band data, ooblen is not 0. It
+ * addresses the whole out-of-band area, OOBSIZE bytes per
+ * page
+ * MUSE_IO_RAW: raw access, without error correction
+ *
+ * At most one of MUSE_IO_OOB_AUTO and MUSE_IO_OOB_PLACE is set.
+ */
+#define MUSE_IO_INBAND (1 << 0)
+#define MUSE_IO_OOB_AUTO (1 << 1)
+#define MUSE_IO_OOB_PLACE (1 << 2)
+#define MUSE_IO_RAW (1 << 3)
+
+/**
+ * struct muse_read_in - MUSE_READ request
+ * @addr: address on the MTD where the in-band data starts
+ * @len: number of bytes of in-band data to read
+ * @ooblen: number of bytes of out-of-band data to read
+ * @ooboffs: offset in the out-of-band area of the page @addr belongs to
+ * where the out-of-band data starts. It continues at offset 0 of
+ * the out-of-band area of the following pages
+ * @flags: MUSE_IO_* flags
+ * @padding: unused
+ *
+ * A request can ask for in-band data, out-of-band data or both, but not for
+ * nothing. @len and @ooblen together do not exceed max_read of struct
+ * muse_init_out. The kernel splits a larger read at page boundaries, such
+ * that a request asks for the out-of-band data of the very pages its
+ * in-band data is in.
+ */
+struct muse_read_in {
+ uint64_t addr;
+ uint64_t len;
+ uint32_t ooblen;
+ uint32_t ooboffs;
+ uint32_t flags;
+ uint32_t padding;
+};
+
+/**
+ * struct muse_read_out - MUSE_READ reply
+ * @len: number of bytes of in-band data read
+ * @ooblen: number of bytes of out-of-band data read
+ * @soft_error: 0 or a negative errno value
+ *
+ * This structure is followed by exactly as many bytes of in-band data as the
+ * request asked for, and then by exactly as many bytes of out-of-band data
+ * as it asked for. Short reads are not allowed: @len and @ooblen have to be
+ * the values of the request, unless @soft_error is set.
+ *
+ * With @soft_error the server makes the read return an error although the
+ * request itself was served. Two values are what a flash driver uses to
+ * report on its error correction, the data which was read is passed on to
+ * the reader together with them: -EUCLEAN, bit-flips were corrected, and
+ * -EBADMSG, the data has bit-flips which could not be corrected. Any other
+ * value makes the read fail with it.
+ */
+struct muse_read_out {
+ uint64_t len;
+ uint32_t ooblen;
+ int32_t soft_error;
+};
+
+/**
+ * struct muse_write_in - MUSE_WRITE request
+ * @addr: address on the MTD where the in-band data starts
+ * @len: number of bytes of in-band data to write
+ * @ooblen: number of bytes of out-of-band data to write
+ * @ooboffs: offset in the out-of-band area of the page @addr belongs to
+ * where the out-of-band data starts. It continues at offset 0 of
+ * the out-of-band area of the following pages
+ * @flags: MUSE_IO_* flags
+ * @padding: unused
+ *
+ * This structure is followed by @len bytes of in-band data and then by
+ * @ooblen bytes of out-of-band data. A request can carry in-band data,
+ * out-of-band data or both, but not nothing. @len and @ooblen together do
+ * not exceed max_write of struct muse_init_out. The kernel splits a larger
+ * write at page boundaries, such that a request carries the out-of-band data
+ * of the very pages its in-band data is for.
+ */
+struct muse_write_in {
+ uint64_t addr;
+ uint64_t len;
+ uint32_t ooblen;
+ uint32_t ooboffs;
+ uint32_t flags;
+ uint32_t padding;
+};
+
+/**
+ * struct muse_write_out - MUSE_WRITE reply
+ * @len: number of bytes of in-band data written
+ * @ooblen: number of bytes of out-of-band data written
+ * @soft_error: 0 or a negative errno value
+ *
+ * Short writes are not allowed: @len and @ooblen have to be the values of
+ * the request, unless @soft_error is set. A @soft_error makes the write
+ * fail with it.
+ */
+struct muse_write_out {
+ uint64_t len;
+ uint32_t ooblen;
+ int32_t soft_error;
+};
+
+/**
+ * struct muse_markbad_in - MUSE_MARKBAD request
+ * @addr: address on the MTD within the erase block to mark as bad
+ */
+struct muse_markbad_in {
+ uint64_t addr;
+};
+
+/**
+ * struct muse_isbad_in - MUSE_ISBAD request
+ * @addr: address on the MTD within the erase block in question
+ */
+struct muse_isbad_in {
+ uint64_t addr;
+};
+
+/**
+ * struct muse_isbad_out - MUSE_ISBAD reply
+ * @result: 1 if the erase block is bad, 0 if it is not
+ * @padding: unused
+ */
+struct muse_isbad_out {
+ uint32_t result;
+ uint32_t padding;
+};
+
#endif /* _LINUX_FUSE_H */
--
2.55.0
next prev parent reply other threads:[~2026-11-30 8:27 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 ` [PATCH 02/10] fuse: Add a public header for users outside of fs/fuse/ Richard Weinberger (sigma star gmbh)
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 ` Richard Weinberger (sigma star gmbh) [this message]
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-7-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