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>, Adrian Bunk <bunk@stusta.de>,
Valerie Henson <val_henson@linux.intel.com>
Subject: [patch 1/1] Relative atime - kernel side
Date: Fri, 25 Aug 2006 16:52:16 -0700 [thread overview]
Message-ID: <20060825235235.605667000@linux.intel.com> (raw)
In-Reply-To: 20060825235215.820563000@linux.intel.com
[-- Attachment #1: relative-atime-kernel --]
[-- Type: text/plain, Size: 2713 bytes --]
Add "relatime" (relative atime) support. Relative atime only updates
the atime if the previous atime is older than the mtime or ctime.
Like noatime, but useful for applications like mutt that need to know
when a file has been read since it was last modified.
Signed-off-by: Valerie Henson <val_henson@linux.intel.com>
---
fs/inode.c | 11 ++++++++++-
fs/namespace.c | 5 ++++-
include/linux/fs.h | 1 +
include/linux/mount.h | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
--- linux-2.6.18-rc4-relatime.orig/fs/inode.c
+++ linux-2.6.18-rc4-relatime/fs/inode.c
@@ -1200,7 +1200,16 @@ 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 relative atime, only update atime if the previous
+ * atime is earlier than either the ctime or mtime.
+ */
+ if (!mnt ||
+ !(mnt->mnt_flags & MNT_RELATIME) ||
+ (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);
}
--- linux-2.6.18-rc4-relatime.orig/fs/namespace.c
+++ linux-2.6.18-rc4-relatime/fs/namespace.c
@@ -376,6 +376,7 @@ static int show_vfsmnt(struct seq_file *
{ MNT_NOEXEC, ",noexec" },
{ MNT_NOATIME, ",noatime" },
{ MNT_NODIRATIME, ",nodiratime" },
+ { MNT_RELATIME, ",relatime" },
{ 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_RELATIME)
+ mnt_flags |= MNT_RELATIME;
flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
- MS_NOATIME | MS_NODIRATIME);
+ MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
/* ... and get the mountpoint */
retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
--- linux-2.6.18-rc4-relatime.orig/include/linux/fs.h
+++ linux-2.6.18-rc4-relatime/include/linux/fs.h
@@ -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_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
#define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31)
--- linux-2.6.18-rc4-relatime.orig/include/linux/mount.h
+++ linux-2.6.18-rc4-relatime/include/linux/mount.h
@@ -27,6 +27,7 @@ struct namespace;
#define MNT_NOEXEC 0x04
#define MNT_NOATIME 0x08
#define MNT_NODIRATIME 0x10
+#define MNT_RELATIME 0x20
#define MNT_SHRINKABLE 0x100
--
next prev parent reply other threads:[~2006-08-25 23:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-25 23:52 [patch 0/1] Relative atime Valerie Henson
2006-08-25 23:52 ` Valerie Henson [this message]
2006-08-25 23:56 ` [patch] Relative atime - userspace Valerie Henson
2006-08-28 21:49 ` Josef Sipek
2006-08-29 0:14 ` Valerie Henson
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=20060825235235.605667000@linux.intel.com \
--to=val_henson@linux.intel.com \
--cc=akkana@shallowsky.com \
--cc=arjan@linux.intel.com \
--cc=bunk@stusta.de \
--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