Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme: use blk_mq_alloc_disk

Switch to use the blk_mq_alloc_disk helper for allocating the
request_queue and gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Link: https://lore.kernel.org/r/20210816131910.615153-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
5f432cce 759e0fd4

+13 -20
+13 -20
drivers/nvme/host/core.c
··· 3728 3728 if (!ns) 3729 3729 goto out_free_id; 3730 3730 3731 - ns->queue = blk_mq_init_queue(ctrl->tagset); 3732 - if (IS_ERR(ns->queue)) 3731 + disk = blk_mq_alloc_disk(ctrl->tagset, ns); 3732 + if (IS_ERR(disk)) 3733 3733 goto out_free_ns; 3734 + disk->fops = &nvme_bdev_ops; 3735 + disk->private_data = ns; 3736 + 3737 + ns->disk = disk; 3738 + ns->queue = disk->queue; 3734 3739 3735 3740 if (ctrl->opts && ctrl->opts->data_digest) 3736 3741 blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue); ··· 3744 3739 if (ctrl->ops->flags & NVME_F_PCI_P2PDMA) 3745 3740 blk_queue_flag_set(QUEUE_FLAG_PCI_P2PDMA, ns->queue); 3746 3741 3747 - ns->queue->queuedata = ns; 3748 3742 ns->ctrl = ctrl; 3749 3743 kref_init(&ns->kref); 3750 3744 3751 3745 if (nvme_init_ns_head(ns, nsid, ids, id->nmic & NVME_NS_NMIC_SHARED)) 3752 - goto out_free_queue; 3746 + goto out_cleanup_disk; 3753 3747 3754 - disk = alloc_disk_node(0, node); 3755 - if (!disk) 3756 - goto out_unlink_ns; 3757 - 3758 - disk->fops = &nvme_bdev_ops; 3759 - disk->private_data = ns; 3760 - disk->queue = ns->queue; 3761 3748 /* 3762 3749 * Without the multipath code enabled, multiple controller per 3763 3750 * subsystems are visible as devices and thus we cannot use the ··· 3758 3761 if (!nvme_mpath_set_disk_name(ns, disk->disk_name, &disk->flags)) 3759 3762 sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, 3760 3763 ns->head->instance); 3761 - ns->disk = disk; 3762 3764 3763 3765 if (nvme_update_ns_info(ns, id)) 3764 - goto out_put_disk; 3766 + goto out_unlink_ns; 3765 3767 3766 3768 if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) { 3767 3769 if (nvme_nvm_register(ns, disk->disk_name, node)) { 3768 3770 dev_warn(ctrl->device, "LightNVM init failure\n"); 3769 - goto out_put_disk; 3771 + goto out_unlink_ns; 3770 3772 } 3771 3773 } 3772 3774 ··· 3784 3788 kfree(id); 3785 3789 3786 3790 return; 3787 - out_put_disk: 3788 - /* prevent double queue cleanup */ 3789 - ns->disk->queue = NULL; 3790 - put_disk(ns->disk); 3791 + 3791 3792 out_unlink_ns: 3792 3793 mutex_lock(&ctrl->subsys->lock); 3793 3794 list_del_rcu(&ns->siblings); ··· 3792 3799 list_del_init(&ns->head->entry); 3793 3800 mutex_unlock(&ctrl->subsys->lock); 3794 3801 nvme_put_ns_head(ns->head); 3795 - out_free_queue: 3796 - blk_cleanup_queue(ns->queue); 3802 + out_cleanup_disk: 3803 + blk_cleanup_disk(disk); 3797 3804 out_free_ns: 3798 3805 kfree(ns); 3799 3806 out_free_id: