summaryrefslogtreecommitdiffstats
path: root/xlators/performance/quick-read
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-10-13 00:56:42 +0300
committerAmar Tumballi <amarts@redhat.com>2018-10-16 06:33:29 +0000
commit98f68cf115a30a101d3be2252ecbe1391720ed88 (patch)
tree4a9da66f8833a936eba95fc078a4605acd632f4f /xlators/performance/quick-read
parentfd70a7d790710da01a8ddd56785a28ab54e07550 (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/quick-read')
-rw-r--r--xlators/performance/quick-read/src/quick-read.c6
1 files changed, 5 insertions, 1 deletions
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);
}