From f52dd9bf2005449f49acd5666a02594fb4c5ac6f Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sun, 20 Nov 2011 09:13:14 +0530 Subject: 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 Reviewed-by: Vijay Bellur --- xlators/cluster/afr/src/afr-transaction.c | 44 +++++++++++++------------------ 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'xlators/cluster/afr/src/afr-transaction.c') diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index d3960dcff..89fbd9ec7 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); -- cgit