From c7d1aee76d5713d1f337ab1c831c0ed74e4676e1 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 27 Dec 2018 18:56:16 +0200 Subject: Multiple files: reduce work while under lock. Mostly, unlock before logging. In some cases, moved different code that was not needed to be under lock (for example, taking time, or malloc'ing) to be executed before taking the lock. Note: logging might be slightly less accurate in order, since it may not be done now under the lock, so order of logs is racy. I think it's a reasonable compromise. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul Change-Id: I2438710016afc9f4f62a176ef1a0d3ed793b4f89 --- xlators/features/barrier/src/barrier.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'xlators/features/barrier') diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c index 4f8fa211d0b..a601c7fa04f 100644 --- a/xlators/features/barrier/src/barrier.c +++ b/xlators/features/barrier/src/barrier.c @@ -461,7 +461,7 @@ out: int notify(xlator_t *this, int event, void *data, ...) { - barrier_priv_t *priv = NULL; + barrier_priv_t *priv = this->private; dict_t *dict = NULL; int ret = -1; int barrier_enabled = _gf_false; @@ -469,7 +469,6 @@ notify(xlator_t *this, int event, void *data, ...) 0, }; - priv = this->private; GF_ASSERT(priv); INIT_LIST_HEAD(&queue); @@ -491,19 +490,23 @@ notify(xlator_t *this, int event, void *data, ...) if (barrier_enabled) { ret = __barrier_enable(this, priv); } else { + UNLOCK(&priv->lock); gf_log(this->name, GF_LOG_ERROR, "Already disabled."); + goto post_unlock; } } else { if (!barrier_enabled) { __barrier_disable(this, &queue); ret = 0; } else { + UNLOCK(&priv->lock); gf_log(this->name, GF_LOG_ERROR, "Already enabled"); + goto post_unlock; } } } UNLOCK(&priv->lock); - + post_unlock: if (!list_empty(&queue)) barrier_dequeue_all(this, &queue); -- cgit