Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1056277rdh; Fri, 27 Oct 2023 03:36:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQZw2MnITxq6JIA1ukyi4nE4GjA0F2ntmIltJ9VzINYSRYlna929ey9VYgK7jDmL+pQI5g X-Received: by 2002:a67:e190:0:b0:457:d97a:4553 with SMTP id e16-20020a67e190000000b00457d97a4553mr2266032vsl.25.1698402990876; Fri, 27 Oct 2023 03:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698402990; cv=none; d=google.com; s=arc-20160816; b=cJFuzjeC8Q4hWF7w1fE1YCDK6vUaFPpqXnclWyRMmiBxuT+R6H52qkzOnuHGHhnaDo F20ntSoS+Lc941YduIhhFHv6aaA9tXqjaG6nxsXH/5tokYFxBBEEuun7d7LQKg4YEO5m 11D+Rr9AGBQv6kRmsRL9JcDGRJa8MVbaku2x6G6GPTkZmA0mPQcgcP8bJGN5aahLrFou wOsbApqq/qqmt9qd3WBIPY8vJs/zX5sfCuqCfiCD/zLCmBP7/K9IdV4CNAgy5Ggvr9H0 sNCbjtY5914EyzY4xXXCa/zRJ49JOj6SodeZn2aUmFi95ywB1U69Y6Zh04xatgk87eXd 6Q6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=wQklQBWWi3q5RrX0mgkbHS32RUoA0iW2wHKZzc9ZHTA=; fh=MHU14lZxjX1JxQ1Gy0OKF7f4lH1kW5nMfbIIW//fpC0=; b=sYjaiLqZQXB4TQdQaYVSV1XnZOdxUp7CNiKXToqv3tf96Sw2BWIKD0gevgQd3KixTt 3RfTV5l5scEMhGcblCBkZCXaepQL+H90ScxbjqBrIystRPwpPiNLf1kQ7zLRjqWO1kRc ylzyaZEldJ0DmYgl26VlNK7OZjbLtRkImGJxnPqt2WHyzok2b0juVLmkXDLHAHnY+sZT Fuxgb9lr+Imxzja5ImKHnJ/HSmwCXBaMhkMUwDgIpes9K9Gedrqj29qd711i4y3D/enz 0tgIxApwc3YqQ1mREsugjWjxtWxla43wFhBdUuB0478mWvaKEBWlNaIU6Xi/7A72pIkj 2VPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UVXKZh2p; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g138-20020a25db90000000b00da07dadfea6si2424727ybf.490.2023.10.27.03.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 03:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UVXKZh2p; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 30E0082E7B32; Fri, 27 Oct 2023 03:36:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345676AbjJ0KgJ (ORCPT + 99 others); Fri, 27 Oct 2023 06:36:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345595AbjJ0KgI (ORCPT ); Fri, 27 Oct 2023 06:36:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CCA418A; Fri, 27 Oct 2023 03:36:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39336C433C8; Fri, 27 Oct 2023 10:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698402961; bh=VhY7QbKdLKYqIDXPYrnQDYPAsjSB5qnb7uEtzCqAr40=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UVXKZh2puLMQITt0KDbqEsmmgGhrSIaUjArTj/QriDrgVKraAist2AE0jWBDqkMHT ek/J3aYZfXbMG+/FCT7xA4Zi3AwrcLD58zQru0GR0mZgTkyHGdmGHt4U0T1d1YvzaQ RvWiCsKGFdE9RWj6E5hsMkft1377XkUIKDCnYbBx49FeN3DXvEgloG7jNWBV62Vhai fsFVEc4KrZkFPWkOwucZw+pQ/M+RKLFFm+/x/A0Ggg9MCMRtNFMBIFHKYe/+DRjoKa QJsDY1eJqd4hcY9s/Q2y6wmnEsaxcKts4CImuXC3iNrZChbj2Z2To5ICWXius09aEt 45jXgjywaDQVw== Message-ID: <6df5ea54463526a3d898ed2bd8a005166caa9381.camel@kernel.org> Subject: Re: [PATCH RFC 2/9] timekeeping: new interfaces for multigrain timestamp handing From: Jeff Layton To: Dave Chinner Cc: Amir Goldstein , Linus Torvalds , Kent Overstreet , Christian Brauner , Alexander Viro , John Stultz , Thomas Gleixner , Stephen Boyd , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jan Kara , David Howells , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Date: Fri, 27 Oct 2023 06:35:58 -0400 In-Reply-To: References: <61b32a4093948ae1ae8603688793f07de764430f.camel@kernel.org> <2ef9ac6180e47bc9cc8edef20648a000367c4ed2.camel@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 03:36:11 -0700 (PDT) On Thu, 2023-10-26 at 13:20 +1100, Dave Chinner wrote: > On Wed, Oct 25, 2023 at 08:25:35AM -0400, Jeff Layton wrote: > > On Wed, 2023-10-25 at 19:05 +1100, Dave Chinner wrote: > > > On Tue, Oct 24, 2023 at 02:40:06PM -0400, Jeff Layton wrote: > > > > On Tue, 2023-10-24 at 10:08 +0300, Amir Goldstein wrote: > > > > > On Tue, Oct 24, 2023 at 6:40=E2=80=AFAM Dave Chinner wrote: > > > > > >=20 > > > > > > On Mon, Oct 23, 2023 at 02:18:12PM -1000, Linus Torvalds wrote: > > > > > > > On Mon, 23 Oct 2023 at 13:26, Dave Chinner wrote: > > > > > Does xfs_repair guarantee that changes of atime, or any inode cha= nges > > > > > for that matter, update i_version? No, it does not. > > > > > So IMO, "atime does not update i_version" is not an "on-disk form= at change", > > > > > it is a runtime behavior change, just like lazytime is. > > > >=20 > > > > This would certainly be my preference. I don't want to break any > > > > existing users though. > > >=20 > > > That's why I'm trying to get some kind of consensus on what > > > rules and/or atime configurations people are happy for me to break > > > to make it look to users like there's a viable working change > > > attribute being supplied by XFS without needing to change the on > > > disk format. > > >=20 > >=20 > > I agree that the only bone of contention is whether to count atime > > updates against the change attribute. I think we have consensus that al= l > > in-kernel users do _not_ want atime updates counted against the change > > attribute. The only real question is these "legacy" users of > > di_changecount. >=20 > Please stop refering to "legacy users" of di_changecount. Whether > there are users or not is irrelevant - it is defined by the current > on-disk format specification, and as such there may be applications > we do not know about making use of the current behaviour. >=20 > It's like a linux syscall - we can't remove them because there may > be some user we don't know about still using that old syscall. We > simply don't make changes that can potentially break user > applications like that. >=20 > The on disk format is the same - there is software out that we don't > know about that expects a certain behaviour based on the > specification. We don't break the on disk format by making silent > behavioural changes - we require a feature flag to indicate > behaviour has changed so that applications can take appropriate > actions with stuff they don't understand. >=20 > The example for this is the BIGTIME timestamp format change. The on > disk inode structure is physically unchanged, but the contents of > the timestamp fields are encoded very differently. Sure, the older > kernels can read the timestamp data without any sort of problem > occurring, except for the fact the timestamps now appear to be > completely corrupted. >=20 > Changing the meaning of ithe contents of di_changecount is no > different. It might look OK and nothing crashes, but nothing can be > inferred from the value in the field because we don't know how it > has been modified. >=20 > Hence we can't just change the meaning, encoding or behaviour of an > on disk field that would result in existing kernels and applications > doing the wrong thing with that field (either read or write) without > adding a feature flag to indicate what behaviour that field should > have. >=20 > > > > Perhaps this ought to be a mkfs option? Existing XFS filesystems co= uld > > > > still behave with the legacy behavior, but we could make mkfs.xfs b= uild > > > > filesystems by default that work like NFS requires. > > >=20 > > > If we require mkfs to set a flag to change behaviour, then we're > > > talking about making an explicit on-disk format change to select the > > > optional behaviour. That's precisely what I want to avoid. > > >=20 > >=20 > > Right. The on-disk di_changecount would have a (subtly) different > > meaning at that point. > >=20 > > It's not a change that requires drastic retooling though. If we were to > > do this, we wouldn't need to grow the on-disk inode. Booting to an olde= r > > kernel would cause the behavior to revert. That's sub-optimal, but not > > fatal. >=20 > See above: redefining the contents, behaviour or encoding of an on > disk field is a change of the on-disk format specification. >=20 > The rules for on disk format changes that we work to were set in > place long before I started working on XFS. They are sane, well > thought out rules that have stood the test of time and massive new > feature introductions (CRCs, reflink, rmap, etc). And they only work > because we don't allow anyone to bend them for convenience, short > cuts or expediting their pet project. >=20 > > What I don't quite understand is how these tools are accessing > > di_changecount? >=20 > As I keep saying: this is largely irrelevant to the problem at hand. >=20 > > XFS only accesses the di_changecount to propagate the value to and from > > the i_version, >=20 > Yes. XFS has a strong separation between on-disk structures and > in-memory values, and i_version is simply the in-memory field we use > to store the current di_changecount value. We force bump i_version > every time we modify the inode core regardless of whether anyone has > queried i_version because that's what di_changecount requires. i.e. > the filesystem controls the contents of i_version, not the VFS. >=20 > Now that NFS is using a proper abstraction (i.e. vfs_statx()) to get > the change cookie, we really don't need to expose di_changecount in > i_version at all - we could simply copy an internal di_changecount > value into the statx cookie field in xfs_vn_getattr() and there > would be almost no change of behaviour from the perspective of NFS > and IMA at all. >=20 > > and there is nothing besides NFSD and IMA that queries > > the i_version value in-kernel. So, this must be done via some sort of > > userland tool that is directly accessing the block device (or some 3rd > > party kernel module). >=20 > Yup, both of those sort of applications exist. e.g. the DMAPI kernel > module allows direct access to inode metadata through a custom > bulkstat formatter implementation - it returns different information > comapred to the standard XFS one in the upstream kernel. >=20 > > In earlier discussions you alluded to some repair and/or analysis tools > > that depended on this counter. >=20 > Yes, and one of those "tools" is *me*. >=20 > I frequently look at the di_changecount when doing forensic and/or > failure analysis on filesystem corpses. SOE analysis, relative > modification activity, etc all give insight into what happened to > the filesystem to get it into the state it is currently in, and > di_changecount provides information no other metadata in the inode > contains. >=20 > > I took a quick look in xfsprogs, but I > > didn't see anything there. Is there a library or something that these > > tools use to get at this value? >=20 > xfs_db is the tool I use for this, such as: >=20 > $ sudo xfs_db -c "sb 0" -c "a rootino" -c "p v3.change_count" /dev/mapper= /fast > v3.change_count =3D 35 > $ >=20 > The root inode in this filesystem has a change count of 35. The root > inode has 32 dirents in it, which means that no entries have ever > been removed or renamed. This sort of insight into the past history > of inode metadata is largely impossible to get any other way, and > it's been the difference between understanding failure and having no > clue more than once. >=20 > Most block device parsing applications simply write their own > decoder that walks the on-disk format. That's pretty trivial to do, > developers can get all the information needed to do this from the > on-disk format specification documentation we keep on kernel.org... >=20 Fair enough. I'm not here to tell you that you guys that you need to change how di_changecount works. If it's too valuable to keep it counting atime-only updates, then so be it. If that's the case however, and given that the multigrain timestamp work is effectively dead, then I don't see an alternative to growing the on- disk inode. Do you? --=20 Jeff Layton