Re: [patch] implement smarter atime updates support, v2

2007-08-05 Thread Ingo Molnar

* Theodore Tso <[EMAIL PROTECTED]> wrote:

> On Sun, Aug 05, 2007 at 09:28:38PM +0200, Ingo Molnar wrote:
> > 
> > added the relatime_interval sysctl that allows the changing of the 
> > atime update frequency. (default: 1 day / 86400 seconds)
> 
> What if you specify the interval as a per-mount option?  i.e.,
> 
>   mount -o relatime=86400 /dev/sda2 /u1
> 
> If you had this, I don't think we would need the sysctl tuning 
> parameter.

it's much more flexible if there are _more_ options available. People 
can thus make use of the feature earlier, use it even on distros that 
dont support it yet, etc.

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


Re: [patch] implement smarter atime updates support, v2

2007-08-05 Thread Theodore Tso
On Sun, Aug 05, 2007 at 09:28:38PM +0200, Ingo Molnar wrote:
> 
> added the relatime_interval sysctl that allows the changing of the atime 
> update frequency. (default: 1 day / 86400 seconds)

What if you specify the interval as a per-mount option?  i.e., 

mount -o relatime=86400 /dev/sda2 /u1

If you had this, I don't think we would need the sysctl tuning parameter.

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


Re: [patch] implement smarter atime updates support

2007-08-05 Thread Arjan van de Ven
On Sun, 2007-08-05 at 21:04 +0100, Alan Cox wrote:
> O> you might want to add
> > 
> > /* 
> >  * if the inode is dirty already, do the atime update since
> >  * we'll be doing the disk IO anyway to clean the inode.
> >  */
> > if (inode->i_state & I_DIRTY)
> > return 1;
> 
> This makes the actual result somewhat less predictable. Is that wise ?
> Right now its clear what happens based on what user sequence of events
> and that this is easily repeatable.

I can see the repeatability argument; on the flipside, having a system
of "opportunistic atime", eg as good as you can go cheaply, but with
minimum guarantees has some attraction as well. For example one could
imagine a system where the inode gets it's atime updated anyway, just
not flagged for writing back to disk. If it later undergoes some event
that would cause it to go to disk, it gets preserved...

otoh that's even more unpredictable since VM pressure could drop this
update early.

For the dirty case, such drawbacks don't exist; it's just one more step
of "when we can cheaply".

-- 
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via 
http://www.linuxfirmwarekit.org

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


Re: [patch] implement smarter atime updates support

2007-08-05 Thread Alan Cox
O> you might want to add
> 
>   /* 
>* if the inode is dirty already, do the atime update since
>* we'll be doing the disk IO anyway to clean the inode.
>*/
>   if (inode->i_state & I_DIRTY)
>   return 1;

This makes the actual result somewhat less predictable. Is that wise ?
Right now its clear what happens based on what user sequence of events
and that this is easily repeatable.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch] implement smarter atime updates support

2007-08-05 Thread Arjan van de Ven

> +static int relatime_need_update(struct inode *inode, struct timespec now)
> +{
> + /*
> +  * Is mtime younger than atime? If yes, update atime:
> +  */
> + if (timespec_compare(&inode->i_mtime, &inode->i_atime) >= 0)
> + return 1;
> + /*
> +  * Is ctime younger than atime? If yes, update atime:
> +  */
> + if (timespec_compare(&inode->i_ctime, &inode->i_atime) >= 0)
> + return 1;
> +
> + /*
> +  * Is the previous atime value older than a day? If yes,
> +  * update atime:
> +  */
> + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
> + return 1;


you might want to add

/* 
 * if the inode is dirty already, do the atime update since
 * we'll be doing the disk IO anyway to clean the inode.
 */
if (inode->i_state & I_DIRTY)
return 1;


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


[patch] implement smarter atime updates support, v2

2007-08-05 Thread Ingo Molnar

new version:

added the relatime_interval sysctl that allows the changing of the atime 
update frequency. (default: 1 day / 86400 seconds)

Ingo

-->
Subject: [patch] [patch] implement smarter atime updates support
From: Ingo Molnar <[EMAIL PROTECTED]>

change relatime updates to be performed once per day. This makes
relatime a compatible solution for HSM, mailer-notification and
tmpwatch applications too.

also add the CONFIG_DEFAULT_RELATIME kernel option, which makes
"norelatime" the default for all mounts without an extra kernel
boot option.

add the "default_relatime=0" boot option to turn this off.

also add the /proc/sys/kernel/default_relatime flag which can be changed
runtime to modify the behavior of subsequent new mounts.

tested by moving the date forward:

   # date
   Sun Aug  5 22:55:14 CEST 2007
   # date -s "Tue Aug  7 22:55:14 CEST 2007"
   Tue Aug  7 22:55:14 CEST 2007

access to a file did not generate disk IO before the date was set, and
it generated exactly one IO after the date was set.

Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
---
 Documentation/kernel-parameters.txt |8 +
 fs/Kconfig  |   22 ++
 fs/inode.c  |   53 +++-
 fs/namespace.c  |   24 
 include/linux/mount.h   |3 ++
 kernel/sysctl.c |   17 +++
 6 files changed, 114 insertions(+), 13 deletions(-)

Index: linux/Documentation/kernel-parameters.txt
===
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -525,6 +525,10 @@ and is between 256 and 4096 characters. 
This is a 16-member array composed of values
ranging from 0-255.
 
+   default_relatime=
+   [FS] mount all filesystems with relative atime
+   updates by default.
+
default_utf8=   [VT]
Format=<0|1>
Set system-wide default UTF-8 mode for all tty's.
@@ -1468,6 +1472,10 @@ and is between 256 and 4096 characters. 
Format: [,[,...]]
See arch/*/kernel/reboot.c or arch/*/kernel/process.c   

 
+   relatime_interval=
+   [FS] relative atime update frequency, in seconds.
+   (default: 1 day: 86400 seconds)
+
reserve=[KNL,BUGS] Force the kernel to ignore some iomem area
 
reservetop= [X86-32]
Index: linux/fs/Kconfig
===
--- linux.orig/fs/Kconfig
+++ linux/fs/Kconfig
@@ -2060,6 +2060,28 @@ config 9P_FS
 
 endmenu
 
+config DEFAULT_RELATIME
+   bool "Mount all filesystems with relatime by default"
+   default y
+   help
+ If you say Y here, all your filesystems will be mounted
+ with the "relatime" mount option. This eliminates many atime
+ ('file last accessed' timestamp) updates (which otherwise
+ is performed on every file access and generates a write
+ IO to the inode) and thus speeds up IO. Atime is still updated,
+ but only once per day.
+
+ The mtime ('file last modified') and ctime ('file created')
+ timestamp are unaffected by this change.
+
+ Use the "norelatime" kernel boot option to turn off this
+ feature.
+
+config DEFAULT_RELATIME_VAL
+   int
+   default "1" if DEFAULT_RELATIME
+   default "0"
+
 if BLOCK
 menu "Partition Types"
 
Index: linux/fs/inode.c
===
--- linux.orig/fs/inode.c
+++ linux/fs/inode.c
@@ -1162,6 +1162,41 @@ sector_t bmap(struct inode * inode, sect
 }
 EXPORT_SYMBOL(bmap);
 
+/*
+ * Relative atime updates frequency (default: 1 day):
+ */
+int relatime_interval __read_mostly = 24*60*60;
+
+/*
+ * With relative atime, only update atime if the
+ * previous atime is earlier than either the ctime or
+ * mtime.
+ */
+static int relatime_need_update(struct inode *inode, struct timespec now)
+{
+   /*
+* Is mtime younger than atime? If yes, update atime:
+*/
+   if (timespec_compare(&inode->i_mtime, &inode->i_atime) >= 0)
+   return 1;
+   /*
+* Is ctime younger than atime? If yes, update atime:
+*/
+   if (timespec_compare(&inode->i_ctime, &inode->i_atime) >= 0)
+   return 1;
+
+   /*
+* Is the previous atime value older than a day? If yes,
+* update atime:
+*/
+   if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval)
+

[patch] implement smarter atime updates support

2007-08-05 Thread Ingo Molnar

* Ingo Molnar <[EMAIL PROTECTED]> wrote:

> tested it by moving the date forward:
> 
>   # date
>   Sun Aug  5 22:55:14 CEST 2007
>   # date -s "Tue Aug  7 22:55:14 CEST 2007"
>   Tue Aug  7 22:55:14 CEST 2007
> 
> access to a file did not generate disk IO before the date was set, and 
> it generated exactly one IO after the date was set.
> 
> ( should i perhaps reduce the number of boot options and only use a
>   single "norelatime_default" boot option to turn this off? )

ok, cleaned it up some more: only a single, consistent boot option and 
all the switches (be that config, boot or sysctl) are now called 
"default_relatime". Also, got rid of that #ifdef ugliness in namespace.c 
via a cleaner Kconfig solution (suggested by Peter Zijlstra).

    Ingo

-------->
Subject: [patch] implement smarter atime updates support
From: Ingo Molnar <[EMAIL PROTECTED]>

change relatime updates to be performed once per day. This makes
relatime a compatible solution for HSM, mailer-notification and
tmpwatch applications too.

also add the CONFIG_DEFAULT_RELATIME kernel option, which makes
"norelatime" the default for all mounts without an extra kernel
boot option.

add the "default_relatime=0" boot option to turn this off.

also add the /proc/sys/kernel/default_relatime flag which can be changed
runtime to modify the behavior of subsequent new mounts.

tested by moving the date forward:

   # date
   Sun Aug  5 22:55:14 CEST 2007
   # date -s "Tue Aug  7 22:55:14 CEST 2007"
   Tue Aug  7 22:55:14 CEST 2007

access to a file did not generate disk IO before the date was set, and
it generated exactly one IO after the date was set.

Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
---
 Documentation/kernel-parameters.txt |4 +++
 fs/Kconfig  |   22 
 fs/inode.c  |   48 ++--
 fs/namespace.c  |   25 ++
 include/linux/mount.h   |2 +
 kernel/sysctl.c |9 ++
 6 files changed, 97 insertions(+), 13 deletions(-)

Index: linux/Documentation/kernel-parameters.txt
===
--- linux.orig/Documentation/kernel-parameters.txt
+++ linux/Documentation/kernel-parameters.txt
@@ -525,6 +525,10 @@ and is between 256 and 4096 characters. 
This is a 16-member array composed of values
ranging from 0-255.
 
+   default_relatime=
+   [FS] mount all filesystems with relative atime
+   updates by default.
+
default_utf8=   [VT]
Format=<0|1>
Set system-wide default UTF-8 mode for all tty's.
Index: linux/fs/Kconfig
===
--- linux.orig/fs/Kconfig
+++ linux/fs/Kconfig
@@ -2060,6 +2060,28 @@ config 9P_FS
 
 endmenu
 
+config DEFAULT_RELATIME
+   bool "Mount all filesystems with relatime by default"
+   default y
+   help
+ If you say Y here, all your filesystems will be mounted
+ with the "relatime" mount option. This eliminates many atime
+ ('file last accessed' timestamp) updates (which otherwise
+ is performed on every file access and generates a write
+ IO to the inode) and thus speeds up IO. Atime is still updated,
+ but only once per day.
+
+ The mtime ('file last modified') and ctime ('file created')
+ timestamp are unaffected by this change.
+
+ Use the "norelatime" kernel boot option to turn off this
+ feature.
+
+config DEFAULT_RELATIME_VAL
+   int
+   default "1" if DEFAULT_RELATIME
+   default "0"
+
 if BLOCK
 menu "Partition Types"
 
Index: linux/fs/inode.c
===
--- linux.orig/fs/inode.c
+++ linux/fs/inode.c
@@ -1162,6 +1162,36 @@ sector_t bmap(struct inode * inode, sect
 }
 EXPORT_SYMBOL(bmap);
 
+/*
+ * With relative atime, only update atime if the
+ * previous atime is earlier than either the ctime or
+ * mtime.
+ */
+static int relatime_need_update(struct inode *inode, struct timespec now)
+{
+   /*
+* Is mtime younger than atime? If yes, update atime:
+*/
+   if (timespec_compare(&inode->i_mtime, &inode->i_atime) >= 0)
+   return 1;
+   /*
+* Is ctime younger than atime? If yes, update atime:
+*/
+   if (timespec_compare(&inode->i_ctime, &inode->i_atime) >= 0)
+   return 1;
+
+   /*
+* Is the previous atime value older than a day? If yes,
+* update atime:
+*/
+