From patchwork Thu Jul 11 11:08:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730385 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 4475BC3DA41 for ; Thu, 11 Jul 2024 11:08:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 859666B0088; Thu, 11 Jul 2024 07:08:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 811CD6B0089; Thu, 11 Jul 2024 07:08:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A8D16B008A; Thu, 11 Jul 2024 07:08:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4BA2D6B0088 for ; Thu, 11 Jul 2024 07:08:33 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BCABE1404FA for ; Thu, 11 Jul 2024 11:08:32 +0000 (UTC) X-FDA: 82327198464.12.17A90E0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 3BE08C001E for ; Thu, 11 Jul 2024 11:08:29 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FeooJrr2; spf=pass (imf28.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=1720696079; 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: references:dkim-signature; bh=tC0a3Oq7wau+pdp/AQtTFLOruhqOXqACB5we1vPQo7o=; b=20rJGqqIEEJ+lJacKnNKEE1SOjZZa966GIlI6zodVWTvCLnUoT9R9kZHhwgu8Kl4+1AV0p rg1BLO5um6DzgW91DZ2HBXI0cr5T10aPh1WyRwdeFHb4mRyDSJoAimv/38WrZQXOKtPOPU 4tcC+TQdgPKdBixOGmnKEsqfvCiVPto= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696079; a=rsa-sha256; cv=none; b=CQx1Oc/hRU9BHYQoMONfNRpEKzdHTwCBNBF3pfSd9c3kDskvGFM230mMHdoMJB0qYHh91X CPNVp8EdN1vsTGXC6pz81+rrdvDMdV4barnl5IqcjCfML4LKIJSW6PI8FRE8W9Sk3K7SH0 cShXfb7igdkC/lRzpEzcO1DMS46k180= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FeooJrr2; spf=pass (imf28.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8CA25CE1024; Thu, 11 Jul 2024 11:08:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E947EC116B1; Thu, 11 Jul 2024 11:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696104; bh=6RdMfN8GT5TlOHt8U/xfrPGOCLGbZMq30a98R04eApo=; h=From:Subject:Date:To:Cc:From; b=FeooJrr2+az8wlTlJzJNBNTQgbxo5CoT2v0Uu+ysdwGu6rdm2VDD2gtW/LX6qPqPB 5Nvb3nBvD0x+DfyM0z1IuR/5LHBKrT6u30B7EgL0mgkd0jIpIYNnJObs3StrfSgtNP m/FzuafDk+x3L3bw1HyKZ+ayyU9bmpZwnIu6cJeEw+mRQ/Elti8ogWbdykQjEt6YfW mrpKLaYpU5r2jhB3LxfkqTs1P5CMvvJkBC16o8quM1AshhIP/IzGQzpiifFk1AdE63 sdIfrjMieal+/+h+IfW0CbGzEWTPPjpuO6bsodSxLxx+UoSrZxPMwpKLR0cekPTkKA ZOAzKJn5iiz8Q== From: Jeff Layton Subject: [PATCH v5 0/9] fs: multigrain timestamp redux Date: Thu, 11 Jul 2024 07:08:04 -0400 Message-Id: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIABS9j2YC/2XOTQ6DIBRG0a0YxqV5/Cl01H00HaCAklZtwJg2x r0XHVgbh98L54YJRRu8jeiSTSjY0Uffd2mIU4aqRne1xd6kjShQDjnNcVsPvrVYVEZCSaSRBFB 6/ArW+fcaut3Tbnwc+vBZuyNZrofESDBgTaRighpw0l0fNnT2ee5DjZbGSH+uALI5mhxRhhOqF QejDo7tndgcS06KkhqtVcmYODi+d3JzfPknOFblrhSFY39unucvAjh/HUUBAAA= To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5229; i=jlayton@kernel.org; h=from:subject:message-id; bh=6RdMfN8GT5TlOHt8U/xfrPGOCLGbZMq30a98R04eApo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70f3nAKvVzwWbeFtmY26vMEGFNsy5Y6kvcLp I62wXPcziGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9HwAKCRAADmhBGVaC FYmPD/46BtIEjpmLwuzvndS0jbI/Wx/CH2yPVhvmwMG/KhPp04qOzAI2cR4fpjbY48b1RS15EX/ eQh4kQ/ICIMpeQeqkfqd9DQVUzJgf3yVREXHgEii7ZZT0+h8aX1/Hu8DJ0gpA/MjjNNNX59wlCR 8Bpt0pFE35x0cnXa1b763A2pyYAZQz/zvvBSIik1M4OtnFbfKg05c1gPsCyipDy4LZUG2E6g6dE QaC1jw5+m2mRceWloHK08sosonspLLe6bKh6JiTM5PrlBbnOntz8jDYs+vxqJUSFNEGqOEgrOY9 SJO08W33hjJ/0tpz/xpTuExehB9mjd9Djal1+XCnJcou+si7ooTss3nQlK8sSyl+f5Mk+dFY8an 8gx+8gCBWo51IiGREPJFAHG45iXx8jzYIhkgMCb8HtLaKpkB7uZE5mCQ9VWT6ELeBTJSLzJXhCh as0kDeofDpVZftPnGQDqpGTRj42/oWHrVKYyOVH897WJs+HpI16CDYPbikYXz4f51hl7Z8LwKCU qbC8oga88Ww5f5/lXGabKKIH/nFXA0ayz0Hn2NCQD+e9lbbUSzX5QoGQ7hEaURES6eEB/2PcXUR JEMj2g5MEISh+nqOCHWZJAED0JYhV6HoSFGOvRZwyTz7Td+2fNU/LNyqmjiGQNob0GkH7LjxvcZ eMV9Prfj8m7Iynw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 3BE08C001E X-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dpU T21+fDx6dkZ8+7iyJ72P1guUK0C1CfyGdzL9LcIrNEya95Fvt7ljCv5/iNB+R7iGhFcacBl1fdC31n8KizUhCHTW5VzlCWv5OnppOzU/mfJiM2R3xVwss80zNr7XlXL14gqXm6Z2L0don3B46gg555zkCkakNYiUESwh0wByHYZfOPoOvfCqspYYqUingCkgvNXbe26LcCIJVtjxRYspak2F7w2oTFbn2ugc6G4x0WJV0gDyne1wzRGt/dw== 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: List-Subscribe: List-Unsubscribe: tl;dr for those who have been following along: There are several changes in this version. The conversion of ctime to be a ktime_t value has been dropped, and we now use an unused bit in the nsec field as the QUERIED flag (like the earlier patchset did). The floor value is now tracked as a monotonic clock value, and is converted to a realtime value on an as-needed basis. This eliminates the problem of trying to detect when the realtime clock jumps backward. Longer patch description for those just joining in: At LSF/MM this year, we had a discussion about the inode change attribute. At the time I mentioned that I thought I could salvage the multigrain timestamp work that had to be reverted last year [1]. That version had to be reverted because it was possible for a file to get a coarse grained timestamp that appeared to be earlier than another file that had recently gotten a fine-grained stamp. This version corrects the problem by establishing a per-time_namespace ctime_floor value that should prevent this from occurring. In the above situation, the two files might end up with the same timestamp value, but they won't appear to have been modified in the wrong order. That problem was discovered by the test-stat-time gnulib test. Note that that test still fails on multigrain timestamps, but that's because its method of determining the minimum delay that will show a timestamp change will no longer work with multigrain timestamps. I have a patch to change the testcase to use a different method that is in the process of being merged. The testing I've done seems to show performance parity with multigrain timestamps enabled vs. disabled, but it's hard to rule this out regressing some workload. This set is based on top of Christian's vfs.misc branch (which has the earlier change to track inode timestamps as discrete integers). If there are no major objections, I'd like to have this considered for v6.12, after a nice long full-cycle soak in linux-next. PS: I took a stab at a conversion for bcachefs too, but it's not trivial. bcachefs handles timestamps backward from the way most block-based filesystems do. Instead of updating them in struct inode and eventually copying them to a disk-based representation, it does the reverse and updates the timestamps in its in-core image of the on-disk inode, and then copies that into struct inode. Either that will need to be changed, or we'll need to come up with a different way to do this for bcachefs. [1]: https://lore.kernel.org/linux-fsdevel/20230807-mgctime-v7-0-d1dec143a704@kernel.org/ Signed-off-by: Jeff Layton Reviewed-by: Josef Bacik --- Changes in v5: - refetch coarse time in coarse_ctime if not returning floor - timestamp_truncate before swapping new ctime value into place - track floor value as atomic64_t - cleanups to Documentation file - Link to v4: https://lore.kernel.org/r/20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org Changes in v4: - reordered tracepoint fields for better packing - rework percpu counters again to also count fine grained timestamps - switch to try_cmpxchg for better efficiency - Link to v3: https://lore.kernel.org/r/20240705-mgtime-v3-0-85b2daa9b335@kernel.org Changes in v3: - Drop the conversion of i_ctime fields to ktime_t, and use an unused bit of the i_ctime_nsec field as QUERIED flag. - Better tracepoints for tracking floor and ctime updates - Reworked percpu counters to be more useful - Track floor as monotonic value, which eliminates clock-jump problem Changes in v2: - Added Documentation file - Link to v1: https://lore.kernel.org/r/20240626-mgtime-v1-0-a189352d0f8f@kernel.org --- Jeff Layton (9): fs: add infrastructure for multigrain timestamps fs: tracepoints around multigrain timestamp events fs: add percpu counters for significant multigrain timestamp events fs: have setattr_copy handle multigrain timestamps appropriately Documentation: add a new file documenting multigrain timestamps xfs: switch to multigrain timestamps ext4: switch to multigrain timestamps btrfs: convert to multigrain timestamps tmpfs: add support for multigrain timestamps Documentation/filesystems/multigrain-ts.rst | 120 ++++++++++++++ fs/attr.c | 52 ++++++- fs/btrfs/file.c | 25 +-- fs/btrfs/super.c | 3 +- fs/ext4/super.c | 2 +- fs/inode.c | 234 ++++++++++++++++++++++++---- fs/stat.c | 39 ++++- fs/xfs/libxfs/xfs_trans_inode.c | 6 +- fs/xfs/xfs_iops.c | 10 +- fs/xfs/xfs_super.c | 2 +- include/linux/fs.h | 34 +++- include/trace/events/timestamp.h | 109 +++++++++++++ mm/shmem.c | 2 +- 13 files changed, 560 insertions(+), 78 deletions(-) --- base-commit: 7507ae6c41bb8990d3ae98ad0f5b0c15ca4156fe change-id: 20240626-mgtime-5cd80b18d810 Best regards,