[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to com
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage. |
Date: |
Wed, 6 Feb 2013 13:32:17 +0100 |
---
block/qcow2-dedup.c | 11 +++++++++++
block/qcow2.h | 18 ++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c
index 308b4f6..72ce1d7 100644
--- a/block/qcow2-dedup.c
+++ b/block/qcow2-dedup.c
@@ -1311,3 +1311,14 @@ void qcow2_dedup_close(BlockDriverState *bs)
{
qcow2_dedup_free(bs);
}
+
+void qcow2_dedup_update_metrics(BlockDriverState *bs)
+{
+ BDRVQcowState *s = bs->opaque;
+
+ uint64_t nb_hashs = s->dedup_metrics.ram_hash_creations -
+ s->dedup_metrics.ram_hash_deletions;
+
+ s->dedup_metrics.ram_usage = nb_hashs * sizeof(GTreeNode_Copy) * 2;
+ s->dedup_metrics.ram_usage += nb_hashs * sizeof(QCowHashNode);
+}
diff --git a/block/qcow2.h b/block/qcow2.h
index fc393d5..191b272 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -76,6 +76,23 @@
#define QCOW_STRATEGY_DISK (1 << 1)
#define QCOW_STRATEGY_RUNNING (1 << 2)
+/* This is an internal structure of glib gtree.c
+ * copy it here so we can compute it's size
+ * from glib/gtree.c in glib sources
+ */
+typedef struct _GTreeNode_Copy GTreeNode_Copy;
+
+struct _GTreeNode_Copy
+{
+ gpointer key; /* key for this node */
+ gpointer value; /* value stored at this node */
+ GTreeNode_Copy *left; /* left subtree */
+ GTreeNode_Copy *right; /* right subtree */
+ gint8 balance; /* height (right) - height (left) */
+ guint8 left_child;
+ guint8 right_child;
+};
+
typedef enum {
QCOW_HASH_SHA256 = 0,
QCOW_HASH_SHA3 = 1,
@@ -507,5 +524,6 @@ void qcow2_dedup_refcount_half_max_reached(BlockDriverState
*bs,
bool qcow2_dedup_is_running(BlockDriverState *bs);
int qcow2_dedup_init(BlockDriverState *bs);
void qcow2_dedup_close(BlockDriverState *bs);
+void qcow2_dedup_update_metrics(BlockDriverState *bs);
#endif
--
1.7.10.4
- [Qemu-devel] [RFC V2 00/16] QCOW2 deduplication metrics, Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 01/16] qcow2: Add qcow2_co_dedup_resume to restart deduplication., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 03/16] qcow2: Add deduplication metrics structures., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 05/16] qcow2: Collect unaligned writes missing data reads metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 06/16] qcow2: Collect deduplicated cluster metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 14/16] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage.,
Benoît Canet <=
- [Qemu-devel] [RFC V2 15/16] qcow2: returns deduplication metrics and status via bdrv_get_info(), Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 10/16] qcow2: Count cluster deleted metric, Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 11/16] qcow2: Count deduplication refcount overflow metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 07/16] qcow2: Collect undeduplicated cluster metric., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 02/16] qcow2: Enable the deduplication feature., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 04/16] qcow2: Initialize deduplication metrics., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 08/16] qcow2: Count QCowHashNode creation metrics., Benoît Canet, 2013/02/06
- [Qemu-devel] [RFC V2 09/16] qcow2: Count QCowHashNode removal from tree for metrics., Benoît Canet, 2013/02/06