From patchwork Wed Feb 6 10:58:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 218552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E9892C02EB for ; Wed, 6 Feb 2013 22:05:54 +1100 (EST) Received: from localhost ([::1]:58843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U32jl-00080V-7m for incoming@patchwork.ozlabs.org; Wed, 06 Feb 2013 06:00:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U32if-0005xN-De for qemu-devel@nongnu.org; Wed, 06 Feb 2013 06:00:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U32iK-0002jR-BY for qemu-devel@nongnu.org; Wed, 06 Feb 2013 05:59:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U32iK-0002jB-2n for qemu-devel@nongnu.org; Wed, 06 Feb 2013 05:58:52 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r16Awp24011524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Feb 2013 05:58:51 -0500 Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r16Awoxg025997; Wed, 6 Feb 2013 05:58:50 -0500 From: Stefan Hajnoczi To: Date: Wed, 6 Feb 2013 11:58:37 +0100 Message-Id: <1360148318-26988-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1360148318-26988-1-git-send-email-stefanha@redhat.com> References: <1360148318-26988-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , fsimonce@redhat.com, Stefan Hajnoczi , crobinso@redhat.com Subject: [Qemu-devel] [PATCH v2 4/5] qemu-img: add compressed clusters to BlockFragInfo X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Show how many clusters are compressed. This can be used to monitor how many compressed clusters remain and whether to recompress the image. Suggested-by: Cole Robinson Signed-off-by: Stefan Hajnoczi --- include/block/block.h | 1 + qemu-img.c | 5 +++-- tests/qemu-iotests/026 | 6 +++--- tests/qemu-iotests/036 | 2 +- tests/qemu-iotests/039 | 2 +- tests/qemu-iotests/044.out | 1 + tests/qemu-iotests/common.rc | 6 +++--- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 5c3b911..24db852 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -24,6 +24,7 @@ typedef struct BlockFragInfo { uint64_t allocated_clusters; uint64_t total_clusters; uint64_t fragmented_clusters; + uint64_t compressed_clusters; } BlockFragInfo; typedef struct QEMUSnapshotInfo { diff --git a/qemu-img.c b/qemu-img.c index 167d65f..fc98a93 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -471,10 +471,11 @@ static int img_check(int argc, char **argv) if (bfi->total_clusters != 0 && bfi->allocated_clusters != 0) { printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, " - "%0.2f%% fragmented\n", + "%0.2f%% fragmented, %0.2f%% compressed clusters\n", bfi->allocated_clusters, bfi->total_clusters, bfi->allocated_clusters * 100.0 / bfi->total_clusters, - bfi->fragmented_clusters * 100.0 / bfi->allocated_clusters); + bfi->fragmented_clusters * 100.0 / bfi->allocated_clusters, + bfi->compressed_clusters * 100.0 / bfi->allocated_clusters); } bdrv_delete(bs); diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index 1602ccd..32c6d32 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -102,7 +102,7 @@ if [ "$event" == "l2_load" ]; then $QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io fi -$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" +_check_test_img | grep -v "refcount=1 reference=0" done done @@ -147,7 +147,7 @@ echo echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" $QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io -$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" +_check_test_img | grep -v "refcount=1 reference=0" done done @@ -186,7 +186,7 @@ echo echo "Event: $event; errno: $errno; imm: $imm; once: $once" $QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io -$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" +_check_test_img | grep -v "refcount=1 reference=0" done done diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 index 329533e..3c76d89 100755 --- a/tests/qemu-iotests/036 +++ b/tests/qemu-iotests/036 @@ -59,7 +59,7 @@ _make_test_img 64M echo echo === Repair image === echo -$QEMU_IMG check -r all $TEST_IMG +_check_test_img -r all ./qcow2.py $TEST_IMG dump-header # success, all done diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index c5ae806..ae35175 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -86,7 +86,7 @@ $QEMU_IO -r -c "read -P 0x5a 0 512" $TEST_IMG | _filter_qemu_io echo echo "== Repairing the image file must succeed ==" -$QEMU_IMG check -r all $TEST_IMG +_check_test_img -r all # The dirty bit must not be set ./qcow2.py $TEST_IMG dump-header | grep incompatible_features diff --git a/tests/qemu-iotests/044.out b/tests/qemu-iotests/044.out index 7a40071..c58c7d5 100644 --- a/tests/qemu-iotests/044.out +++ b/tests/qemu-iotests/044.out @@ -1,4 +1,5 @@ No errors were found on the image. +7292415/8391499= 86.90% allocated, 0.00% fragmented, 0.00% compressed clusters . ---------------------------------------------------------------------- Ran 1 tests diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index aef5f52..ad1a9f2 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -161,9 +161,9 @@ _cleanup_test_img() _check_test_img() { - $QEMU_IMG check -f $IMGFMT $TEST_IMG 2>&1 | \ - grep -v "fragmented$" | \ - sed -e 's/qemu-img\: This image format does not support checks/No errors were found on the image./' + $QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \ + sed -e '/allocated.*fragmented.*compressed clusters/d' \ + -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' } _img_info()