From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
To: Keith Busch <kbusch@kernel.org>
Cc: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
Christoph Hellwig <hch@lst.de>,
Matthew Wilcox <willy@infradead.org>,
"sagi@grimberg.me" <sagi@grimberg.me>
Subject: Re: [PATCH V2 1/2] nvme-core: use xarray for ctrl ns tracking
Date: Wed, 1 Jul 2020 18:40:08 +0000 [thread overview]
Message-ID: <BYAPR04MB49656E94C4AC8B600D03843B866C0@BYAPR04MB4965.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200701182926.GD1988944@dhcp-10-100-145-180.wdl.wdc.com
On 7/1/20 11:29 AM, Keith Busch wrote:
> On Wed, Jul 01, 2020 at 06:19:50PM +0000, Chaitanya Kulkarni wrote:
>> On 7/1/20 6:12 AM, Christoph Hellwig wrote:
>>> [willy: a comment/request on the xa_load API below]
>>> On Tue, Jun 30, 2020 at 07:25:16PM -0700, Chaitanya Kulkarni wrote:
>>>> + if (le32_to_cpu(id->nn) > 1) {
>>>> + dev_warn(ctrl->device,
>>>> + "NVME_IOCTL_IO_CMD not supported when multiple namespaces present!\n");
>>>> + goto out;
>>>> }
>>> This code doesn't make any sense at all. Why does a patch changing
>>> data structures add new calls that go out on the wire?
>>>
>> Yes, this should not be here, I'll remove that and only keep the code to
>> check multiple namespaces and if needed this needs to be a separate
>> patch.
> This isn't actually checking for multiple namespaces, though. It's just
> getting the highest nsid, which doesn't tell us how many namespaces the
> driver is bound to.
>
hmmm, I'll try and fix it in a next version.
>>>> - down_write(&ns->ctrl->namespaces_rwsem);
>>>> - list_del_init(&ns->list);
>>>> - up_write(&ns->ctrl->namespaces_rwsem);
>>>> + xa_lock(xa);
>>>> + __xa_erase(xa, ns->head->ns_id);
>>>> + free = refcount_dec_and_test(&ns->kref.refcount) ? true : false;
>>>> + xa_unlock(xa);
>>>>
>>>> nvme_mpath_check_last_path(ns);
>>>> - nvme_put_ns(ns);
>>>> + if (free)
>>>> + __nvme_free_ns(ns);
>>> This looks very strange to me. Shoudn't this be a normal xa_erase
>>> followed by a normal nvme_put_ns? For certain the driver code has
>>> no business poking into the kref internals.
>>>
>> There is a race when kref is manipulated in nvme_find_get_ns() and
>> nvme _ns_remove() pointed by Keith which needs ns->kref to be guarded
>> with locks. Let me know I'll share a detail scenario.
> That wasn't the race I was pointing out. In your earlier internal
> implementation, you had the xa_erase done after the final put, and I was
> warning against that. The erase needs to happen where you have it, but I
> don't see a need for protecting the kref like this.
>
Okay I've misunderstood it and follow the same pattern here due to my
previous implementation. Maybe we can get rid of it, let me see.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-07-01 18:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 2:25 [PATCH V2 0/2] nvme: replace linked list with xarray for ns tracking Chaitanya Kulkarni
2020-07-01 2:25 ` [PATCH V2 1/2] nvme-core: use xarray for ctrl " Chaitanya Kulkarni
2020-07-01 13:12 ` Christoph Hellwig
2020-07-01 16:44 ` Keith Busch
2020-07-01 18:19 ` Chaitanya Kulkarni
2020-07-01 18:29 ` Keith Busch
2020-07-01 18:40 ` Chaitanya Kulkarni [this message]
2020-07-01 2:25 ` [PATCH V2 2/2] nvmet: use xarray for ctrl ns storing Chaitanya Kulkarni
2020-07-01 6:08 ` Christoph Hellwig
2020-07-01 18:36 ` Chaitanya Kulkarni
2020-07-01 5:36 ` [PATCH V2 0/2] nvme: replace linked list with xarray for ns tracking Christoph Hellwig
2020-07-01 13:21 ` Keith Busch
2020-07-01 16:49 ` Sagi Grimberg
2020-07-01 18:43 ` Chaitanya Kulkarni
2020-07-01 18:41 ` Chaitanya Kulkarni
2020-07-01 18:41 ` 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=BYAPR04MB49656E94C4AC8B600D03843B866C0@BYAPR04MB4965.namprd04.prod.outlook.com \
--to=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=willy@infradead.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).