[PATCHv2] nvme: use srcu for iterating namespace list

Christoph Hellwig hch at lst.de
Fri May 24 00:42:19 PDT 2024


> -	ns = list_first_entry(&ctrl->namespaces, struct nvme_ns, list);
> -	if (ns != list_last_entry(&ctrl->namespaces, struct nvme_ns, list)) {
> +	ns = list_first_or_null_rcu(&ctrl->namespaces, struct nvme_ns, list);
> +	if (!ns) {
>  		dev_warn(ctrl->device,
>  			"NVME_IOCTL_IO_CMD not supported when multiple namespaces present!\n");
>  		ret = -EINVAL;
> @@ -808,14 +808,14 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,
>  	dev_warn(ctrl->device,
>  		"using deprecated NVME_IOCTL_IO_CMD ioctl on the char device!\n");
>  	kref_get(&ns->kref);

This still needs to use a kref_geT_unless_zero as mentioned in the last
round.




More information about the Linux-nvme mailing list