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 19C28CE79A9 for ; Tue, 19 Sep 2023 20:46:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AC316B00D1; Tue, 19 Sep 2023 16:46:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5841E6B00D2; Tue, 19 Sep 2023 16:46:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44B2D6B00D3; Tue, 19 Sep 2023 16:46:37 -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 33C196B00D1 for ; Tue, 19 Sep 2023 16:46:37 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DEA8D120DBF for ; Tue, 19 Sep 2023 20:46:36 +0000 (UTC) X-FDA: 81254530392.12.B10403D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 2E39A160005 for ; Tue, 19 Sep 2023 20:46:34 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q9KdgZu9; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1695156395; 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=Oq9r5r2xAoTCHNL1vl2zSAFYfwjFL747s/IzDVzwbJQ=; b=UCl1Im84AOcKBzFGS6WZ+mw/j+aBGb6jseZMQWTzWIl4QdfXwUp7hOXUgXnGjR/0uZVFBM qlvQKY3AZmSAjSFn3eZMR0tj8jw8DCbT9iOC8WTnGf0vintNwJGS5aQiZ4t1qLeQIx+q0Q 8dC6bv5A4Smhs7qeKw0C2b/g/y4HEuU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q9KdgZu9; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1695156395; a=rsa-sha256; cv=none; b=hUTof9t5Vp68p0oZhxxb08W6mAaxpN+LHz6rHzNC2o1o2Be8h/Tc36z9RFWiFVmqwAUfHL BkPxfaDNMDqWhmquPm2d8Q1ktTbb8gqzMjeoNsjsAF3VmSEs7y6wGDz3yzqSez7qMYEljo wt7keQwkn4yqlBCoNlzPakQUYMkQIn4= 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 F2E59617B9; Tue, 19 Sep 2023 20:46:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A819FC433C9; Tue, 19 Sep 2023 20:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695156393; bh=BmRXQZIEgC13FrkspW8zNhSJjLbclay0bgLqEV3Rrl8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=q9KdgZu946MZfw7DxJLZIxiiIbHL9p62pycuILxZHzw8MqP3sd2qzr3E/ZkzfhbEv Sv560WUNQE0HlwP/5rEqpm3bw7jCmrV5akvxgau1zBqN4rLOK+/ZjoboBONeleNI+5 6SP6lExUu15oD0xQisxQolfz9bgwYx59X/D7X0LTGvi5p2a+XVoY+oMnByTr4quQRa dZXyYP7t6FAFej2yuwhu+Ce8pxPjyRxtNPk1CXlFaDLgBYYr9H9mjHCggTcasxMD+A UZV+ik47sNRSAwVomJhe40/Ndx/tHAngLhTIM40zYtZFnzpPzdTJ314IhHsCYJFhNI PFuADp6gLFx9g== Message-ID: <6e6da8a875a0defec1a0f58314995a6a12dca74e.camel@kernel.org> Subject: Re: [PATCH v7 12/13] ext4: switch to multigrain timestamps From: Jeff Layton To: Paul Eggert , Bruno Haible , Jan Kara , Xi Ruoyao , bug-gnulib@gnu.org Cc: Alexander Viro , Christian Brauner , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Chris Mason , Josef Bacik , David Sterba , Xiubo Li , Ilya Dryomov , Jan Harkes , coda@cs.cmu.edu, Tyler Hicks , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Namjae Jeon , Sungjong Seo , Jan Kara , Theodore Ts'o , Andreas Dilger , Jaegeuk Kim , OGAWA Hirofumi , Miklos Szeredi , Bo b Peterson , Andreas Gruenbacher , Greg Kroah-Hartman , Tejun Heo , Trond Myklebust , Anna Schumaker , Konstantin Komarov , Mark Fasheh , Joel Becker , Joseph Qi , Mike Marshall , Martin Brandenburg , Luis Chamberlain , Kees Cook , Iurii Zaikin , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Sergey Senozhatsky , Richard Weinberger , Hans de Goede , Hugh Dickins , Andrew Morton , Amir Goldstein , "Darrick J. Wong" , Benjamin Coddington , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, codalist@coda.cs.cmu.edu, ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, ntfs3@lists.linux.dev, ocfs2-devel@lists.linux.dev, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, linux-mm@kvack.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org Date: Tue, 19 Sep 2023 16:46:25 -0400 In-Reply-To: References: <20230807-mgctime-v7-0-d1dec143a704@kernel.org> <20230919110457.7fnmzo4nqsi43yqq@quack3> <1f29102c09c60661758c5376018eac43f774c462.camel@kernel.org> <4511209.uG2h0Jr0uP@nimes> <08b5c6fd3b08b87fa564bb562d89381dd4e05b6a.camel@kernel.org> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2E39A160005 X-Stat-Signature: 9h8o7qnwnicbbr87tddy3f7nkw1rahdn X-HE-Tag: 1695156394-295470 X-HE-Meta: U2FsdGVkX1+HRte3lp1tAlkeYObUjcTzatqtNTVSv8t8e1VGnnKn+3SM99H65Xhnalk173W9ayQg6hAt/RT7YpYCmQLXwi5vH/yxlD0kmA/zm1f3o4ZN7Jyp6zMNSEOkYQZi9jtc+iujUrUKm8fIKKs57nXMm9P826sklGA5cH22kcM68TQnuRII+l8TPOAM+0VYM9X3UXbPHaVJ4axkYyVsqk9va3LTLvnaByY5HHqbxN++iYJ8C+Sss61j0HqD99sQlX+B194ZVgUzFJueMGZ/UxCxLuBiDTrTZPUWcW44ptXnHzovaJbgKV/9H5oIdFXxmghB9H9lQnUmTyhEmxnLk8IVIYYkuf7Tk3qI6NopFe9800XG1Yoig8kcSqwzVfOo6e20UVp2Xhsj/nNoEf+tnRvjdUjZ85AdVLCGdsYR8vezcXcaCU9vYe+zCniSiBtRDLxjvlqYWMbG8+KcpDZfUwodktcqU/niTWyBREz+1RpV/iH39sv8Jq8Hs2OvSxAqhcwNyW7VV4+AJl7R4fl4xCItxwgve9IrqWCtA/k/Cviz89iA1K3pNCGINn9/6LdMWefe5Q9E4SJKWgPSDFExGK9OPt/ve+QczrLai1/V3U/kTxl0efHvUXiZYB2d000uF5lxXRZKRIF6hc3u8AMM7wgQ3FjMqLooUWi1EeYQw/YWW0WOOKhO/+S0WfP3ehL1gQspog8zxNSx6f//0zBZkzRcH8cKCPPAUhbAe6rjoMDcyAlyqqbC1y5Z3zEj6VJtsPwZMzbmP67nnXoqpweiPEuczr5w8LeqntJDDA36Y1qtsI5AB8iO9o8SAagL8kergc/FIJvBOLA7e9ndUPryyzcPoZhU3B//59pYQcUX0Ko1fFbF+xcJaKSx6FG1tawA0CdoqzJTVNJnNYfJpLf5HHQCBtH9NxFtqCFLEbTyMS/8ANa6sGDayNCmunL7CxgGuWtcKiXziydy8Nf cpyi3f1/ PwqmxEPDpdW/0BPU3AJLmXK42ttB9UfA97mDS8Q2pNb/AaiCoZrbFSKZRg40hLoL2uHK9YiPGrelEtSpwgghtaj1K4lRBcZ8N3mwuPb5b0DYlB8OCbjuR43rhZWZGERimMRMswSix9Q962hrdW48PIRgiEvj07GbtH/q8mIt0XCT1kngpU2gaQlQhIDnQh2CYYxC+ZzH2yZ3jZlaG6mVLvYd4YfpqZVFPQe2ymOuur0iXJCYnhZMBsKVvZpZFv0vui2ZFHIbXl8qmqjI8JnRhAUkb0UFs//XqmJiPts410ZDeNA7Lh3aY4/r+uS6l8iS2gs9weOKxml9I/kx9q4+vfGjfHTmvPHx9EUof 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 Tue, 2023-09-19 at 13:10 -0700, Paul Eggert wrote: > On 2023-09-19 09:31, Jeff Layton wrote: > > The typical case for make > > timestamp comparisons is comparing source files vs. a build target. If > > those are being written nearly simultaneously, then that could be an > > issue, but is that a typical behavior? >=20 > I vaguely remember running into problems with 'make' a while ago=20 > (perhaps with a BSDish system) when filesystem timestamps were=20 > arbitrarily truncated in some cases but not others. These files would=20 > look older than they really were, so 'make' would think they were=20 > up-to-date when they weren't, and 'make' would omit actions that it=20 > should have done, thus screwing up the build. >=20 > File timestamps can be close together with 'make -j' on fast hosts.=20 > Sometimes a shell script (or 'make' itself) will run 'make', then modify= =20 > a file F, then immediately run 'make' again; the latter 'make' won't=20 > work if F's timestamp is mistakenly older than targets that depend on it. >=20 > Although 'make'-like apps are the biggest canaries in this coal mine,=20 > the issue also affects 'find -newer' (as Bruno mentioned), 'rsync -u',= =20 > 'mv -u', 'tar -u', Emacs file-newer-than-file-p, and surely many other= =20 > places. For example, any app that creates a timestamp file, then backs= =20 > up all files newer than that file, would be at risk. >=20 >=20 > > I wonder if it would be feasible to just advance the coarse-grained > > current_time whenever we end up updating a ctime with a fine-grained > > timestamp? >=20 > Wouldn't this need to be done globally, that is, not just on a per-file= =20 > or per-filesystem basis? If so, I don't see how we'd avoid locking=20 > performance issues. >=20 Maybe. Another idea might be to introduce a new timekeeper for multigrain filesystems, but all of those would likely have to share the same coarse-grained clock source. So yeah, if you stat an inode and then update it, any inode written on a multigrain filesystem within the same jiffy-sized window would have to log an extra transaction to write out the inode. That's what I meant when I was talking about write amplification. >=20 > PS. Although I'm no expert in the Linux inode code I hope you don't mind= =20 > my asking a question about this part of inode_set_ctime_current: >=20 > /* > * If we've recently updated with a fine-grained timestamp, > * then the coarse-grained one may still be earlier than the > * existing ctime. Just keep the existing value if so. > */ > ctime.tv_sec =3D inode->__i_ctime.tv_sec; > if (timespec64_compare(&ctime, &now) > 0) > return ctime; >=20 > Suppose root used clock_settime to set the clock backwards. Won't this= =20 > code incorrectly refuse to update the file's timestamp afterwards? That= =20 > is, shouldn't the last line be "goto fine_grained;" rather than "return= =20 > ctime;", with the comment changed from "keep the existing value" to "use= =20 > a fine-grained value"? It is a problem, and Linus pointed that out yesterday, which is why I sent this earlier today: https://lore.kernel.org/linux-fsdevel/20230919-ctime-v1-1-97b3da92f504@kern= el.org/T/#u Bear in mind that we're not dealing with a situation where the value has not been queried since its last update, so we don't need to use a fine grained timestamp there (and really, it's preferable not to do so). A coarse one should be fine in this case. --=20 Jeff Layton