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@xxxxxxxxx> > Closes: https://lore.kernel.org/oe-lkp/202309071017.a64aca5e-oliver.sang@xxxxxxxxx > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@xxxxxxx> 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@xxxxxxxx> SUSE Labs, CR