From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0DHg-0004Tz-OW for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:35:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0DHX-0002Vr-B8 for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:35:08 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:64984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0DHX-0002M5-1z for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:34:59 -0500 Received: by mail-pw0-f45.google.com with SMTP id ro12so281162pbb.4 for ; Wed, 22 Feb 2012 06:34:58 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 22 Feb 2012 15:33:56 +0100 Message-Id: <1329921236-23461-19-git-send-email-pbonzini@redhat.com> In-Reply-To: <1329921236-23461-1-git-send-email-pbonzini@redhat.com> References: <1329921236-23461-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v4 18/18] scsi-block: always use scsi_generic_ops for cache != none List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index ec8e7cb..4101a59 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, -- 1.7.7.6