From patchwork Thu Sep 7 16:33:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13376612 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 1C40BEC873E for ; Thu, 7 Sep 2023 16:34:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4CE8D0007; Thu, 7 Sep 2023 12:34:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A73A38D0003; Thu, 7 Sep 2023 12:34:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C61C8D0007; Thu, 7 Sep 2023 12:34:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 795F58D0003 for ; Thu, 7 Sep 2023 12:34:03 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4D06F80220 for ; Thu, 7 Sep 2023 16:34:03 +0000 (UTC) X-FDA: 81210348366.28.7F2B90B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 9182E8001A for ; Thu, 7 Sep 2023 16:34:01 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hdFbPPEz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694104441; 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=hFWbSvgYdd6Oh5/F3WQD9lFbTXpZrvdUYMJO36Y5z+E=; b=DfWlOiuToz4wacIJuODtPGEX3u/gPr20vhS8XwKebFYWRJcuvNgVVjf9XRWgdCtwK9SC77 4F2pRFQmbLUf6V0285qNrAktC5hOSzp4RtMjjQWg9l55Dnx3bAnWEiSAdwGj7jxXdf/Icm ZLvCNvJav+8efF6pNaZKYfYTVLsELaw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hdFbPPEz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694104441; a=rsa-sha256; cv=none; b=s2pOnp/2rJZN2nbiO/zxLiyYekNX65NNs+nJ1HYEDLn6FYBQUdM7nDZfyoR5iGV6cPUzxX sFVAKZxmVvRYxBvZtL9wtsr9JU8GttXr6tflIpqR2mYEdBddPL1lTKPslSkMdivfBRCqI4 wdJGgb3SOindZyfNRbOjY/5uLxQroK0= 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 dfw.source.kernel.org (Postfix) with ESMTPS id B2753612E8; Thu, 7 Sep 2023 16:34:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 724F9C433CB; Thu, 7 Sep 2023 16:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694104440; bh=JP9tUiLZ6T/k5I6nBBltrDdOGnjoSsJgaiX+JXKr3so=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hdFbPPEzdSggibPtiqud6tUTPGMrh4MM86UWNxl9U3J28kRJoe+NUIQq+qzv2mje6 Ja2aq6qq2GkG+BDPQWzl2bIZr2AYMmYYX0dvu9txwAR4+BmCRL6iQAy+l5BS2KHf9R L7gsz0OgS9poH0dwdoqLJSmHoBhTg83wfdN8XiSGVTxJwtQqvmVnNieX3WtGq7Qxi7 FCTHt945til2Bt8OkSEcyzDaickDMZjoM49bzDucTwOY4Iex0VDRJpj99XZB9yMrvc 7HL/KThu0iddy0hyBBpdZIX105Oq1xfP4aj41OqLFYN4/CHe1Y3crJbtWHCWTcUgVc WvJQz1IJXrm3A== From: Jeff Layton Date: Thu, 07 Sep 2023 12:33:47 -0400 Subject: [PATCH 1/2] fs: initialize inode->__i_ctime to the epoch MIME-Version: 1.0 Message-Id: <20230907-ctime-fixes-v1-1-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=1130; i=jlayton@kernel.org; h=from:subject:message-id; bh=JP9tUiLZ6T/k5I6nBBltrDdOGnjoSsJgaiX+JXKr3so=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBk+ft2F+0r47Otgg6Kb6XEIaO9dJBYAFU8gjygE 8uEhYSQQs2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZPn7dgAKCRAADmhBGVaC Fc5OD/0bSZpmszFw2mR0jS9vvjyJK3F4b0SARjnyo1q9za9QbR3U8c8lrWzVlySgIRm6ISqeg+C irV1RBOgwNkJRO3/EnwPLcA0K8UAN1VzTC2pn9M7qy6uaxpRlBsFN67vJcdj6I+lmO2QWeTtkkf lMZqAWOh2lR7jc7LqoFT7/Q0hLd0mWFiqtsw2SsSUNj7kIJ8O/QRbpXEfdwPS2Kp4vXtxBFZ34s uyVJFb9N2ZMnDUJiP6cHCnJ8zkAd/ggrB3G5Ea/ydtkv94vSMnJdmr2JYmnUp4QyrNG0qSID0YH XYiQZtdNX8+RGKgBqo4yvR2jrzy8nYAdtXJfejw++Yg22v9gtG26j2eXD9TZWFrYg9w3iPns1mz WRGVVRFZTlfDxJnZggpAYC/S1kCq9xgc4+gFVwmJYfELyIkG74thIdPu8+RSFGQIfTzarjCCytX LoO0DjJMuDA7fcIq7CHGvrn6XLG7AFr1K13ECVagnzBxBXalayHS+ynyi6Al8lW+JjwnIwwd0d8 DbnQCw/H+jM1pllv2qM00QHrq8zwnNekLI/jcZ9OojuPzfxmBby3hA+imSR8zeZdfwRasO7RNZC twEjfkwQ5XzhrFa1e/DlzOrJC2JW/JAqjeXKtqoLrQ0YUIqE1KyW0qN8Aeb5BvS/kH42jezqvTp kG2YAXIFgW/nmJw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 9182E8001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: yks8iz8izhq1cckmefted9i6xk76dk3j X-HE-Tag: 1694104441-822212 X-HE-Meta: U2FsdGVkX1+PLaDge3aL2nK9bPsj8OJGfXpsEEPXlY1CmKZ6SpGpw6G3v171/jQ15rn6/fWPIWGks3lxQH1oGleZE6NKKK1uLG4+SyFwVVShpq0HcuG1kO41JVnLrL6/svbB2GwDx4NCxOzEgIMyC/7oDUzMj/8iY9AQHN+apf0MHoOahIs8VucseuaFHnrsF2/WjCfGLikq7Mtykp7Ohu8V7TEYtZCYwduO4+mngrCSgjc9sUkSi2t4Sh96iRJ2lNrvDWT3rw0aMVyPIVaobZqdpkXT00teu4rxw1nYmjw41FDmJh77jLSnQbMeOA/Ozh7s6wsyrfpCTZPi5ojcGoI/j6B2FJp0KcYWumIb5iopmy1HHsdV6tbxfoxmTCmxj/fej6DmlpzXtVHUtFQ8F9ZEZeSozK5nappgtPIqYVj6MZQD9rnGVqlvppoaDsjdksvXjcOGq1b2jjLTRqAPUAoniz40dwJjS/Ru2K61nT5U+rS6Za9CQJZ3B1c+hhwh8BeMs0aE7BNitBAXtF41ZTV3LJPRWgBkZUVWHJUE3iEgpnFyJ++taevNKF+aeLuqw0tuyo4AHxJnNGThKQtpzjStibuOW+tLzgwf71Go/OgsyRds27344C8+OVxcARl9d3EXNPjw8X5cwzR2sqTruKFbhc1XUmL8vMnNxDNauuqof5NLllrTBR1pGAwILhtRc4r0oZ1tJGcPYby0zvbE3SW7VCAJw9a2uQdZxyktXi4yQ/ehDihf7FLHdhDLwD3rnDTNA+f3cBDiTp4yROyY9vdWXUI6M476CmLPw8x193+iML0p/Jkxz+e+2D6rOmrPPbz/ls0d6XUKoL/iImx89J2qOSGf2mmgv5+B9A7kvlJG5W0K0V+TaivU6yMHf6s6Jn+lPgCR5VNDD5GDzlPDdyxB1hs1HRShEuKX8o4R+EHIZxBu04+SooLXP+3Ku8KsLNBOIzMGPoPNB4P/m/v meWOJgfZ 9DJdfEd9MPDouQvF6hlsitmibdJWKWG0TFqeOJCx2fn6u55XgDu/FDGu0uvwcGW5R29kxYc90pKMKb8/DA/TldewwLlzNTLbqhfXxdSFhXw2wLzsg1GEkhNRvx5StSp84/O/Wdue6nhLoErWyiRcRfgLGMHGsxwwKZ+rKvwDENKNyoBcjPo8QAq24FoPh+S5+1FW0qYiyakGHVYsiSVX66lhLGGKjdaUlhcN+AeNQoJVVyoFsTlneT79dxmNFGnXEKPKf8kdnv1Pj+yddigtE+oZMwf7XShiHAAXf+XaF1uHjogJEps4irf81vcfRTThoAgacVnpUSYsOqUzlsQogSS1TTi2o9nLO7nTV30oapkBJm4Wd9TMBF5WUQe4Oyf7wG3UJiqrbtlWYIcCmrcVxfxadVqae3VJxnkBh 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: With the advent of multigrain timestamps, we use inode_set_ctime_current to set the ctime, which can skip updating if the existing ctime appears to be in the future. Because we don't initialize this field at allocation time, that could prevent the ctime from being initialized properly when the inode is instantiated. Always initialize the ctime field to the epoch so that the filesystem can set the timestamps properly later. 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 35fd688168c5..54237f4242ff 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -168,6 +168,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode) inode->i_fop = &no_open_fops; inode->i_ino = 0; inode->__i_nlink = 1; + inode->__i_ctime.tv_sec = 0; + inode->__i_ctime.tv_nsec = 0; inode->i_opflags = 0; if (sb->s_xattr) inode->i_opflags |= IOP_XATTR; 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/PNOKwDUxsoZe1otUN3uWURQeeH8tG99Sbcg9GaYJqFp7DbkVKmN0RuEG7BbP6FyrnNWA37cPEVuLemLefnO/TvF6u/EfO7B8UHE/EMtR4wf5NYnaR2pxBxLrDvjXop4pHy93nAPUh43seVNbTC35Fs6TBtxsvdkhvzuC5uDK0dVHrxHZ0JUdxCtsjBCjHCkRH9/hdLHNUQzWEngG+r0xg8x5annfgKtu7+GdnedDYtYWID8z5uhAQPxfYhjkwOA0houGIfZOop+pZBgNAEoDbotLTb+DDxE/2GKiegHOe5BvBGxYLdYthZ+7iI6WNhdeCJ8JkRhRBth9uIsKjVUPL+r+ULpQkIQl4KNjYooXvKezrJZWUy9Ts8WHMatlmDhqscDAhE5Fu/pK2gbITbnCuMlxRvu497ke9dfnas81qd1mesP7GKNFN0UiOEUyEK3tacmZQylJx614UlZNtjg9VRRCkSCeV0tPiJxg4Sgp5RmZl3LIe+apOtFxk6rLfjih+N4mzm0fou/j5DsXaRC2SFZzAaEwPzgFU7R/y2gKdsBuSDDUp9OBDDWP7IrpqUas16PjdsU3cydNBrKRWznsAbwjJ2qAIztkFbhw12fDdspLeqvpaDn/ZMbkLWW+vx2q/tUA2MRa6Dtr3q9xH+JKH+l9ZlV5OjIp6vOD9F3s3c/J4w9J4tHtpFJTofm0vgifNy76+oPAHIIRD+uo5LTF6GmXXJ/EBJn 80sELtt+ ng9BJR0yY0/9y70a1tFQ3ijnffiEnZGvvj+aQguhUmm9bbf54yw/Y/hI7AUEg7KYCFw8mhMBLS+ISimZIyi4bZworq7VCDwk5+5xu80uSNM61vIZPpL3sz3sA3hJ3UNguPu1KKWiRPXhmIhzrOVFQk6Q6PwzXGtRoVnnHq1vfpsdjZnYmwUWIlt0b3tB8n/Y8/vxiR/57+FKi7gwt9BnjIbhFGhC7zbhs5RmJ0wT5x6HT1u8Brsq/KoAc/X3EWkia0TsPO9lj3cn9I9Hlwnn0d4/AqiaZGVFCHNtwsxGP+bJ9mNwDMwPXHnxFqUyQCuFZ9TRe8fONWz49ggzaAFCAQjAZ13kF+PQk82rWoihIOc7GZaNHVx+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;