qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [PATCH 2/2] block: Cache total_sectors to reduce bd


From: Kevin Wolf
Subject: Re: [Qemu-devel] Re: [PATCH 2/2] block: Cache total_sectors to reduce bdrv_getlength calls
Date: Mon, 19 Apr 2010 16:31:42 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4

Am 19.04.2010 16:26, schrieb Stefan Hajnoczi:
> On Mon, Apr 19, 2010 at 3:10 PM, Kevin Wolf <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]