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