74b1de
From f293f7ac2f75c58d81da1229b484eb530b7083b5 Mon Sep 17 00:00:00 2001
74b1de
From: Sunny Kumar <sunkumar@redhat.com>
74b1de
Date: Fri, 20 Sep 2019 09:39:12 +0530
74b1de
Subject: [PATCH 299/302] geo-rep: performance improvement while syncing
74b1de
 renames with existing gfid
74b1de
74b1de
Problem:
74b1de
The bug[1] addresses issue of data inconsistency when handling RENAME with
74b1de
existing destination. This fix requires some performance tuning considering
74b1de
this issue occurs in heavy rename workload.
74b1de
74b1de
Solution:
74b1de
If distribution count for master volume is one do not verify op's on
74b1de
master and go ahead with rename.
74b1de
74b1de
The performance improvement with this patch can only be observed if
74b1de
master volume has distribution count one.
74b1de
74b1de
[1]. https://bugzilla.redhat.com/show_bug.cgi?id=1694820
74b1de
Backport of:
74b1de
74b1de
    >fixes: bz#1753857
74b1de
    >Change-Id: I8e9bcd575e7e35f40f9f78b7961c92dee642f47b
74b1de
    >Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
74b1de
74b1de
Upstream Patch:
74b1de
    https://review.gluster.org/#/c/glusterfs/+/23459/
74b1de
74b1de
BUG: 1726000
74b1de
Change-Id: I8e9bcd575e7e35f40f9f78b7961c92dee642f47b
74b1de
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
74b1de
Reviewed-on: https://code.engineering.redhat.com/gerrit/181893
74b1de
Tested-by: RHGS Build Bot <nigelb@redhat.com>
74b1de
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
74b1de
---
74b1de
 geo-replication/gsyncd.conf.in           |  5 +++++
74b1de
 geo-replication/syncdaemon/gsyncd.py     |  2 ++
74b1de
 geo-replication/syncdaemon/monitor.py    |  2 ++
74b1de
 geo-replication/syncdaemon/resource.py   | 13 +++++++++++--
74b1de
 geo-replication/syncdaemon/syncdutils.py | 11 +++++++++++
74b1de
 5 files changed, 31 insertions(+), 2 deletions(-)
74b1de
74b1de
diff --git a/geo-replication/gsyncd.conf.in b/geo-replication/gsyncd.conf.in
74b1de
index 5ebd57a..9155cd8 100644
74b1de
--- a/geo-replication/gsyncd.conf.in
74b1de
+++ b/geo-replication/gsyncd.conf.in
74b1de
@@ -23,6 +23,11 @@ configurable=false
74b1de
 type=int
74b1de
 value=1
74b1de
 
74b1de
+[master-distribution-count]
74b1de
+configurable=false
74b1de
+type=int
74b1de
+value=1
74b1de
+
74b1de
 [glusterd-workdir]
74b1de
 value = @GLUSTERD_WORKDIR@
74b1de
 
74b1de
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
74b1de
index a4c6f32..6ae5269 100644
74b1de
--- a/geo-replication/syncdaemon/gsyncd.py
74b1de
+++ b/geo-replication/syncdaemon/gsyncd.py
74b1de
@@ -134,6 +134,8 @@ def main():
74b1de
                    help="Directory where Gluster binaries exist on slave")
74b1de
     p.add_argument("--slave-access-mount", action="store_true",
74b1de
                    help="Do not lazy umount the slave volume")
74b1de
+    p.add_argument("--master-dist-count", type=int,
74b1de
+                   help="Master Distribution count")
74b1de
 
74b1de
     # Status
74b1de
     p = sp.add_parser("status")
74b1de
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
74b1de
index 234f3f1..236afe7 100644
74b1de
--- a/geo-replication/syncdaemon/monitor.py
74b1de
+++ b/geo-replication/syncdaemon/monitor.py
74b1de
@@ -37,6 +37,8 @@ def get_subvol_num(brick_idx, vol, hot):
74b1de
     tier = vol.is_tier()
74b1de
     disperse_count = vol.disperse_count(tier, hot)
74b1de
     replica_count = vol.replica_count(tier, hot)
74b1de
+    distribute_count = vol.distribution_count(tier, hot)
74b1de
+    gconf.setconfig("master-distribution-count", distribute_count)
74b1de
 
74b1de
     if (tier and not hot):
74b1de
         brick_idx = brick_idx - vol.get_hot_bricks_count(tier)
74b1de
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
74b1de
index b16db60..189d8a1 100644
74b1de
--- a/geo-replication/syncdaemon/resource.py
74b1de
+++ b/geo-replication/syncdaemon/resource.py
74b1de
@@ -377,6 +377,7 @@ class Server(object):
74b1de
     def entry_ops(cls, entries):
74b1de
         pfx = gauxpfx()
74b1de
         logging.debug('entries: %s' % repr(entries))
74b1de
+        dist_count = rconf.args.master_dist_count
74b1de
 
74b1de
         def entry_purge(op, entry, gfid, e, uid, gid):
74b1de
             # This is an extremely racy code and needs to be fixed ASAP.
74b1de
@@ -686,9 +687,15 @@ class Server(object):
74b1de
                                             raise
74b1de
                                 else:
74b1de
                                     raise
74b1de
-                        elif not matching_disk_gfid(gfid, en):
74b1de
+                        elif not matching_disk_gfid(gfid, en) and dist_count > 1:
74b1de
                             collect_failure(e, EEXIST, uid, gid, True)
74b1de
                         else:
74b1de
+                            # We are here which means matching_disk_gfid for
74b1de
+                            # both source and destination has returned false
74b1de
+                            # and distribution count for master vol is greater
74b1de
+                            # then one. Which basically says both the source and
74b1de
+                            # destination exist and not hardlinks.
74b1de
+                            # So we are safe to go ahead with rename here.
74b1de
                             rename_with_disk_gfid_confirmation(gfid, entry, en,
74b1de
                                                                uid, gid)
74b1de
             if blob:
74b1de
@@ -1409,7 +1416,9 @@ class SSH(object):
74b1de
                 '--slave-gluster-log-level',
74b1de
                 gconf.get("slave-gluster-log-level"),
74b1de
                 '--slave-gluster-command-dir',
74b1de
-                gconf.get("slave-gluster-command-dir")]
74b1de
+                gconf.get("slave-gluster-command-dir"),
74b1de
+                '--master-dist-count',
74b1de
+                str(gconf.get("master-distribution-count"))]
74b1de
 
74b1de
         if gconf.get("slave-access-mount"):
74b1de
             args_to_slave.append('--slave-access-mount')
74b1de
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
74b1de
index 2ee10ac..aadaebd 100644
74b1de
--- a/geo-replication/syncdaemon/syncdutils.py
74b1de
+++ b/geo-replication/syncdaemon/syncdutils.py
74b1de
@@ -926,6 +926,14 @@ class Volinfo(object):
74b1de
         else:
74b1de
             return int(self.get('disperseCount')[0].text)
74b1de
 
74b1de
+    def distribution_count(self, tier, hot):
74b1de
+        if (tier and hot):
74b1de
+            return int(self.get('hotBricks/hotdistCount')[0].text)
74b1de
+        elif (tier and not hot):
74b1de
+            return int(self.get('coldBricks/colddistCount')[0].text)
74b1de
+        else:
74b1de
+            return int(self.get('distCount')[0].text)
74b1de
+
74b1de
     @property
74b1de
     @memoize
74b1de
     def hot_bricks(self):
74b1de
@@ -994,6 +1002,9 @@ class VolinfoFromGconf(object):
74b1de
     def disperse_count(self, tier, hot):
74b1de
         return gconf.get("master-disperse-count")
74b1de
 
74b1de
+    def distribution_count(self, tier, hot):
74b1de
+        return gconf.get("master-distribution-count")
74b1de
+
74b1de
     @property
74b1de
     @memoize
74b1de
     def hot_bricks(self):
74b1de
-- 
74b1de
1.8.3.1
74b1de