Blob Blame History Raw
From 0fa384d67b0866e10fc3f73a189f1409b9352425 Mon Sep 17 00:00:00 2001
From: N Balachandran <nbalacha@redhat.com>
Date: Tue, 25 Jul 2017 14:28:00 +0530
Subject: [PATCH 573/576] cluster/dht: Update size processed for non-migrated
 files

The size of non-migrated files was not added to the
size_processed causing incorrect rebalance estimate
calculations. This has been fixed.

> BUG: 1467209
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
> Reviewed-on: https://review.gluster.org/17867
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>

Change-Id: I9f338c44da22b856e9fdc6dc558f732ae9a22f15
BUG: 1460936
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/113512
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/dht/src/dht-rebalance.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 9ae4062..39005f0 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -2587,6 +2587,7 @@ gf_defrag_migrate_single_file (void *opaque)
         int                      fop_errno      = 0;
         gf_dht_migrate_data_type_t rebal_type   = GF_DHT_MIGRATE_DATA;
         char                     value[MAX_REBAL_TYPE_SIZE]    = {0,};
+        struct iatt             *iatt_ptr       = NULL;
 
         rebal_entry = (struct dht_container *)opaque;
         if (!rebal_entry) {
@@ -2606,6 +2607,7 @@ gf_defrag_migrate_single_file (void *opaque)
         migrate_data = rebal_entry->migrate_data;
 
         entry = rebal_entry->df_entry;
+        iatt_ptr = &entry->d_stat;
 
         if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
                 ret = -1;
@@ -2661,6 +2663,8 @@ gf_defrag_migrate_single_file (void *opaque)
                 goto out;
         }
 
+        iatt_ptr = &iatt;
+
         hashed_subvol = dht_subvol_get_hashed (this, &entry_loc);
         if (!hashed_subvol) {
                 gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -2726,7 +2730,6 @@ gf_defrag_migrate_single_file (void *opaque)
                         LOCK (&defrag->lock);
                         {
                                 defrag->skipped += 1;
-                                defrag->size_processed += iatt.ia_size;
                         }
                         UNLOCK (&defrag->lock);
                 } else if (fop_errno == ENOTSUP) {
@@ -2735,7 +2738,6 @@ gf_defrag_migrate_single_file (void *opaque)
                         LOCK (&defrag->lock);
                         {
                                 defrag->skipped += 1;
-                                defrag->size_processed += iatt.ia_size;
                         }
                         UNLOCK (&defrag->lock);
                 } else if (fop_errno != EEXIST) {
@@ -2746,7 +2748,6 @@ gf_defrag_migrate_single_file (void *opaque)
                         LOCK (&defrag->lock);
                         {
                                 defrag->total_failures += 1;
-                                defrag->size_processed += iatt.ia_size;
                         }
                         UNLOCK (&defrag->lock);
 
@@ -2771,7 +2772,6 @@ gf_defrag_migrate_single_file (void *opaque)
         {
                 defrag->total_files += 1;
                 defrag->total_data += iatt.ia_size;
-                defrag->size_processed += iatt.ia_size;
         }
         UNLOCK (&defrag->lock);
 
@@ -2790,6 +2790,13 @@ out:
                 STACK_DESTROY (statfs_frame->root);
         }
 
+        if (iatt_ptr) {
+                LOCK (&defrag->lock);
+                {
+                        defrag->size_processed += iatt_ptr->ia_size;
+                }
+                UNLOCK (&defrag->lock);
+        }
         loc_wipe (&entry_loc);
 
         return ret;
@@ -5035,8 +5042,6 @@ log:
                 "Files migrated: %"PRIu64", size: %"
                 PRIu64", lookups: %"PRIu64", failures: %"PRIu64", skipped: "
                 "%"PRIu64, files, size, lookup, failures, skipped);
-
-
 out:
         return 0;
 }
-- 
1.8.3.1