[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value |
Date: |
Fri, 19 Jul 2013 11:12:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 |
Il 19/07/2013 08:48, Peter Lieven ha scritto:
>> @@ -3040,7 +3040,10 @@ int64_t bdrv_get_block_status(BlockDriverState
>> *bs, int64_t sector_num,
>> int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t
>> sector_num,
>> int nb_sectors, int *pnum)
>> {
>> - return bdrv_get_block_status(bs, sector_num, nb_sectors, pnum);
>> + int64_t ret = bdrv_get_block_status(bs, sector_num, nb_sectors,
>> pnum);
>> + return
>> + (ret & BDRV_BLOCK_DATA) ||
>> + ((ret & BDRV_BLOCK_ZERO) && !bdrv_has_zero_init(bs));
>
> i do also not understand the "((ret & BDRV_BLOCK_ZERO) &&
> !bdrv_has_zero_init(bs))";
> if a block is unallocated and reads as zero, but the device lacks zero
> init, it is declared as allocated with this, isn't it?
Perhaps bdrv_has_zero_init(bs) could be replaced by bs->backing_hd. I'd
have to look at the code more closely.
But I suggest that you try using get_block_status (the function in
qemu-img.c) instead of bdrv_is_allocated in qemu-img.c. It will
probably simplify your code _and_ make it more efficient.
> for iscsi and host_device with lbprz==1 or discardzeroes respectively all
> blocks would return as allocated. is this wanted?
Paolo
- Re: [Qemu-devel] [PATCH v2 04/17] block: make bdrv_co_is_allocated static, (continued)
- [Qemu-devel] [PATCH v2 08/17] block: make bdrv_has_zero_init return false for copy-on-write-images, Paolo Bonzini, 2013/07/16
- [Qemu-devel] [PATCH v2 09/17] block: introduce bdrv_get_block_status API, Paolo Bonzini, 2013/07/16
- [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Paolo Bonzini, 2013/07/16
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Peter Lieven, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Peter Lieven, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Paolo Bonzini, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Peter Lieven, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Paolo Bonzini, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Peter Lieven, 2013/07/19
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Paolo Bonzini, 2013/07/20
- Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Peter Lieven, 2013/07/23
Re: [Qemu-devel] [PATCH v2 10/17] block: define get_block_status return value, Eric Blake, 2013/07/19
[Qemu-devel] [PATCH v2 11/17] block: return get_block_status data and flags for formats, Paolo Bonzini, 2013/07/16
[Qemu-devel] [PATCH v2 13/17] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO, Paolo Bonzini, 2013/07/16