From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47845 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKUXC-0002k0-0j for qemu-devel@nongnu.org; Mon, 22 Nov 2010 06:26:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKUX7-00019q-6q for qemu-devel@nongnu.org; Mon, 22 Nov 2010 06:26:09 -0500 Received: from verein.lst.de ([213.95.11.210]:50347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKUX6-00019i-TU for qemu-devel@nongnu.org; Mon, 22 Nov 2010 06:26:05 -0500 Date: Mon, 22 Nov 2010 12:26:01 +0100 From: Christoph Hellwig Subject: Re: [Qemu-devel] [PATCH 15/16] scsi: Implement get_req_iov callback Message-ID: <20101122112601.GC1579@lst.de> References: <20101118144750.9A528F90AB@ochil.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101118144750.9A528F90AB@ochil.suse.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hannes Reinecke Cc: stefanha@gmail.com, qemu-devel@nongnu.org, nab@linux-iscsi.org, kraxel@redhat.com > @@ -95,14 +95,30 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, > return req; > } > > +static SCSIRequest *scsi_new_request_iovec(SCSIDevice *d, uint32_t tag, > + uint32_t lun, struct iovec *iov, int iov_num) > +{ > + SCSIRequest *req; > + SCSIDiskReq *r; > + > + req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun); > + r = DO_UPCAST(SCSIDiskReq, req, req); > + r->iov = iov; > + r->iov_num = iov_num; > + r->iov_buf = NULL; > + return req; > +} While the amount of duplicated code here is rather small I still hate the duplication. The simplest step is to implement scsi_new_request on top of scsi_new_request_iovec by just allocation the iovec in scsi_new_request and passing it to scsi_new_request_iovec. The next patch on top would be to move the iovec allocation to the HBA driver and only stick to one interface.