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