linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	mingo@redhat.com, val.henson@gmail.com
Subject: Re: [PATCH 1/2] relatime: Make atime updates more useful
Date: Sat, 29 Nov 2008 00:29:07 -0800	[thread overview]
Message-ID: <20081129002907.17f7714e.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081126195457.GA3541@srcf.ucam.org>

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;


  parent reply	other threads:[~2008-11-29  8:29 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Andrew Morton [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081129002907.17f7714e.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjg59@srcf.ucam.org \
    --cc=val.henson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).