summaryrefslogtreecommitdiffstats
path: root/xlators/features/barrier/src/barrier.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-04-28 14:18:50 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-04-28 14:18:50 +0000
commite139b4d0ba2286c0d4d44ba81260c2b287016019 (patch)
tree0a21f0761528e0f79da0a9f67106eb128ace0cf7 /xlators/features/barrier/src/barrier.c
parent73b60c87ca7f62517a8466431f5a8cf167589c8c (diff)
parentf2bac9f9d5b9956969ddd25a54bc636b82f6923e (diff)
Merge branch 'upstream'HEADmaster
Conflicts: rpc/xdr/src/glusterfs3-xdr.c rpc/xdr/src/glusterfs3-xdr.h xlators/features/changelog/src/Makefile.am xlators/features/changelog/src/changelog-helpers.h xlators/features/changelog/src/changelog.c xlators/mgmt/glusterd/src/glusterd-sm.c Change-Id: I9972a5e6184503477eb77a8b56c50a4db4eec3e2
Diffstat (limited to 'xlators/features/barrier/src/barrier.c')
-rw-r--r--xlators/features/barrier/src/barrier.c88
1 files changed, 73 insertions, 15 deletions
diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c
index e5465d1b4..5edb9cdd3 100644
--- a/xlators/features/barrier/src/barrier.c
+++ b/xlators/features/barrier/src/barrier.c
@@ -334,6 +334,74 @@ out:
}
int
+notify (xlator_t *this, int event, void *data, ...)
+{
+ barrier_priv_t *priv = NULL;
+ dict_t *dict = NULL;
+ gf_boolean_t past = _gf_false;
+ int ret = -1;
+ gf_boolean_t barrier_enabled = _gf_false;
+ struct list_head queue = {0,};
+
+ priv = this->private;
+ GF_ASSERT (priv);
+ INIT_LIST_HEAD (&queue);
+
+ switch (event) {
+ case GF_EVENT_TRANSLATOR_OP:
+ {
+ dict = data;
+ GF_OPTION_RECONF ("barrier", barrier_enabled, dict,
+ bool, out);
+
+ LOCK (&priv->lock);
+ {
+ past = priv->barrier_enabled;
+
+ switch (past) {
+ case _gf_false:
+ if (barrier_enabled) {
+ ret = __barrier_enable (this,priv);
+ if (ret)
+ goto unlock;
+ } else {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Already disabled.");
+ goto unlock;
+ }
+ break;
+
+ case _gf_true:
+ if (!barrier_enabled) {
+ __barrier_disable(this, &queue);
+ } else {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Already enabled");
+ goto unlock;
+ }
+ break;
+ }
+ ret = 0;
+ }
+unlock:
+ UNLOCK (&priv->lock);
+
+ if (!list_empty (&queue))
+ barrier_dequeue_all (this, &queue);
+ // missing break is intentional
+ }
+ default:
+ {
+ default_notify (this, event, data);
+ ret = 0;
+ goto out;
+ }
+ }
+out:
+ return ret;
+}
+
+int
reconfigure (xlator_t *this, dict_t *options)
{
barrier_priv_t *priv = NULL;
@@ -347,7 +415,7 @@ reconfigure (xlator_t *this, dict_t *options)
GF_ASSERT (priv);
GF_OPTION_RECONF ("barrier", barrier_enabled, options, bool, out);
- GF_OPTION_RECONF ("timeout", timeout, options, time, out);
+ GF_OPTION_RECONF ("barrier-timeout", timeout, options, time, out);
INIT_LIST_HEAD (&queue);
@@ -359,13 +427,9 @@ reconfigure (xlator_t *this, dict_t *options)
case _gf_false:
if (barrier_enabled) {
ret = __barrier_enable (this, priv);
- if (ret)
+ if (ret) {
goto unlock;
-
- } else {
- gf_log (this->name, GF_LOG_ERROR,
- "Already disabled");
- goto unlock;
+ }
}
break;
@@ -373,16 +437,10 @@ reconfigure (xlator_t *this, dict_t *options)
if (!barrier_enabled) {
__barrier_disable (this, &queue);
- } else {
- gf_log (this->name, GF_LOG_ERROR,
- "Already enabled");
- goto unlock;
}
break;
}
-
priv->timeout.tv_sec = timeout;
-
ret = 0;
}
unlock:
@@ -432,7 +490,7 @@ init (xlator_t *this)
LOCK_INIT (&priv->lock);
GF_OPTION_INIT ("barrier", priv->barrier_enabled, bool, out);
- GF_OPTION_INIT ("timeout", timeout, time, out);
+ GF_OPTION_INIT ("barrier-timeout", timeout, time, out);
priv->timeout.tv_sec = timeout;
INIT_LIST_HEAD (&priv->queue);
@@ -588,7 +646,7 @@ struct volume_options options[] = {
"write (with O_SYNC), fsync. It is turned \"off\" by "
"default."
},
- { .key = {"timeout"},
+ { .key = {"barrier-timeout"},
.type = GF_OPTION_TYPE_TIME,
.default_value = "120",
.description = "After 'timeout' seconds since the time 'barrier' "