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