From b6cc23204f1941184cb08ec3d84beecd2d06fd91 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 9 Apr 2014 11:53:33 +0530 Subject: glusterfs-server : barrier timeout tuning fix Problem : Reconfiguration of barrier timeout through gluster volume set shows a success but it never changes the default timeout value which is 120 seconds. After digging into the code deeper, it was found that timeout is never modified in reconfigure() as the first check i.e. whether barrier is already enabled or disabled always fails since barrier option is not modified in this request. Fix : Introduced notify() in barrier translator which will take care of the rpc request to enable/disable barrier. reconfigure() will simply set barrier enable/disable and timeout options blindly without any validation. Please note this patch only contains the changes in barrier translator however from complete code flow perspective the caller in the glusterfsd mgmt should call notify instead of reconfigure to fix this problem. Change-Id: I1371b294935f6054da7c1dc6a9a19f1d861e60fb BUG: 1085671 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/7428 Reviewed-by: Varun Shastry Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/features/barrier/src/barrier.c | 82 +++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 12 deletions(-) (limited to 'xlators/features/barrier/src/barrier.c') diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c index e5465d1b4..9937698ed 100644 --- a/xlators/features/barrier/src/barrier.c +++ b/xlators/features/barrier/src/barrier.c @@ -333,6 +333,74 @@ out: return ret; } +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) { @@ -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: -- cgit From 22f47322d246c94d0bec8e893e4837a67d39f544 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Mon, 3 Mar 2014 18:00:59 +0530 Subject: Barrier: Barrier translator options configuration barrier enable/disable, barrier-timeout configuration in barrier translator. Change-Id: I7cbf9cd4f5e55d42dcc6b7cd6827234566c7b6f3 BUG: 1060002 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/7177 Reviewed-by: Kaushal M Tested-by: Gluster Build System --- xlators/features/barrier/src/barrier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xlators/features/barrier/src/barrier.c') diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c index 9937698ed..5edb9cdd3 100644 --- a/xlators/features/barrier/src/barrier.c +++ b/xlators/features/barrier/src/barrier.c @@ -415,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); @@ -490,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); @@ -646,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' " -- cgit