From patchwork Thu Jun 27 01:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713681 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 25768C30653 for ; Thu, 27 Jun 2024 01:01:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82C486B00BE; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 795346B00C2; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5392B6B00C0; Wed, 26 Jun 2024 21:00:58 -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 282E56B00BF for ; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D37661A187E for ; Thu, 27 Jun 2024 01:00:57 +0000 (UTC) X-FDA: 82274864154.19.330955E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 1BE2280028 for ; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Tj/hEUIr"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.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=1719450043; a=rsa-sha256; cv=none; b=HJaDsQW3RwTIC6gjDq1tlHkOfxf8FbA7ohqhwNxVDfbC/nMbF7ubNrV9lxJkLIxc4hDGOQ 8I4fTT6uYY4lgb+ZMnmTFSDIrztUY4vUDDzl2vk+2EwmTGIP6sd6BhrDRIlm8cc/ZcCUHW 6rtkcCcZtm3nc1hLu1IoCQjwcVqFJ14= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Tj/hEUIr"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.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=1719450043; 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=x1vxj44RVuP7S/qIvh4Qwx4ry6ReCTsAuhYNCcVPTzY=; b=QmLNcuT+pc/5J5T01nTgG+4kRNHhLR2sj9IJKafKAqAKGkO+2jFo5QKDo2fTpyBDzEP91Q Q/wJ2SCZJcahyyZTcmuzAtI72+vPvzT4tSkBy4IE5t/LyAexVGbkht91di+XHcytp4L2DK f11Gy2FYSHCUhs3SmPb40wwqH21FSCY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 28A5F61D4D; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB109C2BD10; Thu, 27 Jun 2024 01:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450054; bh=AsDPx0Ikfq9IqUjWUD0+xKOHhj2Nou+J4XvWGSgrXC0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Tj/hEUIre2HagQVaZas9rsjLhPRUO2hyax4Y7W9EnRv12Cjx/OdmSrPL7Zttpk+xq 5Ba8mOxPKVAwOyDP00R84XX3ZgPCwYbUTsZNK1eDhp45m/x1q0AbjF9E60otPJmKUS yb0Hj2apyXo2eO+AnolBGG7LnHDlafrI9vTLwedCknDoDe2I75koVeuL+w3DjMpKHz y0JAUppCwXl6NhlcJ3nq1vc9N9Dub+1Ds4N14Adm+nQZQpCBBvaoKsKBNAFRTzf06u UyJol3cTmjhqJWyHF1zdj/CbH8lcBmL2aUpQGGc47GGxPSDgiZZeL6oCUu/UB2OQyU hl3ynx0u2A4wA== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:29 -0400 Subject: [PATCH 09/10] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-9-a189352d0f8f@kernel.org> References: <20240626-mgtime-v1-0-a189352d0f8f@kernel.org> In-Reply-To: <20240626-mgtime-v1-0-a189352d0f8f@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: 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=AsDPx0Ikfq9IqUjWUD0+xKOHhj2Nou+J4XvWGSgrXC0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvrjqqUO8F1XQYn7/QtHzz3TvRUyNVZtAnM UYAmCEwGkaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FVqnD/4lHKGuZjjFq7gg39FIdC0KjRoA7ilhtV7sBg5JQMPyIWf7VpxhqDFqsp6thwF4xwHOzdX oWJMtPQ8TIiEEeNNNf0rRwZt2RFNR8IV5hZJ7q3IqK/63Vn2/vHVVO0i24t32dMvI9TG/vYlTUV gtrw93u7uKQwYD8nRgWmOHf5tQHp0Wrs7FGnmydNQqm46KAaCpjzmIVj5f0ZoKkhs9FsfX3Ni4R HW+auAgJL9zz73vucgy8en74RvQNC5oZsEZQukRLmmS5yUAj7Ls+LRFV59NBuk/w6EmUo++xE1o XtWIMX2PGsln4F8Lc2nIPzme8RgpArnXVVxJJ4IKlNMMAvgaZjrKu/JFRzcinZEQNfe7NEy/BoO YHK9/mIkcFqNr49cOQSdN9zJC9u2XvQFx2/MhShIUugeHnemNQQtgubesIKR/2UpWOndhhPnqII +f8U6wf1uslr1zeP9V4+0GDNuqUZoyDq2Z4eFtM08eDhwLrZHtfOhYl5y51XTdLmt7/3/sO3TyD PupvMCacRh1NlnE/Ne7bKF9zES6Vxcm82a/Q6VZPOLv2Lb/gRxoctePxinPCj90FPpgqVlxZJEH 182F3kKrCLx38YvdJSWmD12Oisp6B13QlZi025Hx1U+BJKmg0fGsHQoVGIaY3AHSEUH+cT4TljH /+c1ye9qlC2quTQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 1BE2280028 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fosyqsuqzb16efxh6es9s4qgb6bybn73 X-HE-Tag: 1719450055-656155 X-HE-Meta: U2FsdGVkX1/cSHh6Ef+kgOsEjDXmECmVLbCT4Ysd20g/tBQXCMV8S+Yu78HcyKLjjrQgi04Ead2z8SEr7XZezN9gXC9xt3Lq2I0w59Rb+R3InU60y3ntAjMDv0nROEyXlDYJFy9NyzzTP1IlZUxnE+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XMxF2WBgYfxvyPEw== 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 e764ac3f22e2..89b3c200c374 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");