LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] nvmet: switch loopback target state to connecting when resetting
@ 2018-05-03 15:00 Johannes Thumshirn
  2018-05-03 15:31 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2018-05-03 15:00 UTC (permalink / raw)
  To: Keith Busch
  Cc: Sagi Grimberg, Christoph Hellwig, Linux Kernel Mailinglist,
	Linux NVMe Mailinglist, James Smart, Johannes Thumshirn

After commit bb06ec31452f ("nvme: expand nvmf_check_if_ready checks")
resetting of the loopback nvme target failed as we forgot to switch
it's state to NVME_CTRL_CONNECTING before we reconnect the admin
queues. Therefore the checks in nvmf_check_if_ready() choose to go to
the reject_io case and thus we couldn't sent out an identify
controller command to reconnect.

Change the controller state to NVME_CTRL_CONNECTING after tearing down
the old connection and before re-establishing the connection.

Fixes: bb06ec31452f ("nvme: expand nvmf_check_if_ready checks")
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/target/loop.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 31fdfba556a8..27a8561c0cb9 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -469,6 +469,12 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
 	nvme_stop_ctrl(&ctrl->ctrl);
 	nvme_loop_shutdown_ctrl(ctrl);
 
+	if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
+		/* state change failure should never happen */
+		WARN_ON_ONCE(1);
+		return;
+	}
+
 	ret = nvme_loop_configure_admin_queue(ctrl);
 	if (ret)
 		goto out_disable;
-- 
2.16.3

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

* Re: [PATCH] nvmet: switch loopback target state to connecting when resetting
  2018-05-03 15:00 [PATCH] nvmet: switch loopback target state to connecting when resetting Johannes Thumshirn
@ 2018-05-03 15:31 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2018-05-03 15:31 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Keith Busch, Sagi Grimberg, James Smart, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist, Christoph Hellwig

On Thu, May 03, 2018 at 05:00:35PM +0200, Johannes Thumshirn wrote:
> After commit bb06ec31452f ("nvme: expand nvmf_check_if_ready checks")
> resetting of the loopback nvme target failed as we forgot to switch
> it's state to NVME_CTRL_CONNECTING before we reconnect the admin
> queues. Therefore the checks in nvmf_check_if_ready() choose to go to
> the reject_io case and thus we couldn't sent out an identify
> controller command to reconnect.
> 
> Change the controller state to NVME_CTRL_CONNECTING after tearing down
> the old connection and before re-establishing the connection.
> 
> Fixes: bb06ec31452f ("nvme: expand nvmf_check_if_ready checks")
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/target/loop.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
> index 31fdfba556a8..27a8561c0cb9 100644
> --- a/drivers/nvme/target/loop.c
> +++ b/drivers/nvme/target/loop.c
> @@ -469,6 +469,12 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
>  	nvme_stop_ctrl(&ctrl->ctrl);
>  	nvme_loop_shutdown_ctrl(ctrl);
>  
> +	if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
> +		/* state change failure should never happen */
> +		WARN_ON_ONCE(1);
> +		return;
> +	}
> +
>  	ret = nvme_loop_configure_admin_queue(ctrl);
>  	if (ret)
>  		goto out_disable;
> -- 
> 2.16.3

Thanks, applied to the 4.17 nvme branch.

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

end of thread, other threads:[~2018-05-03 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 15:00 [PATCH] nvmet: switch loopback target state to connecting when resetting Johannes Thumshirn
2018-05-03 15:31 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).