summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-10-05 04:01:36 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-05 05:16:43 -0700
commit8e0f5e7105c0d03b50a9342f4285a985b9cdb090 (patch)
tree69d5a2b3be95c15782ab31596cb79eaa52439ed9 /xlators
parentb441730b5b54fcd9355bef42bd0f45a4147212e4 (diff)
cluster/afr: Initialize local->first_up_child in AFR_LOCAL_INIT.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 285 ("first up child" can change during a transaction) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=285
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr.c26
-rw-r--r--xlators/cluster/afr/src/afr.h32
2 files changed, 29 insertions, 29 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index b65a4dc466d..befc182b6ab 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -330,32 +330,6 @@ afr_frame_return (call_frame_t *frame)
return call_count;
}
-/**
- * first_up_child - return the index of the first child that is up
- */
-
-int
-afr_first_up_child (afr_private_t *priv)
-{
- xlator_t ** children = NULL;
- int ret = -1;
- int i = 0;
-
- LOCK (&priv->lock);
- {
- children = priv->children;
- for (i = 0; i < priv->child_count; i++) {
- if (priv->child_up[i]) {
- ret = i;
- break;
- }
- }
- }
- UNLOCK (&priv->lock);
-
- return ret;
-}
-
/**
* up_children_count - return the number of children that are up
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 37dc139599e..a708f7d0a35 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -514,9 +514,6 @@ afr_up_children_count (int child_count, unsigned char *child_up);
int
afr_locked_nodes_count (unsigned char *locked_nodes, int child_count);
-int
-afr_first_up_child (afr_private_t *priv);
-
ino64_t
afr_itransform (ino64_t ino, int child_count, int child_index);
@@ -592,11 +589,40 @@ AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
}
+/**
+ * first_up_child - return the index of the first child that is up
+ */
+
+static inline int
+afr_first_up_child (afr_private_t *priv)
+{
+ xlator_t ** children = NULL;
+ int ret = -1;
+ int i = 0;
+
+ LOCK (&priv->lock);
+ {
+ children = priv->children;
+ for (i = 0; i < priv->child_count; i++) {
+ if (priv->child_up[i]) {
+ ret = i;
+ break;
+ }
+ }
+ }
+ UNLOCK (&priv->lock);
+
+ return ret;
+}
+
+
static inline int
afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
{
int i;
+ local->first_up_child = afr_first_up_child (priv);
+
local->child_errno = CALLOC (sizeof (*local->child_errno),
priv->child_count);
if (!local->child_errno) {