summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2011-06-27 03:10:23 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 07:44:59 -0700
commit64b2a56ad0f8ddae9ece8696f7d50a3129c145a3 (patch)
tree0a19177537a36b24cb8f64a111c50c495e17b6d5 /xlators/cluster
parentbf8e3a864eafe7eef5795cd134f6c0d5812a4f17 (diff)
cluster/afr: Move afr local alloc functions from header files to sources
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')
-rw-r--r--xlators/cluster/afr/src/afr-common.c119
-rw-r--r--xlators/cluster/afr/src/afr.h110
2 files changed, 124 insertions, 105 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index e5046cb69d8..b753cbfa85c 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -268,10 +268,6 @@ out:
}
-/**
- * afr_local_cleanup - cleanup everything in frame->local
- */
-
void
afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
{
@@ -399,7 +395,8 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
if (local->xattr_req)
dict_unref (local->xattr_req);
- GF_FREE (local->child_up);
+ if (local->child_up)
+ GF_FREE (local->child_up);
{ /* lookup */
if (local->cont.lookup.xattrs) {
@@ -2758,3 +2755,115 @@ afr_notify (xlator_t *this, int32_t event,
out:
return ret;
}
+
+int
+AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
+{
+ local->child_up = GF_CALLOC (sizeof (*local->child_up),
+ priv->child_count,
+ gf_afr_mt_char);
+ if (!local->child_up) {
+ return -ENOMEM;
+ }
+
+ memcpy (local->child_up, priv->child_up,
+ sizeof (*local->child_up) * priv->child_count);
+
+ local->call_count = afr_up_children_count (priv->child_count,
+ local->child_up);
+ local->op_ret = -1;
+ local->op_errno = EUCLEAN;
+
+ if (local->call_count == 0) {
+ gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up");
+ return -ENOTCONN;
+ }
+
+ return 0;
+}
+
+int
+afr_internal_lock_init (afr_internal_lock_t *lk, size_t child_count,
+ transaction_lk_type_t lk_type)
+{
+ int ret = -ENOMEM;
+
+ lk->inode_locked_nodes = GF_CALLOC (sizeof (*lk->inode_locked_nodes),
+ child_count, gf_afr_mt_char);
+ if (NULL == lk->inode_locked_nodes)
+ goto out;
+
+ lk->entry_locked_nodes = GF_CALLOC (sizeof (*lk->entry_locked_nodes),
+ child_count, gf_afr_mt_char);
+ if (NULL == lk->entry_locked_nodes)
+ goto out;
+
+ lk->locked_nodes = GF_CALLOC (sizeof (*lk->locked_nodes),
+ child_count, gf_afr_mt_char);
+ if (NULL == lk->locked_nodes)
+ goto out;
+
+ lk->lower_locked_nodes = GF_CALLOC (sizeof (*lk->lower_locked_nodes),
+ child_count, gf_afr_mt_char);
+ if (NULL == lk->lower_locked_nodes)
+ goto out;
+
+ lk->lock_op_ret = -1;
+ lk->lock_op_errno = EUCLEAN;
+ lk->transaction_lk_type = lk_type;
+
+ ret = 0;
+out:
+ return ret;
+}
+
+int
+afr_transaction_local_init (afr_local_t *local, afr_private_t *priv)
+{
+ int i;
+ int child_up_count = 0;
+ int ret = -ENOMEM;
+
+ ret = afr_internal_lock_init (&local->internal_lock, priv->child_count,
+ AFR_TRANSACTION_LK);
+ if (ret < 0)
+ goto out;
+
+ ret = -ENOMEM;
+ child_up_count = afr_up_children_count (priv->child_count, local->child_up);
+ 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->child_errno = GF_CALLOC (sizeof (*local->child_errno),
+ priv->child_count,
+ gf_afr_mt_int32_t);
+ if (!local->child_errno)
+ goto out;
+
+ local->pending = GF_CALLOC (sizeof (*local->pending),
+ priv->child_count,
+ gf_afr_mt_int32_t);
+
+ if (!local->pending)
+ goto out;
+
+ for (i = 0; i < priv->child_count; i++) {
+ local->pending[i] = GF_CALLOC (sizeof (*local->pending[i]),
+ 3, /* data + metadata + entry */
+ gf_afr_mt_int32_t);
+ if (!local->pending[i])
+ goto out;
+ }
+
+ local->transaction.child_errno =
+ GF_CALLOC (sizeof (*local->transaction.child_errno),
+ priv->child_count,
+ gf_afr_mt_int32_t);
+ local->transaction.erase_pending = 1;
+
+ ret = 0;
+out:
+ return ret;
+}
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index abfaaac0e7b..55c485f14d8 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -822,45 +822,19 @@ AFR_BASENAME (const char *str)
return __basename_str;
}
-/* initialize local_t */
-static inline int
-AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
-{
- int child_up_count = 0;
-
- local->child_up = GF_CALLOC (sizeof (*local->child_up),
- priv->child_count,
- gf_afr_mt_char);
- if (!local->child_up) {
- return -ENOMEM;
- }
-
- memcpy (local->child_up, priv->child_up,
- sizeof (*local->child_up) * priv->child_count);
-
- child_up_count = afr_up_children_count (priv->child_count, local->child_up);
-
- if (priv->optimistic_change_log && child_up_count == priv->child_count)
- local->optimistic_change_log = 1;
-
- local->call_count = afr_up_children_count (priv->child_count, local->child_up);
- if (local->call_count == 0) {
- gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up");
- return -ENOTCONN;
- }
-
- local->transaction.erase_pending = 1;
-
- local->op_ret = -1;
- local->op_errno = EUCLEAN;
-
- local->internal_lock.lock_op_ret = -1;
- local->internal_lock.lock_op_errno = EUCLEAN;
+int
+afr_transaction_local_init (afr_local_t *local, afr_private_t *priv);
+int32_t
+afr_marker_getxattr (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv );
- return 0;
-}
+int
+AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv);
+int
+afr_internal_lock_init (afr_internal_lock_t *lk, size_t child_count,
+ transaction_lk_type_t lk_type);
/**
* first_up_child - return the index of the first child that is up
@@ -888,68 +862,4 @@ afr_first_up_child (afr_private_t *priv)
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 = GF_CALLOC (sizeof (*local->child_errno),
- priv->child_count,
- gf_afr_mt_int32_t);
- if (!local->child_errno) {
- return -ENOMEM;
- }
-
- local->pending = GF_CALLOC (sizeof (*local->pending),
- priv->child_count,
- gf_afr_mt_int32_t);
-
- if (!local->pending) {
- return -ENOMEM;
- }
-
- for (i = 0; i < priv->child_count; i++) {
- local->pending[i] = GF_CALLOC (sizeof (*local->pending[i]),
- 3, /* data + metadata + entry */
- gf_afr_mt_int32_t);
- if (!local->pending[i])
- return -ENOMEM;
- }
-
- local->internal_lock.inode_locked_nodes =
- GF_CALLOC (sizeof (*local->internal_lock.inode_locked_nodes),
- priv->child_count,
- gf_afr_mt_char);
-
- local->internal_lock.entry_locked_nodes =
- GF_CALLOC (sizeof (*local->internal_lock.entry_locked_nodes),
- priv->child_count,
- gf_afr_mt_char);
-
- local->internal_lock.locked_nodes =
- GF_CALLOC (sizeof (*local->internal_lock.locked_nodes),
- priv->child_count,
- gf_afr_mt_char);
-
- local->internal_lock.lower_locked_nodes
- = GF_CALLOC (sizeof (*local->internal_lock.lower_locked_nodes),
- priv->child_count,
- gf_afr_mt_char);
-
- local->transaction.child_errno = GF_CALLOC (sizeof (*local->transaction.child_errno),
- priv->child_count,
- gf_afr_mt_int32_t);
-
- local->internal_lock.transaction_lk_type = AFR_TRANSACTION_LK;
-
- return 0;
-}
-
-int32_t
-afr_marker_getxattr (call_frame_t *frame, xlator_t *this,
- loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv );
-
#endif /* __AFR_H__ */