summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-02-12 11:19:26 +0200
committerAmar Tumballi <amarts@redhat.com>2019-02-18 02:43:18 +0000
commitfc133767e5ed705f246547cdfa5b7a2db5dcd53f (patch)
treee10b7c8345185e79593dc6f0b3358ee38638ae4c /xlators
parent86a9b5db918c05f2986837d6a00093755540e51e (diff)
md-cache.c: minor reduction of work under lock.
Take the time before taking the lock, not under lock. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I6cd05d8556a9bcc015e1be53f6ba46854e52a380
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/md-cache/src/md-cache.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 186b352fba5..779e78656c0 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -1079,18 +1079,17 @@ mdc_load_statfs_info_from_cache(xlator_t *this, struct statvfs **buf)
goto err;
}
+ *buf = NULL;
+ timespec_now(&now);
+
pthread_mutex_lock(&conf->statfs_cache.lock);
{
- *buf = NULL;
-
/* Skip if the cache is not initialized */
if (!conf->statfs_cache.initialized) {
ret = -1;
goto unlock;
}
- timespec_now(&now);
-
cache_age = (now.tv_sec - conf->statfs_cache.last_refreshed.tv_sec);
gf_log(this->name, GF_LOG_DEBUG, "STATFS cache age = %lf", cache_age);