Skip to contentSkip to conversation

nvme-fc: fix racing controller reset and create association

PATCH Applied James Smart 3 participants 3 messages Mar 9, 2021 – Mar 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme-fc: fix racing controller reset and create association

Recent patch to prevent calling __nvme_fc_abort_outstanding_ios in interrupt context results in a possible race condition. A controller reset results in errored io completions, which schedules error work. The change of error work to a work element allows it to fire after the ctrl state transition to NVME_CTRL_CONNECTING, causing any outstanding io (used to initialize the controller) to fail and cause problems for connect_work.

Add a state check to only schedule error work if not in the RESETTING state.

Fixes 19fce0470f05 ("nvme-fc: avoid calling _nvme_fc_abort_outstanding_ios from interrupt context")
Cc <[email protected]> # v5.10+

---
v2: clean up typo in commit header

---
 drivers/nvme/host/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +1 -1
index 20dadd86e981..0f92bd12123e 100644
@@ -2055,7 +2055,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 		nvme_fc_complete_rq(rq);
 
 check_error:
-	if (terminate_assoc)
+	if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING)
 		queue_work(nvme_reset_wq, &ctrl->ioerr_work);
 }
 
Signature · 1 line
2.26.2
#2 lore raw
In reply to James Smart
Quoted 29 lines · James Smart

Recent patch to prevent calling __nvme_fc_abort_outstanding_ios in interrupt context results in a possible race condition. A controller reset results in errored io completions, which schedules error work. The change of error work to a work element allows it to fire after the ctrl state transition to NVME_CTRL_CONNECTING, causing any outstanding io (used to initialize the controller) to fail and cause problems for connect_work.

Add a state check to only schedule error work if not in the RESETTING state.

Fixes 19fce0470f05 ("nvme-fc: avoid calling

_nvme_fc_abort_outstanding_ios from interrupt context")
Cc: <[email protected]> # v5.10+

---
v2: clean up typo in commit header

---
 drivers/nvme/host/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +0 -0
index 20dadd86e981..0f92bd12123e 100644

drivers/nvme/host/fc.c nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) · line 2061

Quoted 8 lines
drivers/nvme/host/fc.c +1 -1
@@ -2055,7 +2055,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 		nvme_fc_complete_rq(rq);
 
 check_error:
-	if (terminate_assoc)
+	if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING)
 		queue_work(nvme_reset_wq, &ctrl->ioerr_work);
 }
 

This fix resolves the frequent -EBUSY / -ENETRESET errors I saw when resetting the controller via sysfs, as well as the eventual hang with the controller stuck in the _CONNECTING state, thanks. Looks good.

-Ewan