From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz88T-0001Cd-8b for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:29:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uz88R-0005IB-Hs for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:29:57 -0400 Received: from mail-qe0-x230.google.com ([2607:f8b0:400d:c02::230]:47766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz88R-0005Hw-BI for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:29:55 -0400 Received: by mail-qe0-f48.google.com with SMTP id 2so506308qea.21 for ; Tue, 16 Jul 2013 09:29:55 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 16 Jul 2013 18:29:14 +0200 Message-Id: <1373992168-26043-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1373992168-26043-1-git-send-email-pbonzini@redhat.com> References: <1373992168-26043-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 03/17] cow: do not call bdrv_co_is_allocated List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pl@kamp.de, famz@redhat.com, stefanha@redhat.com As we change bdrv_is_allocated to gather more information from bs and bs->file, it will become a bit slower. It is still appropriate for online jobs, but not for reads/writes. Call the internal function instead. Signed-off-by: Paolo Bonzini --- block/cow.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/cow.c b/block/cow.c index 304e4c7..2994f8d 100644 --- a/block/cow.c +++ b/block/cow.c @@ -46,6 +46,9 @@ typedef struct BDRVCowState { int64_t cow_sectors_offset; } BDRVCowState; +static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, int *num_same); + static int cow_probe(const uint8_t *buf, int buf_size, const char *filename) { const struct cow_header_v2 *cow_header = (const void *)buf; @@ -212,7 +215,7 @@ static int coroutine_fn cow_read(BlockDriverState *bs, int64_t sector_num, int ret, n; while (nb_sectors > 0) { - if (bdrv_co_is_allocated(bs, sector_num, nb_sectors, &n)) { + if (cow_co_is_allocated(bs, sector_num, nb_sectors, &n)) { ret = bdrv_pread(bs->file, s->cow_sectors_offset + sector_num * 512, buf, n * 512); -- 1.8.3.1