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