diff mbox series

[12/39] xen-scsifront: compability status handling

Message ID 20210423113944.42672-13-hare@suse.de
State Superseded
Headers show
Series SCSI result cleanup, part 2 | expand

Commit Message

Hannes Reinecke April 23, 2021, 11:39 a.m. UTC
The Xen guest might run against arbitrary backends, so the driver
might receive a status with driver_byte set. Map these errors
to DID_ERROR to be consistent with recent changes.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/xen-scsifront.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Bart Van Assche April 26, 2021, 3:44 a.m. UTC | #1
On 4/23/21 4:39 AM, Hannes Reinecke wrote:
> The Xen guest might run against arbitrary backends, so the driver

> might receive a status with driver_byte set. Map these errors

> to DID_ERROR to be consistent with recent changes.

> 

> Signed-off-by: Hannes Reinecke <hare@suse.de>

> ---

>  drivers/scsi/xen-scsifront.c | 8 +++++++-

>  1 file changed, 7 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c

> index 259fc248d06c..0d813a2d9ad2 100644

> --- a/drivers/scsi/xen-scsifront.c

> +++ b/drivers/scsi/xen-scsifront.c

> @@ -251,6 +251,7 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,

>  	struct scsi_cmnd *sc;

>  	uint32_t id;

>  	uint8_t sense_len;

> +	int result;

>  

>  	id = ring_rsp->rqid;

>  	shadow = info->shadow[id];

> @@ -261,7 +262,12 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,

>  	scsifront_gnttab_done(info, shadow);

>  	scsifront_put_rqid(info, id);

>  

> -	sc->result = ring_rsp->rslt;

> +	result = ring_rsp->rslt;

> +	if ((result >> 24) & 0xff)

> +		set_host_byte(sc, DID_ERROR);

> +	else

> +		set_host_byte(sc, host_byte(result));

> +	set_status_byte(sc, result & 0xff);


The "& 0xff" isn't necessary in "(result >> 24) & 0xff" since 'result'
is a 32-bit variable.

Thanks,

Bart.
Hannes Reinecke April 26, 2021, 7:03 a.m. UTC | #2
On 4/26/21 5:44 AM, Bart Van Assche wrote:
> On 4/23/21 4:39 AM, Hannes Reinecke wrote:

>> The Xen guest might run against arbitrary backends, so the driver

>> might receive a status with driver_byte set. Map these errors

>> to DID_ERROR to be consistent with recent changes.

>>

>> Signed-off-by: Hannes Reinecke <hare@suse.de>

>> ---

>>  drivers/scsi/xen-scsifront.c | 8 +++++++-

>>  1 file changed, 7 insertions(+), 1 deletion(-)

>>

>> diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c

>> index 259fc248d06c..0d813a2d9ad2 100644

>> --- a/drivers/scsi/xen-scsifront.c

>> +++ b/drivers/scsi/xen-scsifront.c

>> @@ -251,6 +251,7 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,

>>  	struct scsi_cmnd *sc;

>>  	uint32_t id;

>>  	uint8_t sense_len;

>> +	int result;

>>  

>>  	id = ring_rsp->rqid;

>>  	shadow = info->shadow[id];

>> @@ -261,7 +262,12 @@ static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,

>>  	scsifront_gnttab_done(info, shadow);

>>  	scsifront_put_rqid(info, id);

>>  

>> -	sc->result = ring_rsp->rslt;

>> +	result = ring_rsp->rslt;

>> +	if ((result >> 24) & 0xff)

>> +		set_host_byte(sc, DID_ERROR);

>> +	else

>> +		set_host_byte(sc, host_byte(result));

>> +	set_status_byte(sc, result & 0xff);

> 

> The "& 0xff" isn't necessary in "(result >> 24) & 0xff" since 'result'

> is a 32-bit variable.

> 

Will be fixing it up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		        Kernel Storage Architect
hare@suse.de			               +49 911 74053 688
SUSE Software Solutions Germany GmbH, 90409 Nürnberg
GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
diff mbox series

Patch

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 259fc248d06c..0d813a2d9ad2 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -251,6 +251,7 @@  static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,
 	struct scsi_cmnd *sc;
 	uint32_t id;
 	uint8_t sense_len;
+	int result;
 
 	id = ring_rsp->rqid;
 	shadow = info->shadow[id];
@@ -261,7 +262,12 @@  static void scsifront_cdb_cmd_done(struct vscsifrnt_info *info,
 	scsifront_gnttab_done(info, shadow);
 	scsifront_put_rqid(info, id);
 
-	sc->result = ring_rsp->rslt;
+	result = ring_rsp->rslt;
+	if ((result >> 24) & 0xff)
+		set_host_byte(sc, DID_ERROR);
+	else
+		set_host_byte(sc, host_byte(result));
+	set_status_byte(sc, result & 0xff);
 	scsi_set_resid(sc, ring_rsp->residual_len);
 
 	sense_len = min_t(uint8_t, VSCSIIF_SENSE_BUFFERSIZE,