From patchwork Mon Jul 15 12:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733446 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 E4450C3DA4B for ; Mon, 15 Jul 2024 12:49:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08A256B00A1; Mon, 15 Jul 2024 08:49:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0126F6B00A2; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE4346B00A3; Mon, 15 Jul 2024 08:49:40 -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 A44186B00A1 for ; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5EA0F4158B for ; Mon, 15 Jul 2024 12:49:40 +0000 (UTC) X-FDA: 82341968520.21.09A82F7 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id B5D0E40007 for ; Mon, 15 Jul 2024 12:49:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZtyYbWAd; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 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=1721047760; 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=6d3DRy+gZjm2SuuQV7XmALdMkOXObiYYdBFF2l5gQ34=; b=8NkTN2QBNL59fCHBm80cW1jkGrd5GFKBph2PCPZceOrDdS07SMHsgk5LCdOehWcEjN6tMD YrZkcRJJExig2HTDy+xQGonanLYKgcG8bWoSDdK9QQjzhEbnKdn91+fA2zli5RuHh/hevz dtykvALEv7nnclWMM/+TX4ETK7O9rus= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZtyYbWAd; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 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=1721047760; a=rsa-sha256; cv=none; b=E9e4Hogfo94l22nfSUnyvaWpYx0D/mFdT5OONjbCSmth4ZoTMPs34clxTXS7Z5sfFRuKsO 3NvxQo+D6B54wL3amqhJ9GZPiEtXzyXhwiYiBUoK+DIIj9ufvIhJAJ1Bq33APBt049xd3t cKuOf1kEI/+OwsD16owK6In8sfffLHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B311ECE0C68; Mon, 15 Jul 2024 12:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA12C4AF0C; Mon, 15 Jul 2024 12:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047773; bh=n/GBFDubJ9Ek68qv1catP2lBxJ/9I9EY6EzBmvQbZCE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZtyYbWAdVGt+M9geIi9nq1XjNNQKoMnt4VvhJB4ByJb93S22H8PaeX8D+elBcZmA8 impfQEW14muDzQ8mqnKoESrz8Gr10uGPLm63I+ch9I+zWCDY92DOYLcnHznRSfIEz5 x/nUQ7EWPdrA/coYjsXKG0S6bIk4DgwnzLIkDZiZlfyt+lexFtIlTZE+/erPHt6QaK 0eM3Pnc3hhcq91YNFO/cFAiRBaYJpg5tpZc+04sECOGNuL3RAY9OYACGN8vPxWKGbZ poCwkG8HsUOnrBLgRdLZtcnNdU667lJj9uPt/n3SS3h0OKujpuh9GXE/MRP4ajdBjV sXgXQH2/rqp0g== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:59 -0400 Subject: [PATCH v6 8/9] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-8-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Arnd Bergmann , Randy Dunlap , 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=2632; i=jlayton@kernel.org; h=from:subject:message-id; bh=n/GBFDubJ9Ek68qv1catP2lBxJ/9I9EY6EzBmvQbZCE=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrD197rYggBbmtQ+Pjfq0t5urOGWrOjhcCqL H+PDb1PlFKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FWPPD/98OrTQhimjzIjdpNE2OeuExL1hLuo1FcAxjnPSODQMEGaEHQrTD1UnX5t+mb6vf7Fkhu5 4/Z4EkWwtnFXTrw7dWpDzmqHAMT7jYXa89Ga0TYbI2wx1q8tAuYvBzEQQ6z1E/pcmNQ1dJqOh/l ZDznTDp1mPTy9iE2jum19TBePEDngLxLqGiyqRE95/lJOwuaddhd4MvHdFWjSVPpdjYKE9KYope zyr90O9njRTaqFQlbSPHrd5XdE0NrF35opH85Yocwm/eGFHcN+SrKAMsbApMomPEaKSiFbC1RlN kLd4iYUx7PNDV+XvVGdTGXYbqSgsV7CL2bOxpOK+CYqU6RSKX15uZSqAnMv4Owpee3gZgAllHYU OHiyNZllPfZEOo72mqw3OgahIaEUKKrcWAFzvoyKbCazaMaqFP3d9XUFqOdYWn/iALgO3ZdUq8o VO3MyzVxCOZDjdISoPM5/cgfWc7wBJNLnudOnaQp2X6gH7vIuy3V78Q6SF7P2rezMSTgMepE/8s 7GkW31uEiZYJcpiE+aF0V33DllQqUoca2q+Eg9he4tHp4Nm05N/SXsadR2wgzOZ63OB15CgDJBn ip0syOwO653BxgR8VkjvdOHXxF+Zra0Ky9CCbWqDZWf49I1BJeeYTWCNNOyFrxFjKrVYOBlYtq3 Eh1fhvKxogJPFdw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B5D0E40007 X-Stat-Signature: bkrpipmap1bc5wpr47ehq3xi1qh39pp8 X-HE-Tag: 1721047777-702795 X-HE-Meta: U2FsdGVkX1/4tHpSOLdLgSm8PqZBRPLx3fuZvYLxf3GTG7Pf0GXajKqACzV9XrjRQ17ezmahyY/A7b1Em0Z9MDL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3WX+3aNwuwnCa9YggjcuoOSDGUFlygkmq1w1/mVzLcXHNi7Bc7+eNQxZT6GBBjpZ2MUAogTXYX2QCkekcxW0gec9WvtNpmuwLZQw5++0C+6mONgwvlZnJWYQAQwWXnW4gwmMoN2dbb5TmfKhrVvG56c09ft7Bg== 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 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");