Received: from eggs.gnu.org ([2001:4830:134:3::10]:60618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC0tu-0003dx-KK for qemu-devel@nongnu.org; Tue, 29 Jul 2014 02:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC0to-0001VD-Dt for qemu-devel@nongnu.org; Tue, 29 Jul 2014 02:28:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC0to-0001V7-6G for qemu-devel@nongnu.org; Tue, 29 Jul 2014 02:28:36 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6T6SZiX024211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 29 Jul 2014 02:28:35 -0400 Date: Tue, 29 Jul 2014 14:28:56 +0800 From: Fam Zheng Message-ID: <20140729062856.GA16854@T430.nay.redhat.com> References: <1406560119-22362-1-git-send-email-pbonzini@redhat.com> <1406560119-22362-4-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1406560119-22362-4-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/5] scsi-block: extract scsi_block_is_passthrough List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Mon, 07/28 17:08, Paolo Bonzini wrote: > This will be used for both scsi_block_new_request and the scsi-block > implementation of parse_cdb. > > Signed-off-by: Paolo Bonzini > --- > hw/scsi/scsi-disk.c | 38 ++++++++++++++++++++++++++------------ > 1 file changed, 26 insertions(+), 12 deletions(-) > > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c > index d47ecd6..81b7276 100644 > --- a/hw/scsi/scsi-disk.c > +++ b/hw/scsi/scsi-disk.c > @@ -2501,12 +2501,8 @@ static int scsi_block_initfn(SCSIDevice *dev) > return scsi_initfn(&s->qdev); > } > > -static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, > - uint32_t lun, uint8_t *buf, > - void *hba_private) > +static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf) > { > - SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d); > - > switch (buf[0]) { > case READ_6: > case READ_10: > @@ -2523,9 +2519,9 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, > 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. > + * 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 (!(bdrv_get_flags(s->qdev.conf.bs) & BDRV_O_NOCACHE)) { > break; > @@ -2542,13 +2538,31 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, > * just make scsi-block operate the same as scsi-generic for them. > */ > if (s->qdev.type != TYPE_ROM) { > - return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun, > - hba_private); > + return false; > } > + break; > + > + default: > + break; Out of curiosity, why add this default branch? Fam > } > > - return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun, > - hba_private); > + return true; > +} > + > + > +static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, > + uint32_t lun, uint8_t *buf, > + void *hba_private) > +{ > + SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d); > + > + if (scsi_block_is_passthrough(s, buf)) { > + return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun, > + hba_private); > + } else { > + return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun, > + hba_private); > + } > } > #endif > > -- > 1.9.3 > > >