diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2018-10-13 00:56:42 +0300 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-10-16 06:33:29 +0000 |
commit | 98f68cf115a30a101d3be2252ecbe1391720ed88 (patch) | |
tree | 4a9da66f8833a936eba95fc078a4605acd632f4f /xlators/performance | |
parent | fd70a7d790710da01a8ddd56785a28ab54e07550 (diff) |
Multiple xlators: perform gettimeofday() not under lock
While it may slightly reduce accuracy, I think it's better to
acquire the time outside a lock and then memcpy the value while
under lock.
Compile-tested only!
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Change-Id: Ic8fb94a56c4fa2d3b13e59767e13646fb39342ba
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 12 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/page.c | 6 | ||||
-rw-r--r-- | xlators/performance/quick-read/src/quick-read.c | 6 |
3 files changed, 20 insertions, 4 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index e8e04c03434..6ffad7d1a64 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -360,6 +360,9 @@ ioc_cache_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, ioc_inode_t *ioc_inode = NULL; size_t destroy_size = 0; struct iatt *local_stbuf = NULL; + struct timeval tv = { + 0, + }; local = frame->local; ioc_inode = local->inode; @@ -397,9 +400,10 @@ ioc_cache_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) local_stbuf = NULL; + gettimeofday(&tv, NULL); ioc_inode_lock(ioc_inode); { - gettimeofday(&ioc_inode->cache.tv, NULL); + memcpy(&ioc_inode->cache.tv, &tv, sizeof(struct timeval)); } ioc_inode_unlock(ioc_inode); @@ -1338,6 +1342,9 @@ ioc_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, { ioc_inode_t *ioc_inode = NULL; uint64_t tmp_inode = 0; + struct timeval tv = { + 0, + }; inode_ctx_get(fd->inode, this, &tmp_inode); ioc_inode = (ioc_inode_t *)(long)tmp_inode; @@ -1348,9 +1355,10 @@ ioc_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, return 0; } + gettimeofday(&tv, NULL); ioc_inode_lock(ioc_inode); { - gettimeofday(&ioc_inode->cache.tv, NULL); + memcpy(&ioc_inode->cache.tv, &tv, sizeof(struct timeval)); } ioc_inode_unlock(ioc_inode); diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index dada4ebc55b..c376ade0fba 100644 --- a/xlators/performance/io-cache/src/page.c +++ b/xlators/performance/io-cache/src/page.c @@ -413,6 +413,9 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, ioc_waitq_t *waitq = NULL; size_t iobref_page_size = 0; char zero_filled = 0; + struct timeval tv = { + 0, + }; GF_ASSERT(frame); @@ -428,6 +431,7 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, zero_filled = ((op_ret >= 0) && (stbuf->ia_mtime == 0)); + gettimeofday(&tv, NULL); ioc_inode_lock(ioc_inode); { if (op_ret == -1 || @@ -444,7 +448,7 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec; } - gettimeofday(&ioc_inode->cache.tv, NULL); + memcpy(&ioc_inode->cache.tv, &tv, sizeof(struct timeval)); if (op_ret < 0) { /* error, readv returned -1 */ diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index ec545ba6193..21734607390 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -421,6 +421,9 @@ qr_content_update(xlator_t *this, qr_inode_t *qr_inode, void *data, qr_private_t *priv = NULL; qr_inode_table_t *table = NULL; uint32_t rollover = 0; + struct timeval tv = { + 0, + }; rollover = gen >> 32; gen = gen & 0xffffffff; @@ -428,6 +431,7 @@ qr_content_update(xlator_t *this, qr_inode_t *qr_inode, void *data, priv = this->private; table = &priv->table; + gettimeofday(&tv, NULL); LOCK(&table->lock); { if ((rollover != qr_inode->gen_rollover) || @@ -450,7 +454,7 @@ qr_content_update(xlator_t *this, qr_inode_t *qr_inode, void *data, qr_inode->buf = *buf; - gettimeofday(&qr_inode->last_refresh, NULL); + memcpy(&qr_inode->last_refresh, &tv, sizeof(struct timeval)); __qr_inode_register(this, table, qr_inode); } |