diff mbox series

[04/10] scsi: virtio_scsi: Drop DID_TARGET_FAILURE use.

Message ID 20220804034100.121125-5-michael.christie@oracle.com
State Superseded
Headers show
Series scsi: Fix internal host code use | expand

Commit Message

Mike Christie Aug. 4, 2022, 3:40 a.m. UTC
DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

1. It's not propagated upwards, so SG IO/passthrough users will not see an
error and think a command was successful.

2. There is no handling for them in scsi_decide_disposition so it results
in the scsi eh running.

It looks like virtio_scsi gets this when something like qemu returns
VIRTIO_SCSI_S_TARGET_FAILURE. It looks like qemu returns that error code
if a host OS returns it, but this shouldn't happen for linux since we
never propagate that error to userspace.

This has us use DID_BAD_TARGET in case some other virt layer is returning
it. In that case we will still get a hard error like before and it conveys
something unexpected happened.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/virtio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Aug. 4, 2022, 6:25 p.m. UTC | #1
On 8/4/22 05:40, Mike Christie wrote:
> DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
> because:
> 
> 1. It's not propagated upwards, so SG IO/passthrough users will not see an
> error and think a command was successful.
> 
> 2. There is no handling for them in scsi_decide_disposition so it results
> in the scsi eh running.
> 
> It looks like virtio_scsi gets this when something like qemu returns
> VIRTIO_SCSI_S_TARGET_FAILURE. It looks like qemu returns that error code
> if a host OS returns it, but this shouldn't happen for linux since we
> never propagate that error to userspace.
> 
> This has us use DID_BAD_TARGET in case some other virt layer is returning
> it. In that case we will still get a hard error like before and it conveys
> something unexpected happened.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/virtio_scsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 578c4b6d0f7d..112d8c3962b0 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -141,7 +141,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
>   		set_host_byte(sc, DID_TRANSPORT_DISRUPTED);
>   		break;
>   	case VIRTIO_SCSI_S_TARGET_FAILURE:
> -		set_host_byte(sc, DID_TARGET_FAILURE);
> +		set_host_byte(sc, DID_BAD_TARGET);
>   		break;
>   	case VIRTIO_SCSI_S_NEXUS_FAILURE:
>   		set_host_byte(sc, DID_NEXUS_FAILURE);

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Michael S. Tsirkin Aug. 9, 2022, 7:40 p.m. UTC | #2
On Wed, Aug 03, 2022 at 10:40:54PM -0500, Mike Christie wrote:
> DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
> because:
> 
> 1. It's not propagated upwards, so SG IO/passthrough users will not see an
> error and think a command was successful.
> 
> 2. There is no handling for them in scsi_decide_disposition so it results
> in the scsi eh running.
> 
> It looks like virtio_scsi gets this when something like qemu returns
> VIRTIO_SCSI_S_TARGET_FAILURE. It looks like qemu returns that error code
> if a host OS returns it, but this shouldn't happen for linux since we
> never propagate that error to userspace.
> 
> This has us use DID_BAD_TARGET in case some other virt layer is returning
> it. In that case we will still get a hard error like before and it conveys
> something unexpected happened.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

pls merge with rest of patchset.

> ---
>  drivers/scsi/virtio_scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 578c4b6d0f7d..112d8c3962b0 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -141,7 +141,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
>  		set_host_byte(sc, DID_TRANSPORT_DISRUPTED);
>  		break;
>  	case VIRTIO_SCSI_S_TARGET_FAILURE:
> -		set_host_byte(sc, DID_TARGET_FAILURE);
> +		set_host_byte(sc, DID_BAD_TARGET);
>  		break;
>  	case VIRTIO_SCSI_S_NEXUS_FAILURE:
>  		set_host_byte(sc, DID_NEXUS_FAILURE);
> -- 
> 2.25.1
diff mbox series

Patch

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 578c4b6d0f7d..112d8c3962b0 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -141,7 +141,7 @@  static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
 		set_host_byte(sc, DID_TRANSPORT_DISRUPTED);
 		break;
 	case VIRTIO_SCSI_S_TARGET_FAILURE:
-		set_host_byte(sc, DID_TARGET_FAILURE);
+		set_host_byte(sc, DID_BAD_TARGET);
 		break;
 	case VIRTIO_SCSI_S_NEXUS_FAILURE:
 		set_host_byte(sc, DID_NEXUS_FAILURE);