From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=34400 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OamnR-0005MJ-3F for qemu-devel@nongnu.org; Mon, 19 Jul 2010 05:38:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OamnM-0005Yx-Vs for qemu-devel@nongnu.org; Mon, 19 Jul 2010 05:38:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23155) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OamnM-0005Yq-My for qemu-devel@nongnu.org; Mon, 19 Jul 2010 05:37:56 -0400 Message-ID: <4C441CF0.3010909@redhat.com> Date: Mon, 19 Jul 2010 11:37:52 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] block: Change bdrv_commit to handle multiple sectors at once References: <1279297056-13392-1-git-send-email-kwolf@redhat.com> <20100716181633.GA29674@lst.de> In-Reply-To: <20100716181633.GA29674@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Am 16.07.2010 20:16, schrieb Christoph Hellwig: > On Fri, Jul 16, 2010 at 06:17:36PM +0200, Kevin Wolf wrote: >> + buf = qemu_malloc(2048 * BDRV_SECTOR_SIZE); > > Please add a COMMIT_BUF_SIZE #define instead of the hardcoded 2048 in > various places. > >> for (i = 0; i < total_sectors;) { >> + if (drv->bdrv_is_allocated(bs, i, 2048, &n)) { >> >> + if (bdrv_read(bs, i, buf, n) != 0) { >> + ret = -EIO; >> + goto ro_cleanup; >> + } >> + >> + if (bdrv_write(bs->backing_hd, i, buf, n) != 0) { >> + ret = -EIO; >> + goto ro_cleanup; >> + } >> } >> + i += n; > > Maybe it's just me, but I'd prefer n getting a more descriptive name > (e.g. sector) and moving the increment of it into the for loop, e.g. > > for (sector = 0; sector < total_sectors; sector += n) { > if (!drv->bdrv_is_allocated(bs, i, 2048, &n)) > continue; > ... > } So you mean i should be renamed, not n, right? I'll change these points in v2. Kevin