diff mbox series

[v2,2/2] scsi: donot increase scsi_device's iorequest_cnt if dispatch failed

Message ID 20221021235638.1968832-3-haowenchao@huawei.com
State New
Headers show
Series Fix scsi device's iodone_cnt mismatch with iorequest_cnt | expand

Commit Message

Wenchao Hao Oct. 21, 2022, 11:56 p.m. UTC
If scsi_dispatch_cmd() failed, the scsi command did not send to disks,
so it would never done from LLDs.

scsi scsi_queue_rq() would return BLK_STS_RESOURCE if
scsi_dispatch_cmd() failed, the related request would be requeued, and
the timeout of this request would not fired any more, so no one
would increase iodone_cnt which matches with this increase of
iorequest_cnt.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mike Christie Nov. 22, 2022, 4:32 p.m. UTC | #1
On 10/21/22 6:56 PM, Wenchao Hao wrote:
> If scsi_dispatch_cmd() failed, the scsi command did not send to disks,
> so it would never done from LLDs.
> 
> scsi scsi_queue_rq() would return BLK_STS_RESOURCE if
> scsi_dispatch_cmd() failed, the related request would be requeued, and
> the timeout of this request would not fired any more, so no one
> would increase iodone_cnt which matches with this increase of
> iorequest_cnt.
> 
> Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
> ---
>  drivers/scsi/scsi_lib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 8b89fab7c420..71edb9ffbe16 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1469,8 +1469,6 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
>  	struct Scsi_Host *host = cmd->device->host;
>  	int rtn = 0;
>  
> -	atomic_inc(&cmd->device->iorequest_cnt);
> ->  	/* check if the device is still usable */
>  	if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
>  		/* in SDEV_DEL we error all commands. DID_NO_CONNECT
> @@ -1764,6 +1762,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
>  		goto out_dec_host_busy;
>  	}
>  
> +	atomic_inc(&cmd->device->iorequest_cnt);
>  	return BLK_STS_OK;
>  
>  out_dec_host_busy:

Reviewed-by: Mike Christie <michael.christie@oracle.com>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8b89fab7c420..71edb9ffbe16 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1469,8 +1469,6 @@  static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 	struct Scsi_Host *host = cmd->device->host;
 	int rtn = 0;
 
-	atomic_inc(&cmd->device->iorequest_cnt);
-
 	/* check if the device is still usable */
 	if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
 		/* in SDEV_DEL we error all commands. DID_NO_CONNECT
@@ -1764,6 +1762,7 @@  static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 		goto out_dec_host_busy;
 	}
 
+	atomic_inc(&cmd->device->iorequest_cnt);
 	return BLK_STS_OK;
 
 out_dec_host_busy: