]> err.no Git - linux-2.6/blobdiff - fs/xfs/linux-2.6/xfs_iops.c
[XFS] fix, speedup and simplify atime handling let the VFS handle atime
[linux-2.6] / fs / xfs / linux-2.6 / xfs_iops.c
index 14215a7db59f4881a902d230557a358ab1119452..8fd274fc26d54c800dbd272dc32dbe6e17026c8c 100644 (file)
 #include <linux/xattr.h>
 #include <linux/namei.h>
 
+#define IS_NOATIME(inode) ((inode->i_sb->s_flags & MS_NOATIME) ||      \
+       (S_ISDIR(inode->i_mode) && inode->i_sb->s_flags & MS_NODIRATIME))
+
+/*
+ * Bring the atime in the XFS inode uptodate.
+ * Used before logging the inode to disk or when the Linux inode goes away.
+ */
+void
+xfs_synchronize_atime(
+       xfs_inode_t     *ip)
+{
+       vnode_t         *vp;
+
+       vp = XFS_ITOV_NULL(ip);
+       if (vp) {
+               struct inode *inode = &vp->v_inode;
+               ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
+               ip->i_d.di_atime.t_nsec = (__int32_t)inode->i_atime.tv_nsec;
+       }
+}
+
 /*
  * Change the requested timestamp in the given inode.
  * We don't lock across timestamp updates, and we don't log them but
@@ -73,23 +94,6 @@ xfs_ichgtime(
        struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
        timespec_t      tv;
 
-       /*
-        * We're not supposed to change timestamps in readonly-mounted
-        * filesystems.  Throw it away if anyone asks us.
-        */
-       if (unlikely(IS_RDONLY(inode)))
-               return;
-
-       /*
-        * Don't update access timestamps on reads if mounted "noatime".
-        * Throw it away if anyone asks us.
-        */
-       if (unlikely(
-           (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
-           (flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
-                       XFS_ICHGTIME_ACC))
-               return;
-
        nanotime(&tv);
        if (flags & XFS_ICHGTIME_MOD) {
                inode->i_mtime = tv;
@@ -126,8 +130,6 @@ xfs_ichgtime(
  * Variant on the above which avoids querying the system clock
  * in situations where we know the Linux inode timestamps have
  * just been updated (and so we can update our inode cheaply).
- * We also skip the readonly and noatime checks here, they are
- * also catered for already.
  */
 void
 xfs_ichgtime_fast(
@@ -138,20 +140,16 @@ xfs_ichgtime_fast(
        timespec_t      *tvp;
 
        /*
-        * We're not supposed to change timestamps in readonly-mounted
-        * filesystems.  Throw it away if anyone asks us.
+        * Atime updates for read() & friends are handled lazily now, and
+        * explicit updates must go through xfs_ichgtime()
         */
-       if (unlikely(IS_RDONLY(inode)))
-               return;
+       ASSERT((flags & XFS_ICHGTIME_ACC) == 0);
 
        /*
-        * Don't update access timestamps on reads if mounted "noatime".
-        * Throw it away if anyone asks us.
+        * We're not supposed to change timestamps in readonly-mounted
+        * filesystems.  Throw it away if anyone asks us.
         */
-       if (unlikely(
-           (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
-           ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
-                       XFS_ICHGTIME_ACC)))
+       if (unlikely(IS_RDONLY(inode)))
                return;
 
        if (flags & XFS_ICHGTIME_MOD) {
@@ -159,11 +157,6 @@ xfs_ichgtime_fast(
                ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
                ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
        }
-       if (flags & XFS_ICHGTIME_ACC) {
-               tvp = &inode->i_atime;
-               ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec;
-               ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec;
-       }
        if (flags & XFS_ICHGTIME_CHG) {
                tvp = &inode->i_ctime;
                ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
@@ -203,7 +196,7 @@ validate_fields(
                ip->i_nlink = va.va_nlink;
                ip->i_blocks = va.va_nblocks;
 
-               /* we're under i_sem so i_size can't change under us */
+               /* we're under i_mutex so i_size can't change under us */
                if (i_size_read(ip) != va.va_size)
                        i_size_write(ip, va.va_size);
        }