diff mbox series

scsi: reset host byte in DID_NEXUS_FAILURE case

Message ID 20190214215741.14146-1-mwilck@suse.com (mailing list archive)
State Mainlined
Commit 4a067cf823d9d8e50d41cfb618011c0d4a969c72
Headers show
Series scsi: reset host byte in DID_NEXUS_FAILURE case | expand

Commit Message

Martin Wilck Feb. 14, 2019, 9:57 p.m. UTC
Up to 4.12, __scsi_error_from_host_byte() would reset the host
byte to DID_OK for various cases including DID_NEXUS_FAILURE.
Commit 2a842acab109 ("block: introduce new block status code type")
replaced this function with scsi_result_to_blk_status() and removed
the host-byte resetting code for the DID_NEXUS_FAILURE case.
As the line set_host_byte(cmd, DID_OK) was preserved for the other
cases, I suppose this was an editing mistake.

The fact that the host byte remains set after 4.13 is causing
problems with the sg_persist tool, which now returns success
rather then exit status 24 when a RESERVATION CONFLICT error is
encountered.

Fixes: 2a842acab109 "block: introduce new block status code type"
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Hannes Reinecke Feb. 15, 2019, 6:58 a.m. UTC | #1
On 2/14/19 10:57 PM, Martin Wilck wrote:
> Up to 4.12, __scsi_error_from_host_byte() would reset the host
> byte to DID_OK for various cases including DID_NEXUS_FAILURE.
> Commit 2a842acab109 ("block: introduce new block status code type")
> replaced this function with scsi_result_to_blk_status() and removed
> the host-byte resetting code for the DID_NEXUS_FAILURE case.
> As the line set_host_byte(cmd, DID_OK) was preserved for the other
> cases, I suppose this was an editing mistake.
> 
> The fact that the host byte remains set after 4.13 is causing
> problems with the sg_persist tool, which now returns success
> rather then exit status 24 when a RESERVATION CONFLICT error is
> encountered.
> 
> Fixes: 2a842acab109 "block: introduce new block status code type"
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>   drivers/scsi/scsi_lib.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 6d65ac5..f8d51c3 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -655,6 +655,7 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
>   		set_host_byte(cmd, DID_OK);
>   		return BLK_STS_TARGET;
>   	case DID_NEXUS_FAILURE:
> +		set_host_byte(cmd, DID_OK);
>   		return BLK_STS_NEXUS;
>   	case DID_ALLOC_FAILURE:
>   		set_host_byte(cmd, DID_OK);
> 
Ah _that_ was the issue. Thanks for figuring it out.

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
hch@lst.de Feb. 15, 2019, 7:42 a.m. UTC | #2
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Martin K. Petersen Feb. 16, 2019, 3:18 a.m. UTC | #3
Martin,

> Up to 4.12, __scsi_error_from_host_byte() would reset the host
> byte to DID_OK for various cases including DID_NEXUS_FAILURE.
> Commit 2a842acab109 ("block: introduce new block status code type")
> replaced this function with scsi_result_to_blk_status() and removed
> the host-byte resetting code for the DID_NEXUS_FAILURE case.
> As the line set_host_byte(cmd, DID_OK) was preserved for the other
> cases, I suppose this was an editing mistake.

Applied to 5.0/scsi-fixes, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 6d65ac5..f8d51c3 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -655,6 +655,7 @@  static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
 		set_host_byte(cmd, DID_OK);
 		return BLK_STS_TARGET;
 	case DID_NEXUS_FAILURE:
+		set_host_byte(cmd, DID_OK);
 		return BLK_STS_NEXUS;
 	case DID_ALLOC_FAILURE:
 		set_host_byte(cmd, DID_OK);