diff mbox series

[v10,16/33] scsi: spi: Have scsi-ml retry spi_execute errors

Message ID 20230714213419.95492-17-michael.christie@oracle.com
State Superseded
Headers show
Series scsi: Allow scsi_execute users to control retries | expand

Commit Message

Mike Christie July 14, 2023, 9:34 p.m. UTC
This has spi_execute have scsi-ml retry errors instead of driving them.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi_transport_spi.c | 35 ++++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Comments

John Garry July 19, 2023, 2:43 p.m. UTC | #1
On 14/07/2023 22:34, Mike Christie wrote:
> This has spi_execute have scsi-ml retry errors instead of driving them.
> 
> Signed-off-by: Mike Christie<michael.christie@oracle.com>
> Reviewed-by: Christoph Hellwig<hch@lst.de>

Just a comment on a comment, below.
Reviewed-by: John Garry <john.g.garry@oracle.com>

> ---
>   drivers/scsi/scsi_transport_spi.c | 35 ++++++++++++++++---------------
>   1 file changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
> index f668c1c0a98f..b2f5c1d2b451 100644
> --- a/drivers/scsi/scsi_transport_spi.c
> +++ b/drivers/scsi/scsi_transport_spi.c
> @@ -108,29 +108,30 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, >   		       enum req_op op, void *buffer, unsigned int bufflen,
>   		       struct scsi_sense_hdr *sshdr)
>   {
> -	int i, result;
> -	struct scsi_sense_hdr sshdr_tmp;
>   	blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
>   			REQ_FAILFAST_DRIVER;
> +	struct scsi_failure failures[] = {
> +		{
> +			.sense = UNIT_ATTENTION,
> +			.asc = SCMD_FAILURE_ASC_ANY,
> +			.ascq = SCMD_FAILURE_ASCQ_ANY,
> +			.allowed = DV_RETRIES,
> +			.result = SAM_STAT_CHECK_CONDITION,
> +		},
> +		{}
> +	};
>   	const struct scsi_exec_args exec_args = {
>   		.req_flags = BLK_MQ_REQ_PM,
> -		.sshdr = sshdr ? : &sshdr_tmp,
> +		.sshdr = sshdr,
> +		.failures = failures,
>   	};
>   
> -	sshdr = exec_args.sshdr;
> -
> -	for(i = 0; i < DV_RETRIES; i++) {
> -		/*
> -		 * The purpose of the RQF_PM flag below is to bypass the
> -		 * SDEV_QUIESCE state.
> -		 */
> -		result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen,
> -					  DV_TIMEOUT, 1, &exec_args);
> -		if (result < 0 || !scsi_sense_valid(sshdr) ||
> -		    sshdr->sense_key != UNIT_ATTENTION)
> -			break;
> -	}
> -	return result;
> +	/*
> +	 * The purpose of the RQF_PM flag below is to bypass the
> +	 * SDEV_QUIESCE state.
> +	 */

I guess that this comment has been misplaced since we switched to using 
scsi_exec_args

> +	return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1,
> +				&exec_args);
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index f668c1c0a98f..b2f5c1d2b451 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -108,29 +108,30 @@  static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		       enum req_op op, void *buffer, unsigned int bufflen,
 		       struct scsi_sense_hdr *sshdr)
 {
-	int i, result;
-	struct scsi_sense_hdr sshdr_tmp;
 	blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
 			REQ_FAILFAST_DRIVER;
+	struct scsi_failure failures[] = {
+		{
+			.sense = UNIT_ATTENTION,
+			.asc = SCMD_FAILURE_ASC_ANY,
+			.ascq = SCMD_FAILURE_ASCQ_ANY,
+			.allowed = DV_RETRIES,
+			.result = SAM_STAT_CHECK_CONDITION,
+		},
+		{}
+	};
 	const struct scsi_exec_args exec_args = {
 		.req_flags = BLK_MQ_REQ_PM,
-		.sshdr = sshdr ? : &sshdr_tmp,
+		.sshdr = sshdr,
+		.failures = failures,
 	};
 
-	sshdr = exec_args.sshdr;
-
-	for(i = 0; i < DV_RETRIES; i++) {
-		/*
-		 * The purpose of the RQF_PM flag below is to bypass the
-		 * SDEV_QUIESCE state.
-		 */
-		result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen,
-					  DV_TIMEOUT, 1, &exec_args);
-		if (result < 0 || !scsi_sense_valid(sshdr) ||
-		    sshdr->sense_key != UNIT_ATTENTION)
-			break;
-	}
-	return result;
+	/*
+	 * The purpose of the RQF_PM flag below is to bypass the
+	 * SDEV_QUIESCE state.
+	 */
+	return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1,
+				&exec_args);
 }
 
 static struct {