[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230908121152.fyjpv4zj4y2bcmqc@quack3>
Date: Fri, 8 Sep 2023 14:11:52 +0200
From: Jan Kara <jack@...e.cz>
To: Jeff Layton <jlayton@...nel.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel test robot <oliver.sang@...el.com>
Subject: Re: [PATCH 2/2] fs: don't update the atime if existing atime is
newer than "now"
On Thu 07-09-23 12:33:48, Jeff Layton wrote:
> It's possible for the atime to be updated with a fine-grained timestamp
> and then later get an update that uses a coarse-grained timestamp which
> makes the atime appear to go backward.
>
> Fix this by only updating the atime if "now" is later than the current
> value.
>
> Reported-by: kernel test robot <oliver.sang@...el.com>
> Closes: https://lore.kernel.org/oe-lkp/202309071017.a64aca5e-oliver.sang@intel.com
> Signed-off-by: Jeff Layton <jlayton@...nel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> fs/inode.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/inode.c b/fs/inode.c
> index 54237f4242ff..cf4726b7f4b5 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -1905,7 +1905,7 @@ int inode_update_timestamps(struct inode *inode, int flags)
> }
>
> if (flags & S_ATIME) {
> - if (!timespec64_equal(&now, &inode->i_atime)) {
> + if (timespec64_compare(&inode->i_atime, &now) < 0) {
> inode->i_atime = now;
> updated |= S_ATIME;
> }
> @@ -1991,7 +1991,7 @@ bool atime_needs_update(const struct path *path, struct inode *inode)
> if (!relatime_need_update(mnt, inode, now))
> return false;
>
> - if (timespec64_equal(&inode->i_atime, &now))
> + if (timespec64_compare(&inode->i_atime, &now) >= 0)
> return false;
>
> return true;
>
> --
> 2.41.0
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists