Skip to content

Commit

Permalink
nvme: cleanup nvme_req_needs_retry
Browse files Browse the repository at this point in the history
Don't pass the status explicitly but derive it from the requeust,
and unwind the complex condition to be more readable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Apr 5, 2017
1 parent 987f699 commit f6324b1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,25 @@ static DEFINE_SPINLOCK(dev_list_lock);

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)) &&
(jiffies - req->start_time) < req->timeout &&
req->retries < nvme_max_retries;
if (blk_noretry_request(req))
return false;
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)
{
int error = 0;

if (unlikely(req->errors)) {
if (nvme_req_needs_retry(req, req->errors)) {
if (nvme_req_needs_retry(req)) {
req->retries++;
blk_mq_requeue_request(req,
!blk_mq_queue_stopped(req->q));
Expand Down

0 comments on commit f6324b1

Please sign in to comment.