|
Vojtech Trefny |
22b10e |
From 940346f14ee5644f2593817b4196c18de8a713f0 Mon Sep 17 00:00:00 2001
|
|
Vojtech Trefny |
22b10e |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
Vojtech Trefny |
22b10e |
Date: Mon, 22 Nov 2021 14:16:02 +0100
|
|
Vojtech Trefny |
22b10e |
Subject: [PATCH] vdo_stats: Default to 100 % savings for invalid savings
|
|
Vojtech Trefny |
22b10e |
values
|
|
Vojtech Trefny |
22b10e |
|
|
Vojtech Trefny |
22b10e |
We are currently using "-1" when VDO logical_blocks_used is 0
|
|
Vojtech Trefny |
22b10e |
which doesn't match the LVM logic which returns 100 so to make
|
|
Vojtech Trefny |
22b10e |
both values in vdo_info and vdo_stats equal we should return 100
|
|
Vojtech Trefny |
22b10e |
in this case too.
|
|
Vojtech Trefny |
22b10e |
---
|
|
Vojtech Trefny |
22b10e |
src/plugins/vdo_stats.c | 2 +-
|
|
Vojtech Trefny |
22b10e |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Vojtech Trefny |
22b10e |
|
|
Vojtech Trefny |
22b10e |
diff --git a/src/plugins/vdo_stats.c b/src/plugins/vdo_stats.c
|
|
Vojtech Trefny |
22b10e |
index 3ec2d60..f3f0390 100644
|
|
Vojtech Trefny |
22b10e |
--- a/src/plugins/vdo_stats.c
|
|
Vojtech Trefny |
22b10e |
+++ b/src/plugins/vdo_stats.c
|
|
Vojtech Trefny |
22b10e |
@@ -96,7 +96,7 @@ static void add_block_stats (GHashTable *stats) {
|
|
Vojtech Trefny |
22b10e |
g_hash_table_replace (stats, g_strdup ("oneKBlocksUsed"), g_strdup_printf ("%"G_GINT64_FORMAT, (data_blocks_used + overhead_blocks_used) * block_size / 1024));
|
|
Vojtech Trefny |
22b10e |
g_hash_table_replace (stats, g_strdup ("oneKBlocksAvailable"), g_strdup_printf ("%"G_GINT64_FORMAT, (physical_blocks - data_blocks_used - overhead_blocks_used) * block_size / 1024));
|
|
Vojtech Trefny |
22b10e |
g_hash_table_replace (stats, g_strdup ("usedPercent"), g_strdup_printf ("%.0f", 100.0 * (gfloat) (data_blocks_used + overhead_blocks_used) / (gfloat) physical_blocks + 0.5));
|
|
Vojtech Trefny |
22b10e |
- savings = (logical_blocks_used > 0) ? (gint64) (100.0 * (gfloat) (logical_blocks_used - data_blocks_used) / (gfloat) logical_blocks_used) : -1;
|
|
Vojtech Trefny |
22b10e |
+ savings = (logical_blocks_used > 0) ? (gint64) (100.0 * (gfloat) (logical_blocks_used - data_blocks_used) / (gfloat) logical_blocks_used) : 100;
|
|
Vojtech Trefny |
22b10e |
g_hash_table_replace (stats, g_strdup ("savings"), g_strdup_printf ("%"G_GINT64_FORMAT, savings));
|
|
Vojtech Trefny |
22b10e |
if (savings >= 0)
|
|
Vojtech Trefny |
22b10e |
g_hash_table_replace (stats, g_strdup ("savingPercent"), g_strdup_printf ("%"G_GINT64_FORMAT, savings));
|
|
Vojtech Trefny |
22b10e |
--
|
|
Vojtech Trefny |
22b10e |
2.31.1
|
|
Vojtech Trefny |
22b10e |
|