From patchwork Mon Aug 7 19:38:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13344821 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 D7805C001DB for ; Mon, 7 Aug 2023 19:40:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6920B6B0080; Mon, 7 Aug 2023 15:40:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 642E16B0081; Mon, 7 Aug 2023 15:40:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BD2D6B0082; Mon, 7 Aug 2023 15:40:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3AB7E6B0080 for ; Mon, 7 Aug 2023 15:40:16 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EFABAB1FB9 for ; Mon, 7 Aug 2023 19:40:15 +0000 (UTC) X-FDA: 81098324790.14.8DFACF1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 0CA45100005 for ; Mon, 7 Aug 2023 19:40:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BXYIfqRh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1691437214; 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=Ycz+PDoS/3K6PCjXTkTSv2kgJvhzHRQDZwW8GIs4mkY=; b=Qy5iYVhSpDnA1c72fQOlIz34FU5LddTJDeaqjMMMS4GgDqtr5f0eZabVKAJM/jLS5+fSTJ ebSlYKZDXiihnArl+zgSm6tSavhkNO1+tECyERBtrxelwPECmLxsujwXGKqDNBqghH/+YQ K/fKLB31g/p2nw3mpV+XCFEuQxaQEGY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BXYIfqRh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1691437214; a=rsa-sha256; cv=none; b=c5idNpattmWNqCyUBGNIDA3FA6JVSZ8nAyihFvnezjnm2evCaM9b3LibndG/C58AOTypoA cKr26HAi1pjTfgRlxWzV1WQHwgDcRylFwi93Amg4mwPOFudRC7MJm9wMgRVdf9r8k2QKsk Yg10Td29OtRD5BuVUjXrnKtOpz5mhTU= 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 4D3AF621BB; Mon, 7 Aug 2023 19:40:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49771C433CA; Mon, 7 Aug 2023 19:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691437212; bh=lN6s1sXYpzZ9zzv+tSr/8W/OSaIgZC0r+RsL44K+ZH4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BXYIfqRhJmmhTr7H/Icv+LIuWhDZCq/Fa1QRxA+FYLQy2wVZqeWUxx42Zy1D2KHG6 N9f651EMax2NVBCBn5bV355x82CMFZzIF9NFtZTNMQuMc8PPjNdqhP5807woRO0S1L unL76YzDYl/Jyxr64UYrZRgboyNg8b5R6XBWSW1cdvBy4sSpnihqb6O64V71kQqQA0 rv2AZehRSWUVQSsQ/ncedHudpMEP+YOTSmdYEkchMRZKS5w/cIAc4xSsjQJ5LVg6BR hz+4C4ymLLgsYLwW8lN7mhC6Rb7gMPMFCCxK63a6AC2kUKL3pzc6gmqk1xu3OLbPLv 3oiS19af0OHPQ== From: Jeff Layton Date: Mon, 07 Aug 2023 15:38:44 -0400 Subject: [PATCH v7 13/13] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20230807-mgctime-v7-13-d1dec143a704@kernel.org> References: <20230807-mgctime-v7-0-d1dec143a704@kernel.org> In-Reply-To: <20230807-mgctime-v7-0-d1dec143a704@kernel.org> To: 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 , Bob 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 Cc: 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, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2749; i=jlayton@kernel.org; h=from:subject:message-id; bh=lN6s1sXYpzZ9zzv+tSr/8W/OSaIgZC0r+RsL44K+ZH4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBk0Ug+oJ8Ypfkd3hBsHRXz54oWzrHgL8wg9atAa a6AaAYOQe+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZNFIPgAKCRAADmhBGVaC FQzzD/9PH4jzuGOTNBwrlcwrXYpmsGoZmIYR7R9NcCgR/m849MEjiNCDcWP1i1bDX/e8eYMeeJz nwC8Yx2MVO1bdnRBgCa+FIqSkV0mceQ3qPA/qobLKnjwb9FcXrfPuXm5WqewuobxvEz7f1xeSoT SF2L+MCnFCanG2OucqJ0gsSHFEcd6Zv7Zwr67KsR4fLn49cnSZy19D0iluSsIZqNMKCDC8aibR/ I8YkhXhbP8+E2AF2CzKv/l68U9VSS4wlrH+kKLn1Ekubzye9qYsMJRP6/E1x18Ycv4Lj0ISvnfV q3HI7BIVYj/34CUEhwOrlSErM56MnkTDJW1F7sDLx5+uhGDdw7I5wEUkTSRIp0xwhn0FKjQn+FQ BaHqVH1bEYlB6ppBWLQv+R0DeNzxWZjZDJijMFcQNaowYQ1YKNU+BOXRBjkVQpTjqOs7OTZCx4v kElqk78njNIJTjfhDC27It2facIRGRq29s+WWxI9RvaWaVjxaEnnGV/J9qBNT0VADJgAK+uiGMU l/WfpwpXbaJFg003gNz9+L5VruoQhn+o0rtkuiJU8+b/qkEKKX5afyqNzac7/COFOu3Hn2w26v+ k3AFETgjkMG2IEhpt4fz2wV2VsKNkreROGaaH0HJ3+XVcu3mQRVb1A4LUl/3AWJLqwsAEi9gj+Y 5SJevE3lM1tE7aQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0CA45100005 X-Stat-Signature: uu5fgw7nq3hktcubunw5kfiftqtrcmwd X-HE-Tag: 1691437213-363798 X-HE-Meta: U2FsdGVkX189sVtPyzR6oEWf6owgc43Pyjv37TAioJDfppAOQXW3iyWh0gFHvU3LyeYmvOMFyvTv2YDCo+c/R5ZqhZ7DuBFOS9kfTG4+XKV5S0kJxpjGWZpR3Mqnd3251n4uDCWSsnYWDemA4gYXEoHDsFgRL5jxmKenaULv+sttm8PjqJ9IwnteFad97MXUE6iS38mJNYG68FP2TpnEU9wybMuL0dQwGd0pc6FbgH5tvj63vv4ibPuUOvT83wh8zBwiQQv19bJnEyv7zJyPDcEHcjeDDC+seItjfTCBzGzpfc/ODio1kdeIx8gMAZctFEsXpQ/UddIMrA4/p+zkeEh1u9xFLhvSv6kJETWpcR/eC0ks0CiKSZPLiwJdK5RohK5yGUN69dO2e+QHREu6O1W9nKlrSCTwp3ErLYY9Pwts2m/619zKRBW104MWSaB8eiou1peytmqMX1nHx6jNLq8T+C2KGG1GR7K7pgQPPoYlX2XAgnOOoHPVLEm5aE+OTRgrf9fcEYYL3Dc2zunE5K1gAIODk7VJ9+RAALTjQ9tk73AYSOG0DbcyFyPKQYsxZUy/NnH78SzJQeB/yJ1sIxB410dDfGITVzqe35bC0BcGWxrASuCnV+rPd2p77hY3y+rjLmn0S7lbHm60zlbAuFx7tay2Ny7L0vxhOK48fljNPhMSn+WTumAx7fIUetZs7jVRdKyP6lDpNrAKLM9MWdKmcUGV3NMz6B7emmYudl2Ac+FIeh9C+f7SV607+q8W3WKX1YDdfzBHzmN3VhHhcFT8uU/u+hnTqmnonH7Ki1k92Yy0sXo+oXv+XDej/T+RyiHSj6Az32F24jS1ErFlgc89UkZSHtSBoJ9zxSSDl9A9YpR1hz2id2GW4uWhUNxPqfHW+qN1ZRrWJQ8fqyt0WzwAycee7hEURaQEFORM7+ZW4xyMGGAJQ2wZRTxzYPxe/bpA5lQhoN/HSWLQAe4 ngfYzPUh vAOjOIHVzhgivjKvjg9MoDiguKToVY/S0qkzUls/sY5SLNRgwg/22uqsVTRY24weDyXai0ypMywfpIv5lrQv1zzw6OsXOQ0dBC/mhfmMd0EevCjs+uoTeVwf3QjZwoBv548BpRgu+KAE7Qg1+RJii7ot8fa5igLUaA2tq09SLqElbhe3gacRg0AGbmJ3QXiIAkuOo+Rmsa9XaP84x0ayVd8ovPYdb7qNNBh209xFDuFaSZw0lphBLpG8pMz4VjX6S90D7hHmC02tDe8DZNHrzTPaUcFfd39S9ziqNZjFbcW4KZJhO3jsARX4w8K9yzEEgYPXBhDnerpAX0tXoq4qA7P48yTWOH6O96XY10UjZYDv6Ia2ue5CNCoup1t4nAMM3AtbCpNRmywkfdrvd4Qz4m8ecW8jKg+oYtn+Z 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 Acked-by: David Sterba Reviewed-by: Jan Kara --- 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");