From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFphl-0005c1-0r for qemu-devel@nongnu.org; Thu, 05 Apr 2012 12:38:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFphZ-00034I-Lo for qemu-devel@nongnu.org; Thu, 05 Apr 2012 12:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFphZ-00033H-Dl for qemu-devel@nongnu.org; Thu, 05 Apr 2012 12:38:25 -0400 From: Kevin Wolf Date: Thu, 5 Apr 2012 17:52:07 +0200 Message-Id: <1333641144-13612-30-git-send-email-kwolf@redhat.com> In-Reply-To: <1333641144-13612-1-git-send-email-kwolf@redhat.com> References: <1333641144-13612-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 29/46] qed: image fragmentation statistics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Dong Xu Wang Signed-off-by: Dong Xu Wang Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qed-check.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/block/qed-check.c b/block/qed-check.c index e4a49ce..94327ff 100644 --- a/block/qed-check.c +++ b/block/qed-check.c @@ -68,6 +68,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) { BDRVQEDState *s = check->s; unsigned int i, num_invalid = 0; + uint64_t last_offset = 0; for (i = 0; i < s->table_nelems; i++) { uint64_t offset = table->offsets[i]; @@ -76,6 +77,11 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) qed_offset_is_zero_cluster(offset)) { continue; } + check->result->bfi.allocated_clusters++; + if (last_offset && (last_offset + s->header.cluster_size != offset)) { + check->result->bfi.fragmented_clusters++; + } + last_offset = offset; /* Detect invalid cluster offset */ if (!qed_check_cluster_offset(s, offset)) { @@ -200,6 +206,9 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix) check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) * sizeof(check.used_clusters[0])); + check.result->bfi.total_clusters = + (s->header.image_size + s->header.cluster_size - 1) / + s->header.cluster_size; ret = qed_check_l1_table(&check, s->l1_table); if (ret == 0) { /* Only check for leaks if entire image was scanned successfully */ -- 1.7.6.5