3604df
From 115786c374680597cebec0de7a9bebf13eea0db4 Mon Sep 17 00:00:00 2001
3604df
From: Krutika Dhananjay <kdhananj@redhat.com>
3604df
Date: Mon, 7 Nov 2016 16:06:56 +0530
3604df
Subject: [PATCH 154/157] features/shard: Fill loc.pargfid too for named lookups on individual shards
3604df
3604df
        Backport of: http://review.gluster.org/15788
3604df
3604df
On a sharded volume when a brick is replaced while IO is going on, named
3604df
lookup on individual shards as part of read/write was failing with
3604df
ENOENT on the replaced brick, and as a result AFR initiated name heal in
3604df
lookup callback. But since pargfid was empty (which is what this patch
3604df
attempts to fix), the resolution of the shards by protocol/server used
3604df
to fail and the following pattern of logs was seen:
3604df
3604df
Brick-logs:
3604df
3604df
[2016-11-08 07:41:49.387127] W [MSGID: 115009]
3604df
[server-resolve.c:566:server_resolve] 0-rep-server: no resolution type
3604df
for (null) (LOOKUP)
3604df
[2016-11-08 07:41:49.387157] E [MSGID: 115050]
3604df
[server-rpc-fops.c:156:server_lookup_cbk] 0-rep-server: 91833: LOOKUP(null)
3604df
(00000000-0000-0000-0000-000000000000/16d47463-ece5-4b33-9c93-470be918c0f6.82)
3604df
==> (Invalid argument) [Invalid argument]
3604df
3604df
Client-logs:
3604df
[2016-11-08 07:41:27.497687] W [MSGID: 114031]
3604df
[client-rpc-fops.c:2930:client3_3_lookup_cbk] 2-rep-client-0: remote
3604df
operation failed. Path: (null) (00000000-0000-0000-0000-000000000000)
3604df
[Invalid argument]
3604df
[2016-11-08 07:41:27.497755] W [MSGID: 114031]
3604df
[client-rpc-fops.c:2930:client3_3_lookup_cbk] 2-rep-client-1: remote
3604df
operation failed. Path: (null) (00000000-0000-0000-0000-000000000000)
3604df
[Invalid argument]
3604df
[2016-11-08 07:41:27.498500] W [MSGID: 114031]
3604df
[client-rpc-fops.c:2930:client3_3_lookup_cbk] 2-rep-client-2: remote
3604df
operation failed. Path: (null) (00000000-0000-0000-0000-000000000000)
3604df
[Invalid argument]
3604df
[2016-11-08 07:41:27.499680] E [MSGID: 133010]
3604df
3604df
Also, this patch makes AFR by itself choose a non-NULL pargfid even if
3604df
its ancestors fail to initialize all pargfid placeholders.
3604df
3604df
Change-Id: Iedbd57ed432f3950171f0ca8549001623fe70f99
3604df
BUG: 1370350
3604df
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/89412
3604df
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
3604df
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
3604df
---
3604df
 libglusterfs/src/xlator.c            |   17 +++++++++++++++++
3604df
 libglusterfs/src/xlator.h            |    1 +
3604df
 xlators/cluster/afr/src/afr-common.c |    6 ++++--
3604df
 xlators/features/shard/src/shard.c   |    1 +
3604df
 4 files changed, 23 insertions(+), 2 deletions(-)
3604df
3604df
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
3604df
index 2221332..3c1cde5 100644
3604df
--- a/libglusterfs/src/xlator.c
3604df
+++ b/libglusterfs/src/xlator.c
3604df
@@ -762,6 +762,23 @@ out:
3604df
         return;
3604df
 }
3604df
 
3604df
+void
3604df
+loc_pargfid (loc_t *loc, uuid_t gfid)
3604df
+{
3604df
+        if (!gfid)
3604df
+                goto out;
3604df
+        gf_uuid_clear (gfid);
3604df
+
3604df
+        if (!loc)
3604df
+                goto out;
3604df
+        else if (!gf_uuid_is_null (loc->pargfid))
3604df
+                gf_uuid_copy (gfid, loc->pargfid);
3604df
+        else if (loc->parent && (!gf_uuid_is_null (loc->parent->gfid)))
3604df
+                gf_uuid_copy (gfid, loc->parent->gfid);
3604df
+out:
3604df
+        return;
3604df
+}
3604df
+
3604df
 char*
3604df
 loc_gfid_utoa (loc_t *loc)
3604df
 {
3604df
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
3604df
index 555916d..70e6f0a 100644
3604df
--- a/libglusterfs/src/xlator.h
3604df
+++ b/libglusterfs/src/xlator.h
3604df
@@ -1011,6 +1011,7 @@ int loc_copy_overload_parent (loc_t *dst,
3604df
 void loc_wipe (loc_t *loc);
3604df
 int loc_path (loc_t *loc, const char *bname);
3604df
 void loc_gfid (loc_t *loc, uuid_t gfid);
3604df
+void loc_pargfid (loc_t *loc, uuid_t pargfid);
3604df
 char* loc_gfid_utoa (loc_t *loc);
3604df
 gf_boolean_t loc_is_root (loc_t *loc);
3604df
 int32_t loc_build_child (loc_t *child, loc_t *parent, char *name);
3604df
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
3604df
index c2922fb..fe0dc2d 100644
3604df
--- a/xlators/cluster/afr/src/afr-common.c
3604df
+++ b/xlators/cluster/afr/src/afr-common.c
3604df
@@ -2234,12 +2234,14 @@ afr_lookup_selfheal_wrap (void *opaque)
3604df
 	afr_local_t *local = NULL;
3604df
 	xlator_t *this = NULL;
3604df
 	inode_t *inode = NULL;
3604df
+        uuid_t pargfid = {0,};
3604df
 
3604df
 	local = frame->local;
3604df
 	this = frame->this;
3604df
+        loc_pargfid (&local->loc, pargfid);
3604df
 
3604df
-	ret = afr_selfheal_name (frame->this, local->loc.pargfid,
3604df
-                                 local->loc.name, &local->cont.lookup.gfid_req);
3604df
+	ret = afr_selfheal_name (frame->this, pargfid, local->loc.name,
3604df
+                                 &local->cont.lookup.gfid_req);
3604df
         if (ret == -EIO)
3604df
                 goto unwind;
3604df
 
3604df
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
3604df
index abac0cc..934aaaf 100644
3604df
--- a/xlators/features/shard/src/shard.c
3604df
+++ b/xlators/features/shard/src/shard.c
3604df
@@ -1678,6 +1678,7 @@ shard_common_lookup_shards (call_frame_t *frame, xlator_t *this, inode_t *inode,
3604df
                 bname = strrchr (path, '/') + 1;
3604df
                 loc.inode = inode_new (this->itable);
3604df
                 loc.parent = inode_ref (priv->dot_shard_inode);
3604df
+                gf_uuid_copy (loc.pargfid, priv->dot_shard_gfid);
3604df
                 ret = inode_path (loc.parent, bname, (char **) &(loc.path));
3604df
                 if (ret < 0 || !(loc.inode)) {
3604df
                         gf_msg (this->name, GF_LOG_ERROR, 0,
3604df
-- 
3604df
1.7.1
3604df