From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3s1T-0000PP-Q2 for qemu-devel@nongnu.org; Mon, 19 Apr 2010 10:32:27 -0400 Received: from [140.186.70.92] (port=48021 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3s1R-0000OW-Gx for qemu-devel@nongnu.org; Mon, 19 Apr 2010 10:32:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3s1H-0007Yb-Ih for qemu-devel@nongnu.org; Mon, 19 Apr 2010 10:32:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54238) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3s1H-0007YE-As for qemu-devel@nongnu.org; Mon, 19 Apr 2010 10:32:15 -0400 Message-ID: <4BCC694E.2080307@redhat.com> Date: Mon, 19 Apr 2010 16:31:42 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 2/2] block: Cache total_sectors to reduce bdrv_getlength calls References: <1271680452-24121-1-git-send-email-stefanha@linux.vnet.ibm.com> <1271680452-24121-2-git-send-email-stefanha@linux.vnet.ibm.com> <4BCC6453.2020605@redhat.com> In-Reply-To: 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: Stefan Hajnoczi Cc: Jan Kiszka , Christoph Hellwig , Stefan Hajnoczi , qemu-devel@nongnu.org Am 19.04.2010 16:26, schrieb Stefan Hajnoczi: > On Mon, Apr 19, 2010 at 3:10 PM, Kevin Wolf wrote: >>> @@ -416,9 +417,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, >>> } >>> >>> bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR); >>> - if (drv->bdrv_getlength) { >>> - bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; >>> - } >>> + bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; >> >> Does this hunk make a difference? If drv->bdrv_getlength == NULL, we'll >> just get back the current value. > > The if statement could be left as is. I removed it to reduce the > number of places where if (drv->bdrv_getlength) is explicitly checked. > If callers don't know the internals of bdrv_getlength() then it is > easier to extend it without auditing and changing callers. Makes sense, I'm not opposed to it. > Having said that, I did add an if (drv->bdrv_getlength) check into > bdrv_truncate... Well, you probably can't do much about it there. Kevin