21ab4e
From b92e632dc6eb72b7cd54441d40b3bfbf71a5c145 Mon Sep 17 00:00:00 2001
21ab4e
From: Ravishankar N <ravishankar@redhat.com>
21ab4e
Date: Fri, 4 Aug 2017 16:23:46 +0530
21ab4e
Subject: [PATCH 595/601] afr: Prevent null gfids in self-heal entry
21ab4e
 re-creation
21ab4e
21ab4e
Patch in master : https://review.gluster.org/17981
21ab4e
Patch in release-3.12: https://review.gluster.org/#/c/17997/
21ab4e
21ab4e
Change-Id: I15abab554835c6899f4d126c94b05ef4e4d3b679
21ab4e
BUG: 1474178
21ab4e
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/114757
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/cluster/afr/src/afr-self-heal-entry.c | 14 +++++++++++---
21ab4e
 1 file changed, 11 insertions(+), 3 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
21ab4e
index 6b79da0..d6ac901 100644
21ab4e
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
21ab4e
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
21ab4e
@@ -84,10 +84,20 @@ afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
21ab4e
         unsigned char *newentry = NULL;
21ab4e
 
21ab4e
         priv = this->private;
21ab4e
+	iatt = &replies[source].poststat;
21ab4e
+        if (iatt->ia_type == IA_INVAL || gf_uuid_is_null (iatt->ia_gfid)) {
21ab4e
+                gf_msg (this->name, GF_LOG_ERROR, 0, AFR_MSG_SELF_HEAL_FAILED,
21ab4e
+                        "Invalid ia_type (%d) or gfid(%s). source brick=%d, "
21ab4e
+                        "pargfid=%s, name=%s", iatt->ia_type,
21ab4e
+                        uuid_utoa(iatt->ia_gfid), source,
21ab4e
+                        uuid_utoa(dir->gfid), name);
21ab4e
+                ret = -EINVAL;
21ab4e
+                goto out;
21ab4e
+        }
21ab4e
+
21ab4e
 	xdata = dict_new();
21ab4e
 	if (!xdata)
21ab4e
 		return -ENOMEM;
21ab4e
-
21ab4e
         newentry = alloca0 (priv->child_count);
21ab4e
 	loc.parent = inode_ref (dir);
21ab4e
 	gf_uuid_copy (loc.pargfid, dir->gfid);
21ab4e
@@ -103,8 +113,6 @@ afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
21ab4e
 	if (ret)
21ab4e
 		goto out;
21ab4e
 
21ab4e
-	iatt = &replies[source].poststat;
21ab4e
-
21ab4e
 	srcloc.inode = inode_ref (inode);
21ab4e
 	gf_uuid_copy (srcloc.gfid, iatt->ia_gfid);
21ab4e
         if (iatt->ia_type != IA_IFDIR)
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e