From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59860 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ7JX-0007F9-70 for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:26:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ7JW-00066m-5p for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:26:23 -0500 Received: from cantor.suse.de ([195.135.220.2]:52991 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ7JV-00066f-Ui for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:26:22 -0500 Message-ID: <4CE5543C.2080701@suse.de> Date: Thu, 18 Nov 2010 17:28:44 +0100 From: Hannes Reinecke MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 09/16] scsi-disk: Allocate iovec dynamically References: <20101118144723.61032F90AB@ochil.suse.de> <4CE54755.8010205@redhat.com> In-Reply-To: <4CE54755.8010205@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: stefanha@gmail.com, qemu-devel@nongnu.org, nab@linux-iscsi.org On 11/18/2010 04:33 PM, Gerd Hoffmann wrote: > Hi, >=20 >> +static size_t scsi_req_iov_len(SCSIDiskReq *r) >> +{ >> + size_t iov_len =3D 0; >> + int i; >> + >> + for (i =3D 0; i< r->iov_num; i++) >> + iov_len +=3D r->iov[i].iov_len; >> + >> + return iov_len; >> +} >=20 > You are aware that there is a QEMUIOVector type with helper functions > which keeps track of both number of elements and total size? >=20 Yes. But I'm passing passing in an entire iovec to the request. However, the QEMUIOVector routines allow you to add only _one_ element at a time, which is pretty wasteful here. And I'm counting the resulting length of the iovec, which might have been changed by read/write operations. For which there is no generic function either. But if requested I could easily move it into cutils.c. Cheers, Hannes --=20 Dr. Hannes Reinecke zSeries & Storage hare@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg GF: Markus Rex, HRB 16746 (AG N=FCrnberg)