Skip to contentSkip to conversation

relatime: Make atime updates more useful

PATCH In review Matthew Garrett 15 participants 44 messages Nov 26, 2008 – Dec 13, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 relatime: Make atime updates more useful

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.

---

Updated version of Ingo's patch from last year - this section is identical.

commit 2c145e187600ca961715fa82ae3ae7919d744bc9

Author: Matthew Garrett <[email protected]>
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.

fs/inode.c +39 -9
index 0487ddb..348fa16 100644
@@ -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;
 
Signature · 1 line
Matthew Garrett | [email protected]
#1 lore raw

PATCH 2/2 relatime: Allow making relatime the default behaviour

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.

---

Updated version of Ingo's patch, but adds MS_NORELATIME. util-linux will need updating to match if this is merged.

Documentation/kernel-parameters.txt +8 -0
index e0f346d..eba3b07 100644
@@ -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]
fs/Kconfig +23 -0
index 522469a..fcd3d48 100644
@@ -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"
 
fs/inode.c +11 -0
index 348fa16..51e9ae1 100644
@@ -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.
fs/namespace.c +23 -0
index 65b3dc8..76f30b5 100644
@@ -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;
 
include/linux/fs.h +1 -0
index 0dcdd94..a4db010 100644
@@ -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)
 
include/linux/mount.h +3 -0
index cab2a85..71c7bc0 100644
@@ -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 */
kernel/sysctl.c +17 -0
index 9d048fa..872c3d3 100644
@@ -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,
Signature · 1 line
Matthew Garrett | [email protected]
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] relatime: Allow making relatime the default behaviour

Quoted 1 line · Matthew Garrett

+#define MS_NORELATIME (1<<24) /* Disable relatie even if the default */

typo

Otherwise, looks good.

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.

Signature · 4 lines
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."
#3 lore raw

Re: [PATCH 2/2] relatime: Allow making relatime the default behaviour

In reply to Matthew Garrett
Quoted 8 lines · Matthew Garrett

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.

---

Hi,

Please use diffstat for all (non-trivial) patches. or whatever git calls it.

Comments below...

Quoted 8 lines

Updated version of Ingo's patch, but adds MS_NORELATIME. util-linux will need updating to match if this is merged.

Documentation/kernel-parameters.txt +0 -0
index e0f346d..eba3b07 100644

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 622

Quoted 7 lines
Documentation/kernel-parameters.txt +4 -0
@@ -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.

Quoted 78 lines
Documentation/kernel-parameters.txt +4 -0
 	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]
fs/Kconfig +23 -0
index 522469a..fcd3d48 100644
@@ -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"
 
fs/inode.c +11 -0
index 348fa16..51e9ae1 100644
@@ -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.
fs/namespace.c +0 -0
index 65b3dc8..76f30b5 100644
@@ -1883,6 +1883,24 @@ int copy_mount_options(const void __user * data, unsigned long *where)
 }
 
 /*

fs/namespace.c int copy_mount_options(const void __user * data, unsigned long *where) · line 1895

Quoted 10 lines
fs/namespace.c +10 -0
+ * 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".

Quoted 28 lines
fs/namespace.c +13 -0
+		"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;
 
include/linux/fs.h +0 -0
index 0dcdd94..a4db010 100644

include/linux/fs.h extern int dir_notify_enable; · line 138

Quoted 4 lines
include/linux/fs.h +1 -0
@@ -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

Quoted 2 lines
include/linux/fs.h +0 -0
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
Signature · 1 line
~Randy
#4 lore raw

PATCH v2 1/2 relatime: Make relatime behaviour smarter

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

fs/inode.c +39 -9
index 0487ddb..348fa16 100644
@@ -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;
 
Signature · 1 line
Matthew Garrett | [email protected]
#5 lore raw

PATCH v2 2/2 relatime: Allow making relatime the default behaviour

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.

---

Incorporates Randy's suggestion to change default_relatime to relatime_default, along with a couple of typographical fixes

Documentation/kernel-parameters.txt +8 -0
index e0f346d..1738be9 100644
@@ -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]
fs/Kconfig +23 -0
index 522469a..fcd3d48 100644
@@ -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"
 
fs/inode.c +11 -0
index 348fa16..51e9ae1 100644
@@ -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.
fs/namespace.c +23 -0
index 65b3dc8..b7b72c2 100644
@@ -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;
 
include/linux/fs.h +1 -0
index 0dcdd94..0dfdce2 100644
@@ -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)
 
include/linux/mount.h +3 -0
index cab2a85..2595882 100644
@@ -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 */
kernel/sysctl.c +17 -0
index 9d048fa..b570827 100644
@@ -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,
Signature · 1 line
Matthew Garrett | [email protected]
Acked-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 14 lines · Matthew Garrett

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.

---

Incorporates Randy's suggestion to change default_relatime to relatime_default, along with a couple of typographical fixes

fs/Kconfig config 9P_FS · line 1551

Quoted 3 lines
fs/Kconfig +3 -0
+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!

Ingo

#8 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 6 lines · Karel Zak
Quoted 1 line · Matthew Garrett

Also add a MS_NORELATIME mount option

[...]

Quoted 1 line

+#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 4 lines · Pádraig Brady
Quoted 3 lines · Karel Zak
Quoted 1 line · Matthew Garrett

Also add a MS_NORELATIME mount option

[...]

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

+#define MS_NORELATIME (1<<24) /* Disable relatime even if the default */

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.

Signature · 5 lines
Matthew Garrett | [email protected]
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

In reply to Matthew Garrett

fs/Kconfig config 9P_FS · line 1551

Quoted 3 lines
fs/Kconfig +3 -0
+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

include/linux/fs.h extern int dir_notify_enable; · line 138

Quoted 7 lines
include/linux/fs.h +1 -0
@@ -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 ;)

#11 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 4 lines · Alan Cox

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.

Signature · 1 line
Matthew Garrett | [email protected]
#12 lore raw

PATCH v3 1/1 relatime: Make relatime smarter

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

---

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(-)
Documentation/kernel-parameters.txt +4 -0
index e0f346d..6d0dc0a 100644
@@ -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]
fs/inode.c +50 -9

73 lines not on this page · raw message

include/linux/mount.h +2 -0
index cab2a85..978fb10 100644
@@ -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 */
kernel/sysctl.c +9 -0
index 9d048fa..f085ad6 100644
@@ -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,
Signature · 1 line
Matthew Garrett | [email protected]
#13 lore raw

Re: [PATCH v3] relatime: Make relatime smarter

Quoted 6 lines · Matthew Garrett

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

fs/inode.c void touch_atime(struct vfsmount *mnt, struct dentry *dentry) · line 1261

Quoted 4 lines
fs/inode.c +3 -0
+	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

#14 lore raw

PATCH v4 1/1 relatime: Make relatime smarter

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.

---

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(-)
Documentation/kernel-parameters.txt +4 -0
index e0f346d..6d0dc0a 100644
@@ -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]
fs/inode.c +54 -9

77 lines not on this page · raw message

include/linux/mount.h +2 -0
index cab2a85..978fb10 100644
@@ -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 */
kernel/sysctl.c +9 -0
index 9d048fa..f085ad6 100644
@@ -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,
Signature · 1 line
Matthew Garrett | [email protected]
#15 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1852

Quoted 3 lines · Matthew Garrett
Documentation/kernel-parameters.txt +3 -0
+	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.

#16 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

Quoted 10 lines · Andreas Dilger

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1852

Quoted 3 lines · Matthew Garrett
Documentation/kernel-parameters.txt +3 -0
+	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?

Signature · 4 lines
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."
#17 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

In reply to Andreas Dilger
Quoted 5 lines · Andreas Dilger

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

#18 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

In reply to Andreas Dilger
Quoted 5 lines · Andreas Dilger

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.

Signature · 1 line
Matthew Garrett | [email protected]
#19 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

In reply to Matthew Garrett
Quoted 2 lines · Matthew Garrett

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

#20 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

Quoted 5 lines · Jamie Lokier
Quoted 2 lines · Matthew Garrett

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?

Signature · 4 lines
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."
#21 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

Quoted 10 lines · Matthew Wilcox
Quoted 5 lines · Jamie Lokier
Quoted 2 lines · Matthew Garrett

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.

Signature · 1 line
Matthew Garrett | [email protected]
#22 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

In reply to Matthew Wilcox
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Jamie Lokier
Quoted 2 lines · Matthew Garrett

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

Quoted 2 lines

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

Signature · 1 line
 Karel Zak  <[email protected]>
#23 lore raw

Re: [PATCH v4] relatime: Make relatime smarter

Quoted 11 lines · Karel Zak
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Jamie Lokier
Quoted 2 lines · Matthew Garrett

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.

Quoted 5 lines
Quoted 2 lines

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?

Signature · 4 lines
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."
Acked-by on v3 1/1
#24 lore raw

Re: [PATCH v3] relatime: Make relatime smarter

In reply to Matthew Garrett

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1852

Quoted 3 lines
Documentation/kernel-parameters.txt +3 -0
+	relatime_interval=
+			[FS] relative atime update frequency, in seconds.
+			(default: 1 day: 86400 seconds)

What about leap seconds ;)

#25 lore raw

Re: [PATCH v3] relatime: Make relatime smarter

Quoted 5 lines · Alan Cox

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1852

Quoted 3 lines
Documentation/kernel-parameters.txt +3 -0
+	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

#26 lore raw

Re: [PATCH v3] relatime: Make relatime smarter

Quoted 9 lines · Jamie Lokier
Quoted 5 lines · Alan Cox

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1852

Quoted 3 lines
Documentation/kernel-parameters.txt +3 -0
+	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.

Signature · 1 line
Matthew Garrett | [email protected]
#27 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

In reply to Matthew Garrett
Quoted 6 lines · Matthew Garrett

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.

#28 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 10 lines · On Thu, 27 Nov 2008 12:03:46 -0500 Christoph Hellwig <[email protected]> wrote:
Quoted 6 lines · Matthew Garrett

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

?

#29 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 5 lines · Andrew Morton

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.

Signature · 4 lines
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."
#30 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 4 lines · Matthew Wilcox

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

Quoted 4 lines · Matthew Garrett

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

Signature · 7 lines
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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#31 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 8 lines · Jörn Engel

...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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#32 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 3 lines · Jamie Lokier

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.

Signature · 1 line
Matthew Garrett | [email protected]
#33 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 8 lines · On Sat, 29 Nov 2008 19:02:45 +0000 Matthew Garrett <[email protected]> wrote:
Quoted 3 lines · Jamie Lokier

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.

Quoted 3 lines

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?

#34 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 5 lines · Andrew Morton

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.

Signature · 4 lines
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."
#35 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 9 lines · On Sat, 29 Nov 2008 13:38:57 -0700 Matthew Wilcox <[email protected]> wrote:
Quoted 5 lines · Andrew Morton

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.

Quoted 1 line

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.

#36 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

In reply to Matthew Wilcox
Quoted 11 lines · Matthew Wilcox
Quoted 5 lines · Andrew Morton

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

#37 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

In reply to Andrew Morton
Quoted 6 lines · On Sat, 29 Nov 2008 12:32:20 -0800 Andrew Morton <[email protected]>…

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.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#38 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

Quoted 3 lines · Arjan van de Ven

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.

Signature · 1 line
Matthew Garrett | [email protected]
#39 lore raw

Re: [PATCH v2 2/2] relatime: Allow making relatime the default behaviour

In reply to Andrew Morton
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Sat, 29 Nov 2008 19:02:45 +0000 Matthew Garrett <[email protected]> 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.

Signature · 1 line
Matthew Garrett | [email protected]
Acked-by on v2 1/2
#40 lore raw

Re: [PATCH v2 1/2] relatime: Make relatime behaviour smarter

In reply to Matthew Garrett
Quoted 9 lines · Matthew Garrett

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!

Ingo

#41 lore raw
In reply to Matthew Garrett
Quoted 12 lines · On Wed, 26 Nov 2008 19:54:57 +0000 Matthew Garrett <[email protected]> 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.

---

Updated version of Ingo's patch from last year - this section is identical.

commit 2c145e187600ca961715fa82ae3ae7919d744bc9

Quoted 9 lines
Author: Matthew Garrett <[email protected]>
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 ;)

fs/inode.c sector_t bmap(struct inode * inode, sector_t block) · line 1185

Quoted 11 lines

index 0487ddb..348fa16 100644

fs/inode.c +4 -0
@@ -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.

Quoted 14 lines
fs/inode.c +14 -0
+/*
+ * 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:

fs/inode.c sector_t bmap(struct inode * inode, sector_t block) · line 1210

Quoted 10 lines
fs/inode.c +10 -0
+	 */
+	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?

Quoted 30 lines
fs/inode.c +10 -9
+	/*
+	 * 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;
#42 lore raw

PATCH 1/1 relatime: Let relatime update atime at least once per day

In reply to Matthew Garrett

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.

---

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.

fs/inode.c +38 -9
index 0487ddb..057c92b 100644
@@ -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;
 
Signature · 1 line
Matthew Garrett | [email protected]
Acked-by on v1 1/1
#43 lore raw

Re: [PATCH] relatime: Let relatime update atime at least once per day

Quoted 7 lines · Matthew Garrett

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.

My name is Valerie Aurora Henson, and I endorse this patch.

-VAL

Quoted 80 lines

---

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.

fs/inode.c +38 -9
index 0487ddb..057c92b 100644
@@ -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;
 
Signature · 5 lines
Matthew Garrett | [email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html