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