From patchwork Thu Sep 7 16:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13376613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93D5EEC873D for ; Thu, 7 Sep 2023 16:34:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1784A8D0008; Thu, 7 Sep 2023 12:34:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 125C68D0003; Thu, 7 Sep 2023 12:34:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE8AD8D0008; Thu, 7 Sep 2023 12:34:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DCEA18D0003 for ; Thu, 7 Sep 2023 12:34:09 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 64AFC1CA48F for ; Thu, 7 Sep 2023 16:34:09 +0000 (UTC) X-FDA: 81210348618.21.ABE3015 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id BB83B40031 for ; Thu, 7 Sep 2023 16:34:06 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ch5oAfNf; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694104447; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=93tq1dZWsLpSfgCz/91Wc+XUtaSEzTbr0TjQcQKl32M=; b=gHAEKI1nd5FFfLC/MP9Rws6JvO5MZjQFjk+N1nyypZikLEtE6zF5uecKXOQff/mx8/u3HW h4bjd78/VrsR6EY5zZM3fs4LCEgJPMiDYGCABeZI3tLG+mTHyxA+jiDUQK64yo9AK2Qtnx yL+ASEph4KHxXbgJY2jwpKp4cvfJFtA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ch5oAfNf; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694104447; a=rsa-sha256; cv=none; b=ZncBEyMEAtkKdE2EoFHBsPacVi5pCoA7UNFP4bIe9Qf1E40eWZ/F56SE3MXJ6IImE4iMMh eDOFx+vaaQuyIwLRpWDZkK5vPdHJSfWulhOh5QLShlVp1YVj5FOeRS2f+q4xP21/DCNdzk u6Wi/kzpOsc2wxPTklYZHVnaKde/jO4= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id CEE7DCE1928; Thu, 7 Sep 2023 16:34:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D749C4339A; Thu, 7 Sep 2023 16:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694104441; bh=1rA76M1gNfenw+XkkpPAQfgJBEGVBm9PuOG7uc/Jkm8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ch5oAfNfwuXOaXDTxKt6lI5yl8T5rJQFAVT0NRgVHrWXuy+QZU0CvU05eqlS1E4He s2ooWMNuNKWz1qOxnh935WS3Keaz1kNDahl/G8ezv0mXx7kvmrn1FLffFLxUuHetAw wXJAb5qu9K7uHtRdRxpp8pVoas0c3zr6rzoEya/ObjKGGuxAlvsn10n4ZXjNdPFwZw 9fpAcRYcHFZI1TY3+iTLudZIiXk49F/Gwm+jFBF8BLjzNMX0SUCRY3We5Exs1x8AW7 4G1RqnI/2bxSqXM1IJE75CL5gaB29mooRiQ/qpsv1Lr6h6DjZIpDs1hp/wX0WXqykk 1JMOqekpDaZsg== From: Jeff Layton Date: Thu, 07 Sep 2023 12:33:48 -0400 Subject: [PATCH 2/2] fs: don't update the atime if existing atime is newer than "now" MIME-Version: 1.0 Message-Id: <20230907-ctime-fixes-v1-2-3b74c970d934@kernel.org> References: <20230907-ctime-fixes-v1-0-3b74c970d934@kernel.org> In-Reply-To: <20230907-ctime-fixes-v1-0-3b74c970d934@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton , kernel test robot X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1253; i=jlayton@kernel.org; h=from:subject:message-id; bh=1rA76M1gNfenw+XkkpPAQfgJBEGVBm9PuOG7uc/Jkm8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBk+ft24KZSXjqnylLBtdm3crreHjPaKA2NTl+Vq 1+dgCFXBRKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZPn7dgAKCRAADmhBGVaC FZPuD/98kwCV1M6EJYg97zAUpyxuVXP0vI6qklYlW6dZ+wrkPLkeaE2VOlbz4dwJjIVfn3S85A/ Gou8Lq8ahPqTJ+DcVi1DD9Iv9FCYKqqRGIAv8aXwA4sNlRjCJyPqe2U+m3ZnW7tYp+zIbLyWyIo eC3q0GwVb/abjQZxfouOavamZVfB4uFA4ZkrSYcUNf3yypt23ZUhqBPpoH1rPVSIh0boAJ+7x/A uDbu7bGbpLHdL29/9jRcTaFXk3k85ucNJhOLkUAjip+xvOWl3KQSI0XScOPhcFGbcDwhaNNhFwl x6oT/gqmu3JpLpXGd+GWZy6mGVhCjMaXjMf2pMfyYwPnvKfwuzC2Ot8bW24Lo2QvB8xK4yeTogm j1TkOajtQPZWU54of+7DAxyc0j968X1PnP70DDPzYAh6CgIKNVFviTJw3Zx/thblA9w8wCOq7cL PMpvoWzyAI2K1uB0Di6iZFDYJJIxDdiOqsi+fcLicpK4BIXo1m0W4kKcL/L/1wuyX2n+dvaYIf/ eKF22UqKB5kJuHcwaNqvIUcPxnurhNxpXVpFH83nPgOMBPUhLkDPW/JEFcFV6M+LPz/qqNYC8Pq HYmgpuegUySatx1qqO7IyH4sCZaZWp35VOce4X9C/Nfkq0aumlnyVInlTiN4v+ueko9qD2Ni6B8 DLz4wdBuZW80C+A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: BB83B40031 X-Rspam-User: X-Stat-Signature: npa9fepz8ozp6zh19ranrjb74sfe98nd X-Rspamd-Server: rspam01 X-HE-Tag: 1694104446-485531 X-HE-Meta: U2FsdGVkX1+9MGnWMbM5eKlPqKCALfuHaPSLMHh78qVW8bs/qcn65ncfcWvoCEpvAt7kiZmxb3MPJuxIHP9qfSXEz7fmRHXuplWgtTD7jVI9Q+DS9KErB5OPBZQwowC+1aHHszQUpmlckeCZ/6eWb+EmL0jlcepmfMVpSh9mJvj76SB3IEV3BlbVsEVu7d/BLl+SFDt6vponpa8yApMdZ5Mg4neGJeEOJTuuZngdIzCDXWlD5St/PNOKwDUxsoZe1otUN3uWURQeeH8tG99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k82rWoihIOc7GZaNHVx+Sc+xXTQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Closes: https://lore.kernel.org/oe-lkp/202309071017.a64aca5e-oliver.sang@intel.com Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- 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;