nvme: set NVME_REQ_CANCELLED flag when cancelling a request
Sagi Grimberg
maintainerPATCH 1/1 nvme: set NVME_REQ_CANCELLED flag when cancelling a request
This will prevent userspace to wrongly get the completion result when we cancelled the command. Also, make sure to clear it from the request flags in nvme_setup_cmd.
--- drivers/nvme/host/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/core.c +2 -0
@@ -298,6 +298,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)if (blk_mq_request_completed (req))return true; +nvme_req (req)->flags |=NVME_REQ_CANCELLED ;nvme_req (req)->status =NVME_SC_HOST_PATH_ERROR ;blk_mq_complete_request (req);return true;
@@ -434,6 +435,7 @@ static inline void nvme_clear_nvme_request(struct request *req)nvme_req (req)->flags =0 ; req->rq_flags |=RQF_DONTPREP ; } +nvme_req (req)->flags &= ~NVME_REQ_CANCELLED ; } struct request *nvme_alloc_request(struct request_queue *q,
Signature · 7 lines
2.17.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
There are couple of places where we explicitly set the NVME_REQ_CANCALLED which is followed by the call to nvme_dev_disable(). Since :-
nvme_dev_disable()
blk_mq_tagset_busy_iter()
nvme_cancel_requets()
with your patch nvme_cancel_request() will duplicate NVME_REQ_CANCELLED assignment, we need to avoid duplicate assignment. Following patch is on the top of yours, please have a look :-
drivers/nvme/host/pci.c +0 -0
@@ -1286,7 +1286,6 @@ static enum blk_eh_timer_return
nvme_timeout(struct request *req, bool reserved
"I/O %d QID %d timeout, disable controller\n",
req->tag, nvmeq->qid);
nvme_dev_disable(dev, true);
- nvme_req(req)->flags |= NVME_REQ_CANCELLED;
return BLK_EH_DONE;
case NVME_CTRL_RESETTING:
return BLK_EH_RESET_TIMER;
@@ -1306,7 +1305,6 @@ static enum blk_eh_timer_return
nvme_timeout(struct request *req, bool reserved
nvme_dev_disable(dev, false);
nvme_reset_ctrl(&dev->ctrl);- nvme_req(req)->flags |= NVME_REQ_CANCELLED;
return BLK_EH_DONE;
}If you are okay I can send a separate patch on the top yours.
Quoted 30 lines · Sagi Grimberg
This will prevent userspace to wrongly get the completion result when we cancelled the command. Also, make sure to clear it from the request flags in
nvme_setup_cmd.Signed-off-by Sagi Grimberg<[email protected]>--- drivers/nvme/host/core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/nvme/host/core.c +2
-1@@ -298,6 +298,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)if (blk_mq_request_completed (req))return true; +nvme_req (req)->flags |=NVME_REQ_CANCELLED ;nvme_req (req)->status =NVME_SC_HOST_PATH_ERROR ;blk_mq_complete_request (req);return true;@@ -434,6 +435,7 @@ static inline void nvme_clear_nvme_request(struct request *req)nvme_req (req)->flags =0 ; req->rq_flags |=RQF_DONTPREP ; } +nvme_req (req)->flags &= ~NVME_REQ_CANCELLED ; } struct request *nvme_alloc_request(struct request_queue *q, -- 2.17.1 _______________________________________________ Linux-nvme
Quoted 3 lines
mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 29 lines
There are couple of places where we explicitly set the
NVME_REQ_CANCALLEDwhich is followed by the call tonvme_dev_disable(). Since :-
nvme_dev_disable()
blk_mq_tagset_busy_iter()
nvme_cancel_requets()with your patch
nvme_cancel_request()will duplicateNVME_REQ_CANCELLEDassignment, we need to avoid duplicate assignment. Following patch is on the top of yours, please have a look :-drivers/nvme/host/pci.c +0
-0@@ -1286,7 +1286,6 @@ static enum blk_eh_timer_returnnvme_timeout(struct request *req, bool reserved
"I/O %d QID %d timeout, disable controller\n", req->tag, nvmeq->qid); nvme_dev_disable(dev, true);drivers/nvme/host/pci.c +0
-1-nvme_req (req)->flags |=NVME_REQ_CANCELLED ;return BLK_EH_DONE ;case NVME_CTRL_RESETTING :return BLK_EH_RESET_TIMER ;@@ -1306,7 +1305,6 @@ static enum blk_eh_timer_returnnvme_timeout(struct request *req, bool reserved
Quoted 8 lines
nvme_dev_disable(dev, false); nvme_reset_ctrl(&dev->ctrl);- nvme_req(req)->flags |= NVME_REQ_CANCELLED; return BLK_EH_DONE; }If you are okay I can send a separate patch on the top yours.
That is fine with me.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 3 lines · Sagi Grimberg
Quoted 1 line
If you are okay I can send a separate patch on the top yours.
That is fine with me.
I think we really should have the whole thing in one patch one way or another.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Okay. We can add missing changes at the time of apply I am fine anyway.
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Sagi Grimberg
Quoted 1 line
If you are okay I can send a separate patch on the top yours.
That is fine with me.
I think we really should have the whole thing in one patch one way or another.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme