Skip to content

Commit

Permalink
nvme: move the retries count to struct nvme_request
Browse files Browse the repository at this point in the history
The way NVMe uses this field is entirely different from the older
SCSI/BLOCK_PC usage, so move it into struct nvme_request.

Also reduce the size of the file to a unsigned char so that we leave
space for additional smaller fields that will appear soon.

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 83f3aeb commit 44e44b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ unsigned char shutdown_timeout = 5;
module_param(shutdown_timeout, byte, 0644);
MODULE_PARM_DESC(shutdown_timeout, "timeout in seconds for controller shutdown");

static unsigned int nvme_max_retries = 5;
module_param_named(max_retries, nvme_max_retries, uint, 0644);
static u8 nvme_max_retries = 5;
module_param_named(max_retries, nvme_max_retries, byte, 0644);
MODULE_PARM_DESC(max_retries, "max number of retries a command may have");

static int nvme_char_major;
Expand All @@ -74,7 +74,7 @@ static inline bool nvme_req_needs_retry(struct request *req)
return false;
if (jiffies - req->start_time >= req->timeout)
return false;
if (req->retries >= nvme_max_retries)
if (nvme_req(req)->retries >= nvme_max_retries)
return false;
return true;
}
Expand All @@ -85,7 +85,7 @@ void nvme_complete_rq(struct request *req)

if (unlikely(req->errors)) {
if (nvme_req_needs_retry(req)) {
req->retries++;
nvme_req(req)->retries++;
blk_mq_requeue_request(req,
!blk_mq_queue_stopped(req->q));
return;
Expand Down Expand Up @@ -356,7 +356,7 @@ int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
int ret = BLK_MQ_RQ_QUEUE_OK;

if (!(req->rq_flags & RQF_DONTPREP)) {
req->retries = 0;
nvme_req(req)->retries = 0;
req->rq_flags |= RQF_DONTPREP;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/nvme/host/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ enum nvme_quirks {
struct nvme_request {
struct nvme_command *cmd;
union nvme_result result;
u8 retries;
};

static inline struct nvme_request *nvme_req(struct request *req)
Expand Down

0 comments on commit 44e44b2

Please sign in to comment.