[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocate
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated() |
Date: |
Mon, 22 Apr 2013 22:46:00 +0200 |
On Mon, Apr 22, 2013 at 5:18 PM, Liu Yuan <address@hidden> wrote:
> On 04/22/2013 11:03 PM, Stefan Hajnoczi wrote:
>> Imagine sector_num = 0 and nb_sectors = SD_DATA_OBJ_SIZE / BDRV_SECTOR_SIZE.
>>
>> start = 0
>> end = 1
>>
>> You don't want object 1, only object 0.
>
> Hmm, math, ouch. So nb_sectors include sector_num? What I mean is
>
> If [start, end] mean a range of sectors,so
>
> 1. nb_sectors = end - start + 1 (I assume this one)
> 2. nb_sectors = end - start (you meant this one?)
>
> which one is correct for .co_is_allocated?
The first sector is included in nb_sectors. Mathematically the range
is defined as [sector_num, sector_num + nb_sectors). Notice the
half-open interval, sector_num + nb_sectors is excluded. The last
included sector is sector_num + nb_sectors - 1.
You can look at qcow2's implementation, especially
count_contiguous_clusters() to double-check.
Stefan