[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v6 12/24] block: Convert bdrv_get_block_status_a
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH v6 12/24] block: Convert bdrv_get_block_status_above() to bytes |
Date: |
Fri, 20 Oct 2017 10:22:56 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/20/2017 10:03 AM, Kevin Wolf wrote:
> Am 12.10.2017 um 05:47 hat Eric Blake geschrieben:
>> We are gradually moving away from sector-based interfaces, towards
>> byte-based. In the common case, allocation is unlikely to ever use
>> values that are not naturally sector-aligned, but it is possible
>> that byte-based values will let us be more precise about allocation
>> at the end of an unaligned file that can do byte-based access.
>>
>> int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
>> int64_t *pnum, int64_t *map, BlockDriverState **file)
>> {
>> - int64_t ret;
>> - int n;
>> -
>> - assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE));
>> - assert(pnum);
>> - /*
>> - * The contract allows us to return pnum smaller than bytes, even
>> - * if the next query would see the same status; we truncate the
>> - * request to avoid overflowing the driver's 32-bit interface.
>> - */
>> - bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);
>
> Is the limitation to BDRV_REQUEST_MAX_BYTES going away without being
> replaced by a new one in bdrv_co_block_status()? What protects us now
> from 32-bit truncation?
As of this patch, we have this 64-bit-clean call chain:
bdrv_block_status()
bdrv_block_status_above()
bdrv_common_block_status_above()
bdrv_block_status_above_co_entry()
bdrv_co_block_status_above()
bdrv_co_block_status()
which in turn has:
/*
* The contract allows us to return pnum smaller than bytes, even
* if the next query would see the same status; we truncate the
* request to avoid overflowing the driver's 32-bit interface.
*/
bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);
added earlier in 8/24.
At the end of series 3, the truncation prevention is still in place when
calling into the drivers, per the changes to bdrv_co_block_status() in
21/24.
Later, in series 4, all drivers are converted to 64-bit interfaces,
where the drivers are either made 64-bit clean, or do their own
truncation to 32 bits.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH v6 07/24] block: Convert bdrv_get_block_status() to bytes, (continued)
- [Qemu-block] [PATCH v6 08/24] block: Switch bdrv_co_get_block_status() to byte-based, Eric Blake, 2017/10/11
- [Qemu-block] [PATCH v6 09/24] block: Switch BdrvCoGetBlockStatusData to byte-based, Eric Blake, 2017/10/11
- [Qemu-block] [PATCH v6 10/24] block: Switch bdrv_common_block_status_above() to byte-based, Eric Blake, 2017/10/11
- [Qemu-block] [PATCH v6 11/24] block: Switch bdrv_co_get_block_status_above() to byte-based, Eric Blake, 2017/10/11
- [Qemu-block] [PATCH v6 12/24] block: Convert bdrv_get_block_status_above() to bytes, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 13/24] qemu-img: Simplify logic in img_compare(), Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 15/24] qemu-img: Add find_nonzero(), Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 14/24] qemu-img: Speed up compare on pre-allocated larger file, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 16/24] qemu-img: Drop redundant error message in compare, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 17/24] qemu-img: Change check_empty_sectors() to byte-based, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 18/24] qemu-img: Change compare_sectors() to be byte-based, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 20/24] qemu-img: Change img_compare() to be byte-based, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 19/24] qemu-img: Change img_rebase() to be byte-based, Eric Blake, 2017/10/11
[Qemu-block] [PATCH v6 22/24] block: Relax bdrv_aligned_preadv() assertion, Eric Blake, 2017/10/11