summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-common.c
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2011-07-14 08:07:46 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 07:45:11 -0700
commitb0a3a3fda3f0993cd8c0e1b135bb569b6543e7c0 (patch)
tree59e736d4246af1ce27d4bf7c9e5e42648d4c051b /xlators/cluster/afr/src/afr-common.c
parentbfc0e16e43815ab6d6e67f4bd26694ebd72b3360 (diff)
cluster/afr: Choose next call child from fresh-children for inode-read-fops
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2840 (files not getting self-healed when the first child goes down) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2840
Diffstat (limited to 'xlators/cluster/afr/src/afr-common.c')
-rw-r--r--xlators/cluster/afr/src/afr-common.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index e8afc6d8de6..21f7b4e4356 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -452,8 +452,9 @@ afr_set_read_ctx_from_policy (xlator_t *this, inode_t *inode,
* in execution there is a chance for inode's read_ctx to change.
*/
int32_t
-afr_next_call_child (int32_t *fresh_children, size_t child_count,
- int32_t *last_index, int32_t read_child)
+afr_next_call_child (int32_t *fresh_children, unsigned char *child_up,
+ size_t child_count, int32_t *last_index,
+ int32_t read_child)
{
int next_index = 0;
int32_t next_call_child = -1;
@@ -463,12 +464,12 @@ afr_next_call_child (int32_t *fresh_children, size_t child_count,
next_index = *last_index;
retry:
next_index++;
- if (next_index >= child_count)
+ if ((next_index >= child_count) ||
+ (fresh_children[next_index] == -1))
goto out;
- if (fresh_children[next_index] == read_child)
+ if ((fresh_children[next_index] == read_child) ||
+ (!child_up[fresh_children[next_index]]))
goto retry;
- if (fresh_children[next_index] == -1)
- goto out;
*last_index = next_index;
next_call_child = fresh_children[next_index];
out:
@@ -1475,7 +1476,8 @@ afr_lookup (call_frame_t *frame, xlator_t *this,
if (ret == 0) {
/* lookup is a revalidate */
- local->read_child_index = afr_inode_get_read_ctx (this, loc->inode,
+ local->read_child_index = afr_inode_get_read_ctx (this,
+ loc->inode,
NULL);
} else {
LOCK (&priv->read_child_lock);
@@ -3070,6 +3072,24 @@ out:
}
int
+afr_first_up_child (unsigned char *child_up, size_t child_count)
+{
+ int ret = -1;
+ int i = 0;
+
+ GF_ASSERT (child_up);
+
+ for (i = 0; i < child_count; i++) {
+ if (child_up[i]) {
+ ret = i;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+int
AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
{
local->op_ret = -1;
@@ -3147,7 +3167,8 @@ afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
if (priv->optimistic_change_log && child_up_count == priv->child_count)
local->optimistic_change_log = 1;
- local->first_up_child = afr_first_up_child (priv);
+ local->first_up_child = afr_first_up_child (local->child_up,
+ priv->child_count);
local->child_errno = GF_CALLOC (sizeof (*local->child_errno),
priv->child_count,