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