qemu-block
[Top][All Lists]
Advanced

[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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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