From patchwork Mon Jul 8 15:53:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726777 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 9355DC3271E for ; Mon, 8 Jul 2024 15:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A1976B00A1; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 100D86B00A4; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E47606B00A3; Mon, 8 Jul 2024 11:54:09 -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 BBC7D6B00A0 for ; Mon, 8 Jul 2024 11:54:09 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 74D4E1413BC for ; Mon, 8 Jul 2024 15:54:09 +0000 (UTC) X-FDA: 82317031818.23.D6FC1E9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id AA6A9C0019 for ; Mon, 8 Jul 2024 15:54:07 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GB5rZu5h; spf=pass (imf28.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=1720454024; 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=5vMS/3B7M9AXRjhPTEbSrlkhwACcn/9XxJJqb8Ng0DE=; b=5ZpchYqKvsUoFymfFitdoS3v4pGePp9SjDFQrPl3wsjzr2kGuapEvZeIYYc9HkQ6aaOKv1 P6hvNct8pGOvqwtZIiPL+T1wW4yQtfqocaeHdCYpGqx+BCiSvLxxLqu/x9PqYfbrX+vzRf 3xhsro4Cb0/SsYWrun3thVdVLeyQG9I= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GB5rZu5h; spf=pass (imf28.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=1720454024; a=rsa-sha256; cv=none; b=N0EYlbpMrAtW7AM4ooLqSzQ1/DKD0j9XPTNrDtOZOforKGIeLo2Yo+JZ9eSLCQ0c7NF15C pCc/mGBVOpykRQLCRhqi3ymcn5H748282+CXY0ncmwFB/LRjyNnjl5yygGMeSZMB+LQKA5 ppa05t6YfgBru8zivP4ohIQj7PLnp7U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DA19B60F37; Mon, 8 Jul 2024 15:54:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC349C32786; Mon, 8 Jul 2024 15:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454046; bh=xTk9IFiZeoZdqPbR7bcsVc6tPLRLkOIJYDVl81q/MME=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GB5rZu5hMI15U2ylbFQqX0YhfA8/WrZ8rZu496zGgZ1UwskaiAWieirmiSY0606Ko urLNop+Q2sDgfXPdUj3B4pokqaMGp2zG/BgyDqswpThDrMg6TR8F0s3XyzG4Rhrnxt gj9l8puIj8+p5UQXYSaVy3m/FS0pW4uRf1cbPf0WM/228SQ9GMeCXMXbtNKQHaEB3S p5m166bxxxSjGzzp9F8ptC7hSXR0mn+kMh8kngD7wDi+o2q3CeM4hcV4onWPTe6Ir7 +od04Ic0bl594sgUqHvEifuuUvN4eu7LTD09AUXSBdxyTNOYX6vZpAN5stpmnakOO4 d0nsnczxdXYvg== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:41 -0400 Subject: [PATCH v4 8/9] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-8-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2583; i=jlayton@kernel.org; h=from:subject:message-id; bh=xTk9IFiZeoZdqPbR7bcsVc6tPLRLkOIJYDVl81q/MME=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuE92mfSh6NfDlCWQlKkv2+4U1n3snVlNA2V SIuSR9NXhSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FYEqD/92ncQwLqYy4hgPbZpX9lkjOfRdvTeYjwgy6RHJ5WXvt9CL15LHhKRu9iCWGuT55UOEBDX BxpZp2takntEWAPpNyLuEe2UKXwe8XL2b8LCGEa0Av4jG2uxZoAdY3Puhf4NH+hTXMPPDxKlPb1 tOcJh/u1gTH+mrkLnSFyfEl4vNmLJ6Fs1yyJVTuRTraPqrLHlv1hmP0SVMu6YFCOE3VL94akxSK 84eEUH9VmtvOH/9SHnwfo2RehVlOZaaubcI9f2Yz5x5u3rBbgT9kpvoTD4MzCUx2Hcgtkd+MTAU 125popAe3xibLBc+r5YOn3MqbW2lS2Qr8TLoQq4LCuWOjeQjuSOSaBjmV7ti/snS8YoMuKPTsaO ZSgOq0MJfDIR409jaE5qswYGInM0lkM3BYy+S84yt5BfpE72bMj4IVud/q2ght+ZFnKepMaoJUb yDdKcmHieDoWAlojT+oEXOPecqzo4qXkZkTBl4HVQw0eKS0IMml38kJib/k2e2lxWJN5plXChKb 0UFQrExJjjC2LAa738FQtlDlESCaVfvPXjPV/jtlFCJavsLPD6ys+/WfdgN1Qreo+w3pwtrxDwv 9PcKml3SHYHCNXt1t9AcqlopfNjRHzLQRKk9MWxU8U3cy+KzH1MbnT/OXQB9Bai0hjLcsRKIBIA HwEogG0gM1mAx2A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: grhbierudkp19xr5749zoxejy7tk7fub X-Rspam-User: X-Rspamd-Queue-Id: AA6A9C0019 X-Rspamd-Server: rspam02 X-HE-Tag: 1720454047-141040 X-HE-Meta: U2FsdGVkX1+kE+LVvhnc+TS2tPqSBVNobby70QrHXWiRjRwTB6+Bv2jtbRUROrFdREwpM87xyaPH2RkW1OeQwQcHL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eINIKuB9pouv/Pk3B1Azcc1fLla4qJK4vLqz2+uPck9Wk2nDhuwVo/QNMKOSluhN7a1+Owukzib2dRCzdOfBsSogiH178vESWEFSzsN831avaRVPl4pmBtC90h4vONwte0Cfqz4AqdNeG0+JDwcI7Eu/8K2v5F5PsE= 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. 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");