From patchwork Wed Oct 2 18:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13820262 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 B57C6CF3189 for ; Wed, 2 Oct 2024 18:50:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC1316B028D; Wed, 2 Oct 2024 14:50:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E22DE4401B5; Wed, 2 Oct 2024 14:50:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C72AF6B028F; Wed, 2 Oct 2024 14:50:26 -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 9A0376B028A for ; Wed, 2 Oct 2024 14:50:26 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 36E4780EE4 for ; Wed, 2 Oct 2024 18:50:26 +0000 (UTC) X-FDA: 82629552852.26.A049D82 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf07.hostedemail.com (Postfix) with ESMTP id 7746F4000B for ; Wed, 2 Oct 2024 18:50:24 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=btST0E3i; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727894984; a=rsa-sha256; cv=none; b=ZURt8dLfT2RkddlwI+z0TL+FOxMHNNmhdS7PqYyXUu/qk7M0jxuzZHAMEf6fvMvoc+xC/e kJnIRRsG5CUhH2Y3Yvojv5hVFxZ4S/2qfu0tgEbSPowe2GnDnvNdg3LQvhlOw5Ths+NHcN A9skIooQlznqYJ+OZxKwQug4BFG6tL0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=btST0E3i; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 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=1727894984; 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=xijyGSIC8tg/9mUjJT0YCP6eSmyLiThSFhxgUHS3XuE=; b=iiG9tTBY3N7B4OhS4GfOOZKTUTbyOEaQWuqDGE9VSY8Df4ouo1xxyAeTU1u9f+WoPev8qj z88FZhwwiBpLph00nFYcOU9t282CROwtc23Bg4MEIW9Wpw+QUV47ucDaEuIc7fYJLBfCWk 2+xwNq452jSTa5sCLchkiQ3IDOyZyWc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id F2023A4320A; Wed, 2 Oct 2024 18:50:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB47C4CED3; Wed, 2 Oct 2024 18:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727895022; bh=eXOv2g+6erFOUU/IZaJxbO9vQa8NYTuiShGXQ/xSzWM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=btST0E3iIz3iPli6d0XpPAZAlh8/lnqSl4ah3WBtM4T3MH8ErVcaBvT2ZWfwETiNb YUSY2+5n9NSMhGVEcYZp+qG5kWLAxDb1EAixKCNENdjIyrDNtWcYV4m2AOi8SMFl8K ZnuQFDpARMh3w3B3slkPCa5+dx0fqm3kiyQ/9McJskBSZEbVrZ64APa0EcDhymjEvO KsMDUPNCuaWpMfYPD29GYkVgR4QskGiLsO82bSgPMYXyKXU0zGiV9ozsdsXhilO4nM TVzjzTDFTCoJwDHZ4V4wRF/HPZqliH4EfLd/oQbMzYM+munWopfG4iQIN3HMAwqBLb JqT5spsL0ogRQ== From: Jeff Layton Date: Wed, 02 Oct 2024 14:49:39 -0400 Subject: [PATCH v9 11/12] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20241002-mgtime-v9-11-77e2baad57ac@kernel.org> References: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> In-Reply-To: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Randy Dunlap , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2730; i=jlayton@kernel.org; h=from:subject:message-id; bh=eXOv2g+6erFOUU/IZaJxbO9vQa8NYTuiShGXQ/xSzWM=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm/ZXNnKUmRwB5iP9mmNcvN/pr53xiTfFvvcjUC +QnCEKMk1mJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZv2VzQAKCRAADmhBGVaC FQQgEACkRH4Qq0FubBmBQFsHTewXtBTlXLGNYfrlI+kSx3fb/dOij2i7ycA8d1/UZPwNpkHi++k XUIS6mXDj/NQ0PlVoOy2k8ybTh0UDwVYHkBDXrFpsxRMc5ZiQp1C4c02RKiET8x76r5KMQJxAJF M0gS+kQEdP64e6qvSZAXIb60uNyfpQb0RV/vgoe8ZTyMC083FnyndAx4JK20ks0nKJVVFf1q5Ag GjJsW/qRwBI0K0/2BcdPNw/pDrjK+1cxRO6jvCa3FhieuIPtCo4HdZJrz0qaIhPocmvVG7UB9EL GVNc7mPk0Yml9ghjsQAFf83e9CoavPbF4to4DT7C8lS1OpwR9nAOW9g0CevmFrUPr8gs8DFmA9I NApVjZlKEnzB0/BbktFG0a1YHet7mfjLdc8oYAiVGj7ycClsAA6dJq4iAvCmh0ozZTgmm5z3RPn EVGKKh8uY++mprUufcphF/TFPLZ6GIefT9oyPyB9CuzwA2AHIMrgbHCo7SKBLv+skxmUVWWGOuc uV03HX6PSiTSaGPvSTDszi7aYP/T0HoMNdGQ+Pv9H02o/RT/W0NoWemRDo5TzttOUiaTVosx7/7 AT9c434zhUstN3P4O7zU98K/VnOls+ZOd3sSblMmPfcBpMx0vgLQYDx33M8XWHDwgVP8ZulNMtI 2nSsA/v1yvbCVfw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Queue-Id: 7746F4000B X-Rspamd-Server: rspam01 X-Stat-Signature: 3jh9hjadrd6hi6qjgtgp7j4umerdm5fa X-HE-Tag: 1727895024-882396 X-HE-Meta: U2FsdGVkX19eeWSNnVLRrqnuFKZCdZGfCbfJTmfdw17TaUGjgCVl2uvXW/NYGiv91jfDD4sBBC+zAWjnAD124BAapyvK4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6BKr0sQTlf+4KlVlIYtWXc65GAUhly7vE7lnN83J7d/2EvKiZiT7F8jdos/4shUG51lKsFa26wdR8q6iBDYPdcW+WG9H+coKZKf5S/uaLDgVfVsv0n+Jy4A11SkDISgcwI8sp5OvSpZntCV5kCbcPMB1Cyq53SgORvAh3L+uNubf/RsiC+J5Iuu2wbdwuFzv4gFwRRi5hH5/NQuOIoeXYa0LadGI/cRuY6GbiJSeSTTTe+1SkkXU6zlakh3oGz1G7HuMvxW9hXFAF+GIAOG/PD0xa3JjN0Wg74zniWFJaA 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: 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. Note that this also drops the IS_I_VERSION check and unconditionally bumps the change attribute, since SB_I_VERSION is always set on btrfs. Reviewed-by: Josef Bacik Tested-by: Randy Dunlap # documentation bits Signed-off-by: Jeff Layton --- fs/btrfs/file.c | 25 ++++--------------------- fs/btrfs/super.c | 3 ++- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 2aeb8116549c..1656ad7498b8 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1120,26 +1120,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, ts; - - if (IS_NOCMTIME(inode)) - return; - - now = current_time(inode); - ts = inode_get_mtime(inode); - if (!timespec64_equal(&ts, &now)) - inode_set_mtime_to_ts(inode, now); - - ts = inode_get_ctime(inode); - if (!timespec64_equal(&ts, &now)) - inode_set_ctime_to_ts(inode, now); - - if (IS_I_VERSION(inode)) - inode_inc_iversion(inode); -} - int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) { struct file *file = iocb->ki_filp; @@ -1170,7 +1150,10 @@ int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) * 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_set_mtime_to_ts(inode, 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 98fa0f382480..d423acfe11d0 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2198,7 +2198,8 @@ static struct file_system_type btrfs_fs_type = { .init_fs_context = btrfs_init_fs_context, .parameters = btrfs_fs_parameters, .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");