From patchwork Thu Jul 13 23:00:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13312723 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 8E309C001B0 for ; Thu, 13 Jul 2023 23:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6CB6B008A; Thu, 13 Jul 2023 19:02:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 167866B008C; Thu, 13 Jul 2023 19:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F22E88D0002; Thu, 13 Jul 2023 19:02:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E20C36B008A for ; Thu, 13 Jul 2023 19:02:02 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7A9F61C87E4 for ; Thu, 13 Jul 2023 23:02:02 +0000 (UTC) X-FDA: 81008113284.10.18EBC36 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 9B369140025 for ; Thu, 13 Jul 2023 23:02:00 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BS7k3xvm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1689289320; 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=Uf8fzofxnNcmoauKYc81EqlxvQyndJgVuHBZzE2ZMg0=; b=7hbHaY13mq1ydkU/WOu+0EHCOhqbOD8ySiBXqo053DBETEFJzDwEfBWIj5Z6yewDdbaZRm 7KSQNjIdj4xwQYHT6VVEc+bPK5pkOEuVGlXic8bEKu7tN7EBVrAatdZF3tVOcVvZCZMmBs DWzgDnnMPzmpLVxUte0yL9IjE1B/o3E= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BS7k3xvm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1689289320; a=rsa-sha256; cv=none; b=7ZeHsFQ9ssdleDhd4ApjTt4XuLO9pSEruWC1ASmAS/759PSPHyeDQhwHORthnrOUOM6Rt9 imj2hK90zuovYXKSFB5gE4YXxNE/hnlyAG4LUm1c+O2VJm0SScJjnE04P6nPskQxTe2g6U 30ViCGE1THsSklEOc5JER1ZFxxhCKyg= 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 BA1F561BB5; Thu, 13 Jul 2023 23:01:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F2C8C433BD; Thu, 13 Jul 2023 23:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689289319; bh=t187d4hlj7Hd2B853hoiIPlXJE4vBx7O1lkOZGTYDW8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BS7k3xvm0kV8VQrl/+Nc8umWhgO+pb9JT0LHiIqUglobFvawLeTwqlzQHpVKTDZvB uzCvx/VSEkD7rBjIYWrgFJPCVeqzpiWP8yPt0omTj30LLcay2tknCTfGbRYu6T8MHO XUKoIaSo5n/Bd8IGVTxHqLGvMrjMe0fw+PscScTZ4jWUdNZ+2byzzdy+o175llL7m5 o50SLzukRXrSYzl6VaWT8ZrHwmm4KFENLB31WgFlIK5T2Pi03WKPiptSSMpQZPxFLm ct6V/7uDGKKjKZCyDiQclhCznfyT/lEVKO0vqyqaIX9NPJI1Mx1EUf0gKBJYoL63GW 31d2FfqFHu4Cw== From: Jeff Layton Date: Thu, 13 Jul 2023 19:00:57 -0400 Subject: [PATCH v5 8/8] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20230713-mgctime-v5-8-9eb795d2ae37@kernel.org> References: <20230713-mgctime-v5-0-9eb795d2ae37@kernel.org> In-Reply-To: <20230713-mgctime-v5-0-9eb795d2ae37@kernel.org> To: 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 , Bob Peterson , Andreas Gruenbacher , Greg Kroah-Hartman , Tejun Heo , Alexander Viro , Christian Brauner , 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 , "Darrick J. Wong" Cc: Dave Chinner , v9fs@lists.linux.dev, linux-kernel@vger.kernel.org, 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-fsdevel@vger.kernel.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-xfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2706; i=jlayton@kernel.org; h=from:subject:message-id; bh=t187d4hlj7Hd2B853hoiIPlXJE4vBx7O1lkOZGTYDW8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBksIIv0d3fY46+2hyVZzGgFlf73uVo9uOX8lOx6 K4UVJ9Da6yJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZLCCLwAKCRAADmhBGVaC FbztD/4uZXXSyTwCnSezUKeydXdyB1DOo4czPXF+iJ085mANTre9b4XbUvuEDf9bQijKjYvAiIF T6aBATLxstNxy4RGAHDXtSLWG232Ink6G1PNMhMC9R96FpJsuPjmMk8NUBog9j/mjyhM2PlaAMX tX5JL88Tb2gI1FbBxP6pQJCDRkYxbfydZ/FGNzZuAcvlJMt3BH7bGga81LPIjr5UOfLB+GnI8oe i5BFOw+r7A+Xu+KDGowTNXor3TGmR763yaM7A/mcig5Jp20jEJIXDGO1tVgSdAP0LebIstIif+9 kiMe/3MWPnPs0eVd+mEtYR53HfccdkA9ShOKV+Jx7qg5v2TSojDh7bRQBVb22NQZGRPBlgv2560 X83w+MU7yhsMU1MCxv2Whg6ooLLErWX5Zp68rM1FJYdQ/3YbvfDj6sg+4Aa3PF5ifwLM33BLCLr pXwEOeLySTL3OWSfSzMqbNqkSShHhPhxZs+ZtZsqAM1fTRTO3svFqI7T/IFjBt7NKwvQJKyhtIJ syGts3Gf66X08k1+2iwyGMuP2FA8o0TGMTCwUBXZtxQhhH4KlMpwsdFurHxhcT/j4CtVbSAH4Uc fB3KEuG+QiBPD89OSHahxCRhPa+vWgmHHVnmaRK/PJC6un6LOOBM1as6ikNxs/Lc9yixCPrHMNq /XZRVwDe3wtNV8A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 9B369140025 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: menq1oodoqfkczsyzwfrnqqm9sa5nc5a X-HE-Tag: 1689289320-710934 X-HE-Meta: U2FsdGVkX1+gDy7prk5A3YqkIi46ga82qE4OOHXu7NoSFvO1ApwPDWdOawfVqGOjhncrtrK5snpHdqrn5DwNJEXw1HXMl3HmFAt0tlzqT8qn75PW93Rw9yqWiFLGUprf1Gxj/gC6+SX+lac5piEtjgoRrY419ytlen/6T418abSg5ZWCMX6WB2P8AWtcOCFhIPCVhpkBwMsutcvs5sdZltT/GQlbgyUoSWnUbTNqgCKSDtxmV+ma2QXuObJefzXh8NRruwcPl+7rn6iLQpS5CcMt0+C7dRuWZdF9/zTuooUZ/L5zXrZ8aSefWFn86kO79FT8uPw8xUdwygoX/41FTuQg7tUv/FjTsLwX4vxKqcyVH08m2E4rjcrHP1bd8E9vmYnSU//NsT3zpqAiVZd2UU8CNVi7ORNl2yCuVq5oiLP5ur/vuQakPbo0y7jVeJ502nfPVjj1FYXSea61bYomoYUXwtJOo/k97VEzrHEaDnY+UJMrxO3Amtw8CeEL8uKoL6ZvnXsDrvPKa0aieleHZE/heReh5+Ds9Ndi/1f5pTXbruOiBGrXoNrkcLpHT7UnRkaQRcPUm4E1H+reF4eCuINFbSeolUW1v84xBs6kUTNq6ACHvoMH/OuvTHWIw3ecSD5LUG3LyHs3kbYMLbsp8glOpbskpPekzkUrDv+z/klLk3Hw/tsvoo/9eBnrqIfDqL8O0w9fHspjOopD1y9r5jVlYpuzlyoylsatPsGIbSl2BSIleH9n+KWMPrp5IlHnr9ljn8iLj9yCdl0ehue9Lq6OVZF+dn7058Rw0gdQX3sVtAoeh+yuzDZmIlG1sZoOhZiA7RBHxFYB9LNWsQZK1sIgRzOrfzk5Xwj2JaLGDcnOV/oyU4SVoFC24RfP6+MUaeTVWnPbi4vdvlw4wk+Yp7+Hoviy308O7uMmovss5vyV6tqJIPlaIqFjBLaw0pOlUGcxljqCuww622nWECz Ocu/2U28 pWU5iIuOBqgCwPwU0cuss+wVcXPzSVrwnFRzH4KLS5I2hm6BN/AljHLO+4hxAZZR0gm9JYYRoc6jHa4N+FqFCpRZttL+Ip3BV3b7VnMacrUA2M98KTz52m2O2iV1c0LtgSpaEaPPgmM1I7pjmbr2t2eiNsVUs8HbssTgH0sdVFRDQ2qGZ1yiS8BZqdT9R9zJwbWuAPi5F2viwToBN0fv2binAo9lTRVMHaFC+/okzt+2f1m/GwAA+iJPKfBuXOH8p/69nTMtDcdM5gBnBPmzZjFU8+7tKm9I1gr6Xoz+cljED6ArVoi/FfQjqxf+M2JVA1k49gkLXguS94GoXya7GDfV2nyUfxqgjJbWj 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: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Beyond enabling the FS_MGTIME flag, this patch eliminates update_time_for_write, which goes to great pains to avoid in-memory stores. Just have it overwrite the timestamps unconditionally. Signed-off-by: Jeff Layton --- fs/btrfs/file.c | 24 ++++-------------------- fs/btrfs/super.c | 5 +++-- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index d7a9ece7a40b..b9e75c9f95ac 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1106,25 +1106,6 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode) btrfs_drew_write_unlock(&inode->root->snapshot_lock); } -static void update_time_for_write(struct inode *inode) -{ - struct timespec64 now, ctime; - - if (IS_NOCMTIME(inode)) - return; - - now = current_time(inode); - if (!timespec64_equal(&inode->i_mtime, &now)) - inode->i_mtime = now; - - ctime = inode_get_ctime(inode); - if (!timespec64_equal(&ctime, &now)) - inode_set_ctime_to_ts(inode, now); - - if (IS_I_VERSION(inode)) - inode_inc_iversion(inode); -} - static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) { @@ -1156,7 +1137,10 @@ static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, * need to start yet another transaction to update the inode as we will * update the inode when we finish writing whatever data we write. */ - update_time_for_write(inode); + if (!IS_NOCMTIME(inode)) { + inode->i_mtime = inode_set_ctime_current(inode); + inode_inc_iversion(inode); + } start_pos = round_down(pos, fs_info->sectorsize); oldsize = i_size_read(inode); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f1dd172d8d5b..8eda51b095c9 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2144,7 +2144,7 @@ static struct file_system_type btrfs_fs_type = { .name = "btrfs", .mount = btrfs_mount, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME, }; static struct file_system_type btrfs_root_fs_type = { @@ -2152,7 +2152,8 @@ static struct file_system_type btrfs_root_fs_type = { .name = "btrfs", .mount = btrfs_mount_root, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | + FS_ALLOW_IDMAP | FS_MGTIME, }; MODULE_ALIAS_FS("btrfs");