[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/6] libqblock APIs
From: |
Wenchao Xia |
Subject: |
Re: [Qemu-devel] [PATCH 1/6] libqblock APIs |
Date: |
Tue, 04 Sep 2012 15:05:17 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 |
δΊ 2012-9-3 22:05, Paolo Bonzini ει:
Il 03/09/2012 15:56, Eric Blake ha scritto:
Exactly how does the *pnum argument work? This interface looks like it
isn't fully thought out yet. Either I want to know if a chunk of
sectors is allocated (I supply start and length of sectors to check),
regardless of how many sectors beyond that point are also allocated
(pnum makes no sense);
pnum makes sense if the [start, start+length) range includes both
allocated and unallocated sectors.
or I want to know how many sectors are allocated
from a given point (I supply start, and the function returns length, so
nb_sectors makes no sense).
About using byte offset instead of sector, I think sector is better,
because the allocation status is based on sector, all bytes data in a
sector would have the same status.
This operation could be O(number of blocks in disk) worst case, so it
makes sense to provide nb_sectors as an upper bound. nb_sectors is
typically dictated by the size of your buffer.
That said, QEMU's internal bdrv_is_allocated function does have one not
entirely appealing property: the block at start + *pnum might have the
same state as the block at start + *pnum - 1, even if *pnum < length.
We may want to work around this in libqblock, but we could also simply
document it.
Paolo
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors,int *pnum)
will the issue happen when nb_sectors > *pnum? if so it seems a bug,
because caller is asking a range of sectors's allocation status, and
*pnum did not reflect the real status.
Either way, I think you are supplying too
many parameters for how I envision checking for allocated sectors.
yes, it is a bit confusing, how about:
int qb_check_allocate_status(struct QBroker *broker,
struct QBlockState *qbs,
offset sector_start,
size_t sector_number,
size_t *pnum,
int *status)
user input sector_start and sector_number to ask check it in this range,
following parameter receive the status, return indicate exception.
--
Best Regards
Wenchao Xia
- [Qemu-devel] [PATCH 0/6] libqblock, qemu block layer library, Wenchao Xia, 2012/09/03
- Re: [Qemu-devel] [PATCH 1/6] libqblock APIs, Eric Blake, 2012/09/03
- Re: [Qemu-devel] [PATCH 1/6] libqblock APIs, Wenchao Xia, 2012/09/04
- Re: [Qemu-devel] [PATCH 1/6] libqblock APIs, Eric Blake, 2012/09/04
- Re: [Qemu-devel] [PATCH 1/6] libqblock APIs, Paolo Bonzini, 2012/09/04
Re: [Qemu-devel] [PATCH 1/6] libqblock APIs, Blue Swirl, 2012/09/03
[Qemu-devel] [PATCH 3/6] libqblock error handling, Wenchao Xia, 2012/09/03
[Qemu-devel] [PATCH 5/6] libqblock test example, Wenchao Xia, 2012/09/03