887953
From 83b57d7278f2c6f493042e3ea34f104822823137 Mon Sep 17 00:00:00 2001
887953
From: Sunny Kumar <sunkumar@redhat.com>
887953
Date: Mon, 14 Jan 2019 11:48:55 +0530
887953
Subject: [PATCH 507/507] geo-rep : fix rename sync on hybrid crawl
887953
887953
Problem: When geo-rep is configured as hybrid crawl
887953
         directory renames are not synced to the slave.
887953
887953
Solution: Rename sync of directory was failing due to incorrect
887953
          destination path calculation.
887953
          During check for existence on slave we miscalculated
887953
          realpath. <host:brickpath/dir>.
887953
887953
Change-Id: I23f1ea60e86a917598fe869d5d24f8da654d8a0a
887953
BUG: 1664235
887953
>Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/22020/
887953
>fixes: bz#1665826
887953
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
887953
887953
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
887953
Change-Id: I0588e38f803cc44a2f044c04563246fcb6aaebec
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/160876
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 geo-replication/syncdaemon/resource.py   |  2 ++
887953
 geo-replication/syncdaemon/syncdutils.py | 22 +++++++++-------------
887953
 2 files changed, 11 insertions(+), 13 deletions(-)
887953
887953
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
887953
index f16066e76..23e509c76 100644
887953
--- a/geo-replication/syncdaemon/resource.py
887953
+++ b/geo-replication/syncdaemon/resource.py
887953
@@ -656,6 +656,8 @@ class Server(object):
887953
                     logging.info(lf("Special case: rename on mkdir",
887953
                                     gfid=gfid, entry=repr(entry)))
887953
                     src_entry = get_slv_dir_path(slv_host, slv_volume, gfid)
887953
+                    if src_entry is None:
887953
+                        collect_failure(e, ENOENT, uid, gid)
887953
                     if src_entry is not None and src_entry != entry:
887953
                         slv_entry_info = {}
887953
                         slv_entry_info['gfid_mismatch'] = False
887953
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
887953
index 32181925d..ec987bdb1 100644
887953
--- a/geo-replication/syncdaemon/syncdutils.py
887953
+++ b/geo-replication/syncdaemon/syncdutils.py
887953
@@ -695,19 +695,15 @@ def get_slv_dir_path(slv_host, slv_volume, gfid):
887953
                                gfid[2:4],
887953
                                gfid], [ENOENT], [ESTALE])
887953
         if dir_path != ENOENT:
887953
-            break
887953
-
887953
-    if not isinstance(dir_path, int):
887953
-        realpath = errno_wrap(os.readlink, [dir_path],
887953
-                              [ENOENT], [ESTALE])
887953
-
887953
-        if not isinstance(realpath, int):
887953
-            realpath_parts = realpath.split('/')
887953
-            pargfid = realpath_parts[-2]
887953
-            basename = realpath_parts[-1]
887953
-            pfx = gauxpfx()
887953
-            dir_entry = os.path.join(pfx, pargfid, basename)
887953
-            return dir_entry
887953
+            realpath = errno_wrap(os.readlink, [dir_path],
887953
+                                  [ENOENT], [ESTALE])
887953
+            if not isinstance(realpath, int):
887953
+                realpath_parts = realpath.split('/')
887953
+                pargfid = realpath_parts[-2]
887953
+                basename = realpath_parts[-1]
887953
+                pfx = gauxpfx()
887953
+                dir_entry = os.path.join(pfx, pargfid, basename)
887953
+                return dir_entry
887953
 
887953
     return None
887953
 
887953
-- 
887953
2.20.1
887953