aboutsummaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-15 14:11:22 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-02-24 14:54:51 +0100
commiteaccf49e9524dbdd43feb6a1cdafddf64252389a (patch)
tree188af2fc8409a34d850f4034c888f8519ed0435d /hw
parentd3d250bddb3f6aa6c26e9dadf10e82d9fd8bfce3 (diff)
scsi-block: always use scsi_generic_ops for cache != none
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/scsi-disk.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index ec8e7cbff..4101a59d3 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1754,6 +1754,15 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
case WRITE_VERIFY_10:
case WRITE_VERIFY_12:
case WRITE_VERIFY_16:
+ /* If we are not using O_DIRECT, we might read stale data from the
+ * host cache if writes were made using other commands than these
+ * ones (such as WRITE SAME or EXTENDED COPY, etc.). So, without
+ * O_DIRECT everything must go through SG_IO.
+ */
+ if (!(s->qdev.conf.bs->open_flags & BDRV_O_NOCACHE)) {
+ break;
+ }
+
/* MMC writing cannot be done via pread/pwrite, because it sometimes
* involves writing beyond the maximum LBA or to negative LBA (lead-in).
* And once you do these writes, reading from the block device is
@@ -1764,10 +1773,11 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
* seen, but performance usually isn't paramount on optical media. So,
* just make scsi-block operate the same as scsi-generic for them.
*/
- if (s->qdev.type != TYPE_ROM) {
- return scsi_req_alloc(&scsi_disk_reqops, &s->qdev, tag, lun,
- hba_private);
- }
+ if (s->qdev.type == TYPE_ROM) {
+ break;
+ }
+ return scsi_req_alloc(&scsi_disk_reqops, &s->qdev, tag, lun,
+ hba_private);
}
return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun,