From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8XHF-00038G-EY for qemu-devel@nongnu.org; Mon, 03 Sep 2012 10:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8XH7-0001Aa-Gk for qemu-devel@nongnu.org; Mon, 03 Sep 2012 10:05:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8XH7-0001A5-8o for qemu-devel@nongnu.org; Mon, 03 Sep 2012 10:05:13 -0400 Message-ID: <5044B912.7020405@redhat.com> Date: Mon, 03 Sep 2012 16:05:06 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1346663926-20188-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1346663926-20188-2-git-send-email-xiawenc@linux.vnet.ibm.com> <5044B720.5080205@redhat.com> In-Reply-To: <5044B720.5080205@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/6] libqblock APIs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, stefanha@gmail.com, aliguori@us.ibm.com, Wenchao Xia , qemu-devel@nongnu.org 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). 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 > Either way, I think you are supplying too > many parameters for how I envision checking for allocated sectors.