From mboxrd@z Thu Jan 1 00:00:00 1970 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 2431FEE7FE2 for ; Fri, 8 Sep 2023 12:11:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8706B00BA; Fri, 8 Sep 2023 08:11:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 988926B00BB; Fri, 8 Sep 2023 08:11:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8509E6B00BC; Fri, 8 Sep 2023 08:11:56 -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 748176B00BA for ; Fri, 8 Sep 2023 08:11:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3C9CF410FB for ; Fri, 8 Sep 2023 12:11:56 +0000 (UTC) X-FDA: 81213316632.16.DF81F68 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf03.hostedemail.com (Postfix) with ESMTP id 359A720038 for ; Fri, 8 Sep 2023 12:11:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ck2HsG6M; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=0NO19Lwp; spf=pass (imf03.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694175114; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=62nbVbwjJ1n6ISwwqNPZJtlzBj6XnR4DabkHQX2j/vk=; b=CbQ32aipR6UL2ugXcAqV1jZjVXUPIX73zoHQ5WRdkjqJyC3N2SLyOPGd+WpG9AlsleBI0J lKvHgdQDXK0rw8FwDUcQ3P+yGOYYZ+gaoqH/Tf30xw0pmo1Af3W4lRrqkjdqrtCP8UyFoR biO5w4b+Iu3xyptTt3x9VZAbASrL3oI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694175114; a=rsa-sha256; cv=none; b=xgsWHZ2OAo0m4YBJEFqn30qMb+7JuWpfatN1qeaxPzsF3khPAGBADEQPkRgEPu/zWsrkXN c0SI+NvL4PaUdQSKRTWYG0v36RSmCUqVKeZo1sedeeI95XjznkX9YIMVKw6EKCPzMR/rTa J9Jz3ES2WIfOZsVVBgC1jJj2Comjh80= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ck2HsG6M; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=0NO19Lwp; spf=pass (imf03.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F356C1FE20; Fri, 8 Sep 2023 12:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1694175112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=62nbVbwjJ1n6ISwwqNPZJtlzBj6XnR4DabkHQX2j/vk=; b=ck2HsG6Mob5USAy+Rg+0sTiOKENC1AzIIVYGpptnQk/DnvdQ0+40jlXn3lgsBkRWtJfxiz feaL25EP1SRHEbkHL497FV57oZGjjBfcJ+CVBCSfGgFFDQVNz2KJp5WfOadKX3OMrd7R+b TkRCogClTe9VglMi0dQShNlusxFZhSY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1694175112; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=62nbVbwjJ1n6ISwwqNPZJtlzBj6XnR4DabkHQX2j/vk=; b=0NO19Lwp++rB/+x6zMjOEAXlDRRaMtD2GtLyoooCa8J8PGAOjRagFMme1ARVRxAtng2e3R QF2NjPfenki4eqBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E0B59132F2; Fri, 8 Sep 2023 12:11:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id PK7VNogP+2RuMQAAMHmgww (envelope-from ); Fri, 08 Sep 2023 12:11:52 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 8083DA0774; Fri, 8 Sep 2023 14:11:52 +0200 (CEST) Date: Fri, 8 Sep 2023 14:11:52 +0200 From: Jan Kara To: Jeff Layton Cc: Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: Re: [PATCH 2/2] fs: don't update the atime if existing atime is newer than "now" Message-ID: <20230908121152.fyjpv4zj4y2bcmqc@quack3> References: <20230907-ctime-fixes-v1-0-3b74c970d934@kernel.org> <20230907-ctime-fixes-v1-2-3b74c970d934@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230907-ctime-fixes-v1-2-3b74c970d934@kernel.org> X-Rspamd-Queue-Id: 359A720038 X-Rspam-User: X-Stat-Signature: zrkzz4awdmsy9grfs4nrm98r1jinbz7n X-Rspamd-Server: rspam03 X-HE-Tag: 1694175113-16996 X-HE-Meta: U2FsdGVkX1/Vud0nYwiUIZaTdTRz5CO/9oUN/N/CXTS+hFnJiA2Mxm4s4o2aQ+J5zhpQHQVgK32Gu89G/fCdpwdcgD3yyTxheyU7FiuHeRbnbDCmSdcjJKG2iHG3NTNfveZkWbPsjvL//te8seEAyYKYGepldWt3O0DByZY2Kxj1qw4FfKHSQIUjnYaZJfu8q0mIGCXPfmsx1VUZY8hgRbrxBrBuZgx68GjiMKHTLLeXVN61f70Mj+7677rr+qDXKP1ll5jtgGq6SmaNjtxcdi7WztBCqR4QEBOfNTWs9KezXZDYB13WBj95/C4i3sAw6bSJL6JjQNrBDiQh5MmlodZ8bBcQR/DMihZGb7SecNMgJKa8m+taxzaNtz534HIHdiZowLZTQcUugfN6u8S9zZ4+gZd/js8HAGgrIJ/hw9ofN6SCXN4kLUm2MDbbMSxW3BfgMDcb1gP5xmyxLWH+Nj18jvMiXdyPEBITj06DAX0TQjMBIQ6lMa9hMOHwqzmrkRPmBGeAE8pYDGoq7U59Ex7cl9HV3Lk3yBelUJiIG1Pn6Qv/khQjH/0P8eQ9CuNeh1qejQMKKmNeH4MLx11leYNGB9rOR2L1idPgT7aESUI2VXg0ekGstB73n8LpN2rElVrX91HADXphPlNcVuvlQIbyZN+gdw7JQjdUOnLYHkghdadUdqH4GFD9cT+oW+RXEwvn/pn8PIcqFgRV6XEP+QZsp1N8Y8Eq0O8AP13KY+GQ+gc9ckrzCg54EpPkmHtCgbCpqiQr/fWabpN5uklOdTDaebpso7/9UWoBGxxp3/LFmFr1Tt0RmBk0vBJkGQohpRH3EyIdvvTLSt61lqpmBRH0p4Se5T1t03aVgf1h2KPzisB1BoWRi12joa5SRYYWrjkBFzBp+cPcClA5uvRoOnNPAMPzyPbFfML7GFUd9TpBN9/wuGjPXR1+H27Ikj0ikVT/Vo8A3P6lwWdtchq a9SUZz/9 v8PnY4aWeso+F3LvuwLv7pa9yOhskbDnUQCyMvy98Zv3SgLVEFVGVW4mXJ2plGeT49xeEolmhfkvhpJVOErEio96GjU17TiJLhOM+L8dZD3A1cmVk2uQZ0VjF1DlY8r958x+a0VIn1OKPgK7R6EpToZKAgyU4q6GFUQVBddYKRr+TrVJq1pneaccmkWet353qdSoxDxkfluevWv3fGsPHX/ffNl+5wytavfg1KNP/X1mC0cmWq3z4zutXKGfPKwV7Xpo7eVAiruF+/vFfhnR7sgZJ4QefBNfILBJHhDFVbYMUb9pY2bmi54OG9VNXzNxwbDjMRaOng5joLX4= 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: 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 > Closes: https://lore.kernel.org/oe-lkp/202309071017.a64aca5e-oliver.sang@intel.com > Signed-off-by: Jeff Layton Looks good. Feel free to add: Reviewed-by: Jan Kara 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 SUSE Labs, CR