diff options
author | Christoph Hellwig <hch@lst.de> | 2015-11-28 09:41:58 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-12-22 11:38:34 -0500 |
commit | 7688faa6dd2c99ce5d66571d9ad65535ec39e8cb (patch) | |
tree | c7e225f067d931754c400635cde063dba49e0ed1 /drivers/nvme | |
parent | 4680072003df14230e9eeeeefb617401012234a5 (diff) |
nvme: factor out a few helpers from req_completion
We'll need them in other places later.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/core.c | 11 | ||||
-rw-r--r-- | drivers/nvme/host/nvme.h | 7 | ||||
-rw-r--r-- | drivers/nvme/host/pci.c | 12 |
3 files changed, 20 insertions, 10 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 875e403830a9..b52a789e1e77 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -78,6 +78,17 @@ static struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk) | |||
78 | return ns; | 78 | return ns; |
79 | } | 79 | } |
80 | 80 | ||
81 | void nvme_requeue_req(struct request *req) | ||
82 | { | ||
83 | unsigned long flags; | ||
84 | |||
85 | blk_mq_requeue_request(req); | ||
86 | spin_lock_irqsave(req->q->queue_lock, flags); | ||
87 | if (!blk_queue_stopped(req->q)) | ||
88 | blk_mq_kick_requeue_list(req->q); | ||
89 | spin_unlock_irqrestore(req->q->queue_lock, flags); | ||
90 | } | ||
91 | |||
81 | struct request *nvme_alloc_request(struct request_queue *q, | 92 | struct request *nvme_alloc_request(struct request_queue *q, |
82 | struct nvme_command *cmd, unsigned int flags) | 93 | struct nvme_command *cmd, unsigned int flags) |
83 | { | 94 | { |
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index aa4b42ecbebe..b0417622d27c 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h | |||
@@ -216,6 +216,12 @@ static inline int nvme_error_status(u16 status) | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | static inline bool nvme_req_needs_retry(struct request *req, u16 status) | ||
220 | { | ||
221 | return !(status & NVME_SC_DNR || blk_noretry_request(req)) && | ||
222 | (jiffies - req->start_time) < req->timeout; | ||
223 | } | ||
224 | |||
219 | int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap); | 225 | int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap); |
220 | int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap); | 226 | int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap); |
221 | int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl); | 227 | int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl); |
@@ -230,6 +236,7 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl); | |||
230 | 236 | ||
231 | struct request *nvme_alloc_request(struct request_queue *q, | 237 | struct request *nvme_alloc_request(struct request_queue *q, |
232 | struct nvme_command *cmd, unsigned int flags); | 238 | struct nvme_command *cmd, unsigned int flags); |
239 | void nvme_requeue_req(struct request *req); | ||
233 | int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, | 240 | int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
234 | void *buf, unsigned bufflen); | 241 | void *buf, unsigned bufflen); |
235 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, | 242 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 686a4e230841..808fb7355603 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -607,17 +607,9 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx, | |||
607 | int error = 0; | 607 | int error = 0; |
608 | 608 | ||
609 | if (unlikely(status)) { | 609 | if (unlikely(status)) { |
610 | if (!(status & NVME_SC_DNR || blk_noretry_request(req)) | 610 | if (nvme_req_needs_retry(req, status)) { |
611 | && (jiffies - req->start_time) < req->timeout) { | ||
612 | unsigned long flags; | ||
613 | |||
614 | nvme_unmap_data(nvmeq->dev, iod); | 611 | nvme_unmap_data(nvmeq->dev, iod); |
615 | 612 | nvme_requeue_req(req); | |
616 | blk_mq_requeue_request(req); | ||
617 | spin_lock_irqsave(req->q->queue_lock, flags); | ||
618 | if (!blk_queue_stopped(req->q)) | ||
619 | blk_mq_kick_requeue_list(req->q); | ||
620 | spin_unlock_irqrestore(req->q->queue_lock, flags); | ||
621 | return; | 613 | return; |
622 | } | 614 | } |
623 | 615 | ||