[PATCH] vfs: update atimes over one day in the past or future

From: yangsheng
Date: Sat Dec 15 2012 - 08:46:22 EST


Relatime should update the inode atime if it is more than one day
in the future. The original problem seen was a tarball that had
a bad atime in the distant future, but could also happen if someone
fat-fingers a "touch". The future atime will never be fixed.

Without relatime enabled, a future atime is updated to the current
kernel time on access. Relatime is meant to reduce the frequency
of atime updates, not decide if whether the system clock or the
inode timestamp is correct or not.

Signed-off-by: Yang Sheng <sickamd@xxxxxxxxx>
Signed-off-by: Andreas Dilger <adilger@xxxxxxxxx>
Acked-by: David Chinner <david@xxxxxxxxxxxxx>
CC: stable@xxxxxxxxxxxxxxx
---
fs/inode.c | 7 ++++---
1 个æ??件被修æ?¹ï¼?æ??å?¥ 4 è¡?(+)ï¼?å? é?¤ 3 è¡?(-)

diff --git a/fs/inode.c b/fs/inode.c
index 14084b7..8713dc8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1488,10 +1488,11 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
return 1;

/*
- * Is the previous atime value older than a day? If yes,
- * update atime:
+ * Update atime if it's older than a day or more than a day
+ * in the future, which we assume is corrupt.
+ *
*/
- if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
+ if (abs(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
return 1;
/*
* Good, we can skip the atime update:
--
1.7.11.7


--------------030503060804010400080106--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/