cb8e9e
From 60fd3fba546d29a038857cf23f6e6feb98593ccc Mon Sep 17 00:00:00 2001
cb8e9e
From: Krutika Dhananjay <kdhananj@redhat.com>
cb8e9e
Date: Mon, 8 Jun 2015 11:36:12 +0530
cb8e9e
Subject: [PATCH 101/101] cluster/afr: Do not attempt entry self-heal if the last lookup on entry failed on src
cb8e9e
cb8e9e
        Backport of: http://review.gluster.org/11119
cb8e9e
cb8e9e
Test bug-948686.t was causing shd to dump core due to gfid being NULL.
cb8e9e
This was due to the volume being stopped while index heal's in progress,
cb8e9e
causing afr_selfheal_unlocked_lookup_on() to fail sometimes on the src brick
cb8e9e
with ENOTCONN. And when afr_selfheal_newentry_mark() copies the gfid off the
cb8e9e
src iatt, it essentially copies null gfid. This was causing the assertion
cb8e9e
as part of xattrop in protocol/client to fail.
cb8e9e
cb8e9e
Change-Id: I4f7117c7a392fab6c8ac819bcf87f58ed2f28144
cb8e9e
BUG: 1233144
cb8e9e
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/51033
cb8e9e
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
cb8e9e
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
cb8e9e
---
cb8e9e
 xlators/cluster/afr/src/afr-self-heal-entry.c |   11 +++++++++--
cb8e9e
 1 files changed, 9 insertions(+), 2 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
cb8e9e
index cb3648c..ab210b3 100644
cb8e9e
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
cb8e9e
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
cb8e9e
@@ -181,6 +181,13 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 	if (!replies[source].valid)
cb8e9e
 		return -EIO;
cb8e9e
 
cb8e9e
+        /* Skip healing this entry if the last lookup on it failed for reasons
cb8e9e
+         * other than ENOENT.
cb8e9e
+         */
cb8e9e
+        if ((replies[source].op_ret < 0) &&
cb8e9e
+            (replies[source].op_errno != ENOENT))
cb8e9e
+                return -replies[source].op_errno;
cb8e9e
+
cb8e9e
 	for (i = 0; i < priv->child_count; i++) {
cb8e9e
 		if (!healed_sinks[i])
cb8e9e
 			continue;
cb8e9e
@@ -188,7 +195,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 		    replies[source].op_errno == ENOENT) {
cb8e9e
 			ret = afr_selfheal_entry_delete (this, fd->inode, name,
cb8e9e
                                                          inode, i, replies);
cb8e9e
-		} else {
cb8e9e
+                } else {
cb8e9e
 			if (!gf_uuid_compare (replies[i].poststat.ia_gfid,
cb8e9e
 					   replies[source].poststat.ia_gfid))
cb8e9e
 				continue;
cb8e9e
@@ -196,7 +203,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 			ret = afr_selfheal_recreate_entry (this, i, source,
cb8e9e
 							   fd->inode, name, inode,
cb8e9e
 							   replies, newentry);
cb8e9e
-		}
cb8e9e
+                }
cb8e9e
 		if (ret < 0)
cb8e9e
 			break;
cb8e9e
 	}
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e