[PATCH 1/8] io_uring: split up io_uring_sqe into hdr + main

Christoph Hellwig hch at lst.de
Thu Mar 18 05:34:54 GMT 2021


> @@ -14,11 +14,22 @@
>  /*
>   * IO submission data structure (Submission Queue Entry)
>   */
> +struct io_uring_sqe_hdr {
> +	__u8	opcode;		/* type of operation for this sqe */
> +	__u8	flags;		/* IOSQE_ flags */
> +	__u16	ioprio;		/* ioprio for the request */
> +	__s32	fd;		/* file descriptor to do IO on */
> +};
> +
>  struct io_uring_sqe {
> +#ifdef __KERNEL__
> +	struct io_uring_sqe_hdr	hdr;
> +#else
>  	__u8	opcode;		/* type of operation for this sqe */
>  	__u8	flags;		/* IOSQE_ flags */
>  	__u16	ioprio;		/* ioprio for the request */
>  	__s32	fd;		/* file descriptor to do IO on */
> +#endif
>  	union {
>  		__u64	off;	/* offset into file */
>  		__u64	addr2;

Please don't do that ifdef __KERNEL__ mess.  We never guaranteed
userspace API compatbility, just ABI compatibility.

But we really do have a biger problem here, and that is ioprio is
a field that is specific to the read and write commands and thus
should not be in the generic header.  On the other hand the
personality is.

So I'm not sure trying to retrofit this even makes all that much sense.

Maybe we should just define io_uring_sqe_hdr the way it makes
sense:

struct io_uring_sqe_hdr {
	__u8	opcode;	
	__u8	flags;
	__u16	personality;
	__s32	fd;
	__u64	user_data;
};

and use that for all new commands going forward while marking the
old ones as legacy.

io_uring_cmd_sqe would then be:

struct io_uring_cmd_sqe {
        struct io_uring_sqe_hdr	hdr;
	__u33			ioc;
	__u32 			len;
	__u8			data[40];
};

for example.  Note the 32-bit opcode just like ioctl to avoid
getting into too much trouble due to collisions.




More information about the Linux-nvme mailing list