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