All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
@ 2022-11-16  7:27 Christoph Hellwig
  2022-11-16  7:52 ` Chao Leng
  2022-11-16 13:20 ` Sagi Grimberg
  0 siblings, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-16  7:27 UTC (permalink / raw)
  To: kbusch, sagi; +Cc: lengchao, linux-nvme, Gerd Bayer

The NVMe drivers support a mode where no tagset is allocated for the I/O
queues and only the admin queue is usable.  In that case ctrl->tagset is
NULL and we must not call the block per-tagset quiesce helpers that
dereference it.

Fixes: 98d81f0df70c ("nvme: use blk_mq_[un]quiesce_tagset")
Reported-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---

It turns out we have a bunch of other quiesce calls that can happen when
only the admin queue is live.  So bring back the original quick fix to
check for the tagset pointer in the quiesce helpers.

 drivers/nvme/host/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3195ae17df309..fd2e26cb7a688 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5215,6 +5215,8 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
 
 void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl)
 {
+	if (!ctrl->tagset)
+		return;
 	if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
 		blk_mq_quiesce_tagset(ctrl->tagset);
 	else
@@ -5224,6 +5226,8 @@ EXPORT_SYMBOL_GPL(nvme_quiesce_io_queues);
 
 void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl)
 {
+	if (!ctrl->tagset)
+		return;
 	if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
 		blk_mq_unquiesce_tagset(ctrl->tagset);
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16  7:27 [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL Christoph Hellwig
@ 2022-11-16  7:52 ` Chao Leng
  2022-11-16 18:38   ` Chaitanya Kulkarni
  2022-11-16 13:20 ` Sagi Grimberg
  1 sibling, 1 reply; 13+ messages in thread
From: Chao Leng @ 2022-11-16  7:52 UTC (permalink / raw)
  To: Christoph Hellwig, kbusch, sagi; +Cc: linux-nvme, Gerd Bayer

Reviewed-by: Chao Leng <lengchao@huawei.com>

On 2022/11/16 15:27, Christoph Hellwig wrote:
> The NVMe drivers support a mode where no tagset is allocated for the I/O
> queues and only the admin queue is usable.  In that case ctrl->tagset is
> NULL and we must not call the block per-tagset quiesce helpers that
> dereference it.
> 
> Fixes: 98d81f0df70c ("nvme: use blk_mq_[un]quiesce_tagset")
> Reported-by: Gerd Bayer <gbayer@linux.ibm.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> It turns out we have a bunch of other quiesce calls that can happen when
> only the admin queue is live.  So bring back the original quick fix to
> check for the tagset pointer in the quiesce helpers.
> 
>   drivers/nvme/host/core.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3195ae17df309..fd2e26cb7a688 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -5215,6 +5215,8 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
>   
>   void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl)
>   {
> +	if (!ctrl->tagset)
> +		return;
>   	if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
>   		blk_mq_quiesce_tagset(ctrl->tagset);
>   	else
> @@ -5224,6 +5226,8 @@ EXPORT_SYMBOL_GPL(nvme_quiesce_io_queues);
>   
>   void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl)
>   {
> +	if (!ctrl->tagset)
> +		return;
>   	if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
>   		blk_mq_unquiesce_tagset(ctrl->tagset);
>   }
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16  7:27 [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL Christoph Hellwig
  2022-11-16  7:52 ` Chao Leng
@ 2022-11-16 13:20 ` Sagi Grimberg
  2022-11-16 13:22   ` Christoph Hellwig
  1 sibling, 1 reply; 13+ messages in thread
From: Sagi Grimberg @ 2022-11-16 13:20 UTC (permalink / raw)
  To: Christoph Hellwig, kbusch; +Cc: lengchao, linux-nvme, Gerd Bayer



On 11/16/22 09:27, Christoph Hellwig wrote:
> The NVMe drivers support a mode where no tagset is allocated for the I/O
> queues and only the admin queue is usable.  In that case ctrl->tagset is
> NULL and we must not call the block per-tagset quiesce helpers that
> dereference it.
> 
> Fixes: 98d81f0df70c ("nvme: use blk_mq_[un]quiesce_tagset")
> Reported-by: Gerd Bayer <gbayer@linux.ibm.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> It turns out we have a bunch of other quiesce calls that can happen when
> only the admin queue is live.  So bring back the original quick fix to
> check for the tagset pointer in the quiesce helpers.
> 
>   drivers/nvme/host/core.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3195ae17df309..fd2e26cb7a688 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -5215,6 +5215,8 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
>   
>   void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl)
>   {
> +	if (!ctrl->tagset)
> +		return;

Can this be placed in the pci code instead?

>   	if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
>   		blk_mq_quiesce_tagset(ctrl->tagset);
>   	else
> @@ -5224,6 +5226,8 @@ EXPORT_SYMBOL_GPL(nvme_quiesce_io_queues);
>   
>   void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl)
>   {
> +	if (!ctrl->tagset)
> +		return;
>   	if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
>   		blk_mq_unquiesce_tagset(ctrl->tagset);
>   }


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16 13:20 ` Sagi Grimberg
@ 2022-11-16 13:22   ` Christoph Hellwig
  2022-11-16 13:23     ` Sagi Grimberg
  0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-16 13:22 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Wed, Nov 16, 2022 at 03:20:23PM +0200, Sagi Grimberg wrote:
>>   {
>> +	if (!ctrl->tagset)
>> +		return;
>
> Can this be placed in the pci code instead?

There's nothing PCIe-specific about this case.  All fabrics drivers
support controllers with I/O queues and thus the I/O tagset, e.g.
discovery controllers.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16 13:22   ` Christoph Hellwig
@ 2022-11-16 13:23     ` Sagi Grimberg
  2022-11-16 13:28       ` Christoph Hellwig
  0 siblings, 1 reply; 13+ messages in thread
From: Sagi Grimberg @ 2022-11-16 13:23 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, lengchao, linux-nvme, Gerd Bayer


>>>    {
>>> +	if (!ctrl->tagset)
>>> +		return;
>>
>> Can this be placed in the pci code instead?
> 
> There's nothing PCIe-specific about this case.  All fabrics drivers
> support controllers with I/O queues and thus the I/O tagset, e.g.
> discovery controllers.

All the other drivers check that they have IO queues before
quiescing/unquiescing them.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16 13:23     ` Sagi Grimberg
@ 2022-11-16 13:28       ` Christoph Hellwig
  2022-11-20 11:38         ` Sagi Grimberg
  0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-16 13:28 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Wed, Nov 16, 2022 at 03:23:55PM +0200, Sagi Grimberg wrote:
> All the other drivers check that they have IO queues before
> quiescing/unquiescing them.

The core firmware activation code does not.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16  7:52 ` Chao Leng
@ 2022-11-16 18:38   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 13+ messages in thread
From: Chaitanya Kulkarni @ 2022-11-16 18:38 UTC (permalink / raw)
  To: Chao Leng; +Cc: linux-nvme

Chao,

On 11/15/22 23:52, Chao Leng wrote:
> Reviewed-by: Chao Leng <lengchao@huawei.com>
> 
> On 2022/11/16 15:27, Christoph Hellwig wrote:
>> The NVMe drivers support a mode where no tagset is allocated for the I/O

Please avoid top posting.

-ck


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-16 13:28       ` Christoph Hellwig
@ 2022-11-20 11:38         ` Sagi Grimberg
  2022-11-21  7:04           ` Christoph Hellwig
  2022-11-22 12:31           ` Christoph Hellwig
  0 siblings, 2 replies; 13+ messages in thread
From: Sagi Grimberg @ 2022-11-20 11:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, lengchao, linux-nvme, Gerd Bayer


>> All the other drivers check that they have IO queues before
>> quiescing/unquiescing them.
> 
> The core firmware activation code does not.

Well, ideally it should, but maybe it would be more readable
if we condition on ctrl->queue_count > 1.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-20 11:38         ` Sagi Grimberg
@ 2022-11-21  7:04           ` Christoph Hellwig
  2022-11-22 12:31           ` Christoph Hellwig
  1 sibling, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-21  7:04 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Sun, Nov 20, 2022 at 01:38:28PM +0200, Sagi Grimberg wrote:
>
>>> All the other drivers check that they have IO queues before
>>> quiescing/unquiescing them.
>>
>> The core firmware activation code does not.
>
> Well, ideally it should, but maybe it would be more readable
> if we condition on ctrl->queue_count > 1.

I find this more confusing to be honest, but if we get a consensus for
that I can live with it.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-20 11:38         ` Sagi Grimberg
  2022-11-21  7:04           ` Christoph Hellwig
@ 2022-11-22 12:31           ` Christoph Hellwig
  2022-11-22 12:34             ` Christoph Hellwig
  2022-11-29  9:04             ` Christoph Hellwig
  1 sibling, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-22 12:31 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Sun, Nov 20, 2022 at 01:38:28PM +0200, Sagi Grimberg wrote:
>
>>> All the other drivers check that they have IO queues before
>>> quiescing/unquiescing them.
>>
>> The core firmware activation code does not.
>
> Well, ideally it should, but maybe it would be more readable
> if we condition on ctrl->queue_count > 1.

This would be the queue_count version.  I have to say I much prefer
the tagset check, as it is self-documenting and matches what
nvme_queue_scan, nvme_cancel_tagset and nvme_cancel_admin_tagset
do.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-22 12:31           ` Christoph Hellwig
@ 2022-11-22 12:34             ` Christoph Hellwig
  2022-11-29  9:04             ` Christoph Hellwig
  1 sibling, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-22 12:34 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Tue, Nov 22, 2022 at 01:31:54PM +0100, Christoph Hellwig wrote:
> This would be the queue_count version.  I have to say I much prefer
> the tagset check, as it is self-documenting and matches what
> nvme_queue_scan, nvme_cancel_tagset and nvme_cancel_admin_tagset
> do.

And here is the actual patch:

---
From 167d14d9613014142ee285c2912dadc089d80e86 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Wed, 16 Nov 2022 08:14:46 +0100
Subject: nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL

The NVMe drivers support a mode where no tagset is allocated for the I/O
queues and only the admin queue is usable.  In that case
ctrl->queue_count is smaller than two and we must not call the block
per-tagset quiesce helpers that dereference it.

Fixes: 98d81f0df70c ("nvme: use blk_mq_[un]quiesce_tagset")
Reported-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3195ae17df309..6c8a110d6738a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5215,6 +5215,8 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
 
 void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl)
 {
+	if (ctrl->queue_count < 2)
+		return;
 	if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
 		blk_mq_quiesce_tagset(ctrl->tagset);
 	else
@@ -5224,6 +5226,8 @@ EXPORT_SYMBOL_GPL(nvme_quiesce_io_queues);
 
 void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl)
 {
+	if (ctrl->queue_count < 2)
+		return;
 	if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
 		blk_mq_unquiesce_tagset(ctrl->tagset);
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-22 12:31           ` Christoph Hellwig
  2022-11-22 12:34             ` Christoph Hellwig
@ 2022-11-29  9:04             ` Christoph Hellwig
  2022-11-30  8:27               ` Sagi Grimberg
  1 sibling, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-11-29  9:04 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Christoph Hellwig, kbusch, lengchao, linux-nvme, Gerd Bayer

On Tue, Nov 22, 2022 at 01:31:54PM +0100, Christoph Hellwig wrote:
> This would be the queue_count version.  I have to say I much prefer
> the tagset check, as it is self-documenting and matches what
> nvme_queue_scan, nvme_cancel_tagset and nvme_cancel_admin_tagset
> do.

So no comments so far.  Unless I hear more feedback I'd prefer to
go with the ->tagset checks that matches what the other code is
doing and also is more readable.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL
  2022-11-29  9:04             ` Christoph Hellwig
@ 2022-11-30  8:27               ` Sagi Grimberg
  0 siblings, 0 replies; 13+ messages in thread
From: Sagi Grimberg @ 2022-11-30  8:27 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, lengchao, linux-nvme, Gerd Bayer


>> This would be the queue_count version.  I have to say I much prefer
>> the tagset check, as it is self-documenting and matches what
>> nvme_queue_scan, nvme_cancel_tagset and nvme_cancel_admin_tagset
>> do.
> 
> So no comments so far.  Unless I hear more feedback I'd prefer to
> go with the ->tagset checks that matches what the other code is
> doing and also is more readable.

OK, I'm not opposed to that anymore. We can take care of this
area on a different occasion.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-11-30  8:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16  7:27 [PATCH] nvme: don't call blk_mq_{,un}quiesce_tagset when ctrl->tagset is NULL Christoph Hellwig
2022-11-16  7:52 ` Chao Leng
2022-11-16 18:38   ` Chaitanya Kulkarni
2022-11-16 13:20 ` Sagi Grimberg
2022-11-16 13:22   ` Christoph Hellwig
2022-11-16 13:23     ` Sagi Grimberg
2022-11-16 13:28       ` Christoph Hellwig
2022-11-20 11:38         ` Sagi Grimberg
2022-11-21  7:04           ` Christoph Hellwig
2022-11-22 12:31           ` Christoph Hellwig
2022-11-22 12:34             ` Christoph Hellwig
2022-11-29  9:04             ` Christoph Hellwig
2022-11-30  8:27               ` Sagi Grimberg

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.