[PATCH] nvme: ensure reset state check ordering
Keith Busch
kbusch at meta.com
Fri Oct 27 11:07:52 PDT 2023
From: Keith Busch <kbusch at 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 at meta.com>
Signed-off-by: Keith Busch <kbusch at 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
More information about the Linux-nvme
mailing list