->retries fixups V2
Subsystems (6)
Christoph Hellwig
maintainerThis series fixes a few lose bits in terms of how nvme uses ->retries, including fixing it for non-PCIe transports. While at it I noticed that nvme and scsi use the field in entirely different ways, and no other driver uses it at all. So I decided to move it into the nvme_request and scsi_request structures instead.
Changes since V1:
- better changelog for one patch
- move the new retries field to the end of struct nvme_request
Christoph Hellwig
maintainerPATCH 1/5 nvme: move ->retries setup to nvme_setup_cmd
->retries is counting the number of times a command is resubmitted, and be cleared on the first time we see the command. We currently don't do that for non-PCIe command, which is easily fixed by moving the setup to common code.
--- drivers/nvme/host/core.c | 5 +++++ drivers/nvme/host/pci.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +5 -0
@@ -350,6 +350,11 @@ 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 ; + req->rq_flags |=RQF_DONTPREP ; + } +switch (req_op (req)) {case REQ_OP_DRV_IN :case REQ_OP_DRV_OUT :
drivers/nvme/host/pci.c +0 -4
@@ -326,10 +326,6 @@ static int nvme_init_iod(struct request *rq, struct nvme_dev *dev) iod->nents =0 ; iod->length = size; -if (!(rq->rq_flags &RQF_DONTPREP )) { - rq->retries =0 ; - rq->rq_flags |=RQF_DONTPREP ; - }return BLK_MQ_RQ_QUEUE_OK ; }
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 2/5 nvme: cleanup nvme_req_needs_retry
In reply to Christoph HellwigDon't pass the status explicitly but derive it from the requeust, and unwind the complex condition to be more readable.
--- drivers/nvme/host/core.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +11 -5
@@ -67,11 +67,17 @@ 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)
@@ -79,7 +85,7 @@ 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));
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 3/5 nvme: mark nvme_max_retries static
In reply to Christoph Hellwig--- drivers/nvme/host/core.c | 3 +-- drivers/nvme/host/nvme.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/nvme/host/core.c +1 -2
@@ -49,10 +49,9 @@ unsigned char shutdown_timeout = 5;module_param (shutdown_timeout, byte,0644 );MODULE_PARM_DESC (shutdown_timeout,"timeout in seconds for controller shutdown" ); -unsigned int nvme_max_retries =5 ; +static unsigned int nvme_max_retries =5 ;module_param_named (max_retries, nvme_max_retries, uint,0644 );MODULE_PARM_DESC (max_retries,"max number of retries a command may have" ); -EXPORT_SYMBOL_GPL (nvme_max_retries);static int nvme_char_major;module_param (nvme_char_major, int,0 );
drivers/nvme/host/nvme.h +0 -2
@@ -43,8 +43,6 @@ extern unsigned char shutdown_timeout;#define NVME_DEFAULT_KATO 5#define NVME_KATO_GRACE 10 -extern unsigned int nvme_max_retries; -enum {NVME_NS_LBA =0 ,NVME_NS_LIGHTNVM =1 ,
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 4/5 nvme: move the retries count to struct nvme_request
In reply to Christoph HellwigThe 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.
--- drivers/nvme/host/core.c | 10 +++++----- drivers/nvme/host/nvme.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +5 -5
@@ -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;
@@ -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; }
@@ -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 ;
@@ -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 ; }
drivers/nvme/host/nvme.h +1 -0
@@ -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)
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 5/5 block, scsi: move the retries field to struct scsi_request
In reply to Christoph HellwigInstead of bloating the generic struct request with it.
--- block/scsi_ioctl.c | 8 ++++---- drivers/scsi/osd/osd_initiator.c | 2 +- drivers/scsi/osst.c | 2 +- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 4 ++-- drivers/scsi/sg.c | 2 +- drivers/scsi/st.c | 2 +- drivers/target/target_core_pscsi.c | 2 +- include/linux/blkdev.h | 1 - include/scsi/scsi_request.h | 1 + 10 files changed, 13 insertions(+), 13 deletions(-)
block/scsi_ioctl.c +4 -4
@@ -362,7 +362,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, goto out_free_cdb; bio = rq->bio; - rq->retries =0 ; + req->retries =0 ; start_time = jiffies;
@@ -476,13 +476,13 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, goto error;/* default. possible overriden later */ - rq->retries =5 ; + req->retries =5 ;switch (opcode) {case SEND_DIAGNOSTIC :case FORMAT_UNIT : rq->timeout =FORMAT_UNIT_TIMEOUT ; - rq->retries =1 ; + req->retries =1 ;break ;case START_STOP : rq->timeout =START_STOP_TIMEOUT ;
@@ -495,7 +495,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,break ;case READ_DEFECT_DATA : rq->timeout =READ_DEFECT_DATA_TIMEOUT ; - rq->retries =1 ; + req->retries =1 ;break ;default : rq->timeout =BLK_DEFAULT_SG_TIMEOUT ;
drivers/scsi/osd/osd_initiator.c +1 -1
@@ -1602,7 +1602,7 @@ static int _init_blk_request(struct osd_request *or, req->rq_flags |=RQF_QUIET ; req->timeout = or->timeout; - req->retries = or->retries; +scsi_req (req)->retries = or->retries;if (has_out) { or->out.req = req;
drivers/scsi/osst.c +1 -1
@@ -414,7 +414,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,memset (rq->cmd,0 ,BLK_MAX_CDB );/* ATAPI hates garbage after CDB */ memcpy (rq->cmd, cmd, rq->cmd_len); req->timeout = timeout; - req->retries = retries; + rq->retries = retries; req->end_io_data = SRpnt;blk_execute_rq_nowait (req->q,NULL , req,1 , osst_end_async);
drivers/scsi/scsi_error.c +1 -1
@@ -1988,7 +1988,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) req->rq_flags |=RQF_QUIET ; req->timeout =10 *HZ ; - req->retries =5 ; + rq->retries =5 ;blk_execute_rq_nowait (req->q,NULL , req,1 , eh_lock_door_done); }
drivers/scsi/scsi_lib.c +2 -2
@@ -256,7 +256,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, rq->cmd_len =COMMAND_SIZE (cmd[0 ]);memcpy (rq->cmd, cmd, rq->cmd_len); - req->retries = retries; + rq->retries = retries; req->timeout = timeout; req->cmd_flags |= flags; req->rq_flags |= rq_flags |RQF_QUIET |RQF_PREEMPT ;
@@ -1177,7 +1177,7 @@ static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req) cmd->cmd_len =scsi_req (req)->cmd_len; cmd->cmnd =scsi_req (req)->cmd; cmd->transfersize =blk_rq_bytes (req); - cmd->allowed = req->retries; + cmd->allowed =scsi_req (req)->retries;return BLKPREP_OK ; }
drivers/scsi/sg.c +1 -1
@@ -1718,7 +1718,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) srp->rq = rq; rq->end_io_data = srp; - rq->retries =SG_DEFAULT_RETRIES ; + req->retries =SG_DEFAULT_RETRIES ;if ((dxfer_len <=0 ) || (dxfer_dir ==SG_DXFER_NONE ))return 0 ;
drivers/scsi/st.c +1 -1
@@ -579,7 +579,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,memset (rq->cmd,0 ,BLK_MAX_CDB );memcpy (rq->cmd, cmd, rq->cmd_len); req->timeout = timeout; - req->retries = retries; + rq->retries = retries; req->end_io_data = SRpnt;blk_execute_rq_nowait (req->q,NULL , req,1 , st_scsi_execute_end);
drivers/target/target_core_pscsi.c +1 -1
@@ -1008,7 +1008,7 @@ pscsi_execute_cmd(struct se_cmd *cmd) req->timeout =PS_TIMEOUT_DISK ; else req->timeout = PS_TIMEOUT_OTHER; - req->retries =PS_RETRY ; +scsi_req (req)->retries =PS_RETRY ; blk_execute_rq_nowait(pdv->pdv_sd->request_queue, NULL, req, (cmd->sam_task_attr == TCM_HEAD_TAG),
include/linux/blkdev.h +0 -1
@@ -224,7 +224,6 @@ struct request {unsigned long deadline;struct list_head timeout_list;unsigned int timeout; -int retries;/* * completion callback.
include/scsi/scsi_request.h +1 -0
@@ -11,6 +11,7 @@ struct scsi_request {unsigned short cmd_len;unsigned int sense_len;unsigned int resid_len;/* residual count */ +int retries;void *sense; };
Signature · 1 line
2.11.0
Re: [PATCH 1/5] nvme: move ->retries setup to nvme_setup_cmd
In reply to Christoph HellwigRe: [PATCH 2/5] nvme: cleanup nvme_req_needs_retry
In reply to Christoph HellwigRe: [PATCH 3/5] nvme: mark nvme_max_retries static
In reply to Christoph HellwigRe: [PATCH 4/5] nvme: move the retries count to struct nvme_request
In reply to Christoph HellwigRe: [PATCH 5/5] block, scsi: move the retries field to struct scsi_request
In reply to Christoph HellwigJens Axboe
maintainerQuoted 9 lines · Christoph Hellwig
This series fixes a few lose bits in terms of how nvme uses ->retries, including fixing it for non-PCIe transports. While at it I noticed that nvme and scsi use the field in entirely different ways, and no other driver uses it at all. So I decided to move it into the
nvme_requestandscsi_requeststructures instead.Changes since V1:
- better changelog for one patch
- move the new retries field to the end of structnvme_request
Applied for 4.12. If we do the below on my box, we remove the (now) 2 holes from struct request and shrink it 8 bytes.
include/linux/blkdev.h +2 -1
@@ -215,6 +215,8 @@ struct request {unsigned short ioprio; +unsigned int timeout; +void *special;/* opaque pointer available for LLD use */ int errors;
@@ -223,7 +225,6 @@ struct request {unsigned long deadline;struct list_head timeout_list; -unsigned int timeout;/* * completion callback.
Signature · 1 line
Jens Axboe
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Christoph Hellwig
This series fixes a few lose bits in terms of how nvme uses ->retries, including fixing it for non-PCIe transports. While at it I noticed that nvme and scsi use the field in entirely different ways, and no other driver uses it at all. So I decided to move it into the
nvme_requestandscsi_requeststructures instead.
Quoted 6 lines
Quoted 3 lines
Changes since V1:
- better changelog for one patch
- move the new retries field to the end of structnvme_requestApplied for 4.12. If we do the below on my box, we remove the (now) 2 holes from struct request and shrink it 8 bytes.
Looks good:
Jens Axboe
maintainerQuoted 12 lines · Christoph Hellwig
Quoted 11 lines · Jens Axboe
Quoted 9 lines · Christoph Hellwig
This series fixes a few lose bits in terms of how nvme uses ->retries, including fixing it for non-PCIe transports. While at it I noticed that nvme and scsi use the field in entirely different ways, and no other driver uses it at all. So I decided to move it into the
nvme_requestandscsi_requeststructures instead.Changes since V1:
- better changelog for one patch
- move the new retries field to the end of structnvme_request
Quoted 6 lines
Quoted 2 lines
Applied for 4.12. If we do the below on my box, we remove the (now) 2 holes from struct request and shrink it 8 bytes.
Looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thanks, added that too.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/5] nvme: move ->retries setup to nvme_setup_cmd
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
->retries is counting the number of times a command is resubmitted, and be cleared on the first time we see the command. We currently don't do that for non-PCIe command, which is easily fixed by moving the setup to common code.
Signed-off-by Christoph Hellwig <[email protected]>---
Thanks a lot.
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850