[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH v4 07/23] block: Convert bdrv_get_b
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH v4 07/23] block: Convert bdrv_get_block_status() to bytes |
Date: |
Tue, 26 Sep 2017 14:57:21 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 09/26/2017 02:39 PM, John Snow wrote:
>> -int64_t bdrv_get_block_status(BlockDriverState *bs,
>> - int64_t sector_num,
>> - int nb_sectors, int *pnum,
>> - BlockDriverState **file)
>> +int64_t bdrv_block_status(BlockDriverState *bs,
>> + int64_t offset, int64_t bytes, int64_t *pnum,
>> + BlockDriverState **file)
>> {
>> - return bdrv_get_block_status_above(bs, backing_bs(bs),
>> - sector_num, nb_sectors, pnum, file);
>> + int64_t ret;
>> + int n;
>> +
>> + assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE));
>> + bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);
>> + ret = bdrv_get_block_status_above(bs, backing_bs(bs),
>> + offset >> BDRV_SECTOR_BITS,
>> + bytes >> BDRV_SECTOR_BITS, &n, file);
>> + if (pnum) {
>> + *pnum = n * BDRV_SECTOR_SIZE;
>> + }
>
> Is it safe to truncate the request in the event that the caller did not
> provide a pnum target? that is, how will they know for what range we are
> answering?
Hmm. I think I have some rebase cruft here. At one point, I was playing
with the idea of allowing pnum == NULL for ALL get_status() callers,
similar to the existing block/vvfat.c:cluster_was_modified():
block/vvfat.c: res = bdrv_is_allocated(s->qcow->bs,
block/vvfat.c- (offset + i) *
BDRV_SECTOR_SIZE,
block/vvfat.c-
BDRV_SECTOR_SIZE, NULL);
but looking further, only bdrv_is_allocated() (and NOT
bdrv_[get_]block_status) is ever used in that manner. Or, in terms of
the 'mapping' variable, a NULL pnum only makes sense when mapping ==
false. So the conditional on 'if (pnum)' should be dropped here.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [Qemu-devel] [PATCH v4 03/23] block: Make bdrv_round_to_clusters() signature more useful, (continued)
- [Qemu-block] [PATCH v4 05/23] block: Switch bdrv_make_zero() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 04/23] qcow2: Switch is_zero_sectors() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 06/23] qemu-img: Switch get_block_status() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 07/23] block: Convert bdrv_get_block_status() to bytes, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 10/23] block: Switch bdrv_common_block_status_above() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 09/23] block: Switch BdrvCoGetBlockStatusData to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 08/23] block: Switch bdrv_co_get_block_status() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 11/23] block: Switch bdrv_co_get_block_status_above() to byte-based, Eric Blake, 2017/09/13
- [Qemu-block] [PATCH v4 13/23] qemu-img: Simplify logic in img_compare(), Eric Blake, 2017/09/13