From fc133767e5ed705f246547cdfa5b7a2db5dcd53f Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Tue, 12 Feb 2019 11:19:26 +0200 Subject: 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 Change-Id: I6cd05d8556a9bcc015e1be53f6ba46854e52a380 --- xlators/performance/md-cache/src/md-cache.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'xlators/performance/md-cache') 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); -- cgit