summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-11-20 09:13:14 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-28 07:48:43 -0800
commitf52dd9bf2005449f49acd5666a02594fb4c5ac6f (patch)
tree0c0b5c7e97009a1df0aaef76b9339978aeb508c7 /xlators/cluster/afr
parent7ae082e9c519ea91540c4d49f9df44c4e6e9f39a (diff)
cluster/afr: Update read-child if it becomes stale
Change-Id: I00c714a89575023f6dbdd3430dcbf191e5d08019 BUG: 3650 Reviewed-on: http://review.gluster.com/740 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r--xlators/cluster/afr/src/afr-common.c20
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c44
-rw-r--r--xlators/cluster/afr/src/afr.h2
3 files changed, 30 insertions, 36 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 108b021b32f..9512f6a5477 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -325,7 +325,6 @@ afr_inode_ctx_set_read_child (afr_inode_ctx_t *ctx, int32_t read_child)
uint64_t remaining_mask = 0;
uint64_t mask = 0;
- GF_ASSERT (read_child >= 0);
remaining_mask = (~AFR_ICTX_READ_CHILD_MASK & ctx->masks);
mask = (AFR_ICTX_READ_CHILD_MASK & read_child);
ctx->masks = remaining_mask | mask;
@@ -347,19 +346,23 @@ afr_inode_ctx_set_read_ctx (afr_inode_ctx_t *ctx, int32_t read_child,
}
void
-afr_inode_ctx_rm_stale_children (afr_inode_ctx_t *ctx, int32_t read_child,
- int32_t *stale_children, int32_t child_count)
+afr_inode_ctx_rm_stale_children (afr_inode_ctx_t *ctx, int32_t *stale_children,
+ int32_t child_count)
{
int i = 0;
+ int32_t read_child = -1;
GF_ASSERT (stale_children);
- afr_inode_ctx_set_read_child (ctx, read_child);
for (i = 0; i < child_count; i++) {
- if ((ctx->fresh_children[i] == -1) || (stale_children[i] == -1))
+ if (stale_children[i] == -1)
break;
afr_children_rm_child (ctx->fresh_children,
stale_children[i], child_count);
}
+ read_child = (int32_t)(ctx->masks & AFR_ICTX_READ_CHILD_MASK);
+ if (!afr_is_child_present (ctx->fresh_children, child_count,
+ read_child))
+ afr_inode_ctx_set_read_child (ctx, ctx->fresh_children[0]);
}
void
@@ -421,9 +424,8 @@ afr_inode_set_ctx (xlator_t *this, inode_t *inode, afr_inode_params_t *params)
priv->child_count);
break;
case AFR_INODE_RM_STALE_CHILDREN:
- read_child = params->u.read_ctx.read_child;
stale_children = params->u.read_ctx.children;
- afr_inode_ctx_rm_stale_children (ctx, read_child,
+ afr_inode_ctx_rm_stale_children (ctx,
stale_children,
priv->child_count);
break;
@@ -488,16 +490,14 @@ afr_inode_set_read_ctx (xlator_t *this, inode_t *inode, int32_t read_child,
}
void
-afr_inode_rm_stale_children (xlator_t *this, inode_t *inode, int32_t read_child,
+afr_inode_rm_stale_children (xlator_t *this, inode_t *inode,
int32_t *stale_children)
{
afr_inode_params_t params = {0};
- GF_ASSERT (read_child >= 0);
GF_ASSERT (stale_children);
params.op = AFR_INODE_RM_STALE_CHILDREN;
- params.u.read_ctx.read_child = read_child;
params.u.read_ctx.children = stale_children;
afr_inode_set_ctx (this, inode, &params);
}
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index d3960dcff40..89fbd9ec754 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -382,44 +382,38 @@ afr_transaction_rm_stale_children (call_frame_t *frame, xlator_t *this,
local = frame->local;
pending = local->pending;
- stale_children = afr_children_create (priv->child_count);
- if (!stale_children)
+ if (local->op_ret < 0)
goto out;
-
fresh_children = local->fresh_children;
read_child = afr_inode_get_read_ctx (this, inode, fresh_children);
-
- GF_ASSERT (read_child >= 0);
-
- if (pending[read_child][idx] == 0)
- read_child = -1;
+ if (read_child < 0) {
+ gf_log (this->name, GF_LOG_DEBUG, "Possible split-brain "
+ "for %s", uuid_utoa (inode->gfid));
+ goto out;
+ }
for (i = 0; i < priv->child_count; i++) {
if (!afr_is_child_present (fresh_children,
priv->child_count, i))
continue;
- if (pending[i][idx] == 0) {
- /* child is down or op failed on it */
- rm_stale_children = _gf_true;
- afr_children_rm_child (fresh_children, i,
- priv->child_count);
- stale_children[count++] = i;
- }
- }
+ if (pending[i][idx])
+ continue;
+ /* child is down or op failed on it */
+ if (!stale_children)
+ stale_children = afr_children_create (priv->child_count);
+ if (!stale_children)
+ goto out;
- if (!rm_stale_children) {
- GF_ASSERT (read_child >= 0);
- goto out;
+ rm_stale_children = _gf_true;
+ stale_children[count++] = i;
+ gf_log (this->name, GF_LOG_DEBUG, "Removing stale child "
+ "%d for %s", i, uuid_utoa (inode->gfid));
}
- if (fresh_children[0] == -1) {
- //All children failed. leave as-is
+ if (!rm_stale_children)
goto out;
- }
- if (read_child == -1)
- read_child = fresh_children[0];
- afr_inode_rm_stale_children (this, inode, read_child, stale_children);
+ afr_inode_rm_stale_children (this, inode, stale_children);
out:
if (stale_children)
GF_FREE (stale_children);
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index e7c948dba35..0566495fe96 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -970,7 +970,7 @@ int32_t
afr_resultant_errno_get (int32_t *children,
int *child_errno, unsigned int child_count);
void
-afr_inode_rm_stale_children (xlator_t *this, inode_t *inode, int32_t read_child,
+afr_inode_rm_stale_children (xlator_t *this, inode_t *inode,
int32_t *stale_children);
void
afr_launch_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode,