linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Nadolski, Edmund" <edmund.nadolski@intel.com>
To: Keith Busch <kbusch@kernel.org>,
	"Nadolski, Edmund" <edmund.nadolski@intel.com>
Cc: Christoph Hellwig <hch@lst.de>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme: clear stale nvmeq->tags after tagset free
Date: Tue, 21 Jan 2020 12:26:56 -0700	[thread overview]
Message-ID: <4a1335e0-1192-ac1e-cb4b-9da9f926e68d@intel.com> (raw)
In-Reply-To: <20200121191234.GB4954@redsun51.ssa.fujisawa.hgst.com>

On 1/21/2020 12:12 PM, Keith Busch wrote:
> On Tue, Jan 21, 2020 at 11:49:53AM -0700, Nadolski, Edmund wrote:
>> On 1/21/2020 10:42 AM, Keith Busch wrote:
>> > On Tue, Jan 21, 2020 at 10:32:22AM -0700, Nadolski, Edmund wrote:
>> > > The tagset pointer gets invalidated when the driver calls the following:
>> > > 
>> > > nvme_reset_work()
>> > >    +-> nvme_setup_io_queues()  <<< cmd fails, no io queues created
>> > >    +-> nvme_kill_queues()
>> > >    +-> nvme_remove_namespaces()
>> > >    |   +-> nvme_ns_remove()  <<< for each ctrl->namespaces
>> > >    |       +-> del_gendisk()
>> > >    |       +-> blk_cleanup_queue()
>> > >    |       |   +-> blk_mq_exit_queue()  <<< invalidates the tags
>> > >    |       |       +-> blk_mq_del_queue_tag_set()
>> > >    |       |       +-> blk_mq_exit_hw_queues()
>> > >    |       |           +-> blk_mq_exit_hctx()
>> > >    |       |               +-> set->ops->exit_hctx(...) <<< driver callback
>> > >    |       +-> nvme_put_ns()
>> > >    +-> nvme_free_tagset()
>> > >    |   +-> blk_mq_free_tagset()
>> > >    +-> nvme_start_ctrl()  <<< allow operation w/o namespaces
>> > > 
>> > > So the nvmeq->tags is already dead and stale by the time we get to
>> > > nvme_free_tagset.
>> > 
>> > No, nvmeq->tags is not stale until we call nvme_free_tagset().
>> 
>> I see this in blk/blk-mq.c:
>> 
>> 2943 /* tags can _not_ be used after returning from blk_mq_exit_queue */
>> 2944 void blk_mq_exit_queue(struct request_queue *q)
> 
> You can't access it through q->tag_set after that. The tagset still
> exists beyond any individual request_queue using it until you call
> blk_mq_free_tag_set().

Ah ok, well that's subtle ;)  (I guess it works as long as blk-mq guarantees 
the tagset lifetime.)

I'll rework the patch to clear the pointers from nvme_free_tagset, as you 
mentioned previously.


>> which ends up being called on every individual ctrl->namespaces entry.  What
>> have I overlooked?
> 
> There are various paths that can have driver can remove a subset of
> namespaces rather than all of them. Is that what you're overlooking?

Yes, I should have looked into all the callers of nvme_ns_remove.

Thanks,
Ed


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

      reply	other threads:[~2020-01-21 19:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 18:17 [PATCH] nvme: clear stale nvmeq->tags after tagset free Edmund Nadolski
2020-01-16 16:06 ` Keith Busch
2020-01-16 22:06   ` Nadolski, Edmund
2020-01-16 23:26     ` Keith Busch
2020-01-21 17:32       ` Nadolski, Edmund
2020-01-21 17:42         ` Keith Busch
2020-01-21 18:49           ` Nadolski, Edmund
2020-01-21 19:12             ` Keith Busch
2020-01-21 19:26               ` Nadolski, Edmund [this message]

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=4a1335e0-1192-ac1e-cb4b-9da9f926e68d@intel.com \
    --to=edmund.nadolski@intel.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.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).