Blob Blame History Raw
From b92e632dc6eb72b7cd54441d40b3bfbf71a5c145 Mon Sep 17 00:00:00 2001
From: Ravishankar N <ravishankar@redhat.com>
Date: Fri, 4 Aug 2017 16:23:46 +0530
Subject: [PATCH 595/601] afr: Prevent null gfids in self-heal entry
 re-creation

Patch in master : https://review.gluster.org/17981
Patch in release-3.12: https://review.gluster.org/#/c/17997/

Change-Id: I15abab554835c6899f4d126c94b05ef4e4d3b679
BUG: 1474178
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/114757
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/afr/src/afr-self-heal-entry.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
index 6b79da0..d6ac901 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -84,10 +84,20 @@ afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
         unsigned char *newentry = NULL;
 
         priv = this->private;
+	iatt = &replies[source].poststat;
+        if (iatt->ia_type == IA_INVAL || gf_uuid_is_null (iatt->ia_gfid)) {
+                gf_msg (this->name, GF_LOG_ERROR, 0, AFR_MSG_SELF_HEAL_FAILED,
+                        "Invalid ia_type (%d) or gfid(%s). source brick=%d, "
+                        "pargfid=%s, name=%s", iatt->ia_type,
+                        uuid_utoa(iatt->ia_gfid), source,
+                        uuid_utoa(dir->gfid), name);
+                ret = -EINVAL;
+                goto out;
+        }
+
 	xdata = dict_new();
 	if (!xdata)
 		return -ENOMEM;
-
         newentry = alloca0 (priv->child_count);
 	loc.parent = inode_ref (dir);
 	gf_uuid_copy (loc.pargfid, dir->gfid);
@@ -103,8 +113,6 @@ afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
 	if (ret)
 		goto out;
 
-	iatt = &replies[source].poststat;
-
 	srcloc.inode = inode_ref (inode);
 	gf_uuid_copy (srcloc.gfid, iatt->ia_gfid);
         if (iatt->ia_type != IA_IFDIR)
-- 
1.8.3.1