diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2019-02-27 22:05:51 +0200 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-03-12 03:09:33 +0000 |
commit | 3e36060b13a86ea4e39fb717dc7f59aacd47bf4f (patch) | |
tree | 6688cf705e8c65b4c51b3126c835f22b1874b20b | |
parent | 48ca0c05df4cee66cf8d07e19ee2267fc9ba920b (diff) |
io-threads.c: Potentially skip a lock.
Before going into the lock, verify stub_cnt != 0.
Otherwise, let's skip this code.
Unrelated, switch a CALLOC to MALLOC, as we
initialize all members right away. This allocation
is done also under lock, so also should help a bit.
Compile-tested only!
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Change-Id: Ie2fe6adff41ae4969abff95eff945b54e1a01d32
-rw-r--r-- | xlators/performance/io-threads/src/io-threads.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index 455531f51c7..a4a5559e286 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -61,7 +61,7 @@ iot_get_ctx(xlator_t *this, client_t *client) int i; if (client_ctx_get(client, this, (void **)&ctx) != 0) { - ctx = GF_CALLOC(GF_FOP_PRI_MAX, sizeof(*ctx), gf_iot_mt_client_ctx_t); + ctx = GF_MALLOC(GF_FOP_PRI_MAX * sizeof(*ctx), gf_iot_mt_client_ctx_t); if (ctx) { for (i = 0; i < GF_FOP_PRI_MAX; ++i) { INIT_LIST_HEAD(&ctx[i].clients); @@ -1001,8 +1001,8 @@ iot_priv_dump(xlator_t *this) */ typedef struct { - uint32_t value; time_t update_time; + uint32_t value; } threshold_t; /* * Variables so that I can hack these for testing. @@ -1309,20 +1309,21 @@ notify(xlator_t *this, int32_t event, void *data, ...) if (GF_EVENT_PARENT_DOWN == event) { if (victim->cleanup_starting) { - clock_gettime(CLOCK_REALTIME, &sleep_till); - sleep_till.tv_sec += 1; /* Wait for draining stub from queue before notify PARENT_DOWN */ stub_cnt = GF_ATOMIC_GET(conf->stub_cnt); - - pthread_mutex_lock(&conf->mutex); - { - while (stub_cnt) { - (void)pthread_cond_timedwait(&conf->cond, &conf->mutex, - &sleep_till); - stub_cnt = GF_ATOMIC_GET(conf->stub_cnt); + if (stub_cnt) { + clock_gettime(CLOCK_REALTIME, &sleep_till); + sleep_till.tv_sec += 1; + pthread_mutex_lock(&conf->mutex); + { + while (stub_cnt) { + (void)pthread_cond_timedwait(&conf->cond, &conf->mutex, + &sleep_till); + stub_cnt = GF_ATOMIC_GET(conf->stub_cnt); + } } + pthread_mutex_unlock(&conf->mutex); } - pthread_mutex_unlock(&conf->mutex); gf_log(this->name, GF_LOG_INFO, "Notify GF_EVENT_PARENT_DOWN for brick %s", victim->name); |