[PATCH v8 04/10] nvme-multipath: pass I/O type to nvme_find_path()

Keith Busch kbusch at kernel.org
Fri Sep 11 15:38:46 PDT 2026


On Sat, Aug 15, 2026 at 11:04:26PM +0530, Nilay Shroff wrote:
> @@ -804,12 +830,24 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
>  int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
>  		unsigned int issue_flags)
>  {
> +	struct nvme_ns *ns;
> +	unsigned int op_type;
>  	struct cdev *cdev = file_inode(ioucmd->file)->i_cdev;
>  	struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev);
>  	int srcu_idx = srcu_read_lock(&head->srcu);
> -	struct nvme_ns *ns = nvme_find_path(head);
>  	int ret = -EINVAL;
> +	const struct nvme_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe,
> +						struct nvme_uring_cmd);
> +	__u8 opcode = READ_ONCE(cmd->opcode);

Just fyi, the READ_ONCE is used because this is shared memory with user
space. We re-read the same field later when constructing the command, so
if the user does something tricky like changing that opcode, you can
have the wrong group for the command that actually gets dispatched.



More information about the Linux-nvme mailing list