From patchwork Tue Oct 1 10:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13817800 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 89483CE7D10 for ; Tue, 1 Oct 2024 10:59:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82DE528007B; Tue, 1 Oct 2024 06:59:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B6F4280068; Tue, 1 Oct 2024 06:59:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 607F928007B; Tue, 1 Oct 2024 06:59:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 39FAE280068 for ; Tue, 1 Oct 2024 06:59:44 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E9E6C120FCD for ; Tue, 1 Oct 2024 10:59:43 +0000 (UTC) X-FDA: 82624737846.17.B122940 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 264D41A0007 for ; Tue, 1 Oct 2024 10:59:41 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mgJN2Sog; spf=pass (imf19.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727780318; 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=8ZvBNRuRJBDYAMjjty7KQbL3GLtKr+olQlL3N78j8uc=; b=mKCYsRCEj9dFrQXWm5X2It1n72jTxemjk1uc5vuAILLbziXEFvueCqPd1fPV7Km2MXRgsF 915qm5MviPlmvQJtCHJwm4UREF1ik4DD3BZa0apryvZz63dQtHRIne2FsBrE6HlmAByXQP Dzl8fknAnUDquX6tILxbSK6Svs/ECV8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mgJN2Sog; spf=pass (imf19.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727780318; a=rsa-sha256; cv=none; b=j1bak0AUl3hlXmiVETv0JFr05avGdg0IaRph6T3EISCx+71fFUFEe3249WYlTbbMfxxNr3 l+vBHnztn0UtI8/HTZ04FoAIcERcKJXih0zqkTL5ozChCIseuE43HL9unRNopUwVHHbxAd BCkG47OBPemB7X2apudeEM67zOkisnU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A7885C53E7; Tue, 1 Oct 2024 10:59:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BD64C4CED4; Tue, 1 Oct 2024 10:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727780381; bh=UttJGln3RsYeF35AMrr2wmS/hNsiLcUiITLEJHfz5Ms=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mgJN2Sog7HIYjLMvgAVx5L/0qUoze9I2mP7px45sIleudkB6K7FWFAeil/EaLhPEH VzjgdMMsdHddmMR+2f/MAtrJt6cNesnog5NsxkUof+2quHpz8CTslLSxToALMQGFM7 wWsQxAB1m4Gt7Pz1CZ5ZMjQY3Tm2l8zwwJdMqJRc62n4R7lgp0KU4B4AeT/10RzU2s Kx6EmB21R4yxJlSlAGDm90IUtao/sJ3amEcEuIwWbcfHidX6A0yqVY1nv30yIhnD9Q xQwjTeAnwm8ExdAUeLxRmp6MTDLeM0ty0u91KcDRi4H0QxGTGEbpMbuem3LnhboaGk wo/PDtzezMb/Q== From: Jeff Layton Date: Tue, 01 Oct 2024 06:59:05 -0400 Subject: [PATCH v8 11/12] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20241001-mgtime-v8-11-903343d91bc3@kernel.org> References: <20241001-mgtime-v8-0-903343d91bc3@kernel.org> In-Reply-To: <20241001-mgtime-v8-0-903343d91bc3@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=UttJGln3RsYeF35AMrr2wmS/hNsiLcUiITLEJHfz5Ms=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm+9X76ziqrcN8sn2M8lQjmFo39dkFvoe6mXrnn gNHXakHKmiJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZvvV+wAKCRAADmhBGVaC FYgcD/9eDy7UZeUD34N6bzAuHIz+P17VcBdQftd5Y6GWHvi87dVZ6Mlr61dUDVaOWLuF2WJxMo1 UGWKR828DQiIL2Esoqo/e2ze5VhRIMSTJWrCqQfKPNOmJiPiwt+QNM6sm/xYBBL1Ck5jGZuQFX5 alNr6JqlME4ENtnSzrUKGrXCbq0vqrQqTo0TrtVA25wzuZ9ySJHEyIpIPTooKEqMYXfV+kMH669 orDknC33K1dOmhupXeN6UJtP2MAl5ahASBDGLj0szE2zh0sg7d8axK5usLOT4n/k0sCX7wge2as uXkTL6tGJ1ZoCeHKsEumoCi/bxdiueJmdvjmdJZ2nt1FAPju/LjezACB2mSIstrOCm5zvfM/YXD 6UbrAShHPdMj/E/uMRjsl1v4VpfN452Y3KQkKf24OAArApkzUMwBQQ6MUnbGyXtkus7jTTSr4Ju rpmIEMR3MKC/PfMJP0S/0ryZQMW8PmleNRy/qsDJWlSfNwcoESOQFGfq9dL3v+smtGGFMvqsFef IYyiHLx7Kh1zBZm70fmQq04umgfyGPM7Awpj7QzG5/R/R2qLJCdYHPdAXflFSZhq4Jz7emrGOJ5 Fbc0Nvxk08/GvArfrACwtuv/r5qXk/aMShjA6AC0Mo+bM9nXhFC1MQorOTtBSYsFRQ0O9OvhhQs j0hQSnLz7Aj6sCQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 264D41A0007 X-Stat-Signature: 6q6wgrh9uq4gszbrx1mnxjxcgbkcgozo X-HE-Tag: 1727780381-571647 X-HE-Meta: U2FsdGVkX1+rEIGRk+HsRWhSQuVbSi9ELij3z40q4ETw92AWOq26NIc0wnuBHa/KXk0OFvDhr0xJQTrWNWIP8NbPb5tFN4DMfyB8KBM/z5yxcHPZxL3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+gDuul2THo1FoMCtQ28CiKYETrUfPuubk9ACU592daP2DJhEoHI4uwkrIaf4sNF9YgBUnpkMhE1YsFswcEL6AAHP8vfVyT7QmRT58INF5WAgdKQ2ngY46/sSRsNdWQHCOuYnQga6m9MqTWpCnUTbTr7Nmhrj9tqg= 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 4fb521d91b06..e5384ceb8acf 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");