linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCH] Relative lazy atime
@ 2006-08-03  6:29 Valerie Henson
  2006-08-03  6:44 ` Josef Sipek
  0 siblings, 1 reply; 24+ messages in thread
From: Valerie Henson @ 2006-08-03  6:29 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel
  Cc: Akkana Peck, Mark Fasheh, Jesse Barnes, Arjan van de Ven,
	Chris Wedgewood, jsipek, Al Viro, Christoph Hellwig

My friend Akkana followed my advice to use noatime on one of her
machines, but discovered that mutt was unusable because it always
thought that new messages had arrived since the last time it had
checked a folder (mbox format).  I thought this was a bummer, so I
wrote a "relative lazy atime" patch which only updates the atime if
the old atime was less than the ctime or mtime.  This is not the same
as the lazy atime patch of yore[1], which maintained a list of inodes
with dirty atimes and wrote them out on unmount.

Patch below.  Current version (plus test program) is at:

http://infohost.nmt.edu/~val/patches.html#lazyatime

Thanks to everyone who discussed this with me, especially the folks on
#linuxfs on irc.oftc.net.

-VAL

[1] http://www.ussg.iu.edu/hypermail/linux/kernel/0005.0/0284.html

---

Relative lazy atime - only update atime if the old atime was older
than the ctime or mtime.  We are maintaining atime relative to
mtime/ctime.

Not for inclusion (yet).

Written by Val Henson <val_henson@linux.intel.com>

 fs/inode.c            |   16 +++++++++++++++-
 fs/namespace.c        |    5 ++++-
 include/linux/fs.h    |    1 +
 include/linux/mount.h |    1 +
 4 files changed, 21 insertions(+), 2 deletions(-)
diff -Nrup a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	2006-08-02 23:10:56 -07:00
+++ b/fs/inode.c	2006-08-02 23:10:56 -07:00
@@ -1200,10 +1200,24 @@ void touch_atime(struct vfsmount *mnt, s
 		return;
 
 	now = current_fs_time(inode->i_sb);
-	if (!timespec_equal(&inode->i_atime, &now)) {
+	if (timespec_equal(&inode->i_atime, &now))
+		return;
+	/*
+	 * With lazy atime, only update atime if the previous atime is
+	 * earlier than either the ctime or mtime.
+	 */
+	if (!mnt ||
+	    !(mnt->mnt_flags & MNT_LAZYATIME) ||
+	    (timespec_compare(&inode->i_atime, &inode->i_mtime) < 0) ||
+	    (timespec_compare(&inode->i_atime, &inode->i_ctime) < 0)) {
 		inode->i_atime = now;
 		mark_inode_dirty_sync(inode);
 	}
+	/*
+	 * We could update the in-memory atime here if we wanted, but
+	 * that makes it possible for atime to revert if we evict the
+	 * inode from memory.
+	 */
 }
 
 EXPORT_SYMBOL(touch_atime);
diff -Nrup a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c	2006-08-02 23:10:56 -07:00
+++ b/fs/namespace.c	2006-08-02 23:10:56 -07:00
@@ -376,6 +376,7 @@ static int show_vfsmnt(struct seq_file *
 		{ MNT_NOEXEC, ",noexec" },
 		{ MNT_NOATIME, ",noatime" },
 		{ MNT_NODIRATIME, ",nodiratime" },
+		{ MNT_LAZYATIME, ",lazyatime" },
 		{ 0, NULL }
 	};
 	struct proc_fs_info *fs_infop;
@@ -1413,9 +1414,11 @@ long do_mount(char *dev_name, char *dir_
 		mnt_flags |= MNT_NOATIME;
 	if (flags & MS_NODIRATIME)
 		mnt_flags |= MNT_NODIRATIME;
+	if (flags & MS_LAZYATIME)
+		mnt_flags |= MNT_LAZYATIME;
 
 	flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
-		   MS_NOATIME | MS_NODIRATIME);
+		   MS_NOATIME | MS_NODIRATIME | MS_LAZYATIME);
 
 	/* ... and get the mountpoint */
 	retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
diff -Nrup a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	2006-08-02 23:10:56 -07:00
+++ b/include/linux/fs.h	2006-08-02 23:10:56 -07:00
@@ -119,6 +119,7 @@ extern int dir_notify_enable;
 #define MS_PRIVATE	(1<<18)	/* change to private */
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
+#define MS_LAZYATIME	(1<<21)	/* Lazily update on-disk access times. */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
diff -Nrup a/include/linux/mount.h b/include/linux/mount.h
--- a/include/linux/mount.h	2006-08-02 23:10:56 -07:00
+++ b/include/linux/mount.h	2006-08-02 23:10:56 -07:00
@@ -27,6 +27,7 @@ struct namespace;
 #define MNT_NOEXEC	0x04
 #define MNT_NOATIME	0x08
 #define MNT_NODIRATIME	0x10
+#define MNT_LAZYATIME	0x20
 
 #define MNT_SHRINKABLE	0x100
 

^ permalink raw reply	[flat|nested] 24+ messages in thread
* [RFC] [PATCH] Relative lazy atime
@ 2006-08-03  6:36 Valerie Henson
  2006-08-03 14:48 ` Matthew Wilcox
  2006-08-05 12:25 ` Christoph Hellwig
  0 siblings, 2 replies; 24+ messages in thread
From: Valerie Henson @ 2006-08-03  6:36 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel
  Cc: Akkana Peck, Mark Fasheh, Jesse Barnes, Arjan van de Ven,
	Chris Wedgwood, jsipek, Al Viro, Christoph Hellwig

(Corrected Chris Wedgwood's name and email.)

My friend Akkana followed my advice to use noatime on one of her
machines, but discovered that mutt was unusable because it always
thought that new messages had arrived since the last time it had
checked a folder (mbox format).  I thought this was a bummer, so I
wrote a "relative lazy atime" patch which only updates the atime if
the old atime was less than the ctime or mtime.  This is not the same
as the lazy atime patch of yore[1], which maintained a list of inodes
with dirty atimes and wrote them out on unmount.

Patch below.  Current version (plus test program) is at:

http://infohost.nmt.edu/~val/patches.html#lazyatime

Thanks to everyone who discussed this with me, especially the folks on
#linuxfs on irc.oftc.net.

-VAL

[1] http://www.ussg.iu.edu/hypermail/linux/kernel/0005.0/0284.html

---

Relative lazy atime - only update atime if the old atime was older
than the ctime or mtime.  We are maintaining atime relative to
mtime/ctime.

Not for inclusion (yet).

Written by Val Henson <val_henson@linux.intel.com>

 fs/inode.c            |   16 +++++++++++++++-
 fs/namespace.c        |    5 ++++-
 include/linux/fs.h    |    1 +
 include/linux/mount.h |    1 +
 4 files changed, 21 insertions(+), 2 deletions(-)
diff -Nrup a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	2006-08-02 23:10:56 -07:00
+++ b/fs/inode.c	2006-08-02 23:10:56 -07:00
@@ -1200,10 +1200,24 @@ void touch_atime(struct vfsmount *mnt, s
 		return;
 
 	now = current_fs_time(inode->i_sb);
-	if (!timespec_equal(&inode->i_atime, &now)) {
+	if (timespec_equal(&inode->i_atime, &now))
+		return;
+	/*
+	 * With lazy atime, only update atime if the previous atime is
+	 * earlier than either the ctime or mtime.
+	 */
+	if (!mnt ||
+	    !(mnt->mnt_flags & MNT_LAZYATIME) ||
+	    (timespec_compare(&inode->i_atime, &inode->i_mtime) < 0) ||
+	    (timespec_compare(&inode->i_atime, &inode->i_ctime) < 0)) {
 		inode->i_atime = now;
 		mark_inode_dirty_sync(inode);
 	}
+	/*
+	 * We could update the in-memory atime here if we wanted, but
+	 * that makes it possible for atime to revert if we evict the
+	 * inode from memory.
+	 */
 }
 
 EXPORT_SYMBOL(touch_atime);
diff -Nrup a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c	2006-08-02 23:10:56 -07:00
+++ b/fs/namespace.c	2006-08-02 23:10:56 -07:00
@@ -376,6 +376,7 @@ static int show_vfsmnt(struct seq_file *
 		{ MNT_NOEXEC, ",noexec" },
 		{ MNT_NOATIME, ",noatime" },
 		{ MNT_NODIRATIME, ",nodiratime" },
+		{ MNT_LAZYATIME, ",lazyatime" },
 		{ 0, NULL }
 	};
 	struct proc_fs_info *fs_infop;
@@ -1413,9 +1414,11 @@ long do_mount(char *dev_name, char *dir_
 		mnt_flags |= MNT_NOATIME;
 	if (flags & MS_NODIRATIME)
 		mnt_flags |= MNT_NODIRATIME;
+	if (flags & MS_LAZYATIME)
+		mnt_flags |= MNT_LAZYATIME;
 
 	flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
-		   MS_NOATIME | MS_NODIRATIME);
+		   MS_NOATIME | MS_NODIRATIME | MS_LAZYATIME);
 
 	/* ... and get the mountpoint */
 	retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
diff -Nrup a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	2006-08-02 23:10:56 -07:00
+++ b/include/linux/fs.h	2006-08-02 23:10:56 -07:00
@@ -119,6 +119,7 @@ extern int dir_notify_enable;
 #define MS_PRIVATE	(1<<18)	/* change to private */
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
+#define MS_LAZYATIME	(1<<21)	/* Lazily update on-disk access times. */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
diff -Nrup a/include/linux/mount.h b/include/linux/mount.h
--- a/include/linux/mount.h	2006-08-02 23:10:56 -07:00
+++ b/include/linux/mount.h	2006-08-02 23:10:56 -07:00
@@ -27,6 +27,7 @@ struct namespace;
 #define MNT_NOEXEC	0x04
 #define MNT_NOATIME	0x08
 #define MNT_NODIRATIME	0x10
+#define MNT_LAZYATIME	0x20
 
 #define MNT_SHRINKABLE	0x100

^ permalink raw reply	[flat|nested] 24+ messages in thread
[parent not found: <6Gts4-6UM-1@gated-at.bofh.it>]

end of thread, other threads:[~2006-08-10 17:26 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03  6:29 [RFC] [PATCH] Relative lazy atime Valerie Henson
2006-08-03  6:44 ` Josef Sipek
  -- strict thread matches above, loose matches on Subject: below --
2006-08-03  6:36 Valerie Henson
2006-08-03 14:48 ` Matthew Wilcox
2006-08-05 12:25 ` Christoph Hellwig
2006-08-05 13:22   ` Arjan van de Ven
2006-08-09 14:03     ` Valerie Henson
2006-08-09 15:49       ` Erez Zadok
2006-08-10 12:27       ` Helge Hafting
2006-08-05 16:58   ` Dave Kleikamp
2006-08-05 17:04     ` Arjan van de Ven
2006-08-05 18:36       ` Chris Wedgwood
2006-08-05 22:22         ` Mark Fasheh
2006-08-05 23:06           ` David Lang
2006-08-05 23:28             ` dean gaudet
2006-08-06  0:11               ` Chris Wedgwood
2006-08-06  3:01               ` Matthew Wilcox
2006-08-09  6:39                 ` Valerie Henson
2006-08-09 12:21                   ` Jörn Engel
2006-08-09 12:58                     ` Dave Kleikamp
2006-08-10 11:34                     ` Frank van Maarseveen
2006-08-10 17:28                   ` Bill Davidsen
2006-08-06  0:13             ` Mark Fasheh
     [not found] <6Gts4-6UM-1@gated-at.bofh.it>
     [not found] ` <6GxFs-4Tg-13@gated-at.bofh.it>
     [not found]   ` <6Gy8r-5Oh-11@gated-at.bofh.it>
     [not found]     ` <6Gze7-7oP-7@gated-at.bofh.it>
     [not found]       ` <6GCOJ-4fv-19@gated-at.bofh.it>
     [not found]         ` <6GDB1-5qX-3@gated-at.bofh.it>
     [not found]           ` <6GDKT-5Eb-37@gated-at.bofh.it>
     [not found]             ` <6GHbD-2hm-1@gated-at.bofh.it>
     [not found]               ` <6HQ3c-6Pf-9@gated-at.bofh.it>
     [not found]                 ` <6HVml-6DI-11@gated-at.bofh.it>
     [not found]                   ` <6Ih3l-5FP-1@gated-at.bofh.it>
2006-08-10 13:07                     ` Bodo Eggert

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).