From 257dbb3efaa44cb2fba409121a26ddbb749a7fd3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Apr 2008 18:12:56 +0100 Subject: [PATCH] SCSI FLUSH CACHE: make asynchronous and handle errors --- hw/scsi-disk.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 30cc9069..99aa2598 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -276,6 +276,16 @@ static uint8_t *scsi_get_buf(SCSIDevice *d, uint32_t tag) return r->dma_buf; } +static void scsi_flush_cb(void *opaque, int ret) { + SCSIRequest *r = opaque; + if (ret) { + BADF("scsi-disc: IO error on flush: %s\n", strerror(-ret)); + scsi_command_complete(r, SENSE_HARDWARE_ERROR); + } else { + scsi_command_complete(r, SENSE_NO_SENSE); + } +} + /* Execute a scsi command. Returns the length of the data expected by the command. This will be Positive for data transfers from the device (eg. disk reads), negative for transfers to the device (eg. disk writes), @@ -621,13 +631,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, break; case 0x35: DPRINTF("Synchronise cache (sector %d, count %d)\n", lba, len); - ret = bdrv_flush(s->bdrv); - if (ret) { - DPRINTF("IO error on bdrv_flush\n"); - scsi_command_complete(r, SENSE_HARDWARE_ERROR); - return 0; - } - break; + bdrv_aio_flush(s->bdrv, scsi_flush_cb, r); + return 0; case 0x43: { int start_track, format, msf, toclen; -- 2.39.5