From 49f524def676e62e0f0cfb8a674bc28923c28f13 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Tue, 22 Oct 2019 15:41:41 +0300 Subject: dht-common.h/dht-helper.c: exctract the LOCK() from DHT_UPDATE_TIME Currently, the code (and only place) that is using this macro is in dht_inode_ctx_time_update() where it is called 3 times in a row, which is essentially 3 cycles of LOCK/UNLOCK on the same lock. Instead, extract the LOCK()/UNLOCK() part of the macro and wrap those calls with it. Change-Id: I6312b985e3d97517857b55f342440accc4063db6 updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/cluster/dht/src/dht-common.h | 24 ++++++++++-------------- xlators/cluster/dht/src/dht-helper.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 3c992297f0f..32f7fcbd9d7 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -823,22 +823,18 @@ typedef struct dht_fd_ctx { dht_local_wipe(__xl, __local); \ } while (0) -#define DHT_UPDATE_TIME(ctx_sec, ctx_nsec, new_sec, new_nsec, inode, post) \ +#define DHT_UPDATE_TIME(ctx_sec, ctx_nsec, new_sec, new_nsec, post) \ do { \ - LOCK(&inode->lock); \ - { \ - if (ctx_sec == new_sec) \ - new_nsec = max(new_nsec, ctx_nsec); \ - else if (ctx_sec > new_sec) { \ - new_sec = ctx_sec; \ - new_nsec = ctx_nsec; \ - } \ - if (post) { \ - ctx_sec = new_sec; \ - ctx_nsec = new_nsec; \ - } \ + if (ctx_sec == new_sec) \ + new_nsec = max(new_nsec, ctx_nsec); \ + else if (ctx_sec > new_sec) { \ + new_sec = ctx_sec; \ + new_nsec = ctx_nsec; \ + } \ + if (post) { \ + ctx_sec = new_sec; \ + ctx_nsec = new_nsec; \ } \ - UNLOCK(&inode->lock); \ } while (0) #define is_greater_time(a, an, b, bn) \ diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 8d8170bc0ed..023d4371c0e 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -1872,12 +1872,16 @@ dht_inode_ctx_time_update(inode_t *inode, xlator_t *this, struct iatt *stat, time = &ctx->time; - DHT_UPDATE_TIME(time->mtime, time->mtime_nsec, stat->ia_mtime, - stat->ia_mtime_nsec, inode, post); - DHT_UPDATE_TIME(time->ctime, time->ctime_nsec, stat->ia_ctime, - stat->ia_ctime_nsec, inode, post); - DHT_UPDATE_TIME(time->atime, time->atime_nsec, stat->ia_atime, - stat->ia_atime_nsec, inode, post); + LOCK(&inode->lock); + { + DHT_UPDATE_TIME(time->mtime, time->mtime_nsec, stat->ia_mtime, + stat->ia_mtime_nsec, post); + DHT_UPDATE_TIME(time->ctime, time->ctime_nsec, stat->ia_ctime, + stat->ia_ctime_nsec, post); + DHT_UPDATE_TIME(time->atime, time->atime_nsec, stat->ia_atime, + stat->ia_atime_nsec, post); + } + UNLOCK(&inode->lock); ret = dht_inode_ctx_set(inode, this, ctx); out: -- cgit