linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	"John L. Hammond" <john.hammond@intel.com>,
	Peng Tao <bergwolf@gmail.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH 32/39] staging/lustre/clio: honor O_NOATIME
Date: Fri, 15 Nov 2013 00:32:55 +0800	[thread overview]
Message-ID: <1384446782-13741-33-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1384446782-13741-1-git-send-email-bergwolf@gmail.com>

From: "John L. Hammond" <john.hammond@intel.com>

Add a ci_noatime bit to struct cl_io. In ll_io_init() set this bit if
O_NOATIME is set in f_flags. Ensure that this bit is propagated down
to lower layers. In osc_io_read_start() don't update atime if this bit
is set. Add sanity test 39n to check that passing O_NOATIME to open()
is honored.

Lustre-change: http://review.whamcloud.com/7442
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3832
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
 drivers/staging/lustre/lustre/include/cl_object.h |    6 ++++-
 drivers/staging/lustre/lustre/llite/file.c        |   29 +++++++++++++++++++++
 drivers/staging/lustre/lustre/lov/lov_io.c        |    1 +
 drivers/staging/lustre/lustre/osc/osc_io.c        |   21 +++++++--------
 4 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 4d692dc..76e1b68 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -2392,7 +2392,11 @@ struct cl_io {
 	/**
 	 * file is released, restore has to to be triggered by vvp layer
 	 */
-			     ci_restore_needed:1;
+			     ci_restore_needed:1,
+	/**
+	 * O_NOATIME
+	 */
+			     ci_noatime:1;
 	/**
 	 * Number of pages owned by this IO. For invariant checking.
 	 */
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 04dc9ce..390bea5 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1032,6 +1032,33 @@ int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm,
 	return rc;
 }
 
+static bool file_is_noatime(const struct file *file)
+{
+	const struct vfsmount *mnt = file->f_path.mnt;
+	const struct inode *inode = file->f_path.dentry->d_inode;
+
+	/* Adapted from file_accessed() and touch_atime().*/
+	if (file->f_flags & O_NOATIME)
+		return true;
+
+	if (inode->i_flags & S_NOATIME)
+		return true;
+
+	if (IS_NOATIME(inode))
+		return true;
+
+	if (mnt->mnt_flags & (MNT_NOATIME | MNT_READONLY))
+		return true;
+
+	if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
+		return true;
+
+	if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
+		return true;
+
+	return false;
+}
+
 void ll_io_init(struct cl_io *io, const struct file *file, int write)
 {
 	struct inode *inode = file->f_dentry->d_inode;
@@ -1051,6 +1078,8 @@ void ll_io_init(struct cl_io *io, const struct file *file, int write)
 	} else if (file->f_flags & O_APPEND) {
 		io->ci_lockreq = CILR_MANDATORY;
 	}
+
+	io->ci_noatime = file_is_noatime(file);
 }
 
 static ssize_t
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index cdd69232..0a32f98 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -194,6 +194,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
 		sub_io->ci_lockreq = io->ci_lockreq;
 		sub_io->ci_type    = io->ci_type;
 		sub_io->ci_no_srvlock = io->ci_no_srvlock;
+		sub_io->ci_noatime = io->ci_noatime;
 
 		lov_sub_enter(sub);
 		result = cl_io_sub_init(sub->sub_env, sub_io,
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 681d60a..e567f2f 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -509,22 +509,19 @@ static void osc_io_setattr_end(const struct lu_env *env,
 static int osc_io_read_start(const struct lu_env *env,
 			     const struct cl_io_slice *slice)
 {
-	struct osc_io    *oio   = cl2osc_io(env, slice);
-	struct cl_object *obj   = slice->cis_obj;
-	struct cl_attr   *attr  = &osc_env_info(env)->oti_attr;
-	int	      result = 0;
+	struct osc_io	 *oio  = cl2osc_io(env, slice);
+	struct cl_object *obj  = slice->cis_obj;
+	struct cl_attr	 *attr = &osc_env_info(env)->oti_attr;
+	int rc = 0;
 
-	if (oio->oi_lockless == 0) {
+	if (oio->oi_lockless == 0 && !slice->cis_io->ci_noatime) {
 		cl_object_attr_lock(obj);
-		result = cl_object_attr_get(env, obj, attr);
-		if (result == 0) {
-			attr->cat_atime = LTIME_S(CURRENT_TIME);
-			result = cl_object_attr_set(env, obj, attr,
-						    CAT_ATIME);
-		}
+		attr->cat_atime = LTIME_S(CURRENT_TIME);
+		rc = cl_object_attr_set(env, obj, attr, CAT_ATIME);
 		cl_object_attr_unlock(obj);
 	}
-	return result;
+
+	return rc;
 }
 
 static int osc_io_write_start(const struct lu_env *env,
-- 
1.7.9.5


  parent reply	other threads:[~2013-11-14 16:52 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 16:32 [PATCH 00/39] staging/lustre: patch bomb 2 Peng Tao
2013-11-14 16:32 ` [PATCH 01/39] staging/lustre/hsm: remove hsm_nl proc file Peng Tao
2013-11-15  4:26   ` Greg Kroah-Hartman
2013-11-15 10:32     ` Peng Tao
2013-11-14 16:32 ` [PATCH 02/39] staging/lustre/clio: wrong cl_lock usage Peng Tao
2013-11-14 16:32 ` [PATCH 03/39] staging/lustre/build: fix 'deadcode' errors Peng Tao
2013-11-14 16:32 ` [PATCH 04/39] staging/lustre/build: fix 'integer handling' issues Peng Tao
2013-11-14 16:32 ` [PATCH 05/39] staging/lustre/ptlrpc: add rpc_cache Peng Tao
2013-11-14 16:32 ` [PATCH 06/39] staging/lustre/lnet: build Lustre with Intel OFED for Xeon Phi Peng Tao
2013-11-14 16:32 ` [PATCH 07/39] staging/lustre/osd-ldiskfs: remove dependency on mdd module Peng Tao
2013-11-14 16:32 ` [PATCH 08/39] staging/lustre/libcfs: improve validity test for valid file descriptors Peng Tao
2013-11-14 16:32 ` [PATCH 09/39] staging/lustre/llite: use 64bits flags in ll_lov_setea() Peng Tao
2013-11-14 16:32 ` [PATCH 10/39] staging/lustre/hsm: small fixes for HSM Peng Tao
2013-11-14 16:32 ` [PATCH 11/39] staging/lustre/mdt: CDT cleanup follow-on patch Peng Tao
2013-11-14 16:32 ` [PATCH 12/39] staging/lustre/utils: Posix copytool fixes Peng Tao
2013-11-14 16:32 ` [PATCH 13/39] staging/lustre/lmv: update coding style Peng Tao
2013-11-14 16:32 ` [PATCH 14/39] staging/lustre/hsm: copy start error should set HP_FLAG_COMPLETED Peng Tao
2013-11-14 16:32 ` [PATCH 15/39] staging/lustre/lov: Get the correct address of lmm_objects Peng Tao
2013-11-14 16:32 ` [PATCH 16/39] staging/lustre/lvfs: remove llog_lvfs.c and other lvfs code from llog Peng Tao
2013-11-14 16:32 ` [PATCH 17/39] staging/lustre/llite: reset writeback index in ll_writepages Peng Tao
2013-11-14 16:32 ` [PATCH 18/39] staging/lustre/llite: Delaying creation of client side proc entries Peng Tao
2013-11-14 16:32 ` [PATCH 19/39] staging/lustre/libcfs: Add relocation function to libcfs heap Peng Tao
2013-11-14 16:32 ` [PATCH 20/39] staging/lustre/build: fix 'data race condition' issues Peng Tao
2013-11-14 16:32 ` [PATCH 21/39] staging/lustre/autoconf: remove LC_LOCK_MAP_ACQUIRE test Peng Tao
2013-11-14 16:32 ` [PATCH 22/39] staging/lustre/mdc: document mdc_rpc_lock Peng Tao
2013-11-14 16:32 ` [PATCH 23/39] staging/lustre/autoconf: remove LC_FS_STRUCT_USE_PATH Peng Tao
2013-11-14 16:32 ` [PATCH 24/39] staging/lustre/obdclass: fix wrong device put in case of race Peng Tao
2013-11-14 16:32 ` [PATCH 25/39] staging/lustre/lmv: choose right MDT for open by FID Peng Tao
2013-11-14 16:32 ` [PATCH 26/39] staging/lustre/osd: remove fld lookup during configuration Peng Tao
2013-11-14 16:32 ` [PATCH 27/39] staging/lustre/mdt: HSM EXIST event not triggered at last rm/mv Peng Tao
2013-11-14 16:32 ` [PATCH 28/39] staging/lustre/ldlm: ldlm_flock_deadlock() ASSERTION( req != lock ) failed Peng Tao
2013-11-14 16:32 ` [PATCH 29/39] staging/lustre/changelogs: Account for changelog_ext_rec in CR_MAXSIZE Peng Tao
2013-11-14 16:32 ` [PATCH 30/39] staging/lustre/build: build error with gcc 4.7.0 20110509 Peng Tao
2013-11-14 16:32 ` [PATCH 31/39] staging/lustre/build: fix 'NULL pointer dereference' errors Peng Tao
2013-11-14 16:32 ` Peng Tao [this message]
2013-11-14 16:32 ` [PATCH 33/39] staging/lustre/llite: return compatible fsid for statfs Peng Tao
2013-11-14 16:32 ` [PATCH 34/39] staging/lustre/llite: cancel open lock before closing file Peng Tao
2013-11-14 16:32 ` [PATCH 35/39] staging/lustre/hsm: Add support to drop all pages for ll_data_version Peng Tao
2013-11-14 16:32 ` [PATCH 36/39] staging/lustre/build: fix 'no effect' errors Peng Tao
2013-11-14 16:33 ` [PATCH 37/39] staging/lustre/obd: add md_stats to MDC and LMV devices Peng Tao
2013-11-14 16:33 ` [PATCH 38/39] staging/lustre/autoconf: remove LC_SECURITY_PLUG test Peng Tao
2013-11-14 16:33 ` [PATCH 39/39] staging/lustre/osc: Lustre returns EINTR from writes when SA_RESTART is set Peng Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384446782-13741-33-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.hammond@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).