Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: ensure reset state check ordering
@ 2023-10-27 18:07 Keith Busch
  2023-10-30 13:27 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Keith Busch @ 2023-10-27 18:07 UTC (permalink / raw)
  To: linux-nvme, hch; +Cc: sagi, Keith Busch, Minh Hoang

From: Keith Busch <kbusch@kernel.org>

A different CPU may be setting the ctrl->state value while flushing the
reset work, so ensure proper barriers to prevent reading a stale state.
Reading the wrong state can report unexpected ENETRESET errors when
everything was successful.

Fixes: 8000d1fdb07e36 ("nvme-rdma: fix sysfs invoked reset_ctrl error flow")
Reported-by: Minh Hoang <mh2022@meta.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 62612f87aafa2..9ec7ce8cc802e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -201,7 +201,7 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)
 	ret = nvme_reset_ctrl(ctrl);
 	if (!ret) {
 		flush_work(&ctrl->reset_work);
-		if (ctrl->state != NVME_CTRL_LIVE)
+		if (smp_load_acquire(&ctrl->state) != NVME_CTRL_LIVE)
 			ret = -ENETRESET;
 	}
 
-- 
2.34.1



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

end of thread, other threads:[~2023-11-20 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 18:07 [PATCH] nvme: ensure reset state check ordering Keith Busch
2023-10-30 13:27 ` Christoph Hellwig
2023-11-20 13:53   ` Sagi Grimberg
2023-11-20 14:26     ` Christoph Hellwig
2023-11-20 14:36       ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox