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
This commit is contained in:
parent
fd70a7d790
commit
98f68cf115
@ -275,6 +275,9 @@ is_fop_latency_started(call_frame_t *frame)
|
||||
struct timespec *begin, *end; \
|
||||
double throughput; \
|
||||
int flag = 0; \
|
||||
struct timeval tv = { \
|
||||
0, \
|
||||
}; \
|
||||
\
|
||||
begin = &frame->begin; \
|
||||
end = &frame->end; \
|
||||
@ -285,11 +288,13 @@ is_fop_latency_started(call_frame_t *frame)
|
||||
throughput = op_ret / elapsed; \
|
||||
\
|
||||
conf = this->private; \
|
||||
gettimeofday(&tv, NULL); \
|
||||
LOCK(&iosstat->lock); \
|
||||
{ \
|
||||
if (iosstat->thru_counters[type].throughput <= throughput) { \
|
||||
iosstat->thru_counters[type].throughput = throughput; \
|
||||
gettimeofday(&iosstat->thru_counters[type].time, NULL); \
|
||||
memcpy(&iosstat->thru_counters[type].time, &tv, \
|
||||
sizeof(struct timeval)); \
|
||||
flag = 1; \
|
||||
} \
|
||||
} \
|
||||
|
@ -115,7 +115,6 @@ __stale_entrylk(xlator_t *this, pl_entry_lock_t *candidate_lock,
|
||||
{
|
||||
posix_locks_private_t *priv = NULL;
|
||||
struct timeval curr;
|
||||
gettimeofday(&curr, NULL);
|
||||
|
||||
priv = this->private;
|
||||
|
||||
@ -123,6 +122,7 @@ __stale_entrylk(xlator_t *this, pl_entry_lock_t *candidate_lock,
|
||||
* chance? Or just the locks we are attempting to acquire?
|
||||
*/
|
||||
if (names_conflict(candidate_lock->basename, requested_lock->basename)) {
|
||||
gettimeofday(&curr, NULL);
|
||||
*lock_age_sec = curr.tv_sec - candidate_lock->granted_time.tv_sec;
|
||||
if (*lock_age_sec > priv->revocation_secs)
|
||||
return _gf_true;
|
||||
@ -541,11 +541,11 @@ __lock_blocked_add(xlator_t *this, pl_inode_t *pinode, pl_dom_list_t *dom,
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
if (nonblock)
|
||||
goto out;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
lock->blkd_time = now;
|
||||
list_add_tail(&lock->blocked_locks, &dom->blocked_entrylks);
|
||||
|
||||
|
@ -145,11 +145,11 @@ __stale_inodelk(xlator_t *this, pl_inode_lock_t *candidate_lock,
|
||||
struct timeval curr;
|
||||
|
||||
priv = this->private;
|
||||
gettimeofday(&curr, NULL);
|
||||
/* Question: Should we just prune them all given the
|
||||
* chance? Or just the locks we are attempting to acquire?
|
||||
*/
|
||||
if (inodelk_conflict(candidate_lock, requested_lock)) {
|
||||
gettimeofday(&curr, NULL);
|
||||
*lock_age_sec = curr.tv_sec - candidate_lock->granted_time.tv_sec;
|
||||
if (*lock_age_sec > priv->revocation_secs)
|
||||
return _gf_true;
|
||||
@ -403,12 +403,12 @@ __lock_blocked_add(xlator_t *this, pl_dom_list_t *dom, pl_inode_lock_t *lock,
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
if (can_block == 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
lock->blkd_time = now;
|
||||
list_add_tail(&lock->blocked_locks, &dom->blocked_inodelks);
|
||||
|
||||
|
@ -591,6 +591,9 @@ quota_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
quota_meta_t size = {
|
||||
0,
|
||||
};
|
||||
struct timeval tv = {
|
||||
0,
|
||||
};
|
||||
|
||||
local = frame->local;
|
||||
|
||||
@ -628,12 +631,13 @@ quota_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
* loop of validation and checking
|
||||
* limit when timeout is zero.
|
||||
*/
|
||||
gettimeofday(&tv, NULL);
|
||||
LOCK(&ctx->lock);
|
||||
{
|
||||
ctx->size = size.size;
|
||||
ctx->file_count = size.file_count;
|
||||
ctx->dir_count = size.dir_count;
|
||||
gettimeofday(&ctx->tv, NULL);
|
||||
memcpy(&ctx->tv, &tv, sizeof(struct timeval));
|
||||
}
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
@ -4306,6 +4310,9 @@ quota_statfs_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
quota_meta_t size = {
|
||||
0,
|
||||
};
|
||||
struct timeval tv = {
|
||||
0,
|
||||
};
|
||||
|
||||
local = frame->local;
|
||||
|
||||
@ -4337,12 +4344,13 @@ quota_statfs_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
op_errno = EINVAL;
|
||||
}
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
LOCK(&ctx->lock);
|
||||
{
|
||||
ctx->size = size.size;
|
||||
ctx->file_count = size.file_count;
|
||||
ctx->dir_count = size.dir_count;
|
||||
gettimeofday(&ctx->tv, NULL);
|
||||
memcpy(&ctx->tv, &tv, sizeof(struct timeval));
|
||||
}
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user