[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 18/18] nbd: BLOCK_STATUS for standard get_block_
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-block] [PATCH 18/18] nbd: BLOCK_STATUS for standard get_block_status function: client part |
Date: |
Wed, 15 Feb 2017 18:04:37 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 09/02/2017 17:00, Eric Blake wrote:
>> + if (!client->block_status_ok) {
>> + *pnum = nb_sectors;
>> + ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
>> + if (bs->drv->protocol_name) {
This condition is always true, I think?
>> + ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num *
>> BDRV_SECTOR_SIZE);
>> + }
>> + return ret;
>> + }
> Looks like a sane fallback when we don't have anything more accurate.
>> +
>> + ret = nbd_client_co_cmd_block_status(bs, sector_num << BDRV_SECTOR_BITS,
>> + nb_sectors << BDRV_SECTOR_BITS,
>> + &extents, &nb_extents);
>> + if (ret < 0) {
>> + return ret;
>> + }
>> +
>> + *pnum = extents[0].length >> BDRV_SECTOR_BITS;
>> + ret = (extents[0].flags & NBD_STATE_HOLE ? 0 : BDRV_BLOCK_ALLOCATED) |
>> + (extents[0].flags & NBD_STATE_ZERO ? BDRV_BLOCK_ZERO : 0);
>> +
>> + if ((ret & BDRV_BLOCK_ALLOCATED) && !(ret & BDRV_BLOCK_ZERO)) {
>> + ret |= BDRV_BLOCK_DATA;
>> + }
You can always return BDRV_BLOCK_OFFSET_VALID here, too.
Paolo
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH 10/18] block/dirty-bitmap: add bdrv_load_dirty_bitmap, (continued)
- [Qemu-block] [PATCH 18/18] nbd: BLOCK_STATUS for standard get_block_status function: client part, Vladimir Sementsov-Ogievskiy, 2017/02/03
- [Qemu-block] [PATCH 01/18] nbd: rename NBD_REPLY_MAGIC to NBD_SIMPLE_REPLY_MAGIC, Vladimir Sementsov-Ogievskiy, 2017/02/03
- [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Vladimir Sementsov-Ogievskiy, 2017/02/03
- Re: [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/02/07
- Re: [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Vladimir Sementsov-Ogievskiy, 2017/02/09
- Re: [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/02/09
- Re: [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Vladimir Sementsov-Ogievskiy, 2017/02/10
- Re: [Qemu-block] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/02/13
- Re: [Qemu-block] [Qemu-devel] [PATCH 04/18] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/02/20
[Qemu-block] [PATCH 11/18] nbd: BLOCK_STATUS for bitmap export: server part, Vladimir Sementsov-Ogievskiy, 2017/02/03