lustre/clio: honor O_NOATIME
authorJohn L. Hammond <john.hammond@intel.com>
Sat, 1 Mar 2014 02:16:35 +0000 (21:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Mar 2014 03:11:20 +0000 (19:11 -0800)
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.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-on: http://review.whamcloud.com/7442
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3832
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/cl_object.h
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/lov/lov_io.c
drivers/staging/lustre/lustre/osc/osc_io.c

index 4d692dcd96cfb76b296e23c7c34f4f2f4c6b71c6..76e1b68b38eda39f2d15f4f77baf30dcbddf07b0 100644 (file)
@@ -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.
         */
index 36c54aa48a6aa3dc3a54ebd33695b6eb3bb37301..362f5ecb94a04947c8cabdaeb9d7b354206873e9 100644 (file)
@@ -1035,6 +1035,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;
@@ -1054,6 +1081,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
index 5a6ab70ed0a1a3a4126e836a3b144e4d880bf5d2..65133ea308b6b6c1c8e3acae995c55960a1700f1 100644 (file)
@@ -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,
index 777ae24bbfff465aa91c2e5169da20c662300e6a..5f3c545418d11cd765068ae6f3d5409e82618c5f 100644 (file)
@@ -512,19 +512,15 @@ static int osc_io_read_start(const struct lu_env *env,
        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;
+       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,
This page took 0.031601 seconds and 5 git commands to generate.