From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: "Stefan Haberland" <sth@linux.ibm.com>, "Jan Hoeppner" <hoeppner@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, "Doug Gilbert" <dgilbert@interlog.com>, "Kai Mäkisara" <Kai.Makisara@kolumbus.fi>, "Luis Chamberlain" <mcgrof@kernel.org>, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 1/9] nvme: use blk_mq_alloc_disk Date: Mon, 16 Aug 2021 15:19:02 +0200 [thread overview] Message-ID: <20210816131910.615153-2-hch@lst.de> (raw) In-Reply-To: <20210816131910.615153-1-hch@lst.de> Switch to use the blk_mq_alloc_disk helper for allocating the request_queue and gendisk. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/core.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1478d825011d..a5878ba14c55 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -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); if (nvme_init_ns_head(ns, nsid, ids, id->nmic & NVME_NS_NMIC_SHARED)) - goto out_free_queue; + goto out_cleanup_disk; - disk = alloc_disk_node(0, node); - if (!disk) - goto out_unlink_ns; - - disk->fops = &nvme_bdev_ops; - disk->private_data = ns; - disk->queue = ns->queue; /* * Without the multipath code enabled, multiple controller per * subsystems are visible as devices and thus we cannot use the @@ -3762,15 +3759,14 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, if (!nvme_mpath_set_disk_name(ns, disk->disk_name, &disk->flags)) sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance); - ns->disk = disk; if (nvme_update_ns_info(ns, id)) - goto out_put_disk; + goto out_unlink_ns; if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) { if (nvme_nvm_register(ns, disk->disk_name, node)) { dev_warn(ctrl->device, "LightNVM init failure\n"); - goto out_put_disk; + goto out_unlink_ns; } } @@ -3789,10 +3785,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, kfree(id); return; - out_put_disk: - /* prevent double queue cleanup */ - ns->disk->queue = NULL; - put_disk(ns->disk); + out_unlink_ns: mutex_lock(&ctrl->subsys->lock); list_del_rcu(&ns->siblings); @@ -3800,8 +3793,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, list_del_init(&ns->head->entry); mutex_unlock(&ctrl->subsys->lock); nvme_put_ns_head(ns->head); - out_free_queue: - blk_cleanup_queue(ns->queue); + out_cleanup_disk: + blk_cleanup_disk(disk); out_free_ns: kfree(ns); out_free_id: -- 2.30.2 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: "Stefan Haberland" <sth@linux.ibm.com>, "Jan Hoeppner" <hoeppner@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, "Doug Gilbert" <dgilbert@interlog.com>, "Kai Mäkisara" <Kai.Makisara@kolumbus.fi>, "Luis Chamberlain" <mcgrof@kernel.org>, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 1/9] nvme: use blk_mq_alloc_disk Date: Mon, 16 Aug 2021 15:19:02 +0200 [thread overview] Message-ID: <20210816131910.615153-2-hch@lst.de> (raw) In-Reply-To: <20210816131910.615153-1-hch@lst.de> Switch to use the blk_mq_alloc_disk helper for allocating the request_queue and gendisk. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/core.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1478d825011d..a5878ba14c55 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -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); if (nvme_init_ns_head(ns, nsid, ids, id->nmic & NVME_NS_NMIC_SHARED)) - goto out_free_queue; + goto out_cleanup_disk; - disk = alloc_disk_node(0, node); - if (!disk) - goto out_unlink_ns; - - disk->fops = &nvme_bdev_ops; - disk->private_data = ns; - disk->queue = ns->queue; /* * Without the multipath code enabled, multiple controller per * subsystems are visible as devices and thus we cannot use the @@ -3762,15 +3759,14 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, if (!nvme_mpath_set_disk_name(ns, disk->disk_name, &disk->flags)) sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance); - ns->disk = disk; if (nvme_update_ns_info(ns, id)) - goto out_put_disk; + goto out_unlink_ns; if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) { if (nvme_nvm_register(ns, disk->disk_name, node)) { dev_warn(ctrl->device, "LightNVM init failure\n"); - goto out_put_disk; + goto out_unlink_ns; } } @@ -3789,10 +3785,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, kfree(id); return; - out_put_disk: - /* prevent double queue cleanup */ - ns->disk->queue = NULL; - put_disk(ns->disk); + out_unlink_ns: mutex_lock(&ctrl->subsys->lock); list_del_rcu(&ns->siblings); @@ -3800,8 +3793,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, list_del_init(&ns->head->entry); mutex_unlock(&ctrl->subsys->lock); nvme_put_ns_head(ns->head); - out_free_queue: - blk_cleanup_queue(ns->queue); + out_cleanup_disk: + blk_cleanup_disk(disk); out_free_ns: kfree(ns); out_free_id: -- 2.30.2
next prev parent reply other threads:[~2021-08-16 13:21 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-16 13:19 ensure each gendisk always has a request_queue reference v2 Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig [this message] 2021-08-16 13:19 ` [PATCH 1/9] nvme: use blk_mq_alloc_disk Christoph Hellwig 2021-08-19 14:54 ` Keith Busch 2021-08-19 14:54 ` Keith Busch 2021-08-19 14:58 ` Keith Busch 2021-08-19 14:58 ` Keith Busch 2021-08-19 22:57 ` Luis Chamberlain 2021-08-19 22:57 ` Luis Chamberlain 2021-08-20 4:06 ` Christoph Hellwig 2021-08-20 4:06 ` Christoph Hellwig 2021-08-23 17:22 ` Sagi Grimberg 2021-08-23 17:22 ` Sagi Grimberg 2021-08-16 13:19 ` [PATCH 2/9] st: do not allocate a gendisk Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 3/9] sg: " Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-19 21:33 ` Luis Chamberlain 2021-08-19 21:33 ` Luis Chamberlain 2021-08-19 21:36 ` Luis Chamberlain 2021-08-19 21:36 ` Luis Chamberlain 2021-08-20 4:05 ` Christoph Hellwig 2021-08-20 4:05 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 4/9] block: cleanup the lockdep handling in *alloc_disk Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 5/9] block: remove alloc_disk and alloc_disk_node Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 6/9] block: remove the minors argument to __alloc_disk_node Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 7/9] block: pass a request_queue to __blk_alloc_disk Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-16 13:19 ` [PATCH 8/9] block: hold a request_queue reference for the lifetime of struct gendisk Christoph Hellwig 2021-08-16 13:19 ` Christoph Hellwig 2021-08-20 13:42 ` Ming Lei 2021-08-20 13:42 ` Ming Lei 2021-08-16 13:46 ` [PATCH 9/9] block: add an explicit ->disk backpointer to the request_queue Christoph Hellwig 2021-08-16 13:46 ` Christoph Hellwig 2021-08-19 14:39 ` Sven Schnelle 2021-08-19 14:39 ` Sven Schnelle 2021-08-23 18:55 ` ensure each gendisk always has a request_queue reference v2 Jens Axboe 2021-08-23 18:55 ` Jens Axboe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210816131910.615153-2-hch@lst.de \ --to=hch@lst.de \ --cc=Kai.Makisara@kolumbus.fi \ --cc=axboe@kernel.dk \ --cc=dgilbert@interlog.com \ --cc=hoeppner@linux.ibm.com \ --cc=linux-block@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=linux-s390@vger.kernel.org \ --cc=linux-scsi@vger.kernel.org \ --cc=martin.petersen@oracle.com \ --cc=mcgrof@kernel.org \ --cc=sth@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.