* [PATCH 1/2] relatime: Make atime updates more useful @ 2008-11-26 19:54 Matthew Garrett 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett ` (2 more replies) 0 siblings, 3 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-26 19:54 UTC (permalink / raw) To: linux-kernel; +Cc: linux-fsdevel, mingo, val.henson Allow atime to be updated once per day even with relatime enabled. This lets utilities like tmpreaper (which deletes files based on last access time) continue working. Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Updated version of Ingo's patch from last year - this section is identical. commit 2c145e187600ca961715fa82ae3ae7919d744bc9 Author: Matthew Garrett <mjg@redhat.com> Date: Wed Nov 26 17:44:07 2008 +0000 Make relatime smarter Allow atime to be updated once per day even with relatime. This lets utilities like tmpreaper (which delete files based on last access time) continue working. diff --git a/fs/inode.c b/fs/inode.c index 0487ddb..348fa16 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1179,6 +1179,41 @@ sector_t bmap(struct inode * inode, sector_t block) } 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 the update interval? + * If yes, update atime: + */ + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval) + return 1; + /* + * Good, we can skip the atime update: + */ + return 0; +} + /** * touch_atime - update the access time * @mnt: mount the inode is accessed on @@ -1206,17 +1241,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) goto out; if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) goto out; - if (mnt->mnt_flags & MNT_RELATIME) { - /* - * With relative atime, only update atime if the previous - * atime is earlier than either the ctime or mtime. - */ - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) - goto out; - } now = current_fs_time(inode->i_sb); + + if (mnt->mnt_flags & MNT_RELATIME) + if (!relatime_need_update(inode, now)) + goto out; if (timespec_equal(&inode->i_atime, &now)) goto out; -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH 2/2] relatime: Allow making relatime the default behaviour 2008-11-26 19:54 [PATCH 1/2] relatime: Make atime updates more useful Matthew Garrett @ 2008-11-26 19:58 ` Matthew Garrett 2008-11-26 21:11 ` Matthew Wilcox 2008-11-26 22:39 ` Randy Dunlap 2008-11-29 8:29 ` [PATCH 1/2] relatime: Make atime updates more useful Andrew Morton 2008-12-02 17:19 ` [PATCH] relatime: Let relatime update atime at least once per day Matthew Garrett 2 siblings, 2 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-26 19:58 UTC (permalink / raw) To: linux-kernel; +Cc: linux-fsdevel, mingo, val.henson Allow the kernel to enable relatime on all mounts by default. This can be configured at build time or by a kernel parameter or sysctl. Also add an MS_NORELATIME mount option to allow the default to be overridden for specific mount points. Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Updated version of Ingo's patch, but adds MS_NORELATIME. util-linux will need updating to match if this is merged. diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index e0f346d..eba3b07 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -616,6 +616,10 @@ and is between 256 and 4096 characters. It is defined in the file 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. + vt.default_utf8= [VT] Format=<0|1> @@ -1847,6 +1851,10 @@ and is between 256 and 4096 characters. It is defined in the file [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cpusets.txt. + 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] diff --git a/fs/Kconfig b/fs/Kconfig index 522469a..fcd3d48 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1546,6 +1546,29 @@ config 9P_FS endif # NETWORK_FILESYSTEMS +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" diff --git a/fs/inode.c b/fs/inode.c index 348fa16..51e9ae1 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1185,6 +1185,17 @@ EXPORT_SYMBOL(bmap); int relatime_interval __read_mostly = 24*60*60; /* + * Allow overriding the default relatime value on the kernel command line + */ +static int __init set_relatime_interval(char *str) +{ + get_option(&str, &relatime_interval); + + return 1; +} +__setup("relatime_interval=", set_relatime_interval); + +/* * With relative atime, only update atime if the * previous atime is earlier than either the ctime or * mtime. diff --git a/fs/namespace.c b/fs/namespace.c index 65b3dc8..76f30b5 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1883,6 +1883,24 @@ int copy_mount_options(const void __user * data, unsigned long *where) } /* + * Allow users to disable (or enable) atime updates via a .config + * option or via the boot line, or via /proc/sys/fs/default_relatime: + */ +int default_relatime __read_mostly = CONFIG_DEFAULT_RELATIME_VAL; + +static int __init set_default_relatime(char *str) +{ + get_option(&str, &default_relatime); + + printk(KERN_INFO "Mount all filesystems with" + "default relative atime updates: %s.\n", + default_relatime ? "enabled" : "disabled"); + + return 1; +} +__setup("default_relatime=", set_default_relatime); + +/* * Flags is a 32-bit value that allows up to 31 non-fs dependent flags to * be given to the mount() call (ie: read-only, no-dev, no-suid etc). * @@ -1930,6 +1948,11 @@ long do_mount(char *dev_name, char *dir_name, char *type_page, mnt_flags |= MNT_NODIRATIME; if (flags & MS_RELATIME) mnt_flags |= MNT_RELATIME; + else if (default_relatime && + !(flags & (MS_NOATIME | MS_NODIRATIME | MS_NORELATIME))) { + mnt_flags |= MNT_RELATIME; + flags |= MS_RELATIME; + } if (flags & MS_RDONLY) mnt_flags |= MNT_READONLY; diff --git a/include/linux/fs.h b/include/linux/fs.h index 0dcdd94..a4db010 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -135,6 +135,7 @@ extern int dir_notify_enable; #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ #define MS_I_VERSION (1<<23) /* Update inode I_version field */ +#define MS_NORELATIME (1<<24) /* Disable relatie even if the default */ #define MS_ACTIVE (1<<30) #define MS_NOUSER (1<<31) diff --git a/include/linux/mount.h b/include/linux/mount.h index cab2a85..71c7bc0 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -112,4 +112,7 @@ extern void mark_mounts_for_expiry(struct list_head *mounts); extern spinlock_t vfsmount_lock; extern dev_t name_to_dev_t(char *name); +extern int default_relatime; +extern int relatime_interval; + #endif /* _LINUX_MOUNT_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9d048fa..872c3d3 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -29,6 +29,7 @@ #include <linux/utsname.h> #include <linux/smp_lock.h> #include <linux/fs.h> +#include <linux/mount.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/kobject.h> @@ -1334,6 +1335,22 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "default_relatime", + .data = &default_relatime, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "relatime_interval", + .data = &relatime_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) { .ctl_name = CTL_UNNUMBERED, -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH 2/2] relatime: Allow making relatime the default behaviour 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett @ 2008-11-26 21:11 ` Matthew Wilcox 2008-11-26 22:39 ` Randy Dunlap 1 sibling, 0 replies; 44+ messages in thread From: Matthew Wilcox @ 2008-11-26 21:11 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson On Wed, Nov 26, 2008 at 07:58:24PM +0000, Matthew Garrett wrote: > +#define MS_NORELATIME (1<<24) /* Disable relatie even if the default */ typo Otherwise, looks good. Reviewed-by: Matthew Wilcox <willy@linux.intel.com> Instead of using __setup, could we use core_param() for these two parameters? I'm not sure that core_param are exposed in /sys or /proc anywhere ... if we could fix that, I think it'd simplify this patch enormously. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH 2/2] relatime: Allow making relatime the default behaviour 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-26 21:11 ` Matthew Wilcox @ 2008-11-26 22:39 ` Randy Dunlap 2008-11-27 15:01 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Matthew Garrett 1 sibling, 1 reply; 44+ messages in thread From: Randy Dunlap @ 2008-11-26 22:39 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson Matthew Garrett wrote: > Allow the kernel to enable relatime on all mounts by default. This can > be configured at build time or by a kernel parameter or sysctl. Also add > an MS_NORELATIME mount option to allow the default to be overridden for > specific mount points. > > Signed-off-by: Matthew Garrett <mjg@redhat.com> > > --- Hi, Please use diffstat for all (non-trivial) patches. or whatever git calls it. Comments below... > Updated version of Ingo's patch, but adds MS_NORELATIME. util-linux will > need updating to match if this is merged. > > diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt > index e0f346d..eba3b07 100644 > --- a/Documentation/kernel-parameters.txt > +++ b/Documentation/kernel-parameters.txt > @@ -616,6 +616,10 @@ and is between 256 and 4096 characters. It is defined in the file > 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. > + I had rather see it called "relatime_default" fwiw. > vt.default_utf8= > [VT] > Format=<0|1> > @@ -1847,6 +1851,10 @@ and is between 256 and 4096 characters. It is defined in the file > [KNL, SMP] Set scheduler's default relax_domain_level. > See Documentation/cpusets.txt. > > + 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] > diff --git a/fs/Kconfig b/fs/Kconfig > index 522469a..fcd3d48 100644 > --- a/fs/Kconfig > +++ b/fs/Kconfig > @@ -1546,6 +1546,29 @@ config 9P_FS > > endif # NETWORK_FILESYSTEMS > > +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" > > diff --git a/fs/inode.c b/fs/inode.c > index 348fa16..51e9ae1 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -1185,6 +1185,17 @@ EXPORT_SYMBOL(bmap); > int relatime_interval __read_mostly = 24*60*60; > > /* > + * Allow overriding the default relatime value on the kernel command line > + */ > +static int __init set_relatime_interval(char *str) > +{ > + get_option(&str, &relatime_interval); > + > + return 1; > +} > +__setup("relatime_interval=", set_relatime_interval); > + > +/* > * With relative atime, only update atime if the > * previous atime is earlier than either the ctime or > * mtime. > diff --git a/fs/namespace.c b/fs/namespace.c > index 65b3dc8..76f30b5 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -1883,6 +1883,24 @@ int copy_mount_options(const void __user * data, unsigned long *where) > } > > /* > + * Allow users to disable (or enable) atime updates via a .config > + * option or via the boot line, or via /proc/sys/fs/default_relatime: > + */ > +int default_relatime __read_mostly = CONFIG_DEFAULT_RELATIME_VAL; > + > +static int __init set_default_relatime(char *str) > +{ > + get_option(&str, &default_relatime); > + > + printk(KERN_INFO "Mount all filesystems with" missing a space between "with" and "default". > + "default relative atime updates: %s.\n", > + default_relatime ? "enabled" : "disabled"); > + > + return 1; > +} > +__setup("default_relatime=", set_default_relatime); > + > +/* > * Flags is a 32-bit value that allows up to 31 non-fs dependent flags to > * be given to the mount() call (ie: read-only, no-dev, no-suid etc). > * > @@ -1930,6 +1948,11 @@ long do_mount(char *dev_name, char *dir_name, char *type_page, > mnt_flags |= MNT_NODIRATIME; > if (flags & MS_RELATIME) > mnt_flags |= MNT_RELATIME; > + else if (default_relatime && > + !(flags & (MS_NOATIME | MS_NODIRATIME | MS_NORELATIME))) { > + mnt_flags |= MNT_RELATIME; > + flags |= MS_RELATIME; > + } > if (flags & MS_RDONLY) > mnt_flags |= MNT_READONLY; > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 0dcdd94..a4db010 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -135,6 +135,7 @@ extern int dir_notify_enable; > #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ > #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ > #define MS_I_VERSION (1<<23) /* Update inode I_version field */ > +#define MS_NORELATIME (1<<24) /* Disable relatie even if the default */ relatime > #define MS_ACTIVE (1<<30) > #define MS_NOUSER (1<<31) -- ~Randy ^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH v2 1/2] relatime: Make relatime behaviour smarter 2008-11-26 22:39 ` Randy Dunlap @ 2008-11-27 15:01 ` Matthew Garrett 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-27 15:06 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Ingo Molnar 0 siblings, 2 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 15:01 UTC (permalink / raw) To: Randy Dunlap; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson, matthew Make relatime smarter Allow atime to be updated once per day even with relatime. This lets utilities like tmpreaper (which delete files based on last access time) continue working. --- Subset of Ingo's original patch, rediffed against current git diff --git a/fs/inode.c b/fs/inode.c index 0487ddb..348fa16 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1179,6 +1179,41 @@ sector_t bmap(struct inode * inode, sector_t block) } 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 the update interval? + * If yes, update atime: + */ + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval) + return 1; + /* + * Good, we can skip the atime update: + */ + return 0; +} + /** * touch_atime - update the access time * @mnt: mount the inode is accessed on @@ -1206,17 +1241,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) goto out; if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) goto out; - if (mnt->mnt_flags & MNT_RELATIME) { - /* - * With relative atime, only update atime if the previous - * atime is earlier than either the ctime or mtime. - */ - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) - goto out; - } now = current_fs_time(inode->i_sb); + + if (mnt->mnt_flags & MNT_RELATIME) + if (!relatime_need_update(inode, now)) + goto out; if (timespec_equal(&inode->i_atime, &now)) goto out; -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 15:01 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Matthew Garrett @ 2008-11-27 15:03 ` Matthew Garrett 2008-11-27 15:07 ` Ingo Molnar ` (3 more replies) 2008-11-27 15:06 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Ingo Molnar 1 sibling, 4 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 15:03 UTC (permalink / raw) To: Randy Dunlap; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson, matthew Add support for defaulting to relatime Allow the kernel to enable relatime on all mounts by default. This can be configured at build time or by a kernel parameter or sysctl. Also add a MS_NORELATIME mount option to allow the default to be overridden for specific mount points. Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Incorporates Randy's suggestion to change default_relatime to relatime_default, along with a couple of typographical fixes diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index e0f346d..1738be9 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1847,6 +1847,14 @@ and is between 256 and 4096 characters. It is defined in the file [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cpusets.txt. + relatime_default= + [FS] mount all filesystems with relative atime + updates by default. + + 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] diff --git a/fs/Kconfig b/fs/Kconfig index 522469a..fcd3d48 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1546,6 +1546,29 @@ config 9P_FS endif # NETWORK_FILESYSTEMS +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" diff --git a/fs/inode.c b/fs/inode.c index 348fa16..51e9ae1 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1185,6 +1185,17 @@ EXPORT_SYMBOL(bmap); int relatime_interval __read_mostly = 24*60*60; /* + * Allow overriding the default relatime value on the kernel command line + */ +static int __init set_relatime_interval(char *str) +{ + get_option(&str, &relatime_interval); + + return 1; +} +__setup("relatime_interval=", set_relatime_interval); + +/* * With relative atime, only update atime if the * previous atime is earlier than either the ctime or * mtime. diff --git a/fs/namespace.c b/fs/namespace.c index 65b3dc8..b7b72c2 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1883,6 +1883,24 @@ int copy_mount_options(const void __user * data, unsigned long *where) } /* + * Allow users to disable (or enable) atime updates via a .config + * option or via the boot line, or via /proc/sys/fs/relatime_default: + */ +int relatime_default __read_mostly = CONFIG_DEFAULT_RELATIME_VAL; + +static int __init set_relatime_default(char *str) +{ + get_option(&str, &relatime_default); + + printk(KERN_INFO "Mount all filesystems with " + "default relative atime updates: %s.\n", + relatime_default ? "enabled" : "disabled"); + + return 1; +} +__setup("relatime_default=", set_relatime_default); + +/* * Flags is a 32-bit value that allows up to 31 non-fs dependent flags to * be given to the mount() call (ie: read-only, no-dev, no-suid etc). * @@ -1930,6 +1948,11 @@ long do_mount(char *dev_name, char *dir_name, char *type_page, mnt_flags |= MNT_NODIRATIME; if (flags & MS_RELATIME) mnt_flags |= MNT_RELATIME; + else if (relatime_default && + !(flags & (MS_NOATIME | MS_NODIRATIME | MS_NORELATIME))) { + mnt_flags |= MNT_RELATIME; + flags |= MS_RELATIME; + } if (flags & MS_RDONLY) mnt_flags |= MNT_READONLY; diff --git a/include/linux/fs.h b/include/linux/fs.h index 0dcdd94..0dfdce2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -135,6 +135,7 @@ extern int dir_notify_enable; #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ #define MS_I_VERSION (1<<23) /* Update inode I_version field */ +#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */ #define MS_ACTIVE (1<<30) #define MS_NOUSER (1<<31) diff --git a/include/linux/mount.h b/include/linux/mount.h index cab2a85..2595882 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -112,4 +112,7 @@ extern void mark_mounts_for_expiry(struct list_head *mounts); extern spinlock_t vfsmount_lock; extern dev_t name_to_dev_t(char *name); +extern int relatime_default; +extern int relatime_interval; + #endif /* _LINUX_MOUNT_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9d048fa..b570827 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -29,6 +29,7 @@ #include <linux/utsname.h> #include <linux/smp_lock.h> #include <linux/fs.h> +#include <linux/mount.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/kobject.h> @@ -1334,6 +1335,22 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "relatime_default", + .data = &relatime_default, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "relatime_interval", + .data = &relatime_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) { .ctl_name = CTL_UNNUMBERED, -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett @ 2008-11-27 15:07 ` Ingo Molnar 2008-11-27 16:03 ` Karel Zak ` (2 subsequent siblings) 3 siblings, 0 replies; 44+ messages in thread From: Ingo Molnar @ 2008-11-27 15:07 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew * Matthew Garrett <mjg@redhat.com> wrote: > Add support for defaulting to relatime > > Allow the kernel to enable relatime on all mounts by default. This can be > configured at build time or by a kernel parameter or sysctl. Also add a > MS_NORELATIME mount option to allow the default to be overridden for specific > mount points. > > Signed-off-by: Matthew Garrett <mjg@redhat.com> > > --- > > Incorporates Randy's suggestion to change default_relatime to > relatime_default, along with a couple of typographical fixes > +config DEFAULT_RELATIME > + bool "Mount all filesystems with relatime by default" > + default y This should not be enabled by default - but distros can set it to enabled just fine. Looks good otherwise! Acked-by: Ingo Molnar <mingo@elte.hu> Ingo ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-27 15:07 ` Ingo Molnar @ 2008-11-27 16:03 ` Karel Zak [not found] ` <20081127160353.GQ2961-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org> 2008-11-27 16:35 ` Alan Cox 2008-11-27 17:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Christoph Hellwig 3 siblings, 1 reply; 44+ messages in thread From: Karel Zak @ 2008-11-27 16:03 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew, util-linux-ng On Thu, Nov 27, 2008 at 03:03:41PM +0000, Matthew Garrett wrote: > Also add a MS_NORELATIME mount option [...] > +#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */ CC: util-linux-ng@vger.kernel.org Karel -- Karel Zak <kzak@redhat.com> ^ permalink raw reply [flat|nested] 44+ messages in thread
[parent not found: <20081127160353.GQ2961-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>]
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour [not found] ` <20081127160353.GQ2961-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org> @ 2008-11-27 17:30 ` Pádraig Brady [not found] ` <492ED945.5010600-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org> 0 siblings, 1 reply; 44+ messages in thread From: Pádraig Brady @ 2008-11-27 17:30 UTC (permalink / raw) To: Karel Zak Cc: Matthew Garrett, Randy Dunlap, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, mingo-H+wXaHxf7aLQT0dZR+AlfA, val.henson-Re5JQEeQqe8AvxtiuMwx3w, matthew-Ztpu424NOJ8, util-linux-ng-u79uwXL29TY76Z2rM5mHXA Karel Zak wrote: > On Thu, Nov 27, 2008 at 03:03:41PM +0000, Matthew Garrett wrote: >> Also add a MS_NORELATIME mount option > [...] >> +#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */ > > CC: util-linux-ng-u79uwXL29TY76Z2rM5mHXA@public.gmane.org That's useful. Without this, to disable relatime you needed to: echo 0 > /proc/sys/fs/default_relatime mount -o remount,atime /mnt/point/ -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 44+ messages in thread
[parent not found: <492ED945.5010600-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>]
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour [not found] ` <492ED945.5010600-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org> @ 2008-11-27 17:39 ` Matthew Garrett 0 siblings, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 17:39 UTC (permalink / raw) To: Pádraig Brady Cc: Karel Zak, Randy Dunlap, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, mingo-H+wXaHxf7aLQT0dZR+AlfA, val.henson-Re5JQEeQqe8AvxtiuMwx3w, matthew-Ztpu424NOJ8, util-linux-ng-u79uwXL29TY76Z2rM5mHXA On Thu, Nov 27, 2008 at 05:30:45PM +0000, Pádraig Brady wrote: > Karel Zak wrote: > > On Thu, Nov 27, 2008 at 03:03:41PM +0000, Matthew Garrett wrote: > >> Also add a MS_NORELATIME mount option > > [...] > >> +#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */ > > > > CC: util-linux-ng-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > > That's useful. Without this, to disable relatime you needed to: > > echo 0 > /proc/sys/fs/default_relatime > mount -o remount,atime /mnt/point/ I'm dropping that hunk - it's easier to default to relatime in userspace, so there's no need to have a kernel fs parameter to forcibly disable it. -- Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-27 15:07 ` Ingo Molnar 2008-11-27 16:03 ` Karel Zak @ 2008-11-27 16:35 ` Alan Cox 2008-11-27 16:47 ` Matthew Garrett 2008-11-27 17:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Christoph Hellwig 3 siblings, 1 reply; 44+ messages in thread From: Alan Cox @ 2008-11-27 16:35 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew > +config DEFAULT_RELATIME > + bool "Mount all filesystems with relatime by default" > + default y NAK this This is a change in behaviour and you don't turn it on by default so most users will miss it. You don't need it anyway and it doesn't need to be a kernel configuration option > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -135,6 +135,7 @@ extern int dir_notify_enable; > #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ > #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ > #define MS_I_VERSION (1<<23) /* Update inode I_version field */ > +#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */ NAK this Putting in extra flags to allow the kernel and user space to fight each other over mount defaults is a recipe for disaster. Take your userspace mount command and beat it up appropriately. If you want a mount command that defaults to relatime then ship a mount command that does. This patch really doesn't make sense. You add a compile time option to vary behaviour Because it is compile time you then add a way to change it back at runtime Because you need to override this you then add a flag to mount It's rather easier just to fix your distribution mount package. Also please keep different features in different patches. This patch muddles together - Improvements to relatime algorithms for stuff like tmpwatch - A large chunk of material to do with changing mount behaviour The two are I think unrelated and the algorithm change looks quite sensible. Alan PS: NTL still hates you ;) ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 16:35 ` Alan Cox @ 2008-11-27 16:47 ` Matthew Garrett 2008-11-27 16:59 ` [PATCH v3] relatime: Make relatime smarter Matthew Garrett 0 siblings, 1 reply; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 16:47 UTC (permalink / raw) To: Alan Cox Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Thu, Nov 27, 2008 at 04:35:35PM +0000, Alan Cox wrote: > Putting in extra flags to allow the kernel and user space to fight each > other over mount defaults is a recipe for disaster. Take your userspace > mount command and beat it up appropriately. If you want a mount command > that defaults to relatime then ship a mount command that does. Yes, that sounds like a reasonable approach. In that case I'll update the first to include the support for configuring the timeout. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH v3] relatime: Make relatime smarter 2008-11-27 16:47 ` Matthew Garrett @ 2008-11-27 16:59 ` Matthew Garrett 2008-11-27 17:06 ` Christoph Hellwig 2008-11-27 19:15 ` [PATCH v3] " Alan Cox 0 siblings, 2 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 16:59 UTC (permalink / raw) To: Alan Cox Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew Make relatime smarter Allow atime to be updated once per day even with relatime. This lets utilities like tmpreaper (which delete files based on last access time) continue working. The time between atime updates can be configured at boot with the relatime_interval kernel argument, or at runtime through /proc Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Drop the default behaviour section - as Alan suggests, it can be handled in userspace. Merge the configuration code into the change in behaviour patch. Documentation/kernel-parameters.txt | 4 ++ fs/inode.c | 59 +++++++++++++++++++++++++++++----- include/linux/mount.h | 2 + kernel/sysctl.c | 9 +++++ 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index e0f346d..6d0dc0a 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1847,6 +1847,10 @@ and is between 256 and 4096 characters. It is defined in the file [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cpusets.txt. + 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] diff --git a/fs/inode.c b/fs/inode.c index 0487ddb..51e9ae1 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1179,6 +1179,52 @@ sector_t bmap(struct inode * inode, sector_t block) } EXPORT_SYMBOL(bmap); +/* + * Relative atime updates frequency (default: 1 day): + */ +int relatime_interval __read_mostly = 24*60*60; + +/* + * Allow overriding the default relatime value on the kernel command line + */ +static int __init set_relatime_interval(char *str) +{ + get_option(&str, &relatime_interval); + + return 1; +} +__setup("relatime_interval=", set_relatime_interval); + +/* + * 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 the update interval? + * If yes, update atime: + */ + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval) + return 1; + /* + * Good, we can skip the atime update: + */ + return 0; +} + /** * touch_atime - update the access time * @mnt: mount the inode is accessed on @@ -1206,17 +1252,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) goto out; if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) goto out; - if (mnt->mnt_flags & MNT_RELATIME) { - /* - * With relative atime, only update atime if the previous - * atime is earlier than either the ctime or mtime. - */ - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) - goto out; - } now = current_fs_time(inode->i_sb); + + if (mnt->mnt_flags & MNT_RELATIME) + if (!relatime_need_update(inode, now)) + goto out; if (timespec_equal(&inode->i_atime, &now)) goto out; diff --git a/include/linux/mount.h b/include/linux/mount.h index cab2a85..978fb10 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -112,4 +112,6 @@ extern void mark_mounts_for_expiry(struct list_head *mounts); extern spinlock_t vfsmount_lock; extern dev_t name_to_dev_t(char *name); +extern int relatime_interval; + #endif /* _LINUX_MOUNT_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9d048fa..f085ad6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -29,6 +29,7 @@ #include <linux/utsname.h> #include <linux/smp_lock.h> #include <linux/fs.h> +#include <linux/mount.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/kobject.h> @@ -1334,6 +1335,14 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "relatime_interval", + .data = &relatime_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) { .ctl_name = CTL_UNNUMBERED, -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH v3] relatime: Make relatime smarter 2008-11-27 16:59 ` [PATCH v3] relatime: Make relatime smarter Matthew Garrett @ 2008-11-27 17:06 ` Christoph Hellwig 2008-11-27 17:58 ` [PATCH v4] " Matthew Garrett 2008-11-27 19:15 ` [PATCH v3] " Alan Cox 1 sibling, 1 reply; 44+ messages in thread From: Christoph Hellwig @ 2008-11-27 17:06 UTC (permalink / raw) To: Matthew Garrett Cc: Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Thu, Nov 27, 2008 at 04:59:29PM +0000, Matthew Garrett wrote: > Make relatime smarter > > Allow atime to be updated once per day even with relatime. This lets > utilities like tmpreaper (which delete files based on last access time) > continue working. The time between atime updates can be configured at boot > with the relatime_interval kernel argument, or at runtime through /proc Technically it's sysctl which just happens to be exposed in /proc.. > + if (mnt->mnt_flags & MNT_RELATIME) > + if (!relatime_need_update(inode, now)) > + goto out; > if (timespec_equal(&inode->i_atime, &now)) Maybe rename relatime_need_update to atime_need_update and factor this check into it? Except for this nitpicks this seems extremly useful ^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH v4] relatime: Make relatime smarter 2008-11-27 17:06 ` Christoph Hellwig @ 2008-11-27 17:58 ` Matthew Garrett 2008-11-27 22:08 ` Andreas Dilger 2008-11-28 11:18 ` Jamie Lokier 0 siblings, 2 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-27 17:58 UTC (permalink / raw) To: Christoph Hellwig Cc: Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew Make relatime smarter Allow atime to be updated once per day even with relatime. This lets utilities like tmpreaper (which delete files based on last access time) continue working. The time between atime updates can be configured at boot with the relatime_interval kernel argument, or at runtime through a sysctl. Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Adds Christoph's suggestions. Documentation/kernel-parameters.txt | 4 ++ fs/inode.c | 63 ++++++++++++++++++++++++++++++----- include/linux/mount.h | 2 + kernel/sysctl.c | 9 +++++ 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index e0f346d..6d0dc0a 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1847,6 +1847,10 @@ and is between 256 and 4096 characters. It is defined in the file [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cpusets.txt. + 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] diff --git a/fs/inode.c b/fs/inode.c index 0487ddb..4899063 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1179,6 +1179,56 @@ sector_t bmap(struct inode * inode, sector_t block) } EXPORT_SYMBOL(bmap); +/* + * Relative atime updates frequency (default: 1 day): + */ +int relatime_interval __read_mostly = 24*60*60; + +/* + * Allow overriding the default relatime value on the kernel command line + */ +static int __init set_relatime_interval(char *str) +{ + get_option(&str, &relatime_interval); + + return 1; +} +__setup("relatime_interval=", set_relatime_interval); + +/* + * With relative atime, only update atime if the + * previous atime is earlier than either the ctime or + * mtime. + */ +static int atime_need_update(struct vfsmount *mnt, struct inode *inode, + struct timespec now) +{ + + if (!(mnt->mnt_flags & MNT_RELATIME)) + return 1; + /* + * 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 the update interval? + * If yes, update atime: + */ + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval) + return 1; + /* + * Good, we can skip the atime update: + */ + return 0; +} + /** * touch_atime - update the access time * @mnt: mount the inode is accessed on @@ -1206,17 +1256,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) goto out; if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) goto out; - if (mnt->mnt_flags & MNT_RELATIME) { - /* - * With relative atime, only update atime if the previous - * atime is earlier than either the ctime or mtime. - */ - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) - goto out; - } now = current_fs_time(inode->i_sb); + + if (!atime_need_update(mnt, inode, now)) + goto out; + if (timespec_equal(&inode->i_atime, &now)) goto out; diff --git a/include/linux/mount.h b/include/linux/mount.h index cab2a85..978fb10 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -112,4 +112,6 @@ extern void mark_mounts_for_expiry(struct list_head *mounts); extern spinlock_t vfsmount_lock; extern dev_t name_to_dev_t(char *name); +extern int relatime_interval; + #endif /* _LINUX_MOUNT_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9d048fa..f085ad6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -29,6 +29,7 @@ #include <linux/utsname.h> #include <linux/smp_lock.h> #include <linux/fs.h> +#include <linux/mount.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/kobject.h> @@ -1334,6 +1335,14 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "relatime_interval", + .data = &relatime_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) { .ctl_name = CTL_UNNUMBERED, -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-27 17:58 ` [PATCH v4] " Matthew Garrett @ 2008-11-27 22:08 ` Andreas Dilger 2008-11-27 22:35 ` Matthew Wilcox ` (2 more replies) 2008-11-28 11:18 ` Jamie Lokier 1 sibling, 3 replies; 44+ messages in thread From: Andreas Dilger @ 2008-11-27 22:08 UTC (permalink / raw) To: Matthew Garrett Cc: Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Nov 27, 2008 17:58 +0000, Matthew Garrett wrote: > + relatime_interval= > + [FS] relative atime update frequency, in seconds. > + (default: 1 day: 86400 seconds) The one problem with a 1-day default is that cron jobs like updatedb will revert to updating the atime on every single file every day. It would be better to make it slightly more than 1 day (e.g. 25h) to avoid this and at least defer atime updates to every other day for files that are not otherwise accessed except by cron. Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc. ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-27 22:08 ` Andreas Dilger @ 2008-11-27 22:35 ` Matthew Wilcox 2008-11-28 11:13 ` Jamie Lokier 2008-11-28 13:41 ` Matthew Garrett 2 siblings, 0 replies; 44+ messages in thread From: Matthew Wilcox @ 2008-11-27 22:35 UTC (permalink / raw) To: Andreas Dilger Cc: Matthew Garrett, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Thu, Nov 27, 2008 at 03:08:39PM -0700, Andreas Dilger wrote: > On Nov 27, 2008 17:58 +0000, Matthew Garrett wrote: > > + relatime_interval= > > + [FS] relative atime update frequency, in seconds. > > + (default: 1 day: 86400 seconds) > > The one problem with a 1-day default is that cron jobs like updatedb will > revert to updating the atime on every single file every day. It would be > better to make it slightly more than 1 day (e.g. 25h) to avoid this and > at least defer atime updates to every other day for files that are not > otherwise accessed except by cron. Doesn't updatedb only access directories, not files? I don't think relatime implies nodiratime, but certainly the two could both be specified, and that would fix one of the updatedb problems. Are there any other common cronjobs you're concerned about? -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-27 22:08 ` Andreas Dilger 2008-11-27 22:35 ` Matthew Wilcox @ 2008-11-28 11:13 ` Jamie Lokier 2008-11-28 13:41 ` Matthew Garrett 2 siblings, 0 replies; 44+ messages in thread From: Jamie Lokier @ 2008-11-28 11:13 UTC (permalink / raw) To: Andreas Dilger Cc: Matthew Garrett, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew Andreas Dilger wrote: > The one problem with a 1-day default is that cron jobs like updatedb will > revert to updating the atime on every single file every day. It would be > better to make it slightly more than 1 day (e.g. 25h) to avoid this and > at least defer atime updates to every other day for files that are not > otherwise accessed except by cron. On my computers (laptops) updatedb doesn't run at exact 24h intervals - that would only happen for computers powered up all the time. -- Jamie ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-27 22:08 ` Andreas Dilger 2008-11-27 22:35 ` Matthew Wilcox 2008-11-28 11:13 ` Jamie Lokier @ 2008-11-28 13:41 ` Matthew Garrett 2 siblings, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-28 13:41 UTC (permalink / raw) To: Andreas Dilger Cc: Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Thu, Nov 27, 2008 at 03:08:39PM -0700, Andreas Dilger wrote: > The one problem with a 1-day default is that cron jobs like updatedb will > revert to updating the atime on every single file every day. It would be > better to make it slightly more than 1 day (e.g. 25h) to avoid this and > at least defer atime updates to every other day for files that are not > otherwise accessed except by cron. I don't see the real benefit to this. If you want to prevent atime updates entirely, use noatime rather than relatime. Increasing the timeout just means that you get increased disk activity every other day rather than every day, which isn't really the problem we're trying to solve. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-27 17:58 ` [PATCH v4] " Matthew Garrett 2008-11-27 22:08 ` Andreas Dilger @ 2008-11-28 11:18 ` Jamie Lokier 2008-11-28 13:40 ` Matthew Wilcox 1 sibling, 1 reply; 44+ messages in thread From: Jamie Lokier @ 2008-11-28 11:18 UTC (permalink / raw) To: Matthew Garrett Cc: Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew Matthew Garrett wrote: > The time between atime updates can be configured at boot > with the relatime_interval kernel argument, or at runtime through a sysctl. Shouldn't it be a per-mount value, with defaults coming from the sysctl? -- Jamie ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-28 11:18 ` Jamie Lokier @ 2008-11-28 13:40 ` Matthew Wilcox 2008-11-28 13:47 ` Matthew Garrett 2008-12-02 11:10 ` Karel Zak 0 siblings, 2 replies; 44+ messages in thread From: Matthew Wilcox @ 2008-11-28 13:40 UTC (permalink / raw) To: Jamie Lokier Cc: Matthew Garrett, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Fri, Nov 28, 2008 at 11:18:09AM +0000, Jamie Lokier wrote: > Matthew Garrett wrote: > > The time between atime updates can be configured at boot > > with the relatime_interval kernel argument, or at runtime through a sysctl. > > Shouldn't it be a per-mount value, with defaults coming from the sysctl? Perhaps a more sensible question would be "Why make it configurable at all?" What's wrong with hardcoding 24 hours? Or, to put it another way, who wants to change it from 24 hours, and why? -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-28 13:40 ` Matthew Wilcox @ 2008-11-28 13:47 ` Matthew Garrett 2008-12-02 11:10 ` Karel Zak 1 sibling, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-28 13:47 UTC (permalink / raw) To: Matthew Wilcox Cc: Jamie Lokier, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Fri, Nov 28, 2008 at 06:40:55AM -0700, Matthew Wilcox wrote: > On Fri, Nov 28, 2008 at 11:18:09AM +0000, Jamie Lokier wrote: > > Matthew Garrett wrote: > > > The time between atime updates can be configured at boot > > > with the relatime_interval kernel argument, or at runtime through a sysctl. > > > > Shouldn't it be a per-mount value, with defaults coming from the sysctl? > > Perhaps a more sensible question would be "Why make it configurable at > all?" What's wrong with hardcoding 24 hours? Or, to put it another > way, who wants to change it from 24 hours, and why? There's approximately no cost to it, and arguably use cases that would benefit. I don't think they'd be common enough to benefit from the additional complexity of making it per-mount. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-11-28 13:40 ` Matthew Wilcox 2008-11-28 13:47 ` Matthew Garrett @ 2008-12-02 11:10 ` Karel Zak 2008-12-02 16:46 ` Matthew Wilcox 1 sibling, 1 reply; 44+ messages in thread From: Karel Zak @ 2008-12-02 11:10 UTC (permalink / raw) To: Matthew Wilcox Cc: Jamie Lokier, Matthew Garrett, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Fri, Nov 28, 2008 at 06:40:55AM -0700, Matthew Wilcox wrote: > On Fri, Nov 28, 2008 at 11:18:09AM +0000, Jamie Lokier wrote: > > Matthew Garrett wrote: > > > The time between atime updates can be configured at boot > > > with the relatime_interval kernel argument, or at runtime through a sysctl. > > > > Shouldn't it be a per-mount value, with defaults coming from the sysctl? > > Perhaps a more sensible question would be "Why make it configurable at this is GNOME-mentality :-) > all?" What's wrong with hardcoding 24 hours? Or, to put it another > way, who wants to change it from 24 hours, and why? Why do you think that 24 hours is the right default value? Do you have any logical argument for this setting? Karel -- Karel Zak <kzak@redhat.com> ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v4] relatime: Make relatime smarter 2008-12-02 11:10 ` Karel Zak @ 2008-12-02 16:46 ` Matthew Wilcox 0 siblings, 0 replies; 44+ messages in thread From: Matthew Wilcox @ 2008-12-02 16:46 UTC (permalink / raw) To: Karel Zak Cc: Jamie Lokier, Matthew Garrett, Christoph Hellwig, Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Tue, Dec 02, 2008 at 12:10:25PM +0100, Karel Zak wrote: > On Fri, Nov 28, 2008 at 06:40:55AM -0700, Matthew Wilcox wrote: > > On Fri, Nov 28, 2008 at 11:18:09AM +0000, Jamie Lokier wrote: > > > Matthew Garrett wrote: > > > > The time between atime updates can be configured at boot > > > > with the relatime_interval kernel argument, or at runtime through a sysctl. > > > > > > Shouldn't it be a per-mount value, with defaults coming from the sysctl? > > > > Perhaps a more sensible question would be "Why make it configurable at > > this is GNOME-mentality :-) Yes, I frequently pal around with terrorists. > > all?" What's wrong with hardcoding 24 hours? Or, to put it another > > way, who wants to change it from 24 hours, and why? > > Why do you think that 24 hours is the right default value? Do you > have any logical argument for this setting? Once a day seems like a good value to me. It's a good human being timescale and still cuts down the number of atime updates by a lot. If somebody really cares, they could graph the relatime_update value against number of writes performed in a given period and determine a better cutoff. I can think of a hundred better ways to spend my time though. Good job of not answering the question, by the way. Why _not_ 24 hours? -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v3] relatime: Make relatime smarter 2008-11-27 16:59 ` [PATCH v3] relatime: Make relatime smarter Matthew Garrett 2008-11-27 17:06 ` Christoph Hellwig @ 2008-11-27 19:15 ` Alan Cox 2008-11-28 11:16 ` Jamie Lokier 1 sibling, 1 reply; 44+ messages in thread From: Alan Cox @ 2008-11-27 19:15 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew > + relatime_interval= > + [FS] relative atime update frequency, in seconds. > + (default: 1 day: 86400 seconds) What about leap seconds ;) Acked-by: Alan Cox <alan@redhat.com> ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v3] relatime: Make relatime smarter 2008-11-27 19:15 ` [PATCH v3] " Alan Cox @ 2008-11-28 11:16 ` Jamie Lokier 2008-11-28 13:45 ` Matthew Garrett 0 siblings, 1 reply; 44+ messages in thread From: Jamie Lokier @ 2008-11-28 11:16 UTC (permalink / raw) To: Alan Cox Cc: Matthew Garrett, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew Alan Cox wrote: > > + relatime_interval= > > + [FS] relative atime update frequency, in seconds. > > + (default: 1 day: 86400 seconds) > > What about leap seconds ;) More generally - is the relatime_interval in "monotonic" seconds, or in gettimeofday seconds which are changed by clock updates? -- Jamie ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v3] relatime: Make relatime smarter 2008-11-28 11:16 ` Jamie Lokier @ 2008-11-28 13:45 ` Matthew Garrett 0 siblings, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-28 13:45 UTC (permalink / raw) To: Jamie Lokier Cc: Alan Cox, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Fri, Nov 28, 2008 at 11:16:30AM +0000, Jamie Lokier wrote: > Alan Cox wrote: > > > + relatime_interval= > > > + [FS] relative atime update frequency, in seconds. > > > + (default: 1 day: 86400 seconds) > > > > What about leap seconds ;) > > More generally - is the relatime_interval in "monotonic" seconds, or > in gettimeofday seconds which are changed by clock updates? If this is actually a problem people in the real world are worried about, I think there's been a fundamental failure in the human race. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett ` (2 preceding siblings ...) 2008-11-27 16:35 ` Alan Cox @ 2008-11-27 17:03 ` Christoph Hellwig 2008-11-29 8:24 ` Andrew Morton 3 siblings, 1 reply; 44+ messages in thread From: Christoph Hellwig @ 2008-11-27 17:03 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Thu, Nov 27, 2008 at 03:03:41PM +0000, Matthew Garrett wrote: > Add support for defaulting to relatime > > Allow the kernel to enable relatime on all mounts by default. This can be > configured at build time or by a kernel parameter or sysctl. Also add a > MS_NORELATIME mount option to allow the default to be overridden for specific > mount points. NACK. Please just do it in fstab. ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-27 17:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Christoph Hellwig @ 2008-11-29 8:24 ` Andrew Morton 2008-11-29 13:03 ` Matthew Wilcox 0 siblings, 1 reply; 44+ messages in thread From: Andrew Morton @ 2008-11-29 8:24 UTC (permalink / raw) To: Christoph Hellwig Cc: Matthew Garrett, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew On Thu, 27 Nov 2008 12:03:46 -0500 Christoph Hellwig <hch@infradead.org> wrote: > On Thu, Nov 27, 2008 at 03:03:41PM +0000, Matthew Garrett wrote: > > Add support for defaulting to relatime > > > > Allow the kernel to enable relatime on all mounts by default. This can be > > configured at build time or by a kernel parameter or sysctl. Also add a > > MS_NORELATIME mount option to allow the default to be overridden for specific > > mount points. > > NACK. Please just do it in fstab. > Yes, that's what I was wondering. No /proc thingy, no new Kconfig entries, no __setup() thing. Just mount -o relatime=$((24*60*60)) /dev/sda1 /mnt/point mount -o remount,relatime=$((24*60*60)) /dev/sda1 /mnt/point ? ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 8:24 ` Andrew Morton @ 2008-11-29 13:03 ` Matthew Wilcox 2008-11-29 13:57 ` Jörn Engel 0 siblings, 1 reply; 44+ messages in thread From: Matthew Wilcox @ 2008-11-29 13:03 UTC (permalink / raw) To: Andrew Morton Cc: Christoph Hellwig, Matthew Garrett, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, Nov 29, 2008 at 12:24:19AM -0800, Andrew Morton wrote: > Yes, that's what I was wondering. No /proc thingy, no new Kconfig > entries, no __setup() thing. Just > > mount -o relatime=$((24*60*60)) /dev/sda1 /mnt/point > mount -o remount,relatime=$((24*60*60)) /dev/sda1 /mnt/point That would imply that relatime could be different per-mountpoint. I favour not making it configurable at all. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 13:03 ` Matthew Wilcox @ 2008-11-29 13:57 ` Jörn Engel 2008-11-29 18:56 ` Jamie Lokier 0 siblings, 1 reply; 44+ messages in thread From: Jörn Engel @ 2008-11-29 13:57 UTC (permalink / raw) To: Matthew Wilcox Cc: Andrew Morton, Christoph Hellwig, Matthew Garrett, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, 29 November 2008 06:03:08 -0700, Matthew Wilcox wrote: > > That would imply that relatime could be different per-mountpoint. > > I favour not making it configurable at all. I guess some amount if configuration may be necessary. If you go back to the beginning of the thread... On Wed, 26 November 2008 19:54:57 +0000, Matthew Garrett wrote: > > Allow atime to be updated once per day even with relatime enabled. This > lets utilities like tmpreaper (which deletes files based on last access > time) continue working. ...and check the tmpreaper manpage, you will notice that tmpreaper can be configured as well. So relatime has a default timeout of T and tmpreaper is configured to delete files after 1/2 T (never mind what T might be), the system breaks. Guessing a value of T that is good enough for everyone is a complicated business, so one configurable makes sense imo. One per mountpoint is rather silly, of course. Jörn -- Mundie uses a textbook tactic of manipulation: start with some reasonable talk, and lead the audience to an unreasonable conclusion. -- Bruce Perens -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 13:57 ` Jörn Engel @ 2008-11-29 18:56 ` Jamie Lokier 2008-11-29 19:02 ` Matthew Garrett 0 siblings, 1 reply; 44+ messages in thread From: Jamie Lokier @ 2008-11-29 18:56 UTC (permalink / raw) To: Jörn Engel Cc: Matthew Wilcox, Andrew Morton, Christoph Hellwig, Matthew Garrett, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson Jörn Engel wrote: > ...and check the tmpreaper manpage, you will notice that tmpreaper can > be configured as well. So relatime has a default timeout of T and > tmpreaper is configured to delete files after 1/2 T (never mind what T > might be), the system breaks. Guessing a value of T that is good enough > for everyone is a complicated business, so one configurable makes sense > imo. > > One per mountpoint is rather silly, of course. If it's configurable at all for tmpreaper (or similar), it should work the same for tmpreaper in virtual machine containers. (Same as, e.g. utsname is different in containers). If not now, someone will have to patch it later. Each VM runs it's own tmpreaper, configured usually by separate people. It's probably simpler to make it per-mountpoint than a virtualised global. I don't see why there is an objection to per-mountpoint. Andrew Morton's syntax: mount /dev/foo /mnt/bar -o relatime=86400 looks natural to me. -- Jamie -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 18:56 ` Jamie Lokier @ 2008-11-29 19:02 ` Matthew Garrett 2008-11-29 20:32 ` Andrew Morton 0 siblings, 1 reply; 44+ messages in thread From: Matthew Garrett @ 2008-11-29 19:02 UTC (permalink / raw) To: Jamie Lokier Cc: Jörn Engel, Matthew Wilcox, Andrew Morton, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, Nov 29, 2008 at 06:56:45PM +0000, Jamie Lokier wrote: > I don't see why there is an objection to per-mountpoint. > Andrew Morton's syntax: mount /dev/foo /mnt/bar -o relatime=86400 > looks natural to me. If somebody feels that this functionality would be useful, they're welcome to write it. A global default doesn't preclude per-mountpoint settings. This patch makes the existing kernel code more useful and so is worthwhile on its own, even if it doesn't scratch everyone's itch. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 19:02 ` Matthew Garrett @ 2008-11-29 20:32 ` Andrew Morton 2008-11-29 20:38 ` Matthew Wilcox ` (2 more replies) 0 siblings, 3 replies; 44+ messages in thread From: Andrew Morton @ 2008-11-29 20:32 UTC (permalink / raw) To: Matthew Garrett Cc: Jamie Lokier, Jörn Engel, Matthew Wilcox, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, 29 Nov 2008 19:02:45 +0000 Matthew Garrett <mjg@redhat.com> wrote: > On Sat, Nov 29, 2008 at 06:56:45PM +0000, Jamie Lokier wrote: > > > I don't see why there is an objection to per-mountpoint. > > Andrew Morton's syntax: mount /dev/foo /mnt/bar -o relatime=86400 > > looks natural to me. > > If somebody feels that this functionality would be useful, they're > welcome to write it. If someone writes it, I'll merge it. > A global default doesn't preclude per-mountpoint > settings. This patch makes the existing kernel code more useful and so > is worthwhile on its own, even if it doesn't scratch everyone's itch. The standard, usual, expected way of modifying a filesystem's behaviour is via mount options. This is also quite flexible. Is there some extraordinary reason why the standard interface is not to be used here? ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:32 ` Andrew Morton @ 2008-11-29 20:38 ` Matthew Wilcox 2008-11-29 20:56 ` Andrew Morton 2008-11-29 21:41 ` Ingo Molnar 2008-11-29 20:55 ` Arjan van de Ven 2008-11-29 21:02 ` Matthew Garrett 2 siblings, 2 replies; 44+ messages in thread From: Matthew Wilcox @ 2008-11-29 20:38 UTC (permalink / raw) To: Andrew Morton Cc: Matthew Garrett, Jamie Lokier, J?rn Engel, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, Nov 29, 2008 at 12:32:20PM -0800, Andrew Morton wrote: > The standard, usual, expected way of modifying a filesystem's behaviour > is via mount options. This is also quite flexible. > > Is there some extraordinary reason why the standard interface is not to > be used here? Because it would have to be managed (and consulted) per ... what? vfsmount? superblock? This is featuritis gone MAD. I'll take my bikeshed in teal, stippled with cornsilk. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:38 ` Matthew Wilcox @ 2008-11-29 20:56 ` Andrew Morton 2008-11-29 21:41 ` Ingo Molnar 1 sibling, 0 replies; 44+ messages in thread From: Andrew Morton @ 2008-11-29 20:56 UTC (permalink / raw) To: Matthew Wilcox Cc: Matthew Garrett, Jamie Lokier, J?rn Engel, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, 29 Nov 2008 13:38:57 -0700 Matthew Wilcox <matthew@wil.cx> wrote: > On Sat, Nov 29, 2008 at 12:32:20PM -0800, Andrew Morton wrote: > > The standard, usual, expected way of modifying a filesystem's behaviour > > is via mount options. This is also quite flexible. > > > > Is there some extraordinary reason why the standard interface is not to > > be used here? > > Because it would have to be managed (and consulted) per ... what? > vfsmount? superblock? Per superblock, of course. > This is featuritis gone MAD. No it isn't - it's the expected and standard behaviour. We have all the kernel infrastructure and userspace tools in place for doing it this way. Modifying the behaviour of all filesystems with a single knob is a weird thing to do. MNT_RELATIME itself is already per-superblock. ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:38 ` Matthew Wilcox 2008-11-29 20:56 ` Andrew Morton @ 2008-11-29 21:41 ` Ingo Molnar 1 sibling, 0 replies; 44+ messages in thread From: Ingo Molnar @ 2008-11-29 21:41 UTC (permalink / raw) To: Matthew Wilcox Cc: Andrew Morton, Matthew Garrett, Jamie Lokier, J?rn Engel, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson * Matthew Wilcox <matthew@wil.cx> wrote: > On Sat, Nov 29, 2008 at 12:32:20PM -0800, Andrew Morton wrote: > > The standard, usual, expected way of modifying a filesystem's behaviour > > is via mount options. This is also quite flexible. > > > > Is there some extraordinary reason why the standard interface is not to > > be used here? > > Because it would have to be managed (and consulted) per ... what? > vfsmount? superblock? This is featuritis gone MAD. > > I'll take my bikeshed in teal, stippled with cornsilk. agreed. Meanwhile, 10 years and counting, the Linux kernel still generates a stupid write IO for every file read that apps do. Fortunately hardware designers will get rid of rotating disks faster than we can fix our glaring process problems in this space - but it's still a bit sad. Ingo ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:32 ` Andrew Morton 2008-11-29 20:38 ` Matthew Wilcox @ 2008-11-29 20:55 ` Arjan van de Ven 2008-11-29 21:03 ` Matthew Garrett 2008-11-29 21:02 ` Matthew Garrett 2 siblings, 1 reply; 44+ messages in thread From: Arjan van de Ven @ 2008-11-29 20:55 UTC (permalink / raw) To: Andrew Morton Cc: Matthew Garrett, Jamie Lokier, Jörn Engel, Matthew Wilcox, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, 29 Nov 2008 12:32:20 -0800 Andrew Morton <akpm@linux-foundation.org> wrote: > > The standard, usual, expected way of modifying a filesystem's > behaviour is via mount options. This is also quite flexible. > > Is there some extraordinary reason why the standard interface is not > to be used here? let me ask this: Has anmyone ever had the desire to change the default of 1 day of relatime? Ever? Maybe this code isn't really needed if nobody even thought about changing it. Clearly there are two extremes (always and never) for which we have atime/noatime. I'm not sure we need to have any smarts in the middle point for the user to change. If this is something people wish to see tuned better, I would rather spend the code size in trying to get it autotuning. -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:55 ` Arjan van de Ven @ 2008-11-29 21:03 ` Matthew Garrett 0 siblings, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-29 21:03 UTC (permalink / raw) To: Arjan van de Ven Cc: Andrew Morton, Jamie Lokier, Jörn Engel, Matthew Wilcox, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, Nov 29, 2008 at 12:55:29PM -0800, Arjan van de Ven wrote: > let me ask this: > Has anmyone ever had the desire to change the default of 1 day of > relatime? Ever? The current kernel code has no time-based heuristics. It'll only update atime if it's older than ctime or mtime. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour 2008-11-29 20:32 ` Andrew Morton 2008-11-29 20:38 ` Matthew Wilcox 2008-11-29 20:55 ` Arjan van de Ven @ 2008-11-29 21:02 ` Matthew Garrett 2 siblings, 0 replies; 44+ messages in thread From: Matthew Garrett @ 2008-11-29 21:02 UTC (permalink / raw) To: Andrew Morton Cc: Jamie Lokier, Jörn Engel, Matthew Wilcox, Christoph Hellwig, Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson On Sat, Nov 29, 2008 at 12:32:20PM -0800, Andrew Morton wrote: > On Sat, 29 Nov 2008 19:02:45 +0000 Matthew Garrett <mjg@redhat.com> wrote: > > A global default doesn't preclude per-mountpoint > > settings. This patch makes the existing kernel code more useful and so > > is worthwhile on its own, even if it doesn't scratch everyone's itch. > > The standard, usual, expected way of modifying a filesystem's behaviour > is via mount options. This is also quite flexible. Yes, if something is configured at a per-filesystem level, a mount option makes sense. I don't personally see any terribly sensible use cases for having this be per-filesystem and so wasn't planning on implementing that. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 1/2] relatime: Make relatime behaviour smarter 2008-11-27 15:01 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Matthew Garrett 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett @ 2008-11-27 15:06 ` Ingo Molnar 1 sibling, 0 replies; 44+ messages in thread From: Ingo Molnar @ 2008-11-27 15:06 UTC (permalink / raw) To: Matthew Garrett Cc: Randy Dunlap, linux-kernel, linux-fsdevel, mingo, val.henson, matthew * Matthew Garrett <mjg@redhat.com> wrote: > Make relatime smarter > > Allow atime to be updated once per day even with relatime. This lets > utilities like tmpreaper (which delete files based on last access time) > continue working. > > --- > > Subset of Ingo's original patch, rediffed against current git thanks Matthew for picking this up! Acked-by: Ingo Molnar <mingo@elte.hu> Ingo ^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH 1/2] relatime: Make atime updates more useful 2008-11-26 19:54 [PATCH 1/2] relatime: Make atime updates more useful Matthew Garrett 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett @ 2008-11-29 8:29 ` Andrew Morton 2008-12-02 17:19 ` [PATCH] relatime: Let relatime update atime at least once per day Matthew Garrett 2 siblings, 0 replies; 44+ messages in thread From: Andrew Morton @ 2008-11-29 8:29 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson On Wed, 26 Nov 2008 19:54:57 +0000 Matthew Garrett <mjg59@srcf.ucam.org> wrote: > Allow atime to be updated once per day even with relatime enabled. This > lets utilities like tmpreaper (which deletes files based on last access > time) continue working. > > Signed-off-by: Matthew Garrett <mjg@redhat.com> > > --- > > Updated version of Ingo's patch from last year - this section is > identical. > > commit 2c145e187600ca961715fa82ae3ae7919d744bc9 > Author: Matthew Garrett <mjg@redhat.com> > Date: Wed Nov 26 17:44:07 2008 +0000 > > Make relatime smarter > > Allow atime to be updated once per day even with relatime. This lets > utilities like tmpreaper (which delete files based on last access time) > continue working. > Two changelogs always sends me into a panic. It's easier when they are identical ;) > index 0487ddb..348fa16 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -1179,6 +1179,41 @@ sector_t bmap(struct inode * inode, sector_t block) > } > EXPORT_SYMBOL(bmap); > > +/* > + * Relative atime updates frequency (default: 1 day): > + */ > +int relatime_interval __read_mostly = 24*60*60; I assume that it's global for the benefit of the second patch. Yes, we do put a lot of extern-decls-in-C over in sysctl.c. But that doesn't make it good. It would be better to add the declaration to a header which is visible to all sites which use the symbol. We should perhaps have a standalone sysctl-definitions.h for this purpose, so we don't end up having to #include <everything> in sysctl.c. > +/* > + * 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 the update interval? > + * If yes, update atime: > + */ > + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= relatime_interval) > + return 1; I dunno what type those tv_secs have, but the whole thing is cast to a long and is then signed-compared with an integer. Is this correct and intended? I guess it is, but.. just checking? > + /* > + * Good, we can skip the atime update: > + */ > + return 0; > +} > + > /** > * touch_atime - update the access time > * @mnt: mount the inode is accessed on > @@ -1206,17 +1241,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) > goto out; > if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) > goto out; > - if (mnt->mnt_flags & MNT_RELATIME) { > - /* > - * With relative atime, only update atime if the previous > - * atime is earlier than either the ctime or mtime. > - */ > - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && > - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) > - goto out; > - } > > now = current_fs_time(inode->i_sb); > + > + if (mnt->mnt_flags & MNT_RELATIME) > + if (!relatime_need_update(inode, now)) > + goto out; > if (timespec_equal(&inode->i_atime, &now)) > goto out; ^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH] relatime: Let relatime update atime at least once per day 2008-11-26 19:54 [PATCH 1/2] relatime: Make atime updates more useful Matthew Garrett 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-29 8:29 ` [PATCH 1/2] relatime: Make atime updates more useful Andrew Morton @ 2008-12-02 17:19 ` Matthew Garrett 2008-12-13 5:26 ` Valerie Aurora Henson 2 siblings, 1 reply; 44+ messages in thread From: Matthew Garrett @ 2008-12-02 17:19 UTC (permalink / raw) To: linux-kernel; +Cc: linux-fsdevel, mingo, val.henson Allow atime to be updated once per day even with relatime. This lets utilities like tmpreaper (which delete files based on last access time) continue working. Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: Ingo Molnar <mingo@redhat.com> Acked-by: Alan Cox <alan@redhat.com> --- I've removed the adjustable time code, since nobody's come up with a terribly good use case for it. This makes relatime more useful in the generic case - there may be situations where it still doesn't satisfy people, but that's not a regression over the current situation. diff --git a/fs/inode.c b/fs/inode.c index 0487ddb..057c92b 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1179,6 +1179,40 @@ sector_t bmap(struct inode * inode, sector_t block) } EXPORT_SYMBOL(bmap); +/* + * With relative atime, only update atime if the previous atime is + * earlier than either the ctime or mtime or if at least a day has + * passed since the last atime update. + */ +static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, + struct timespec now) +{ + + if (!(mnt->mnt_flags & MNT_RELATIME)) + return 1; + /* + * 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; + /* + * Good, we can skip the atime update: + */ + return 0; +} + /** * touch_atime - update the access time * @mnt: mount the inode is accessed on @@ -1206,17 +1240,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) goto out; if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) goto out; - if (mnt->mnt_flags & MNT_RELATIME) { - /* - * With relative atime, only update atime if the previous - * atime is earlier than either the ctime or mtime. - */ - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) - goto out; - } now = current_fs_time(inode->i_sb); + + if (!relatime_need_update(mnt, inode, now)) + goto out; + if (timespec_equal(&inode->i_atime, &now)) goto out; -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH] relatime: Let relatime update atime at least once per day 2008-12-02 17:19 ` [PATCH] relatime: Let relatime update atime at least once per day Matthew Garrett @ 2008-12-13 5:26 ` Valerie Aurora Henson 0 siblings, 0 replies; 44+ messages in thread From: Valerie Aurora Henson @ 2008-12-13 5:26 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-kernel, linux-fsdevel, mingo, val.henson On Tue, Dec 02, 2008 at 05:19:26PM +0000, Matthew Garrett wrote: > Allow atime to be updated once per day even with relatime. This lets > utilities like tmpreaper (which delete files based on last access time) > continue working. > > Signed-off-by: Matthew Garrett <mjg@redhat.com> > Acked-by: Ingo Molnar <mingo@redhat.com> > Acked-by: Alan Cox <alan@redhat.com> My name is Valerie Aurora Henson, and I endorse this patch. Acked-by: Valerie Aurora Henson <vaurora@redhat.com> -VAL > --- > > I've removed the adjustable time code, since nobody's come up with a > terribly good use case for it. This makes relatime more useful in the > generic case - there may be situations where it still doesn't satisfy > people, but that's not a regression over the current situation. > > diff --git a/fs/inode.c b/fs/inode.c > index 0487ddb..057c92b 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -1179,6 +1179,40 @@ sector_t bmap(struct inode * inode, sector_t block) > } > EXPORT_SYMBOL(bmap); > > +/* > + * With relative atime, only update atime if the previous atime is > + * earlier than either the ctime or mtime or if at least a day has > + * passed since the last atime update. > + */ > +static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, > + struct timespec now) > +{ > + > + if (!(mnt->mnt_flags & MNT_RELATIME)) > + return 1; > + /* > + * 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; > + /* > + * Good, we can skip the atime update: > + */ > + return 0; > +} > + > /** > * touch_atime - update the access time > * @mnt: mount the inode is accessed on > @@ -1206,17 +1240,12 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) > goto out; > if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) > goto out; > - if (mnt->mnt_flags & MNT_RELATIME) { > - /* > - * With relative atime, only update atime if the previous > - * atime is earlier than either the ctime or mtime. > - */ > - if (timespec_compare(&inode->i_mtime, &inode->i_atime) < 0 && > - timespec_compare(&inode->i_ctime, &inode->i_atime) < 0) > - goto out; > - } > > now = current_fs_time(inode->i_sb); > + > + if (!relatime_need_update(mnt, inode, now)) > + goto out; > + > if (timespec_equal(&inode->i_atime, &now)) > goto out; > > -- > Matthew Garrett | mjg59@srcf.ucam.org > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 44+ messages in thread
end of thread, other threads:[~2008-12-13 5:26 UTC | newest] Thread overview: 44+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-11-26 19:54 [PATCH 1/2] relatime: Make atime updates more useful Matthew Garrett 2008-11-26 19:58 ` [PATCH 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-26 21:11 ` Matthew Wilcox 2008-11-26 22:39 ` Randy Dunlap 2008-11-27 15:01 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Matthew Garrett 2008-11-27 15:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Matthew Garrett 2008-11-27 15:07 ` Ingo Molnar 2008-11-27 16:03 ` Karel Zak [not found] ` <20081127160353.GQ2961-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org> 2008-11-27 17:30 ` Pádraig Brady [not found] ` <492ED945.5010600-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org> 2008-11-27 17:39 ` Matthew Garrett 2008-11-27 16:35 ` Alan Cox 2008-11-27 16:47 ` Matthew Garrett 2008-11-27 16:59 ` [PATCH v3] relatime: Make relatime smarter Matthew Garrett 2008-11-27 17:06 ` Christoph Hellwig 2008-11-27 17:58 ` [PATCH v4] " Matthew Garrett 2008-11-27 22:08 ` Andreas Dilger 2008-11-27 22:35 ` Matthew Wilcox 2008-11-28 11:13 ` Jamie Lokier 2008-11-28 13:41 ` Matthew Garrett 2008-11-28 11:18 ` Jamie Lokier 2008-11-28 13:40 ` Matthew Wilcox 2008-11-28 13:47 ` Matthew Garrett 2008-12-02 11:10 ` Karel Zak 2008-12-02 16:46 ` Matthew Wilcox 2008-11-27 19:15 ` [PATCH v3] " Alan Cox 2008-11-28 11:16 ` Jamie Lokier 2008-11-28 13:45 ` Matthew Garrett 2008-11-27 17:03 ` [PATCH v2 2/2] relatime: Allow making relatime the default behaviour Christoph Hellwig 2008-11-29 8:24 ` Andrew Morton 2008-11-29 13:03 ` Matthew Wilcox 2008-11-29 13:57 ` Jörn Engel 2008-11-29 18:56 ` Jamie Lokier 2008-11-29 19:02 ` Matthew Garrett 2008-11-29 20:32 ` Andrew Morton 2008-11-29 20:38 ` Matthew Wilcox 2008-11-29 20:56 ` Andrew Morton 2008-11-29 21:41 ` Ingo Molnar 2008-11-29 20:55 ` Arjan van de Ven 2008-11-29 21:03 ` Matthew Garrett 2008-11-29 21:02 ` Matthew Garrett 2008-11-27 15:06 ` [PATCH v2 1/2] relatime: Make relatime behaviour smarter Ingo Molnar 2008-11-29 8:29 ` [PATCH 1/2] relatime: Make atime updates more useful Andrew Morton 2008-12-02 17:19 ` [PATCH] relatime: Let relatime update atime at least once per day Matthew Garrett 2008-12-13 5:26 ` Valerie Aurora Henson
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).