Skip to contentSkip to conversation

NVMe: Use error handling on failed sync commands

PATCH New Keith Busch 2 participants 3 messages Dec 20, 2013

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

PATCH 1/1 NVMe: Use error handling on failed sync commands

Sync commands schedule an internal timeout to cancel rather than using the nvme timeout handler kthread. We should still try to recover so moving the check for cancelled commands after the error handling.

Signed-off-by Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme-core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/nvme-core.c +2 -2
index b59a93a..79a130c 100644
@@ -1122,12 +1122,12 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
 
 		if (timeout && !time_after(now, info[cmdid].timeout))
 			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
-			continue;
 		if (timeout && nvmeq->dev->initialized) {
 			nvme_abort_cmd(cmdid, nvmeq);
 			continue;
 		}
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
+			continue;
 		dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d QID %d\n", cmdid,
 								nvmeq->qid);
 		ctx = cancel_cmdid(nvmeq, cmdid, &fn);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 NVMe: Use error handling on failed sync commands

Quoted 7 lines · Keith Busch

Sync commands schedule an internal timeout to cancel rather than using the nvme timeout handler kthread. We should still try to recover so moving the check for cancelled commands after the error handling.

drivers/block/nvme-core.c +0 -1
 		if (timeout && !time_after(now, info[cmdid].timeout))
 			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)

drivers/block/nvme-core.c static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout) · line 1133

Quoted 10 lines
drivers/block/nvme-core.c +2 -1
-			continue;
 		if (timeout && nvmeq->dev->initialized) {
 			nvme_abort_cmd(cmdid, nvmeq);
 			continue;
 		}
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
+			continue;
 		dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d QID %d\n", cmdid,
 								nvmeq->qid);
 		ctx = cancel_cmdid(nvmeq, cmdid, &fn);

I'm confused by this patch. Won't it cause us to send abort commands repeatedly for commands IDs that have already been cancelled, but haven't yet been completed as cancelled?

#2 lore raw

PATCH 1/1 NVMe: Use error handling on failed sync commands

Quoted 14 lines · Matthew Wilcox
Quoted 13 lines · Keith Busch

Sync commands schedule an internal timeout to cancel rather than using the nvme timeout handler kthread. We should still try to recover so moving the check for cancelled commands after the error handling.

drivers/block/nvme-core.c +1 -2
 		if (timeout && !time_after(now, info[cmdid].timeout))
 			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
-			continue;
 		if (timeout && nvmeq->dev->initialized) {
 			nvme_abort_cmd(cmdid, nvmeq);
 			continue;
 		}
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
Quoted 8 lines

drivers/block/nvme-core.c static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout) · line 1133

Quoted 4 lines
drivers/block/nvme-core.c +1 -0
+			continue;
 		dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d QID %d\n", cmdid,
 								nvmeq->qid);
 		ctx = cancel_cmdid(nvmeq, cmdid, &fn);

I'm confused by this patch. Won't it cause us to send abort commands repeatedly for commands IDs that have already been cancelled, but haven't yet been completed as cancelled?

It appears so, but 'nvme_abort_cmd' aborts only once then resets the controller if the command still isn't returned. The drive is not polled for timeouts when the reset handler is running so it won't timeout again, and the command is forced cancelled during reset with cancel_ios() 'timeout' set to false.

'sync_command' is the only place an IO can be cancelled while the device being polled for timeouts. I think we want to try recovering the unresponsive controller even if the sync timeout already cancelled.

Without this patch, a failed sync command just leaks a cmdid until the controller is reset some other way.