summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-common.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-03-02 13:26:36 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-05 22:55:15 -0800
commite435faeae8bdedbfcdeae6a37e51b913b7c7ff00 (patch)
treebdcd1cea0303473c01540ad9f3c76eef1584400a /xlators/cluster/afr/src/afr-common.c
parent347b4d48cba3cc1e00d40ec50e62497d65a27c84 (diff)
cluster/afr: handle node failures in lookup
When a transaction is in progress lookup depends on inode ctx for read-child. If the lookup fails on the read-child while another transaction is in progress, it should select the read-child as the next success_child which is in fresh_children. Change-Id: I33a04b102966b63a64bacf8d2e29f0d0119fdac6 BUG: 773225 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/2858 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-common.c')
-rw-r--r--xlators/cluster/afr/src/afr-common.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index e82eecbf03c..3118601707c 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -1030,20 +1030,43 @@ afr_update_loc_gfids (loc_t *loc, struct iatt *buf, struct iatt *postparent)
int
afr_lookup_build_response_params (afr_local_t *local, xlator_t *this)
{
- int32_t read_child = -1;
struct iatt *buf = NULL;
struct iatt *postparent = NULL;
dict_t **xattr = NULL;
+ int32_t *success_children = NULL;
+ int32_t *sources = NULL;
+ afr_private_t *priv = NULL;
+ int32_t read_child = -1;
int ret = 0;
+ int i = 0;
GF_ASSERT (local);
buf = &local->cont.lookup.buf;
postparent = &local->cont.lookup.postparent;
xattr = &local->cont.lookup.xattr;
+ priv = this->private;
read_child = afr_inode_get_read_ctx (this, local->cont.lookup.inode,
- NULL);
+ local->fresh_children);
+ if (read_child < 0) {
+ ret = -1;
+ goto out;
+ }
+ success_children = local->cont.lookup.success_children;
+ sources = local->cont.lookup.sources;
+ memset (sources, 0, sizeof (*sources) * priv->child_count);
+ afr_children_intersection_get (local->fresh_children, success_children,
+ sources, priv->child_count);
+ if (!sources[read_child]) {
+ read_child = -1;
+ for (i = 0; i < priv->child_count; i++) {
+ if (sources[i]) {
+ read_child = i;
+ break;
+ }
+ }
+ }
if (read_child < 0) {
ret = -1;
goto out;