From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com> To: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>, "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>, Sagi Grimberg <sagi@grimberg.me> Cc: Hannes Reinecke <hare@suse.com>, "Martin K . Petersen" <martin.petersen@oracle.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Jens Axboe <axboe@fb.com>, Logan Gunthorpe <logang@deltatee.com> Subject: Re: [PATCH] nvme: Restore device naming sanity Date: Sat, 7 Sep 2019 18:42:49 +0000 [thread overview] Message-ID: <BYAPR04MB5749E4FBF82F23C41A494A6286B50@BYAPR04MB5749.namprd04.prod.outlook.com> (raw) In-Reply-To: 20190904173159.22921-1-kbusch@kernel.org Apart from the some nits, this looks okay. Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> May be subject line should be 's/nvme/nvme-core/' ? On 09/04/2019 10:34 AM, Keith Busch wrote: > The namespace names must be unique for the lifetime of the subsystem. > This was accomplished by using their parent subsystems' instances which > was independent of the controllers connected to that subsystem. > > The consequence of that naming scheme meant that name prefixes given to > namespaces may match a controller from an unrelated subsystem. This has > understandbly invited confusion when examining device nodes. 's/understandbly/understandably/' > > Ensure the namespace's subsystem instance never clashes with a > controller instance of another subsystem by transferring the instance > ownership to parent subsystem from the first controller discovered in > that subsystem. > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com> > Signed-off-by: Keith Busch <kbusch@kernel.org> > --- > drivers/nvme/host/core.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 14c0bfb55615..8a8279ece5ee 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -81,7 +81,6 @@ EXPORT_SYMBOL_GPL(nvme_reset_wq); > struct workqueue_struct *nvme_delete_wq; > EXPORT_SYMBOL_GPL(nvme_delete_wq); > > -static DEFINE_IDA(nvme_subsystems_ida); > static LIST_HEAD(nvme_subsystems); > static DEFINE_MUTEX(nvme_subsystems_lock); > > @@ -2344,7 +2343,8 @@ static void nvme_release_subsystem(struct device *dev) > struct nvme_subsystem *subsys = > container_of(dev, struct nvme_subsystem, dev); > > - ida_simple_remove(&nvme_subsystems_ida, subsys->instance); > + if (subsys->instance >= 0) > + ida_simple_remove(&nvme_instance_ida, subsys->instance); > kfree(subsys); > } > > @@ -2473,12 +2473,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > subsys = kzalloc(sizeof(*subsys), GFP_KERNEL); > if (!subsys) > return -ENOMEM; > - ret = ida_simple_get(&nvme_subsystems_ida, 0, 0, GFP_KERNEL); > - if (ret < 0) { > - kfree(subsys); > - return ret; > - } > - subsys->instance = ret; > + > + subsys->instance = -1; > mutex_init(&subsys->lock); > kref_init(&subsys->ref); > INIT_LIST_HEAD(&subsys->ctrls); > @@ -2497,7 +2493,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > subsys->dev.class = nvme_subsys_class; > subsys->dev.release = nvme_release_subsystem; > subsys->dev.groups = nvme_subsys_attrs_groups; > - dev_set_name(&subsys->dev, "nvme-subsys%d", subsys->instance); > + dev_set_name(&subsys->dev, "nvme-subsys%d", ctrl->instance); > device_initialize(&subsys->dev); > > mutex_lock(&nvme_subsystems_lock); > @@ -2528,6 +2524,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > goto out_put_subsystem; > } > > + if (!found) > + subsys->instance = ctrl->instance; > ctrl->subsys = subsys; > list_add_tail(&ctrl->subsys_entry, &subsys->ctrls); > mutex_unlock(&nvme_subsystems_lock); > @@ -3803,7 +3801,9 @@ static void nvme_free_ctrl(struct device *dev) > container_of(dev, struct nvme_ctrl, ctrl_device); > struct nvme_subsystem *subsys = ctrl->subsys; > > - ida_simple_remove(&nvme_instance_ida, ctrl->instance); > + if (subsys && ctrl->instance != subsys->instance) > + ida_simple_remove(&nvme_instance_ida, ctrl->instance); > + > kfree(ctrl->effects); > nvme_mpath_uninit(ctrl); > __free_page(ctrl->discard_page); > @@ -4085,7 +4085,6 @@ static int __init nvme_core_init(void) > > static void __exit nvme_core_exit(void) > { > - ida_destroy(&nvme_subsystems_ida); > class_destroy(nvme_subsys_class); > class_destroy(nvme_class); > unregister_chrdev_region(nvme_chr_devt, NVME_MINORS); >
WARNING: multiple messages have this Message-ID (diff)
From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com> To: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>, "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>, Sagi Grimberg <sagi@grimberg.me> Cc: Jens Axboe <axboe@fb.com>, Hannes Reinecke <hare@suse.com>, Logan Gunthorpe <logang@deltatee.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "Martin K . Petersen" <martin.petersen@oracle.com> Subject: Re: [PATCH] nvme: Restore device naming sanity Date: Sat, 7 Sep 2019 18:42:49 +0000 [thread overview] Message-ID: <BYAPR04MB5749E4FBF82F23C41A494A6286B50@BYAPR04MB5749.namprd04.prod.outlook.com> (raw) In-Reply-To: 20190904173159.22921-1-kbusch@kernel.org Apart from the some nits, this looks okay. Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> May be subject line should be 's/nvme/nvme-core/' ? On 09/04/2019 10:34 AM, Keith Busch wrote: > The namespace names must be unique for the lifetime of the subsystem. > This was accomplished by using their parent subsystems' instances which > was independent of the controllers connected to that subsystem. > > The consequence of that naming scheme meant that name prefixes given to > namespaces may match a controller from an unrelated subsystem. This has > understandbly invited confusion when examining device nodes. 's/understandbly/understandably/' > > Ensure the namespace's subsystem instance never clashes with a > controller instance of another subsystem by transferring the instance > ownership to parent subsystem from the first controller discovered in > that subsystem. > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com> > Signed-off-by: Keith Busch <kbusch@kernel.org> > --- > drivers/nvme/host/core.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 14c0bfb55615..8a8279ece5ee 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -81,7 +81,6 @@ EXPORT_SYMBOL_GPL(nvme_reset_wq); > struct workqueue_struct *nvme_delete_wq; > EXPORT_SYMBOL_GPL(nvme_delete_wq); > > -static DEFINE_IDA(nvme_subsystems_ida); > static LIST_HEAD(nvme_subsystems); > static DEFINE_MUTEX(nvme_subsystems_lock); > > @@ -2344,7 +2343,8 @@ static void nvme_release_subsystem(struct device *dev) > struct nvme_subsystem *subsys = > container_of(dev, struct nvme_subsystem, dev); > > - ida_simple_remove(&nvme_subsystems_ida, subsys->instance); > + if (subsys->instance >= 0) > + ida_simple_remove(&nvme_instance_ida, subsys->instance); > kfree(subsys); > } > > @@ -2473,12 +2473,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > subsys = kzalloc(sizeof(*subsys), GFP_KERNEL); > if (!subsys) > return -ENOMEM; > - ret = ida_simple_get(&nvme_subsystems_ida, 0, 0, GFP_KERNEL); > - if (ret < 0) { > - kfree(subsys); > - return ret; > - } > - subsys->instance = ret; > + > + subsys->instance = -1; > mutex_init(&subsys->lock); > kref_init(&subsys->ref); > INIT_LIST_HEAD(&subsys->ctrls); > @@ -2497,7 +2493,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > subsys->dev.class = nvme_subsys_class; > subsys->dev.release = nvme_release_subsystem; > subsys->dev.groups = nvme_subsys_attrs_groups; > - dev_set_name(&subsys->dev, "nvme-subsys%d", subsys->instance); > + dev_set_name(&subsys->dev, "nvme-subsys%d", ctrl->instance); > device_initialize(&subsys->dev); > > mutex_lock(&nvme_subsystems_lock); > @@ -2528,6 +2524,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) > goto out_put_subsystem; > } > > + if (!found) > + subsys->instance = ctrl->instance; > ctrl->subsys = subsys; > list_add_tail(&ctrl->subsys_entry, &subsys->ctrls); > mutex_unlock(&nvme_subsystems_lock); > @@ -3803,7 +3801,9 @@ static void nvme_free_ctrl(struct device *dev) > container_of(dev, struct nvme_ctrl, ctrl_device); > struct nvme_subsystem *subsys = ctrl->subsys; > > - ida_simple_remove(&nvme_instance_ida, ctrl->instance); > + if (subsys && ctrl->instance != subsys->instance) > + ida_simple_remove(&nvme_instance_ida, ctrl->instance); > + > kfree(ctrl->effects); > nvme_mpath_uninit(ctrl); > __free_page(ctrl->discard_page); > @@ -4085,7 +4085,6 @@ static int __init nvme_core_init(void) > > static void __exit nvme_core_exit(void) > { > - ida_destroy(&nvme_subsystems_ida); > class_destroy(nvme_subsys_class); > class_destroy(nvme_class); > unregister_chrdev_region(nvme_chr_devt, NVME_MINORS); > _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2019-09-07 18:42 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-04 17:31 [PATCH] nvme: Restore device naming sanity Keith Busch 2019-09-04 17:31 ` Keith Busch 2019-09-05 16:11 ` Christoph Hellwig 2019-09-05 16:11 ` Christoph Hellwig 2019-09-07 18:42 ` Chaitanya Kulkarni [this message] 2019-09-07 18:42 ` Chaitanya Kulkarni
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=BYAPR04MB5749E4FBF82F23C41A494A6286B50@BYAPR04MB5749.namprd04.prod.outlook.com \ --to=chaitanya.kulkarni@wdc.com \ --cc=axboe@fb.com \ --cc=hare@suse.com \ --cc=hch@lst.de \ --cc=kbusch@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=logang@deltatee.com \ --cc=martin.petersen@oracle.com \ --cc=sagi@grimberg.me \ /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.