Blob Blame History Raw
From a6b18bb41ac68fe3fa9acd7e9785b07fe655c39a Mon Sep 17 00:00:00 2001
From: Kotresh HR <khiremat@redhat.com>
Date: Wed, 26 Jul 2017 08:09:31 -0400
Subject: [PATCH 578/587] geo-rep: Fix syncing of self healed hardlinks

Problem:
In a distribute replicate volume, if the hardlinks
are created when a subvolume is down, it gets
healed from other subvolume when it comes up.
If this subvolume becomes ACTIVE in geo-rep
there are chances that those hardlinks won't
be synced to slave.

Cause:
AFR can't detect hardlinks during self heal.
It just create those files using mknod and
the same is recorded in changelog. Geo-rep
processes these mknod and ignores it as
it finds gfid already on slave.

Solution:
Geo-rep should process the mknod as link
if the gfid already exists on slave.

> Change-Id: I2f721b462b38a74c60e1df261662db4b99b32057
> BUG: 1475308
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
> Reviewed-on: https://review.gluster.org/17880
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Aravinda VK <avishwan@redhat.com>

Change-Id: I2f721b462b38a74c60e1df261662db4b99b32057
BUG: 1474380
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/113790
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/resource.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
index 55bebe1..943e3ec 100644
--- a/geo-replication/syncdaemon/resource.py
+++ b/geo-replication/syncdaemon/resource.py
@@ -747,6 +747,14 @@ class Server(object):
                 if isinstance(st, int):
                     blob = entry_pack_reg(
                         gfid, bname, e['mode'], e['uid'], e['gid'])
+                # Self healed hardlinks are recorded as MKNOD.
+                # So if the gfid already exists, it should be
+                # processed as hard link not mknod.
+                elif op in ['MKNOD']:
+                    cmd_ret = errno_wrap(os.link,
+                                         [slink, entry],
+                                         [ENOENT, EEXIST], [ESTALE])
+                    collect_failure(e, cmd_ret)
             elif op == 'MKDIR':
                 slink = os.path.join(pfx, gfid)
                 st = lstat(slink)
-- 
1.8.3.1