From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH 2/2] fs: don't update the atime if existing atime is newer than "now"
Date: Fri, 8 Sep 2023 14:11:52 +0200 [thread overview]
Message-ID: <20230908121152.fyjpv4zj4y2bcmqc@quack3> (raw)
In-Reply-To: <20230907-ctime-fixes-v1-2-3b74c970d934@kernel.org>
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@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202309071017.a64aca5e-oliver.sang@intel.com
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.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@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-09-08 12:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 16:33 [PATCH 0/2] fs: fixes for multigrain ctime code Jeff Layton
2023-09-07 16:33 ` [PATCH 1/2] fs: initialize inode->__i_ctime to the epoch Jeff Layton
2023-09-08 10:42 ` Jan Kara
2023-09-08 11:41 ` Jeff Layton
2023-09-08 12:10 ` Jan Kara
2023-09-07 16:33 ` [PATCH 2/2] fs: don't update the atime if existing atime is newer than "now" Jeff Layton
2023-09-08 12:11 ` Jan Kara [this message]
2023-09-08 12:10 ` [PATCH 0/2] fs: fixes for multigrain ctime code Christian Brauner
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=20230908121152.fyjpv4zj4y2bcmqc@quack3 \
--to=jack@suse.cz \
--cc=brauner@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oliver.sang@intel.com \
--cc=viro@zeniv.linux.org.uk \
/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