From: Hannes Reinecke <hare@suse.de>
To: Ming Lei <ming.lei@redhat.com>, Christoph Hellwig <hch@lst.de>,
linux-nvme@lists.infradead.org
Cc: Yi Zhang <yi.zhang@redhat.com>, Sagi Grimberg <sagi@grimberg.me>,
Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH 1/2] nvme: make NVMe freeze API reliably
Date: Wed, 24 Aug 2022 13:15:28 +0200 [thread overview]
Message-ID: <a2f9fd7c-7562-a79c-0ee2-76dcb7dd387b@suse.de> (raw)
In-Reply-To: <20220821084754.340585-2-ming.lei@redhat.com>
On 8/21/22 10:47, Ming Lei wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> In some corner cases[1], freeze wait and unfreeze API may be called on
> unfrozen queue, add one per-ns flag of NVME_NS_FREEZE to make these
> freeze APIs more reliably, then this kind of issues can be avoided.
> And similar approach has been applied on stopping/quiescing nvme queues.
>
> [1] https://lore.kernel.org/linux-nvme/20220801125753.1434024-1-ming.lei@redhat.com/
>
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Link: https://lore.kernel.org/linux-block/CAHj4cs--KPTAGP=jj+7KMe=arDv=HeGeOgs1T8vbusyk=EjXow@mail.gmail.com/#r
>
> Add comment log.
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> drivers/nvme/host/core.c | 16 +++++++++++++---
> drivers/nvme/host/nvme.h | 1 +
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index af367b22871b..fe4ae3616ed1 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -5028,8 +5028,11 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl)
> struct nvme_ns *ns;
>
> down_read(&ctrl->namespaces_rwsem);
> - list_for_each_entry(ns, &ctrl->namespaces, list)
> + list_for_each_entry(ns, &ctrl->namespaces, list) {
> + if (!test_and_clear_bit(NVME_NS_FREEZE, &ns->flags))
> + continue;
> blk_mq_unfreeze_queue(ns->queue);
> + }
> up_read(&ctrl->namespaces_rwsem);
> }
> EXPORT_SYMBOL_GPL(nvme_unfreeze);
> @@ -5040,6 +5043,8 @@ int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
>
> down_read(&ctrl->namespaces_rwsem);
> list_for_each_entry(ns, &ctrl->namespaces, list) {
> + if (!test_bit(NVME_NS_FREEZE, &ns->flags))
> + continue;
> timeout = blk_mq_freeze_queue_wait_timeout(ns->queue, timeout);
> if (timeout <= 0)
> break;
> @@ -5054,8 +5059,11 @@ void nvme_wait_freeze(struct nvme_ctrl *ctrl)
> struct nvme_ns *ns;
>
> down_read(&ctrl->namespaces_rwsem);
> - list_for_each_entry(ns, &ctrl->namespaces, list)
> + list_for_each_entry(ns, &ctrl->namespaces, list) {
> + if (!test_bit(NVME_NS_FREEZE, &ns->flags))
> + continue;
> blk_mq_freeze_queue_wait(ns->queue);
> + }
> up_read(&ctrl->namespaces_rwsem);
> }
> EXPORT_SYMBOL_GPL(nvme_wait_freeze);
> @@ -5065,8 +5073,10 @@ void nvme_start_freeze(struct nvme_ctrl *ctrl)
> struct nvme_ns *ns;
>
> down_read(&ctrl->namespaces_rwsem);
> - list_for_each_entry(ns, &ctrl->namespaces, list)
> + list_for_each_entry(ns, &ctrl->namespaces, list) { > + set_bit(NVME_NS_FREEZE, &ns->flags);
Why not test_and_set_bit()?
Which would have the nice effect of adding a memory barrier ...
> blk_freeze_queue_start(ns->queue);
> + }
> up_read(&ctrl->namespaces_rwsem);
> }
> EXPORT_SYMBOL_GPL(nvme_start_freeze);
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
next prev parent reply other threads:[~2022-08-24 11:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-21 8:47 [PATCH 0/2] nvme: make NVMe freeze API reliably Ming Lei
2022-08-21 8:47 ` [PATCH 1/2] " Ming Lei
2022-08-24 11:15 ` Hannes Reinecke [this message]
2022-08-24 14:07 ` Keith Busch
2022-08-25 10:02 ` Chao Leng
2022-09-06 4:49 ` Christoph Hellwig
2022-09-06 8:45 ` Ming Lei
2022-09-06 9:32 ` Chao Leng
2022-09-07 0:33 ` Ming Lei
2022-09-07 1:18 ` Chao Leng
2022-09-07 2:06 ` Ming Lei
2022-09-07 5:58 ` Chao Leng
2022-08-28 14:37 ` Sagi Grimberg
2022-08-21 8:47 ` [PATCH 2/2] nvme-pci: don't wait freeze during resetting Ming Lei
2022-08-25 10:05 ` Chao Leng
2022-08-25 11:34 ` Ming Lei
2022-08-25 13:42 ` Keith Busch
2022-08-25 14:15 ` Ming Lei
2022-08-26 1:27 ` Chao Leng
2022-08-28 14:37 ` Sagi Grimberg
2022-09-06 4:49 ` Christoph Hellwig
2022-08-24 11:57 ` [PATCH 0/2] nvme: make NVMe freeze API reliably Yi Zhang
2022-09-19 14:52 ` Christoph Hellwig
2022-09-20 0:51 ` 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=a2f9fd7c-7562-a79c-0ee2-76dcb7dd387b@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@redhat.com \
--cc=sagi@grimberg.me \
--cc=yi.zhang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox