Blame SOURCES/0006-Fix-vdo-stats-calculation.patch

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