[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <PS1PR03MB4939C825BD5D9A135AA0EB9188919@PS1PR03MB4939.apcprd03.prod.outlook.com>
Date: Thu, 6 Apr 2023 16:18:18 +0000
From: Lei Lei2 Yin <yinlei2@...ovo.com>
To: "kbusch@...nel.org" <kbusch@...nel.org>,
"axboe@...com" <axboe@...com>, "hch@....de" <hch@....de>,
Sagi Grimberg <sagi@...mberg.me>
CC: "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"cybeyond@...mail.com" <cybeyond@...mail.com>
Subject: [PATCH] nvme: fix double blk_mq_complete_request for timeout request
with low probability
>From 612bdaa44a8bed09cf8da15df0ad98c018fb5ae4 Mon Sep 17 00:00:00 2001
From: Lei Yin <yinlei2@...ovo.com>
Date: Thu, 6 Apr 2023 23:39:11 +0800
Subject: [PATCH] nvme: fix double blk_mq_complete_request for timeout request
with low probability
When nvme_cancel_tagset traverses all tagsets and executes
nvme_cancel_request, this request may be executing blk_mq_free_request
that is called by nvme_rdma_complete_timed_out/nvme_tcp_complete_timed_out.
When blk_mq_free_request executes to WRITE_ONCE(rq->state, MQ_RQ_IDLE) and
__blk_mq_free_request(rq), it will cause double blk_mq_complete_request for
this request, and it will cause a null pointer error in the second
execution of this function because rq->mq_hctx has set to NULL in first
execution.
Signed-off-by: Lei Yin <yinlei2@...ovo.com>
---
drivers/nvme/host/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 53ef028596c6..c1cc384f4f3e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -450,8 +450,8 @@ bool nvme_cancel_request(struct request *req, void *data)
dev_dbg_ratelimited(((struct nvme_ctrl *) data)->device,
"Cancelling I/O %d", req->tag);
- /* don't abort one completed request */
- if (blk_mq_request_completed(req))
+ /* don't abort one completed or idle request */
+ if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT)
return true;
nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;
--
2.39.1
Powered by blists - more mailing lists