[10/10] scsi: only start the request just before dispatching

Message ID 20201005084130.143273-11-hch@lst.de
State New
Headers show
Series
  • [01/10] scsi: don't export scsi_device_from_queue
Related show

Commit Message

Christoph Hellwig Oct. 5, 2020, 8:41 a.m.
This has no change in behavior, but improves the accounting a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi_lib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Bart Van Assche Oct. 5, 2020, 4:11 p.m. | #1
On 10/5/20 1:41 AM, Christoph Hellwig wrote:
> This has no change in behavior, but improves the accounting a bit.

> 

> Signed-off-by: Christoph Hellwig <hch@lst.de>

> ---

>   drivers/scsi/scsi_lib.c | 4 +---

>   1 file changed, 1 insertion(+), 3 deletions(-)

> 

> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c

> index f7b88d8cf975d5..f0254f913b3e3f 100644

> --- a/drivers/scsi/scsi_lib.c

> +++ b/drivers/scsi/scsi_lib.c

> @@ -1548,8 +1548,6 @@ static blk_status_t scsi_prepare_cmd(struct request *req)

>   			(struct scatterlist *)(cmd->prot_sdb + 1);

>   	}

>   

> -	blk_mq_start_request(req);

> -

>   	/*

>   	 * Special handling for passthrough commands, which don't go to the ULP

>   	 * at all:

> @@ -1649,7 +1647,6 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,

>   		req->rq_flags |= RQF_DONTPREP;

>   	} else {

>   		clear_bit(SCMD_STATE_COMPLETE, &cmd->state);

> -		blk_mq_start_request(req);

>   	}

>   

>   	cmd->flags &= SCMD_PRESERVED_FLAGS;

> @@ -1662,6 +1659,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,

>   	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);

>   	cmd->scsi_done = scsi_mq_done;

>   

> +	blk_mq_start_request(req);

>   	reason = scsi_dispatch_cmd(cmd);

>   	if (reason) {

>   		scsi_set_blocked(cmd, reason);


That's a nice cleanup!

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f7b88d8cf975d5..f0254f913b3e3f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1548,8 +1548,6 @@  static blk_status_t scsi_prepare_cmd(struct request *req)
 			(struct scatterlist *)(cmd->prot_sdb + 1);
 	}
 
-	blk_mq_start_request(req);
-
 	/*
 	 * Special handling for passthrough commands, which don't go to the ULP
 	 * at all:
@@ -1649,7 +1647,6 @@  static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 		req->rq_flags |= RQF_DONTPREP;
 	} else {
 		clear_bit(SCMD_STATE_COMPLETE, &cmd->state);
-		blk_mq_start_request(req);
 	}
 
 	cmd->flags &= SCMD_PRESERVED_FLAGS;
@@ -1662,6 +1659,7 @@  static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 	cmd->scsi_done = scsi_mq_done;
 
+	blk_mq_start_request(req);
 	reason = scsi_dispatch_cmd(cmd);
 	if (reason) {
 		scsi_set_blocked(cmd, reason);