From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Dong Xu Wang <wdongxu@linux.vnet.ibm.com>,
stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
Date: Thu, 15 Mar 2012 20:47:19 +0800 [thread overview]
Message-ID: <1331815641-4789-1-git-send-email-wdongxu@linux.vnet.ibm.com> (raw)
From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Discussion can be found at:
http://patchwork.ozlabs.org/patch/128730/
This patch add image fragmentation statistics while using qemu-img check.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
block.h | 7 +++++++
qemu-img.c | 9 ++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/block.h b/block.h
index 415bb17..32e1e58 100644
--- a/block.h
+++ b/block.h
@@ -17,6 +17,12 @@ typedef struct BlockDriverInfo {
int64_t vm_state_offset;
} BlockDriverInfo;
+typedef struct BlockFragInfo {
+ uint64_t allocated_clusters;
+ uint64_t total_clusters;
+ uint64_t fragmented_clusters;
+} BlockFragInfo;
+
typedef struct QEMUSnapshotInfo {
char id_str[128]; /* unique snapshot id */
/* the following fields are informative. They are not needed for
@@ -175,6 +181,7 @@ typedef struct BdrvCheckResult {
int corruptions;
int leaks;
int check_errors;
+ BlockFragInfo bfi;
} BdrvCheckResult;
int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res);
diff --git a/qemu-img.c b/qemu-img.c
index 0e48b35..4de48ba 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -428,6 +428,13 @@ static int img_check(int argc, char **argv)
}
}
+ if (result.bfi.total_clusters != 0 && result.bfi.allocated_clusters != 0) {
+ printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, %0.2f%% fragmented\n",
+ result.bfi.allocated_clusters, result.bfi.total_clusters,
+ result.bfi.allocated_clusters * 100.0 / result.bfi.total_clusters,
+ result.bfi.fragmented_clusters * 100.0 / result.bfi.allocated_clusters);
+ }
+
bdrv_delete(bs);
if (ret < 0 || result.check_errors) {
@@ -716,7 +723,7 @@ static int img_convert(int argc, char **argv)
ret = -1;
goto out;
}
-
+
qemu_progress_init(progress, 2.0);
qemu_progress_print(0, 100);
--
1.7.5.4
next reply other threads:[~2012-03-15 12:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 12:47 Dong Xu Wang [this message]
2012-03-15 12:47 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang
2012-03-15 12:47 ` [Qemu-devel] [PATCH 3/4 v3] block: add dirty flag status to qemu-img Dong Xu Wang
-- strict thread matches above, loose matches on Subject: below --
2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics " Dong Xu Wang
2012-03-15 12:45 ` Stefan Hajnoczi
2012-03-29 15:56 ` Stefan Hajnoczi
2012-03-29 16:00 ` Stefan Hajnoczi
2012-04-02 16:13 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331815641-4789-1-git-send-email-wdongxu@linux.vnet.ibm.com \
--to=wdongxu@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).