scsi-generic: check for additional SG_IO status on completion
authorHannes Reinecke <hare@suse.de>
Wed, 11 Nov 2020 14:40:52 +0000 (15:40 +0100)
committerwanchao-xu <wanchao.xu@samsung.com>
Tue, 9 Jan 2024 11:47:48 +0000 (19:47 +0800)
References: bsc#1178049

SG_IO may return additional status in the 'status', 'driver_status',
and 'host_status' fields. When either of these fields are set the
command has not been executed normally, so we should not continue
processing this command but rather return an error.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bruce Rogers <brogers@suse.com>
hw/scsi/scsi-generic.c

index b3ea492beedc2a075157957e05958fcc3252d455..2379ca9e91b4e775080d4246ba2a76fa652e084a 100644 (file)
@@ -254,7 +254,10 @@ static void scsi_read_complete(void * opaque, int ret)
 
     aio_context_acquire(blk_get_aio_context(s->conf.blk));
 
-    if (ret || r->req.io_canceled) {
+    if (ret || r->req.io_canceled ||
+        r->io_header.status ||
+        r->io_header.driver_status ||
+        r->io_header.host_status) {
         scsi_command_complete_noio(r, ret);
         goto done;
     }
@@ -368,7 +371,10 @@ static void scsi_write_complete(void * opaque, int ret)
 
     aio_context_acquire(blk_get_aio_context(s->conf.blk));
 
-    if (ret || r->req.io_canceled) {
+    if (ret || r->req.io_canceled ||
+        r->io_header.status ||
+        r->io_header.driver_status ||
+        r->io_header.host_status) {
         scsi_command_complete_noio(r, ret);
         goto done;
     }