All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	Keith Busch <kbusch@kernel.org>, Chao Leng <lengchao@huawei.com>
Cc: Ming Lei <ming.lei@redhat.com>,
	linux-nvme@lists.infradead.org, linux-block@vger.kernel.org
Subject: Re: [PATCH 6/8] nvme: move the NS_DEAD flag to the controller
Date: Thu, 20 Oct 2022 16:30:21 +0300	[thread overview]
Message-ID: <ac33021a-b7a1-37cf-b156-df021ac4de43@grimberg.me> (raw)
In-Reply-To: <20221020105608.1581940-7-hch@lst.de>



On 10/20/22 13:56, Christoph Hellwig wrote:
> The NVME_NS_DEAD flag is only set in nvme_set_queue_dying, which is
> called in a loop over all namespaces in nvme_kill_queues.  Switch it
> to a controller flag checked and set outside said loop.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/core.c | 16 +++++++---------
>   drivers/nvme/host/nvme.h |  2 +-
>   2 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a74212a4f1a5f..fa7fdb744979c 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4330,7 +4330,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_info *info)
>   {
>   	int ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
>   
> -	if (test_bit(NVME_NS_DEAD, &ns->flags))
> +	if (test_bit(NVME_CTRL_NS_DEAD, &ns->ctrl->flags))
>   		goto out;
>   
>   	ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
> @@ -4404,7 +4404,8 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
>   
>   	down_write(&ctrl->namespaces_rwsem);
>   	list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
> -		if (ns->head->ns_id > nsid || test_bit(NVME_NS_DEAD, &ns->flags))
> +		if (ns->head->ns_id > nsid ||
> +		    test_bit(NVME_CTRL_NS_DEAD, &ns->ctrl->flags))
>   			list_move_tail(&ns->list, &rm_list);
>   	}
>   	up_write(&ctrl->namespaces_rwsem);
> @@ -5110,9 +5111,6 @@ static void nvme_stop_ns_queue(struct nvme_ns *ns)
>    */
>   static void nvme_set_queue_dying(struct nvme_ns *ns)
>   {
> -	if (test_and_set_bit(NVME_NS_DEAD, &ns->flags))
> -		return;
> -
>   	blk_mark_disk_dead(ns->disk);
>   	nvme_start_ns_queue(ns);
>   }
> @@ -5129,14 +5127,14 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
>   	struct nvme_ns *ns;
>   
>   	down_read(&ctrl->namespaces_rwsem);
> -
>   	/* Forcibly unquiesce queues to avoid blocking dispatch */
>   	if (ctrl->admin_q && !blk_queue_dying(ctrl->admin_q))
>   		nvme_start_admin_queue(ctrl);
>   
> -	list_for_each_entry(ns, &ctrl->namespaces, list)
> -		nvme_set_queue_dying(ns);
> -
> +	if (!test_and_set_bit(NVME_CTRL_NS_DEAD, &ctrl->flags)) {
> +		list_for_each_entry(ns, &ctrl->namespaces, list)
> +			nvme_set_queue_dying(ns);
> +	}

Looking at it now, I'm not sure I understand the need for this flag. It
seems to make nvme_kill_queues reentrant safe, but the admin queue
unquiesce can still end up unbalanced under reentrance?

How is this not broken today (or ever since quiesce/unquiesce started
accounting)? Maybe I lost some context on the exact subtlety of how
nvme-pci uses this interface...

>   	up_read(&ctrl->namespaces_rwsem);
>   }
>   EXPORT_SYMBOL_GPL(nvme_kill_queues);
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index a29877217ee65..82989a3322130 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -237,6 +237,7 @@ enum nvme_ctrl_flags {
>   	NVME_CTRL_FAILFAST_EXPIRED	= 0,
>   	NVME_CTRL_ADMIN_Q_STOPPED	= 1,
>   	NVME_CTRL_STARTED_ONCE		= 2,
> +	NVME_CTRL_NS_DEAD     		= 3,
>   };
>   
>   struct nvme_ctrl {
> @@ -483,7 +484,6 @@ struct nvme_ns {
>   	unsigned long features;
>   	unsigned long flags;
>   #define NVME_NS_REMOVING	0
> -#define NVME_NS_DEAD     	1
>   #define NVME_NS_ANA_PENDING	2
>   #define NVME_NS_FORCE_RO	3
>   #define NVME_NS_READY		4

  reply	other threads:[~2022-10-20 13:30 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 10:56 per-tagset SRCU struct and quiesce Christoph Hellwig
2022-10-20 10:56 ` [PATCH 1/8] block: set the disk capacity to 0 in blk_mark_disk_dead Christoph Hellwig
2022-10-20 13:16   ` Sagi Grimberg
2022-10-21  1:09   ` Ming Lei
2022-10-21 13:11     ` Christoph Hellwig
2022-10-21  1:53   ` Chao Leng
2022-10-21  6:49   ` Hannes Reinecke
2022-10-21 13:13     ` Christoph Hellwig
2022-10-21 21:12   ` Bart Van Assche
2022-10-20 10:56 ` [PATCH 2/8] blk-mq: skip non-mq queues in blk_mq_quiesce_queue Christoph Hellwig
2022-10-20 13:16   ` Sagi Grimberg
2022-10-21  1:13   ` Ming Lei
2022-10-21 13:19     ` Christoph Hellwig
2022-10-21 15:08       ` Ming Lei
2022-10-21  2:47   ` Chao Leng
2022-10-21  3:16     ` Chao Leng
2022-10-21  6:49   ` Hannes Reinecke
2022-10-20 10:56 ` [PATCH 3/8] blk-mq: move the srcu_struct used for quiescing to the tagset Christoph Hellwig
2022-10-20 13:23   ` Sagi Grimberg
2022-10-20 17:26   ` Keith Busch
2022-10-21 13:20     ` Christoph Hellwig
2022-10-21  1:41   ` Ming Lei
2022-10-21  2:49   ` Chao Leng
2022-10-21  6:50   ` Hannes Reinecke
2022-10-21  7:16   ` Chao Leng
2022-10-21 13:22     ` Christoph Hellwig
2022-10-20 10:56 ` [PATCH 4/8] blk-mq: pass a tagset to blk_mq_wait_quiesce_done Christoph Hellwig
2022-10-20 13:23   ` Sagi Grimberg
2022-10-21  1:46   ` Ming Lei
2022-10-21 13:23     ` Christoph Hellwig
2022-10-21  2:49   ` Chao Leng
2022-10-21  6:50   ` Hannes Reinecke
2022-10-21 21:18   ` Bart Van Assche
2022-10-20 10:56 ` [PATCH 5/8] blk-mq: add tagset quiesce interface Christoph Hellwig
2022-10-20 13:24   ` Sagi Grimberg
2022-10-21  1:53   ` Ming Lei
2022-10-21  2:49   ` Chao Leng
2022-10-21  6:51   ` Hannes Reinecke
2022-10-21 21:22   ` Bart Van Assche
2022-10-24  1:57     ` Chao Leng
2022-10-24 13:35       ` Bart Van Assche
2022-10-25  1:38         ` Chao Leng
2022-10-20 10:56 ` [PATCH 6/8] nvme: move the NS_DEAD flag to the controller Christoph Hellwig
2022-10-20 13:30   ` Sagi Grimberg [this message]
2022-10-21 13:28     ` Christoph Hellwig
2022-10-24  8:43       ` Sagi Grimberg
2022-10-24  8:50         ` Sagi Grimberg
2022-10-21  2:49   ` Chao Leng
2022-10-21  6:51   ` Hannes Reinecke
2022-10-20 10:56 ` [PATCH 7/8] nvme: remove nvme_set_queue_dying Christoph Hellwig
2022-10-20 13:10   ` Sagi Grimberg
2022-10-21 13:29     ` Christoph Hellwig
2022-10-24  8:48       ` Sagi Grimberg
2022-10-21  2:50   ` Chao Leng
2022-10-21  6:52   ` Hannes Reinecke
2022-10-20 10:56 ` [PATCH 8/8] nvme: use blk_mq_[un]quiesce_tagset Christoph Hellwig
2022-10-20 13:35   ` Sagi Grimberg
2022-10-21  2:50   ` Chao Leng
2022-10-21  6:52   ` Hannes Reinecke
2022-10-20 13:16 ` per-tagset SRCU struct and quiesce Sagi Grimberg
2022-10-21 18:06 ` Keith Busch

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=ac33021a-b7a1-37cf-b156-df021ac4de43@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=lengchao@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=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.