blob: d6cae2008d11ec63f1e3b77e40237eb044ab8b96 [file] [log] [blame]
From e3c02baed2cd408d4b18679ba63eb74144699637 Mon Sep 17 00:00:00 2001
From: Anton Eidelman <>
Date: Mon, 10 Feb 2020 10:37:18 -0800
Subject: [PATCH] nvme/tcp: fix bug on double requeue when send fails
commit 2d570a7c0251c594489a2c16b82b14ae30345c03 upstream.
When nvme_tcp_io_work() fails to send to socket due to
connection close/reset, error_recovery work is triggered
from nvme_tcp_state_change() socket callback.
This cancels all the active requests in the tagset,
which requeues them.
The failed request, however, was ended and thus requeued
individually as well unless send returned -EPIPE.
Another return code to be treated the same way is -ECONNRESET.
Double requeue caused BUG_ON(blk_queued_rq(rq))
in blk_mq_requeue_request() from either the individual requeue
of the failed request or the bulk requeue from
blk_mq_tagset_busy_iter(, nvme_cancel_request, );
Signed-off-by: Anton Eidelman <>
Reviewed-by: Sagi Grimberg <>
Signed-off-by: Keith Busch <>
Signed-off-by: Jens Axboe <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index bdadb27b28bb..94d64de6f8af 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1051,7 +1051,12 @@ static void nvme_tcp_io_work(struct work_struct *w)
} else if (unlikely(result < 0)) {
"failed to send request %d\n", result);
- if (result != -EPIPE)
+ /*
+ * Fail the request unless peer closed the connection,
+ * in which case error recovery flow will complete all.
+ */
+ if ((result != -EPIPE) && (result != -ECONNRESET))