From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCC26606A31C for ; Mon, 30 Nov 2026 08:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=szMdoWkp; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DMSDJgS6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=QZEOxGwcvHbmp4tNqvxCpqo8Gwt5lJsnbsSoN5x8UDs=; b=szMdoWkpTb+yt5Z+AIqr/tWn37 /YY4N92/oDeK9tV2xZ/HVF6S7YANYGbmn1avpvfpAnyUyn91V7vIVu09jucRtojq6p4etwq3Tv+/8 DDTa8HproY1wWet1/yWvmookTO53U3J6r6S5tIGs3NqeLtVzo777o/AAAk4B4Ln5L9vCER1H0ZOCd rVgej95f7MNdUJ2IeNM14x0o/EYKBLGi2f1928bfbu3+VmsQ4muEyhlV5qOtp8biefWuW6oZ6WWca D/SfRxB4LdVMH14PfmYeQ1H1WGMQSPbVMsCxApiUJug64P8p4JJRTSBD/dUF9N08O54GmwNXFgsEZ BinoovtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXwjD-00000003kE8-2654; Mon, 30 Nov 2026 08:27:15 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXwjC-00000003kDH-1sTH for linux-mtd@lists.infradead.org; Mon, 30 Nov 2026 08:27:14 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0E2F544D91; Mon, 30 Nov 2026 08:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C194A1F00897; Mon, 30 Nov 2026 08:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796027233; bh=20ymGQpZSZtmsAbSwBNYif2Hr0QdHXTuhEJjQd8hfs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DMSDJgS6WDuJ1mCvo4oAS5cG6aIYy0DDheHaqfdESKwqVI2EMc7WuF1f/dWGMqrad HVZn9hICruT6NWcp/lGMZGEH11iZjegeiCEGUgzRACGo1iL3YJig5ZHaMSwjKRHY+j BvlRxWbVJCPt34opdpWyUmWeXshuxDR0jzqL5OiRnFXstotEfyheQDpeypY+D0T+L7 4RCeHTIYBycZiYTv0Nf16T6/qJbtwRei331RtH9dMzN5FnuVCpkIpEWM519UwwrEgF 8JwpBu2BGuXCIygfmu14PUlGDig/fJjfWUxszOb2kyGiyeJEqr9W223mmoErdO7sQt ZYnQ71yLFplHQ== From: "Richard Weinberger (sigma star gmbh)" 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 Subject: [PATCH 06/10] fuse: Add MUSE specific defines to FUSE interface Date: Mon, 30 Nov 2026 09:26:29 +0100 Message-ID: <20261130082634.2750846-7-rw@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130082634.2750846-1-rw@kernel.org> References: <20261130082634.2750846-1-rw@kernel.org> X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Richard Weinberger 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 --- 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 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/