[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/5] scsi-disk: flush cache after disabling it
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 5/5] scsi-disk: flush cache after disabling it |
Date: |
Mon, 12 Nov 2012 15:03:31 +0100 |
SBC says that "if an application client changes the WCE bit from one to
zero via a MODE SELECT command, then the device server shall write
any data in volatile cache to non-volatile medium before completing
the command".
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-disk.c | 9 +++++++++
1 file modificato, 9 inserzioni(+)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index d15f891..49b5686 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1387,6 +1387,7 @@ invalid_param_len:
static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
{
+ SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint8_t *p = inbuf;
int cmd = r->req.cmd.buf[0];
int len = r->req.cmd.xfer;
@@ -1423,6 +1424,14 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq
*r, uint8_t *inbuf)
return;
}
}
+ if (!bdrv_enable_write_cache(s->qdev.conf.bs)) {
+ /* The request is used as the AIO opaque value, so add a ref. */
+ scsi_req_ref(&r->req);
+ bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
+ r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
+ return;
+ }
+
scsi_req_complete(&r->req, GOOD);
return;
--
1.7.12.1
- [Qemu-devel] [PULL 1.3 0/5] SCSI updates for 2012-11-12, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 1/5] scsi: do not return short responses for emulated commands, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 2/5] virtio-scsi: factor checks for VIRTIO_SCSI_S_DRIVER_OK when reporting events, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 3/5] scsi: remove superfluous call to scsi_device_set_ua, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 4/5] megasas: do not include block_int.h, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 5/5] scsi-disk: flush cache after disabling it,
Paolo Bonzini <=
- Re: [Qemu-devel] [PULL 1.3 0/5] SCSI updates for 2012-11-12, Paolo Bonzini, 2012/11/12
- Re: [Qemu-devel] [PULL 1.3 0/5] SCSI updates for 2012-11-12, Anthony Liguori, 2012/11/14