From: Valerie Henson <val_henson@linux.intel.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Akkana Peck <akkana@shallowsky.com>,
Mark Fasheh <mark.fasheh@oracle.com>,
Jesse Barnes <jesse.barnes@intel.com>,
Arjan van de Ven <arjan@linux.intel.com>,
Chris Wedgewood <cw@foof.org>,
jsipek@cs.sunysb.edu, Al Viro <viro@ftp.linux.org.uk>,
Christoph Hellwig <hch@lst.de>
Subject: [RFC] [PATCH] Relative lazy atime
Date: Wed, 2 Aug 2006 23:29:45 -0700 [thread overview]
Message-ID: <20060803062944.GA8631@goober> (raw)
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
next reply other threads:[~2006-08-03 6:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-03 6:29 Valerie Henson [this message]
2006-08-03 6:44 ` [RFC] [PATCH] Relative lazy atime 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
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=20060803062944.GA8631@goober \
--to=val_henson@linux.intel.com \
--cc=akkana@shallowsky.com \
--cc=arjan@linux.intel.com \
--cc=cw@foof.org \
--cc=hch@lst.de \
--cc=jesse.barnes@intel.com \
--cc=jsipek@cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.fasheh@oracle.com \
--cc=viro@ftp.linux.org.uk \
/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).