From patchwork Wed Mar 11 18:37:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uri Lublin X-Patchwork-Id: 11183 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2BIbupX017026 for ; Wed, 11 Mar 2009 18:37:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752805AbZCKSh3 (ORCPT ); Wed, 11 Mar 2009 14:37:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752295AbZCKSh3 (ORCPT ); Wed, 11 Mar 2009 14:37:29 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56862 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751385AbZCKSh1 (ORCPT ); Wed, 11 Mar 2009 14:37:27 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2BIbKhO030271; Wed, 11 Mar 2009 14:37:20 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2BIbKie019252; Wed, 11 Mar 2009 14:37:20 -0400 Received: from [10.35.1.187] (dhcp-1-187.tlv.redhat.com [10.35.1.187]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2BIbHUk016278; Wed, 11 Mar 2009 14:37:18 -0400 Message-ID: <49B804DD.6010608@redhat.com> Date: Wed, 11 Mar 2009 20:37:17 +0200 From: Uri Lublin User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Anthony Liguori CC: Avi Kivity , Jay Mann , kvm@vger.kernel.org, Uri Lublin , qemu-devel Subject: Re: Problems KVM-84 References: <49B79D50.4090300@redhat.com> <49B7C6BF.6030803@codemonkey.ws> In-Reply-To: <49B7C6BF.6030803@codemonkey.ws> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Anthony Liguori wrote: > Avi Kivity wrote: >> Jay Mann wrote: >>> Hi, >>> >>> I just downloaded built and installed kvm-84 on ubuntu Hardy x64 >>> 2.6.24-23- >>> server and I’m getting the following 2 problems that did not exists >>> in kvm-83. >>> >>> 1. The qemu emulater (bios screen) takes a long time to start (~10 >>> seconds), and subsequently Libvirt times out when I try to start a >>> guest VM from virsh. >> >> This is caused by qemu r6404: >> >> commit 5d4cbd78aa33f6d034a62207c99ad0b64af44621 >> Author: aliguori >> Date: Thu Jan 22 18:57:22 2009 +0000 >> >> block-qcow2: keep highest allocated byte (Uri Lublin) >> We want to know the highest written offset for qcow2 images. >> This gives a pretty good (and easy to calculate) estimation to how >> much more allocation can be done for the block device. >> It can be usefull for allocating more diskspace for that image >> (if possible, e.g. lvm) before we run out-of-disk-space >> Signed-off-by: Uri Lublin >> Signed-off-by: Anthony Liguori >> >> Scanning the file at startup is slow. We need to find a better way. > > Any quick ideas? Seems like this is broken by design. Unless we can > find a quick fix, I'm going to revert this in the stable tree. > > Regards, > > Anthony Liguori > We only need to scan the given filename (no backing files). We can pass a flag to qcow_open (bdrv_open of bs->backing_hd) specifying it's a backing file. (attached 2 patches). That makes things better for small images with big backing files. It does not fix the problem for very large images. A better solution may we to allocate a qcow2-extension to keep highest-alloc and num-free-bytes so we don't have to scan refcount table of the image upon open. With that solution qcow_create initializes them, qcow_open reads them and bdrv_close updates them. We can also add a qemu-img command to scan and update those values. Regards, Uri. From c618b293a64d1690105505d7cb28ba1ca8dd33c7 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Wed, 11 Mar 2009 20:18:23 +0200 Subject: [PATCH] block-qcow2: do not scan refcounts when opening a backing file It takes too long and is not needed. Signed-off-by: Uri Lublin --- qemu/block-qcow2.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 465dcd6..41cdbe9 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -276,7 +276,8 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) if (refcount_init(bs) < 0) goto fail; - scan_refcount(bs, &s->highest_alloc, &s->nc_free); + if ((flags & BDRV_O_BACKING) == 0) + scan_refcount(bs, &s->highest_alloc, &s->nc_free); /* read the backing file name */ if (header.backing_file_offset != 0) { -- 1.6.0.6