From patchwork Mon Jul 1 10:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13717788 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 E6224C2BD09 for ; Mon, 1 Jul 2024 10:27:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C7A26B00A3; Mon, 1 Jul 2024 06:27:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 851EA6B00A4; Mon, 1 Jul 2024 06:27:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A4066B00A5; Mon, 1 Jul 2024 06:27:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3DFC46B00A3 for ; Mon, 1 Jul 2024 06:27:32 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 069DBA1AFE for ; Mon, 1 Jul 2024 10:27:32 +0000 (UTC) X-FDA: 82290807144.28.AB0C2F5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 319F480027 for ; Mon, 1 Jul 2024 10:27:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LcqTr9O6; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1719829639; 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=vKAahAF2yw27HeBezw4hEaA+QpmJvd8GztLdofMDzIY=; b=s/Nmdr2UnwIgje9W/uQRqKXN7uJ/5AKPhgRsYYFjqF1FoejDo79KysFwIsIC/OD621aGec d6+ZEDwluAhFk8CmPXCLLp+U1Z8HYzuak5oTml/jbkVlEu+QVflnpKN2BV5r+2L0cIa9I9 uGIUdBv/Vn8nkhDfFabLP5P5Hnt0xHA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LcqTr9O6; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719829639; a=rsa-sha256; cv=none; b=3vkenSHwPMQVfgsXObXEoPVe5rkpkDuMc3FtglA6OBmx2nNbJePzIK95dX20j8HoBNqE27 oejMZ4Vb/8j2Qh17tfx9ilteAysME1YBbDa1RzyNn02voRGXyeU6VF4zo97ULwu+gtZa1L Smj42lZu0zvYk+cP69ucxa06aSk8/No= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 583CD61221; Mon, 1 Jul 2024 10:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE85CC4AF11; Mon, 1 Jul 2024 10:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719829649; bh=g6LPjexoZumsLrWQmoQEww6pUVCduYJaKswCWiwjKIg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LcqTr9O6d73yjRPzUOQt3rFcYTBLQZMcbUK8iYcP0QWHG/g9apYIn6p+aPj98OQdG rNXNotsR7h9h6k8c1SI4yOe5w0A0j+DDcUNf2hjfMX0rD6+VnFCDs/XMqHp5IOXSwY MiM+/js9xsFoC9dOVgDc5Y76poHyippIMejuCSnh6YSg00N4x13bd8/Od3DQeIicxR 7F2g+c0OuLfAim7geGIXUUjXgw1MibgvZONgzODpNaUvIefre84JqgqeoPJoZ3Mq1E T6hpFcS96P98iish5/M1eh2SynsIcqr00bNy745ZsMcZyzX57sj2rtNbsM4zP7SGO3 /RjdT8MeQ9q2Q== From: Jeff Layton Date: Mon, 01 Jul 2024 06:26:45 -0400 Subject: [PATCH v2 09/11] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240701-mgtime-v2-9-19d412a940d9@kernel.org> References: <20240701-mgtime-v2-0-19d412a940d9@kernel.org> In-Reply-To: <20240701-mgtime-v2-0-19d412a940d9@kernel.org> 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 Cc: Andi Kleen , 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, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2439; i=jlayton@kernel.org; h=from:subject:message-id; bh=g6LPjexoZumsLrWQmoQEww6pUVCduYJaKswCWiwjKIg=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmgoR5peVlEh/9fCIgBmWdUayZz1OsZCQEyAymb qH/Z9hlOVmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZoKEeQAKCRAADmhBGVaC FZICD/9SQ9g5VLi8qohQ4mJbihBrn0jgzZ/fl6AyCHsI1a+lsfbbpF7BFpvr29WWehMrohSp1dS qEuFGmBwGI/Sm/T+rIO8cqXV9AQlIDd3ePLCO/XWOjPN0CGPLvhGF4ywT1j9MQ+HJn0zUp+kyL0 4GOEv5aXE3X4GZCnxcSG/kDucEjIf5oajhC3l0Kwh+/7QjT783shrSn1OCK57izMhMaqGMrunrV icbjNokBR8s6eM9NlX5IecTBDuPwIG9OBc/15k2tyDsiSj6gISY4GHtI9QL5XQzvEZEe+dejQyR XoV63JJZkCKSJVOKE9+alHFA8EIDroXQt70LTLuWnzB9ROfaOIku11h0/C5Pd6zFVgsEPQS22ay N9NXud7se+TdCm2czPGP+WeSNF4YH0AoDB4ihXIPcob180XPVfNI5s/dOsCBBOel4ym1IvUyEZd 9a2IZOzRMZt29IiEB2VEK8BEVVF2DVBFvS2Ve9EhgrhkHT1LZoHI37sdn2Jt3BPf1TTTFqobHHH EVDpkOTsHyU4PZBc0cBaG7iU7+xU+HPx5xi+mrpJSQtpJNXN84yEVgFP8ctA3tG6XTQHcSJbpLS 2mT2UwJiFyz0LRQkvrrhS6vR/wCODRLMTTFjNIE3zDMrAy1Tn5vWkcaky13cdpTs+uCjtGEnHsm sX/vCHXB2Caf2CQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 319F480027 X-Stat-Signature: wjtdgf3djexyzdhhibprberd857oetqg X-HE-Tag: 1719829649-724300 X-HE-Meta: U2FsdGVkX1+s+fJGjG1JkUTEWMnwomm31pOLraiqFkaLx2ckQCDujgD2JZT1EhGga0e7BwNyNIWqgaQbMl5Kxg/8/eHJtRX4Otv8Yb6DP+gs2MNqwO7O2rEZTSmyF/IoVdKPa9mn5rPhI/DwsEhaZaHEXv9Rn5O8zXuMql8n3+p3J/UYL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nKDGIGHqgf78BXD/V5BpyCONGNcdUR2W9xHtLVjRNQkfmef+5KHOfOHCHQP7gCzh9STyE2s6UNi/EeU5zb4Z0slfIv2A5VWMhC9sgS6KmLzRhN+k= 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. 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 d90138683a0a..409628c0c3cc 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); -} - static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) { @@ -1171,7 +1151,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_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 f05cce7c8b8d..1cd50293b98d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2173,7 +2173,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");