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