Commit f6324b1b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

nvme: cleanup nvme_req_needs_retry

Don't pass the status explicitly but derive it from the requeust,
and unwind the complex condition to be more readable.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 987f699a
...@@ -67,11 +67,17 @@ static DEFINE_SPINLOCK(dev_list_lock); ...@@ -67,11 +67,17 @@ static DEFINE_SPINLOCK(dev_list_lock);
static struct class *nvme_class; static struct class *nvme_class;
static inline bool nvme_req_needs_retry(struct request *req, u16 status) static inline bool nvme_req_needs_retry(struct request *req)
{ {
return !(status & NVME_SC_DNR || blk_noretry_request(req)) && if (blk_noretry_request(req))
(jiffies - req->start_time) < req->timeout && return false;
req->retries < nvme_max_retries; if (req->errors & NVME_SC_DNR)
return false;
if (jiffies - req->start_time >= req->timeout)
return false;
if (req->retries >= nvme_max_retries)
return false;
return true;
} }
void nvme_complete_rq(struct request *req) void nvme_complete_rq(struct request *req)
...@@ -79,7 +85,7 @@ void nvme_complete_rq(struct request *req) ...@@ -79,7 +85,7 @@ void nvme_complete_rq(struct request *req)
int error = 0; int error = 0;
if (unlikely(req->errors)) { if (unlikely(req->errors)) {
if (nvme_req_needs_retry(req, req->errors)) { if (nvme_req_needs_retry(req)) {
req->retries++; req->retries++;
blk_mq_requeue_request(req, blk_mq_requeue_request(req,
!blk_mq_queue_stopped(req->q)); !blk_mq_queue_stopped(req->q));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment