From 6636813027cb4a71c0ba955ad9e281088e57d997 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 22 Feb 2012 14:12:59 +0100 Subject: [PATCH 103/109] scsi-block: always use scsi_generic_ops for cache != none RH-Author: Paolo Bonzini Message-id: <1329919979-20948-103-git-send-email-pbonzini@redhat.com> Patchwork-id: 37583 O-Subject: [RHEL 6.3 qemu-kvm PATCH v2 102/102] scsi-block: always use scsi_generic_ops for cache != none Bugzilla: 782029 RH-Acked-by: Laszlo Ersek RH-Acked-by: Orit Wasserman RH-Acked-by: Gerd Hoffmann Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- hw/scsi-disk.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index bc5c3f0..789f49f 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1768,6 +1768,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 -- 1.7.7.6