From: Ming Lei ming.lei@redhat.com
mainline inclusion from mainline-v5.4-rc1 commit 78ca40724713bd422873cb4ebee86f9f499650f7 category: bugfix bugzilla: NA CVE: NA Link: https://gitee.com/openeuler/kernel/issues/I1WGZE
--------------------------------
Before aborting in-flight requests, all IO queues and their interrupts have been shutdown. However, request's completion function may not be done yet because it can be scheduled to run via IPI.
So don't abort one request if it is marked as completed, otherwise we may abort one normal completed request.
Cc: Max Gurtovoy maxg@mellanox.com Cc: Sagi Grimberg sagi@grimberg.me Cc: Keith Busch keith.busch@intel.com Cc: Christoph Hellwig hch@lst.de Reviewed-by: Sagi Grimberg sagi@grimberg.me Signed-off-by: Ming Lei ming.lei@redhat.com Signed-off-by: Jens Axboe axboe@kernel.dk Conflicts: nvme_cancel_request function does not return a value. Reviewed-by: Chao Leng lengchao@huawei.com Reviewed-by: Jike Cheng chengjike.cheng@huawei.com Signed-off-by: Lijie lijie34@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index c9b497ab31d4..449840fdda83 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -294,6 +294,10 @@ void nvme_cancel_request(struct request *req, void *data, bool reserved) 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)) + return; + nvme_req(req)->status = NVME_SC_ABORT_REQ; blk_mq_complete_request(req);