Skip to contentSkip to conversation

virtio_scsi: do not overwrite SCSI status

PATCH Superseded Hannes Reinecke 5 participants 7 messages Jun 10, 2021 – Jun 22, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 virtio_scsi: do not overwrite SCSI status

When a sense code is present we should not override the scsi status; the driver already sets it based on the response from the hypervisor.

Fixes 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE")
---
 drivers/scsi/virtio_scsi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/virtio_scsi.c +0 -1
index fd69a03d6137..43177a62916a 100644
@@ -161,7 +161,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
 		       min_t(u32,
 			     virtio32_to_cpu(vscsi->vdev, resp->sense_len),
 			     VIRTIO_SCSI_SENSE_SIZE));
-		set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
 	}
 
 	sc->scsi_done(sc);
Signature · 1 line
2.26.2
Tested-by on v1 1/2
#1 lore raw
Quoted 5 lines · Hannes Reinecke

When a sense code is present we should not override the scsi status; the driver already sets it based on the response from the hypervisor.

Fixes 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE")
Quoted 17 lines
---
  drivers/scsi/virtio_scsi.c | 1 -
  1 file changed, 1 deletion(-)
drivers/scsi/virtio_scsi.c +0 -1
index fd69a03d6137..43177a62916a 100644
@@ -161,7 +161,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
  		       min_t(u32,
  			     virtio32_to_cpu(vscsi->vdev, resp->sense_len),
  			     VIRTIO_SCSI_SENSE_SIZE));
-		set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
  	}
 
  	sc->scsi_done(sc);
Signature · 2 lines
js
suse labs
#2 lore raw
In reply to Hannes Reinecke

Hannes,

Quoted 2 lines

When a sense code is present we should not override the scsi status; the driver already sets it based on the response from the hypervisor.

Color me confused. The code looks like this:

        if (sc->sense_buffer) {
                memcpy(sc->sense_buffer, resp->sense,
                       min_t(u32,
                             virtio32_to_cpu(vscsi->vdev, resp->sense_len),
                             VIRTIO_SCSI_SENSE_SIZE));
                set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
        }

But sc->sense_buffer is always true, the scsi_cmnd obviously has a sense buffer.

Shouldn't that be looking at the returned response instead?

	if (resp->sense_len) {
                memcpy(sc->sense_buffer, resp->sense,
                       min_t(u32,
                             virtio32_to_cpu(vscsi->vdev, resp->sense_len),
                             VIRTIO_SCSI_SENSE_SIZE));
                set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
        }

What am I missing?

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
Tested-by on v1 1/2
#6 lore raw
In reply to Hannes Reinecke
Quoted 5 lines · Hannes Reinecke

When a sense code is present we should not override the scsi status; the driver already sets it based on the response from the hypervisor.

Fixes 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE")

As may be known by now, scsi-virtio support in linux-next is broken. The problem bisects to "scsi: core: Kill DRIVER_SENSE", and this patch fixes the problem.

Guenter

Quoted 19 lines
---
 drivers/scsi/virtio_scsi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/virtio_scsi.c +0 -1
index fd69a03d6137..43177a62916a 100644
@@ -161,7 +161,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
 		       min_t(u32,
 			     virtio32_to_cpu(vscsi->vdev, resp->sense_len),
 			     VIRTIO_SCSI_SENSE_SIZE));
-		set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
 	}
 
 	sc->scsi_done(sc);
Signature · 1 line
2.26.2
#5 lore raw
In reply to Christian Borntraeger
Quoted 4 lines · Christian Borntraeger

FWIW,
I have just bisected a virtio-scsi failure to "scsi: Kill DRIVER_SENSE" and this patch "repairs" the problem.

Any outlook when this lands in next? Having a broken virtio-scsi in next for 2 weeks now is kind of painful.

#3 lore raw
In reply to Martin K. Petersen
Quoted 29 lines · Martin K. Petersen

Hannes,

Quoted 2 lines

When a sense code is present we should not override the scsi status; the driver already sets it based on the response from the hypervisor.

Color me confused. The code looks like this:

        if (sc->sense_buffer) {
                memcpy(sc->sense_buffer, resp->sense,
                       min_t(u32,
                             virtio32_to_cpu(vscsi->vdev, resp->sense_len),
                             VIRTIO_SCSI_SENSE_SIZE));
                set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
        }

But sc->sense_buffer is always true, the scsi_cmnd obviously has a sense buffer.

Shouldn't that be looking at the returned response instead?

	if (resp->sense_len) {
                memcpy(sc->sense_buffer, resp->sense,
                       min_t(u32,
                             virtio32_to_cpu(vscsi->vdev, resp->sense_len),
                             VIRTIO_SCSI_SENSE_SIZE));
                set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
        }
Quoted 2 lines

What am I missing?

Indeed, you are right. Will be fixing it up.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		           Kernel Storage Architect
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer