From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=32826 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OZpSl-0002wZ-1M for qemu-devel@nongnu.org; Fri, 16 Jul 2010 14:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OZpSj-00088Y-PA for qemu-devel@nongnu.org; Fri, 16 Jul 2010 14:16:42 -0400 Received: from verein.lst.de ([213.95.11.210]:38022) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZpSj-00087P-BC for qemu-devel@nongnu.org; Fri, 16 Jul 2010 14:16:41 -0400 Date: Fri, 16 Jul 2010 20:16:33 +0200 From: Christoph Hellwig Subject: Re: [Qemu-devel] [PATCH] block: Change bdrv_commit to handle multiple sectors at once Message-ID: <20100716181633.GA29674@lst.de> References: <1279297056-13392-1-git-send-email-kwolf@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1279297056-13392-1-git-send-email-kwolf@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org 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; ... } Otherwise this looks good to me.