qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC V2 16/16] qapi: Return virtual block device deduplicat


From: Benoît Canet
Subject: [Qemu-devel] [RFC V2 16/16] qapi: Return virtual block device deduplication metrics in QMP
Date: Wed, 6 Feb 2013 13:32:19 +0100

---
 block.c |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/block.c b/block.c
index 50dab8e..fec29f4 100644
--- a/block.c
+++ b/block.c
@@ -2889,6 +2889,40 @@ BlockInfoList *qmp_query_block(Error **errp)
     return head;
 }
 
+static void bdrv_get_dedup_metrics(const BlockDriverState *bs,
+                                   BlockDeviceStats *stats)
+{
+    BlockDriverInfo bdi;
+
+    if (bdrv_get_info((BlockDriverState *) bs, &bdi) < 0) {
+        return;
+    }
+
+    if (!bdi.has_dedup) {
+        return;
+    }
+
+    stats->has_deduplication = true;
+    stats->deduplication = g_malloc0(sizeof(*stats->deduplication));
+    stats->deduplication->deduplicated_clusters =
+        bdi.dedup_metrics.deduplicated_clusters;
+    stats->deduplication->non_deduplicated_clusters =
+        bdi.dedup_metrics.non_deduplicated_clusters;
+    stats->deduplication->missing_data_reads =
+        bdi.dedup_metrics.missing_data_reads;
+    stats->deduplication->ram_hash_creations =
+        bdi.dedup_metrics.ram_hash_creations;
+    stats->deduplication->ram_hash_deletions =
+        bdi.dedup_metrics.ram_hash_deletions;
+    stats->deduplication->ram_usage =
+        bdi.dedup_metrics.ram_usage;
+    stats->deduplication->deleted_clusters =
+        bdi.dedup_metrics.deleted_clusters;
+    stats->deduplication->refcount_overflows =
+        bdi.dedup_metrics.refcount_overflows;
+    stats->deduplication->status = bdi.dedup_status;
+}
+
 BlockStats *bdrv_query_stats(const BlockDriverState *bs)
 {
     BlockStats *s;
@@ -2911,6 +2945,8 @@ BlockStats *bdrv_query_stats(const BlockDriverState *bs)
     s->stats->rd_total_time_ns = bs->total_time_ns[BDRV_ACCT_READ];
     s->stats->flush_total_time_ns = bs->total_time_ns[BDRV_ACCT_FLUSH];
 
+    bdrv_get_dedup_metrics(bs, s->stats);
+
     if (bs->file) {
         s->has_parent = true;
         s->parent = bdrv_query_stats(bs->file);
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]