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