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