History

Merge tag 'for-5.20/block-2022-07-29' of git://git.kernel.dk/linux-block

Pull block updates from Jens Axboe: - Improve the type checking of request flags (Bart) - Ensure queue mapping for a single queues always picks the right queue (Bart) - Sanitize the io priority handling (Jan) - rq-qos race fix (Jinke) - Reserved tags handling improvements (John) - Separate memory alignment from file/disk offset aligment for O_DIRECT (Keith) - Add new ublk driver, userspace block driver using io_uring for communication with the userspace backend (Ming) - Use try_cmpxchg() to cleanup the code in various spots (Uros) - Finally remove bdevname() (Christoph) - Clean up the zoned device handling (Christoph) - Clean up independent access range support (Christoph) - Clean up and improve block sysfs handling (Christoph) - Clean up and improve teardown of block devices. This turns the usual two step process into something that is simpler to implement and handle in block drivers (Christoph) - Clean up chunk size handling (Christoph) - Misc cleanups and fixes (Bart, Bo, Dan, GuoYong, Jason, Keith, Liu, Ming, Sebastian, Yang, Ying) * tag 'for-5.20/block-2022-07-29' of git://git.kernel.dk/linux-block: (178 commits) ublk_drv: fix double shift bug ublk_drv: make sure that correct flags(features) returned to userspace ublk_drv: fix error handling of ublk_add_dev ublk_drv: fix lockdep warning block: remove __blk_get_queue block: call blk_mq_exit_queue from disk_release for never added disks blk-mq: fix error handling in __blk_mq_alloc_disk ublk: defer disk allocation ublk: rewrite ublk_ctrl_get_queue_affinity to not rely on hctx->cpumask ublk: fold __ublk_create_dev into ublk_ctrl_add_dev ublk: cleanup ublk_ctrl_uring_cmd ublk: simplify ublk_ch_open and ublk_ch_release ublk: remove the empty open and release block device operations ublk: remove UBLK_IO_F_PREFLUSH ublk: add a MAINTAINERS entry block: don't allow the same type rq_qos add more than once mmc: fix disk/queue leak in case of adding disk failure ublk_drv: fix an IS_ERR() vs NULL check ublk: remove UBLK_IO_F_INTEGRITY ublk_drv: remove unneeded semicolon ...

Linus Torvalds committed 4 years ago

Commit c013d0a2 parents 42df1cb 8d9fdb6261 files · +3635 −2158Browse files

Showing the changes to include/uapi (1 of 261 files). Show all

Unified · Split

include/uapi/linux/ublk_cmd.h+161−0
@@ -0,0 +1,161 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef USER_BLK_DRV_CMD_INC_H
3+#define USER_BLK_DRV_CMD_INC_H
4+
5+#include <linux/types.h>
6+
7+/* ublk server command definition */
8+
9+/*
10+ * Admin commands, issued by ublk server, and handled by ublk driver.
11+ */
12+#define UBLK_CMD_GET_QUEUE_AFFINITY 0x01
13+#define UBLK_CMD_GET_DEV_INFO 0x02
14+#define UBLK_CMD_ADD_DEV 0x04
15+#define UBLK_CMD_DEL_DEV 0x05
16+#define UBLK_CMD_START_DEV 0x06
17+#define UBLK_CMD_STOP_DEV 0x07
18+
19+/*
20+ * IO commands, issued by ublk server, and handled by ublk driver.
21+ *
22+ * FETCH_REQ: issued via sqe(URING_CMD) beforehand for fetching IO request
23+ * from ublk driver, should be issued only when starting device. After
24+ * the associated cqe is returned, request's tag can be retrieved via
25+ * cqe->userdata.
26+ *
27+ * COMMIT_AND_FETCH_REQ: issued via sqe(URING_CMD) after ublkserver handled
28+ * this IO request, request's handling result is committed to ublk
29+ * driver, meantime FETCH_REQ is piggyback, and FETCH_REQ has to be
30+ * handled before completing io request.
31+ */
32+#define UBLK_IO_FETCH_REQ 0x20
33+#define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
34+
35+/* only ABORT means that no re-fetch */
36+#define UBLK_IO_RES_OK 0
37+#define UBLK_IO_RES_ABORT (-ENODEV)
38+
39+#define UBLKSRV_CMD_BUF_OFFSET 0
40+#define UBLKSRV_IO_BUF_OFFSET 0x80000000
41+
42+/* tag bit is 12bit, so at most 4096 IOs for each queue */
43+#define UBLK_MAX_QUEUE_DEPTH 4096
44+
45+/*
46+ * zero copy requires 4k block size, and can remap ublk driver's io
47+ * request into ublksrv's vm space
48+ */
49+#define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
50+
51+/*
52+ * Force to complete io cmd via io_uring_cmd_complete_in_task so that
53+ * performance comparison is done easily with using task_work_add
54+ */
55+#define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
56+
57+/* device state */
58+#define UBLK_S_DEV_DEAD 0
59+#define UBLK_S_DEV_LIVE 1
60+
61+/* shipped via sqe->cmd of io_uring command */
62+struct ublksrv_ctrl_cmd {
63+ /* sent to which device, must be valid */
64+ __u32 dev_id;
65+
66+ /* sent to which queue, must be -1 if the cmd isn't for queue */
67+ __u16 queue_id;
68+ /*
69+ * cmd specific buffer, can be IN or OUT.
70+ */
71+ __u16 len;
72+ __u64 addr;
73+
74+ /* inline data */
75+ __u64 data[2];
76+};
77+
78+struct ublksrv_ctrl_dev_info {
79+ __u16 nr_hw_queues;
80+ __u16 queue_depth;
81+ __u16 block_size;
82+ __u16 state;
83+
84+ __u32 rq_max_blocks;
85+ __u32 dev_id;
86+
87+ __u64 dev_blocks;
88+
89+ __s32 ublksrv_pid;
90+ __s32 reserved0;
91+ __u64 flags;
92+ __u64 flags_reserved;
93+
94+ /* For ublksrv internal use, invisible to ublk driver */
95+ __u64 ublksrv_flags;
96+ __u64 reserved1[9];
97+};
98+
99+#define UBLK_IO_OP_READ 0
100+#define UBLK_IO_OP_WRITE 1
101+#define UBLK_IO_OP_FLUSH 2
102+#define UBLK_IO_OP_DISCARD 3
103+#define UBLK_IO_OP_WRITE_SAME 4
104+#define UBLK_IO_OP_WRITE_ZEROES 5
105+
106+#define UBLK_IO_F_FAILFAST_DEV (1U << 8)
107+#define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9)
108+#define UBLK_IO_F_FAILFAST_DRIVER (1U << 10)
109+#define UBLK_IO_F_META (1U << 11)
110+#define UBLK_IO_F_FUA (1U << 13)
111+#define UBLK_IO_F_NOUNMAP (1U << 15)
112+#define UBLK_IO_F_SWAP (1U << 16)
113+
114+/*
115+ * io cmd is described by this structure, and stored in share memory, indexed
116+ * by request tag.
117+ *
118+ * The data is stored by ublk driver, and read by ublksrv after one fetch command
119+ * returns.
120+ */
121+struct ublksrv_io_desc {
122+ /* op: bit 0-7, flags: bit 8-31 */
123+ __u32 op_flags;
124+
125+ __u32 nr_sectors;
126+
127+ /* start sector for this io */
128+ __u64 start_sector;
129+
130+ /* buffer address in ublksrv daemon vm space, from ublk driver */
131+ __u64 addr;
132+};
133+
134+static inline __u8 ublksrv_get_op(const struct ublksrv_io_desc *iod)
135+{
136+ return iod->op_flags & 0xff;
137+}
138+
139+static inline __u32 ublksrv_get_flags(const struct ublksrv_io_desc *iod)
140+{
141+ return iod->op_flags >> 8;
142+}
143+
144+/* issued to ublk driver via /dev/ublkcN */
145+struct ublksrv_io_cmd {
146+ __u16 q_id;
147+
148+ /* for fetch/commit which result */
149+ __u16 tag;
150+
151+ /* io result, it is valid for COMMIT* command only */
152+ __s32 result;
153+
154+ /*
155+ * userspace buffer address in ublksrv daemon process, valid for
156+ * FETCH* command only
157+ */
158+ __u64 addr;
159+};
160+
161+#endif