[Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Liu Yuan
From: Liu Yuan tailai...@taobao.com Cc: MORITA Kazutaka morita.kazut...@lab.ntt.co.jp Cc: Kevin Wolf kw...@redhat.com Cc: Stefan Hajnoczi stefa...@redhat.com Signed-off-by: Liu Yuan tailai...@taobao.com --- block/sheepdog.c | 36 1 file changed, 36

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Stefan Hajnoczi
On Mon, Apr 22, 2013 at 02:59:10PM +0800, Liu Yuan wrote: +static coroutine_fn int +sd_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, + int *pnum) +{ +BDRVSheepdogState *s = bs-opaque; +SheepdogInode *inode = s-inode; +unsigned long

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Liu Yuan
On 04/22/2013 08:00 PM, Stefan Hajnoczi wrote: On Mon, Apr 22, 2013 at 02:59:10PM +0800, Liu Yuan wrote: +static coroutine_fn int +sd_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, + int *pnum) +{ +BDRVSheepdogState *s = bs-opaque; +

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Stefan Hajnoczi
On Mon, Apr 22, 2013 at 08:10:58PM +0800, Liu Yuan wrote: On 04/22/2013 08:00 PM, Stefan Hajnoczi wrote: On Mon, Apr 22, 2013 at 02:59:10PM +0800, Liu Yuan wrote: +static coroutine_fn int +sd_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, +

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Liu Yuan
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

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Stefan Hajnoczi
On Mon, Apr 22, 2013 at 5:18 PM, Liu Yuan namei.u...@gmail.com 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

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: implement .bdrv_co_is_allocated()

2013-04-22 Thread Liu Yuan
On 04/23/2013 04:46 AM, Stefan Hajnoczi wrote: 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 -