summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-02-12 11:05:58 +0200
committerN Balachandran <nbalacha@redhat.com>2019-02-14 11:56:06 +0000
commit6fbeb89e869a2a669698405c3d479052e090f4b7 (patch)
tree9c4fb078e04e31b4767330af25af0afe599df98a /xlators
parent2856e001b5a31887eb1b78e5b0932204f128f04b (diff)
dht-shared.c: minor reduction of work under lock.
Minor changes to reduce work done under a lock. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ia58adfb5125129e5d1f3bbf2202f38520fdbc29f
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-shared.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index c7ef2f1190b..e5a2367598b 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -19,17 +19,16 @@
#define GF_DECIDE_DEFRAG_THROTTLE_COUNT(throttle_count, conf) \
{ \
+ throttle_count = MAX((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); \
pthread_mutex_lock(&conf->defrag->dfq_mutex); \
\
if (!strcasecmp(conf->dthrottle, "lazy")) \
conf->defrag->recon_thread_count = 1; \
\
- throttle_count = MAX((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); \
- \
- if (!strcasecmp(conf->dthrottle, "normal")) \
+ else if (!strcasecmp(conf->dthrottle, "normal")) \
conf->defrag->recon_thread_count = (throttle_count / 2); \
\
- if (!strcasecmp(conf->dthrottle, "aggressive")) \
+ else if (!strcasecmp(conf->dthrottle, "aggressive")) \
conf->defrag->recon_thread_count = throttle_count; \
\
pthread_mutex_unlock(&conf->defrag->dfq_mutex); \
@@ -401,18 +400,20 @@ dht_configure_throttle(xlator_t *this, dht_conf_t *conf, char *temp_str)
} else if ((gf_string2int(temp_str, &rebal_thread_count) == 0)) {
if ((rebal_thread_count > 0) &&
(rebal_thread_count <= MAX_REBAL_THREADS)) {
+ conf->defrag->recon_thread_count = rebal_thread_count;
+ pthread_mutex_unlock(&conf->defrag->dfq_mutex);
gf_msg(this->name, GF_LOG_INFO, 0, 0,
"rebal thread count configured to %d",
rebal_thread_count);
- conf->defrag->recon_thread_count = rebal_thread_count;
+ goto out;
} else {
+ pthread_mutex_unlock(&conf->defrag->dfq_mutex);
gf_msg(this->name, GF_LOG_ERROR, 0, DHT_MSG_INVALID_OPTION,
"Invalid option: Reconfigure: "
"rebal-throttle should be "
"within range of 0 and maximum number of"
" cores available");
ret = -1;
- pthread_mutex_unlock(&conf->defrag->dfq_mutex);
goto out;
}
} else {