From 1ee1666df5a5f30075536c6816582bbdad229f27 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Sat, 14 Jul 2018 18:01:30 +0530 Subject: performance/read-ahead: stricter adherence to force-atime-update Throwaway read-ahead cache in fstat only if force-atime-update is set. Note that fstat flushes read-ahead cache only for atime consistency. However if atime consistency is needed user is required to set force-atime-update which updates atime on backend fs even though application reads are served from read-ahead cache. So, if user has not set force-atime-update, atime won't be accurate and there is no point in flushing read-ahead cache in fstats. mounts requiring atime consistency have to mandatorily set force-atime-update. Also note that normally kernel interspers reads with fstat. So, read-ahead is not effective as fstats flush read-ahead-cache. Instead it regresses performance due to wasted network reads. It is recommended to turn off read-ahead if applications require atime consistency. This patch is aimed at applications which don't require atime consistency. Without atime consistency required, read-ahead cache is effective and increases performance of sequential reads. Change-Id: I122bbc410cee96661823f9c4b934383495c18446 Signed-off-by: Raghavendra G Fixes: bz#1601166 --- xlators/performance/read-ahead/src/read-ahead.c | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'xlators/performance/read-ahead') diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index 1185c6e4183..652b001129b 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -867,6 +867,9 @@ ra_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) inode_t *inode = NULL; uint64_t tmp_file = 0; int32_t op_errno = EINVAL; + ra_conf_t *conf = NULL; + + conf = this->private; GF_ASSERT (frame); GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind); @@ -874,20 +877,23 @@ ra_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) inode = fd->inode; - LOCK (&inode->lock); - { - list_for_each_entry (iter_fd, &inode->fd_list, inode_list) { - tmp_file = 0; - fd_ctx_get (iter_fd, this, &tmp_file); - file = (ra_file_t *)(long)tmp_file; - - if (!file) - continue; - flush_region (frame, file, 0, - file->pages.prev->offset + 1, 0); + if (conf->force_atime_update) { + LOCK (&inode->lock); + { + list_for_each_entry (iter_fd, &inode->fd_list, + inode_list) { + tmp_file = 0; + fd_ctx_get (iter_fd, this, &tmp_file); + file = (ra_file_t *)(long)tmp_file; + + if (!file) + continue; + flush_region (frame, file, 0, + file->pages.prev->offset + 1, 0); + } } + UNLOCK (&inode->lock); } - UNLOCK (&inode->lock); STACK_WIND (frame, ra_attr_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->fstat, fd, xdata); -- cgit