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