qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH v6 18/20] vpc: Switch to .bdrv_co_b


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v6 18/20] vpc: Switch to .bdrv_co_block_status()
Date: Tue, 2 Jan 2018 14:30:37 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 12/28/2017 08:55 PM, Fam Zheng wrote:
> On Thu, 12/07 14:30, Eric Blake wrote:
>> We are gradually moving away from sector-based interfaces, towards
>> byte-based.  Update the vpc driver accordingly.  Drop the now-unused
>> get_sector_offset().
> 
> No get_sector_offset change in the patch any more, it was removed by
> 778b087e513ea6fdc525c5a194ff7c9b8d3f53cb.

Will tweak the commit message if I have reason to spin v7 (at least 9/20
had a real bug, which is probably easier for me to respin than to ask
the maintainer to adjust).

> 
>>
>> Signed-off-by: Eric Blake <address@hidden>
>>
>> ---

>> -    int64_t start, offset;
>> +    int64_t image_offset;
>>      bool allocated;
>> -    int64_t ret;
>> +    int ret;
>>      int n;
>>

>>      do {
>>          /* All sectors in a block are contiguous (without using the bitmap) 
>> */
>> -        n = ROUND_UP(sector_num + 1, s->block_size / BDRV_SECTOR_SIZE)
>> -          - sector_num;
>> -        n = MIN(n, nb_sectors);
>> +        n = ROUND_UP(offset + 1, s->block_size) - offset;
>> +        n = MIN(n, bytes);
> 
> Should 'n' be updated to int64_t to match the types of offset and bytes?

s->block_size is uint32_t, and a power of 2; therefore, rounding 'offset
+ 1' up to block size, then subtracting offset, can't exceed 32 bits.

But that's tricky to audit for; I'm not opposed to changing the type of
'n' to 64-bits if you think that is easier to read.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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