From: ming.lei@redhat.com (Ming Lei)
Subject: [PATCH 1/2] nvme: Do not remove namespaces during reset
Date: Thu, 20 Jun 2019 09:22:01 +0800 [thread overview]
Message-ID: <20190620012200.GA31179@ming.t460p> (raw)
In-Reply-To: <20190618101025.78840-2-hare@suse.de>
Hi Hannes,
Could you explain a bit what the user visible issue is addressed by this
patch?
On Tue, Jun 18, 2019@12:10:24PM +0200, Hannes Reinecke wrote:
> When a controller is resetting or reconnecting there is no way
> how we could establish the validity of any given namespace.
> So do not call nvme_ns_remove() during resetting or reconnecting
> and rely on the call to nvme_scan_queue() after reset to fixup
> things.
>
> Signed-off-by: Hannes Reinecke <hare at suse.com>
> ---
> drivers/nvme/host/core.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index ba2079d217da..e872591e5fe7 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3358,6 +3358,17 @@ static int nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
>
> static void nvme_ns_remove(struct nvme_ns *ns)
> {
> + /*
> + * We cannot make any assumptions about namespaces during
> + * reset; in particular we shouldn't attempt to remove them
> + * as I/O might still be queued to them.
> + * So ignore this call during reset and rely on the
> + * rescan after reset to clean up things again.
> + */
> + if (ns->ctrl->state == NVME_CTRL_RESETTING ||
> + ns->ctrl->state == NVME_CTRL_CONNECTING)
> + return;
> +
> if (test_and_set_bit(NVME_NS_REMOVING, &ns->flags))
> return;
nvme_ns_remove() may be called from nvme_remove_invalid_namespaces()
and nvme_remove_namespaces(), in which the 'ns' to be removed is
retrieved & deleted from ctrl->namespaces.
That means if the 'ns' needs to be removed by the two mentioned
functions from scan work context again after reset is done, the removal
may never be done because the 'ns' can't be found in ctrl->namespaces.
If you want to avoid the use-after-free issue[1], I'd suggest to use
the queue refcount.
https://lore.kernel.org/linux-block/20190424110221.17435-10-ming.lei at redhat.com/
Thanks,
Ming
next prev parent reply other threads:[~2019-06-20 1:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 10:10 [PATCH 0/2] nvme: flush rescan worker before resetting Hannes Reinecke
2019-06-18 10:10 ` [PATCH 1/2] nvme: Do not remove namespaces during reset Hannes Reinecke
2019-06-18 17:30 ` Sagi Grimberg
2019-06-20 1:22 ` Ming Lei [this message]
2019-06-18 10:10 ` [PATCH 2/2] nvme: flush scan_work when resetting controller Hannes Reinecke
2019-06-18 17:41 ` Sagi Grimberg
2019-06-19 6:22 ` Hannes Reinecke
2019-06-19 16:56 ` Sagi Grimberg
2019-06-19 18:45 ` Hannes Reinecke
2019-06-19 20:04 ` Sagi Grimberg
2019-06-21 16:26 ` Sagi Grimberg
2019-06-24 5:48 ` Hannes Reinecke
2019-06-24 6:13 ` Hannes Reinecke
2019-06-24 18:08 ` Sagi Grimberg
2019-06-24 18:51 ` James Smart
2019-06-25 6:07 ` Hannes Reinecke
2019-06-25 21:50 ` Sagi Grimberg
2019-06-26 5:34 ` Hannes Reinecke
2019-06-26 20:22 ` Sagi Grimberg
2019-07-02 5:38 ` Sagi Grimberg
2019-07-02 13:29 ` Hannes Reinecke
2019-06-20 1:36 ` Ming Lei
2019-06-21 6:14 ` Hannes Reinecke
2019-06-21 6:58 ` Ming Lei
2019-06-21 7:59 ` Hannes Reinecke
2019-06-21 17:23 ` James Smart
2019-06-21 17:23 ` James Smart
2019-06-24 3:29 ` Ming Lei
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=20190620012200.GA31179@ming.t460p \
--to=ming.lei@redhat.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: link
Be 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.