History

ublk: add new batch command UBLK_U_IO_PREP_IO_CMDS & UBLK_U_IO_COMMIT_IO_CMDS

Add new command UBLK_U_IO_PREP_IO_CMDS, which is the batch version of UBLK_IO_FETCH_REQ. Add new command UBLK_U_IO_COMMIT_IO_CMDS, which is for committing io command result only, still the batch version. The new command header type is `struct ublk_batch_io`. This patch doesn't actually implement these commands yet, just validates the SQE fields.

Ming Lei committed 10 months ago

Commit e86f89a1 parent 7ba62f52 files · +135 −1Browse files

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

Unified · Split

include/uapi/linux/ublk_cmd.h+49−0
@@ -103,6 +103,10 @@ · 102 unmodified lines
103103 _IOWR('u', 0x23, struct ublksrv_io_cmd)
104104 #define UBLK_U_IO_UNREGISTER_IO_BUF \
105105 _IOWR('u', 0x24, struct ublksrv_io_cmd)
106+#define UBLK_U_IO_PREP_IO_CMDS \
107+ _IOWR('u', 0x25, struct ublk_batch_io)
108+#define UBLK_U_IO_COMMIT_IO_CMDS \
109+ _IOWR('u', 0x26, struct ublk_batch_io)
106110
107111 /* only ABORT means that no re-fetch */
108112 #define UBLK_IO_RES_OK 0
@@ -544,6 +548,51 @@ struct ublksrv_io_cmd { · 435 unmodified lines
544548 };
545549 };
546550
551+struct ublk_elem_header {
552+ __u16 tag; /* IO tag */
553+
554+ /*
555+ * Buffer index for incoming io command, only valid iff
556+ * UBLK_F_AUTO_BUF_REG is set
557+ */
558+ __u16 buf_index;
559+ __s32 result; /* I/O completion result (commit only) */
560+};
561+
562+/*
563+ * uring_cmd buffer structure for batch commands
564+ *
565+ * buffer includes multiple elements, which number is specified by
566+ * `nr_elem`. Each element buffer is organized in the following order:
567+ *
568+ * struct ublk_elem_buffer {
569+ * // Mandatory fields (8 bytes)
570+ * struct ublk_elem_header header;
571+ *
572+ * // Optional fields (8 bytes each, included based on flags)
573+ *
574+ * // Buffer address (if UBLK_BATCH_F_HAS_BUF_ADDR) for copying data
575+ * // between ublk request and ublk server buffer
576+ * __u64 buf_addr;
577+ *
578+ * // returned Zone append LBA (if UBLK_BATCH_F_HAS_ZONE_LBA)
579+ * __u64 zone_lba;
580+ * }
581+ *
582+ * Used for `UBLK_U_IO_PREP_IO_CMDS` and `UBLK_U_IO_COMMIT_IO_CMDS`
583+ */
584+struct ublk_batch_io {
585+ __u16 q_id;
586+#define UBLK_BATCH_F_HAS_ZONE_LBA (1 << 0)
587+#define UBLK_BATCH_F_HAS_BUF_ADDR (1 << 1)
588+#define UBLK_BATCH_F_AUTO_BUF_REG_FALLBACK (1 << 2)
589+ __u16 flags;
590+ __u16 nr_elem;
591+ __u8 elem_bytes;
592+ __u8 reserved;
593+ __u64 reserved2;
594+};
595+
547596 struct ublk_param_basic {
548597 #define UBLK_ATTR_READ_ONLY (1 << 0)
549598 #define UBLK_ATTR_ROTATIONAL (1 << 1)