From a69ea2e635eb2ba64f53e3d280b345cb2a65ad13 Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Wed, 9 Dec 2015 13:46:17 +0530 Subject: geo-rep: Symlink Rename issue If ENTRY creation failed for symlink in Slave and symlink renamed in Master. If Source not exists to Rename in Slave Geo-rep interprets as Create of Target file. Geo-rep sends blob of regular file to create symlink instead of sending blob of symlink. With this patch, Geo-rep identifies symlink and sends respective blob. BUG: 1292697 Change-Id: If9351974d1945141a1d3abb838b7d0de7591e48e Signed-off-by: Aravinda VK Reviewed-on: http://review.gluster.org/12917 Tested-by: Gluster Build System Reviewed-by: Kotresh HR Reviewed-by: Milind Changire Tested-by: Milind Changire Tested-by: NetBSD Build System (cherry picked from commit 3151194fad1aed3ab340b53aeeb4e8d131538d12) Reviewed-on: http://review.gluster.org/12998 Reviewed-by: Venky Shankar --- geo-replication/syncdaemon/master.py | 8 +++++++- geo-replication/syncdaemon/resource.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'geo-replication') diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py index 38b9d9c9fc9..f318e7901f8 100644 --- a/geo-replication/syncdaemon/master.py +++ b/geo-replication/syncdaemon/master.py @@ -884,10 +884,16 @@ class GMasterChangelogMixin(GMasterCommon): if isinstance(st, int): st = {} + rl = None + if st and stat.S_ISLNK(st.st_mode): + rl = errno_wrap(os.readlink, [en], [ENOENT], [ESTALE]) + if isinstance(rl, int): + rl = None + entry_update() e1 = unescape(os.path.join(pfx, ec[self.POS_ENTRY1 - 1])) entries.append(edct(ty, gfid=gfid, entry=e1, entry1=en, - stat=st)) + stat=st, link=rl)) else: # stat() to get mode and other information go = os.path.join(pfx, gfid) diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index 740861a23f3..19363401e65 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -717,8 +717,14 @@ class Server(object): st = lstat(entry) if isinstance(st, int): if e['stat'] and not stat.S_ISDIR(e['stat']['mode']): - (pg, bname) = entry2pb(en) - blob = entry_pack_reg_stat(gfid, bname, e['stat']) + if stat.S_ISLNK(e['stat']['mode']) and \ + e['link'] is not None: + (pg, bname) = entry2pb(en) + blob = entry_pack_symlink(gfid, bname, + e['link'], e['stat']) + else: + (pg, bname) = entry2pb(en) + blob = entry_pack_reg_stat(gfid, bname, e['stat']) else: cmd_ret = errno_wrap(os.rename, [entry, en], -- cgit