From: kbusch@kernel.org (Keith Busch)
Subject: [PATCH rfc 1/2] nvme: don't remove namespace if revalidate failed because of controller reset
Date: Tue, 30 Jul 2019 11:30:48 -0600 [thread overview]
Message-ID: <20190730173048.GC13948@localhost.localdomain> (raw)
In-Reply-To: <2825eb74-1df5-5dd2-3e90-c696bc7fa3d1@grimberg.me>
On Tue, Jul 30, 2019@10:12:42AM -0700, Sagi Grimberg wrote:
>
> > > Yes, and again, addresses the case that the namespace is going away.
> > >
> > > So I think we are in agreement? I only need to change the commit
> > > message from: "the revalidation I/O" to "the admin I/O" ?
> >
> > That words of 'admin I/O' isn't related with the patch or issue.
>
> But it is, the original issue was due to the fact that
> nvme_revalidate_disk() I/Os such as nvme_identify_ns() or
> nvme_identify_ns_descs(). This was the original issue.
>
> > > Yea, this should do the trick I guess:
> > > --
> > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> > > index fa31da0762b9..d01976c93160 100644
> > > --- a/drivers/nvme/host/core.c
> > > +++ b/drivers/nvme/host/core.c
> > > @@ -3428,7 +3428,8 @@ static void nvme_validate_ns(struct nvme_ctrl
> > > *ctrl, unsigned nsid)
> > >
> > > ns = nvme_find_get_ns(ctrl, nsid);
> > > if (ns) {
> > > - if (ns->disk && revalidate_disk(ns->disk))
> > > + if (ns->disk && ctrl->state == NVME_CTRL_LIVE &&
> > > + revalidate_disk(ns->disk)
> > > nvme_ns_remove(ns);
> > > nvme_put_ns(ns);
> > > } else
> >
> > If RESET is triggered just inside revalidate_disk(), and not done after
> > revalidate_disk() returns, there is still race between reset and scan work.
> >
>
> You are correct, this was why I had the ctrl->state check after
> revalidate_disk so if it failed because we are in a reset we should
> not remove the namespace.
>
> We need a reliable way to NOT remove the namespace if revalidate_disk
> failed because the controller is resetting and we don't have a channel
> to the controller at this very moment...
>
> Keith,
>
> As for the failure during reset scenario, this is happening only when
> the namespace is about to go away or something is seriously wrong right
> (looking from where nvme_kill_queues is called).
>
> Do you still think we should avoid calling the revalidate_disk if the
> controller is resetting?
I was considering if a reset happens to trigger when nvme's
revalidate_disk tries to read identify namespace. It's possible that
command gets aborted, and we don't retry admin commands, so we'd return
-ENODEV and nvme_validate_ns() removes an otherwise healthy namespace.
I'm not too concerned about this corner case actually occuring in
practice, though.
next prev parent reply other threads:[~2019-07-30 17:30 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 23:31 [PATCH rfc 0/2] nvme controller reset and namespace scan work race conditions Sagi Grimberg
2019-07-29 23:32 ` [PATCH rfc 1/2] nvme: don't remove namespace if revalidate failed because of controller reset Sagi Grimberg
2019-07-30 0:59 ` Keith Busch
2019-07-30 1:04 ` Sagi Grimberg
2019-07-30 1:04 ` Ming Lei
2019-07-30 1:06 ` Sagi Grimberg
2019-07-30 1:10 ` Ming Lei
2019-07-30 1:19 ` Sagi Grimberg
2019-07-30 1:30 ` Ming Lei
2019-07-30 1:40 ` Sagi Grimberg
2019-07-30 2:09 ` Ming Lei
2019-07-30 17:12 ` Sagi Grimberg
2019-07-30 17:30 ` Keith Busch [this message]
2019-07-30 18:15 ` Sagi Grimberg
2019-07-31 7:13 ` Hannes Reinecke
2019-07-31 18:08 ` Sagi Grimberg
2019-07-31 7:01 ` Hannes Reinecke
2019-07-31 14:16 ` Keith Busch
2019-07-31 18:03 ` Sagi Grimberg
2019-07-31 19:32 ` Keith Busch
2019-07-31 20:08 ` Sagi Grimberg
2019-07-31 20:16 ` Keith Busch
2019-07-31 20:45 ` Sagi Grimberg
2019-07-31 20:58 ` Keith Busch
2019-07-31 21:14 ` Sagi Grimberg
2019-07-31 21:54 ` Keith Busch
2019-08-01 1:13 ` Sagi Grimberg
2019-08-01 14:33 ` Keith Busch
2019-08-01 18:52 ` Sagi Grimberg
2019-07-31 6:58 ` Hannes Reinecke
2019-07-31 18:11 ` Sagi Grimberg
2019-07-31 20:02 ` Hannes Reinecke
2019-07-31 20:16 ` Sagi Grimberg
2019-07-31 12:18 ` Hannes Reinecke
2019-07-31 18:16 ` Sagi Grimberg
2019-07-31 20:04 ` Hannes Reinecke
2019-07-31 20:37 ` Sagi Grimberg
2019-07-29 23:32 ` [PATCH rfc 2/2] nvme: fix possible use-after-free condition when controller reset is racing namespace scanning Sagi Grimberg
2019-07-31 12:23 ` Hannes Reinecke
2019-07-31 18:21 ` Sagi Grimberg
2019-08-01 7:24 ` Hannes Reinecke
2019-08-01 18:46 ` Sagi Grimberg
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=20190730173048.GC13948@localhost.localdomain \
--to=kbusch@kernel.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