[PATCH 1/9] nvme: use blk_mq_alloc_disk

Keith Busch kbusch at kernel.org
Thu Aug 19 07:54:55 PDT 2021


On Mon, Aug 16, 2021 at 03:19:02PM +0200, Christoph Hellwig wrote:
> @@ -3729,9 +3729,14 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
>  	if (!ns)
>  		goto out_free_id;
>  
> -	ns->queue = blk_mq_init_queue(ctrl->tagset);
> -	if (IS_ERR(ns->queue))
> +	disk = blk_mq_alloc_disk(ctrl->tagset, ns);
> +	if (IS_ERR(disk))
>  		goto out_free_ns;
> +	disk->fops = &nvme_bdev_ops;
> +	disk->private_data = ns;
> +
> +	ns->disk = disk;
> +	ns->queue = disk->queue;
>  
>  	if (ctrl->opts && ctrl->opts->data_digest)
>  		blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
> @@ -3740,20 +3745,12 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
>  	if (ctrl->ops->flags & NVME_F_PCI_P2PDMA)
>  		blk_queue_flag_set(QUEUE_FLAG_PCI_P2PDMA, ns->queue);
>  
> -	ns->queue->queuedata = ns;
>  	ns->ctrl = ctrl;
>  	kref_init(&ns->kref);

With this removal, I don't find queuedata being set anywhere, but
the driver still uses it in various places expecting 'ns'. Am I missing
something? Should all nvme's queuedata references be changed to
q->disk->private_data?



More information about the Linux-nvme mailing list