qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
@ 2012-03-15 12:13 Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Dong Xu Wang @ 2012-03-15 12:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang, stefanha

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
@ 2012-03-15 12:13 ` Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 3/4 v3] block: add dirty flag status to qemu-img Dong Xu Wang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dong Xu Wang @ 2012-03-15 12:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang, stefanha

From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>


Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 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.5.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 3/4 v3] block: add dirty flag status to qemu-img
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang
@ 2012-03-15 12:13 ` Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 4/4] block: track dirty flag status in qed Dong Xu Wang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dong Xu Wang @ 2012-03-15 12:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang, stefanha

From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>

Some block drivers can verify their image files are clean or not. So we can show
it while using "qemu-img info".

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 block.h    |    1 +
 qemu-img.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/block.h b/block.h
index 32e1e58..12219d0 100644
--- a/block.h
+++ b/block.h
@@ -15,6 +15,7 @@ typedef struct BlockDriverInfo {
     int cluster_size;
     /* offset at which the VM state can be saved (0 if not possible) */
     int64_t vm_state_offset;
+    bool is_dirty;
 } BlockDriverInfo;
 
 typedef struct BlockFragInfo {
diff --git a/qemu-img.c b/qemu-img.c
index 4de48ba..6a61ca8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1132,6 +1132,9 @@ static int img_info(int argc, char **argv)
         if (bdi.cluster_size != 0) {
             printf("cluster_size: %d\n", bdi.cluster_size);
         }
+        if (bdi.is_dirty) {
+            printf("cleanly shut down: no\n");
+        }
     }
     bdrv_get_backing_filename(bs, backing_filename, sizeof(backing_filename));
     if (backing_filename[0] != '\0') {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 4/4] block: track dirty flag status in qed
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 3/4 v3] block: add dirty flag status to qemu-img Dong Xu Wang
@ 2012-03-15 12:13 ` Dong Xu Wang
  2012-03-15 12:45 ` [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Stefan Hajnoczi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Dong Xu Wang @ 2012-03-15 12:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang, stefanha

From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>


Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 block/qed.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/block/qed.c b/block/qed.c
index a041d31..44b72aa 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1441,6 +1441,7 @@ static int bdrv_qed_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
 
     memset(bdi, 0, sizeof(*bdi));
     bdi->cluster_size = s->header.cluster_size;
+    bdi->is_dirty = s->header.features & QED_F_NEED_CHECK;
     return 0;
 }
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
                   ` (2 preceding siblings ...)
  2012-03-15 12:13 ` [Qemu-devel] [PATCH 4/4] block: track dirty flag status in qed 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
  5 siblings, 1 reply; 9+ messages in thread
From: Stefan Hajnoczi @ 2012-03-15 12:45 UTC (permalink / raw)
  To: Dong Xu Wang; +Cc: kwolf, qemu-devel

On Thu, Mar 15, 2012 at 08:13:31PM +0800, Dong Xu Wang wrote:
> 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(-)

A minor comment that doesn't require resending:

Please avoid introducing whitespace or reformatting changes in a patch
that makes other code changes.  Patch 1 changes whitespace in a place
that is not touched by the rest of your patch, so that change is not
essential and it's best to leave it out.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed
  2012-03-15 12:47 Dong Xu Wang
@ 2012-03-15 12:47 ` Dong Xu Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Dong Xu Wang @ 2012-03-15 12:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang, stefanha

From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>


Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 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.5.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
  2012-03-15 12:45 ` [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Stefan Hajnoczi
@ 2012-03-29 15:56   ` Stefan Hajnoczi
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2012-03-29 15:56 UTC (permalink / raw)
  To: kwolf; +Cc: Dong Xu Wang, qemu-devel, Stefan Hajnoczi

On Thu, Mar 15, 2012 at 12:45 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> On Thu, Mar 15, 2012 at 08:13:31PM +0800, Dong Xu Wang wrote:
>> 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(-)
>
> A minor comment that doesn't require resending:
>
> Please avoid introducing whitespace or reformatting changes in a patch
> that makes other code changes.  Patch 1 changes whitespace in a place
> that is not touched by the rest of your patch, so that change is not
> essential and it's best to leave it out.
>
> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Ping?

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
                   ` (3 preceding siblings ...)
  2012-03-15 12:45 ` [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Stefan Hajnoczi
@ 2012-03-29 16:00 ` Stefan Hajnoczi
  2012-04-02 16:13 ` Kevin Wolf
  5 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2012-03-29 16:00 UTC (permalink / raw)
  To: Dong Xu Wang; +Cc: kwolf, qemu-devel, stefanha

On Thu, Mar 15, 2012 at 12:13 PM, Dong Xu Wang
<wdongxu@linux.vnet.ibm.com> wrote:
> 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(-)

In the future please send a 0/4 email when sending a patch series:

git format-patch --cover-letter ...

The cover letter introduces the patch series and also acts as the
single place where reviewers can reply to say they are happy with the
series.

Kevin: my Reviewed-by: applies to the whole series.

Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img
  2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
                   ` (4 preceding siblings ...)
  2012-03-29 16:00 ` Stefan Hajnoczi
@ 2012-04-02 16:13 ` Kevin Wolf
  5 siblings, 0 replies; 9+ messages in thread
From: Kevin Wolf @ 2012-04-02 16:13 UTC (permalink / raw)
  To: Dong Xu Wang; +Cc: qemu-devel, stefanha

Am 15.03.2012 13:13, schrieb Dong Xu Wang:
> 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>

Thanks, applied all to the block branch.

Please make the subject line prefix more specific in future commits, I
changed it for this series. For example, don't write "block: foo in qed"
or "block: Add bar to qemu-img", but "qed: foo" and "qemu-img: Add bar".
The "block:" prefix is reserved for changes that are purely in the
generic block layer (mainly block.c, blockdev.c).

Kevin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-02 16:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 12:13 [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Dong Xu Wang
2012-03-15 12:13 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang
2012-03-15 12:13 ` [Qemu-devel] [PATCH 3/4 v3] block: add dirty flag status to qemu-img Dong Xu Wang
2012-03-15 12:13 ` [Qemu-devel] [PATCH 4/4] block: track dirty flag status in qed Dong Xu Wang
2012-03-15 12:45 ` [Qemu-devel] [PATCH 1/4 v3] block: add image fragmentation statistics to qemu-img Stefan Hajnoczi
2012-03-29 15:56   ` Stefan Hajnoczi
2012-03-29 16:00 ` Stefan Hajnoczi
2012-04-02 16:13 ` Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2012-03-15 12:47 Dong Xu Wang
2012-03-15 12:47 ` [Qemu-devel] [PATCH 2/4 v3] block: image fragmentation statistics for qed Dong Xu Wang

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).