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