17b94a
From 9be255f76c78fcbbda1e3a72eb2e99d3aface53e Mon Sep 17 00:00:00 2001
17b94a
From: Sanju Rakonde <srakonde@redhat.com>
17b94a
Date: Wed, 16 Oct 2019 23:26:03 +0530
17b94a
Subject: [PATCH 322/335] glusterd: display correct rebalance data size after
17b94a
 glusterd restart
17b94a
17b94a
Problem: After completion of rebalance, if glusterd is restarted,
17b94a
rebalance status displays wrong rebalance data size in its output.
17b94a
17b94a
Cause: While glusterd restoring the information from /var/lib/glusterd/
17b94a
into its memory, glusterd fetches rebalance_data from
17b94a
/var/lib/glusterd/vols/volname/node_state.info. This value is
17b94a
converted into an integer using atoi(), which is returning
17b94a
incorrect value for larger values.
17b94a
17b94a
Solution: use sscanf() instead of atoi() to convert string to
17b94a
integer(in this case it is unsigned long)
17b94a
17b94a
> upstream patch: https://review.gluster.org/#/c/glusterfs/+/23560/
17b94a
> fixes: bz#1762438
17b94a
> Change-Id: Icbdb096919612b4a1d6fb0e315f09d38900abf4e
17b94a
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
17b94a
17b94a
BUG: 1761486
17b94a
Change-Id: Icbdb096919612b4a1d6fb0e315f09d38900abf4e
17b94a
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/185752
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 xlators/mgmt/glusterd/src/glusterd-store.c | 10 +++++-----
17b94a
 1 file changed, 5 insertions(+), 5 deletions(-)
17b94a
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
17b94a
index 8a10eb8..b3b5ee9 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
17b94a
@@ -2974,19 +2974,19 @@ glusterd_store_retrieve_node_state(glusterd_volinfo_t *volinfo)
17b94a
             volinfo->rebal.op = atoi(value);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_REB_FILES))) {
17b94a
-            volinfo->rebal.rebalance_files = atoi(value);
17b94a
+            sscanf(value, "%" PRIu64, &volinfo->rebal.rebalance_files);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_SIZE))) {
17b94a
-            volinfo->rebal.rebalance_data = atoi(value);
17b94a
+            sscanf(value, "%" PRIu64, &volinfo->rebal.rebalance_data);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_SCANNED))) {
17b94a
-            volinfo->rebal.lookedup_files = atoi(value);
17b94a
+            sscanf(value, "%" PRIu64, &volinfo->rebal.lookedup_files);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_FAILURES))) {
17b94a
-            volinfo->rebal.rebalance_failures = atoi(value);
17b94a
+            sscanf(value, "%" PRIu64, &volinfo->rebal.rebalance_failures);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_SKIPPED))) {
17b94a
-            volinfo->rebal.skipped_files = atoi(value);
17b94a
+            sscanf(value, "%" PRIu64, &volinfo->rebal.skipped_files);
17b94a
         } else if (!strncmp(key, GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME,
17b94a
                             SLEN(GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME))) {
17b94a
             volinfo->rebal.rebalance_time = atoi(value);
17b94a
-- 
17b94a
1.8.3.1
17b94a