From: Jeff Layton <jlayton@kernel.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v5 8/8] btrfs: convert to multigrain timestamps
Date: Thu, 13 Jul 2023 19:00:57 -0400 [thread overview]
Message-ID: <20230713-mgctime-v5-8-9eb795d2ae37@kernel.org> (raw)
In-Reply-To: <20230713-mgctime-v5-0-9eb795d2ae37@kernel.org>
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 <jlayton@kernel.org>
---
fs/btrfs/file.c | 24 ++++--------------------
fs/btrfs/super.c | 5 +++--
2 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d7a9ece7a40b..b9e75c9f95ac 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1106,25 +1106,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, ctime;
-
- if (IS_NOCMTIME(inode))
- return;
-
- now = current_time(inode);
- if (!timespec64_equal(&inode->i_mtime, &now))
- inode->i_mtime = now;
-
- ctime = inode_get_ctime(inode);
- if (!timespec64_equal(&ctime, &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)
{
@@ -1156,7 +1137,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->i_mtime = 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 f1dd172d8d5b..8eda51b095c9 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2144,7 +2144,7 @@ static struct file_system_type btrfs_fs_type = {
.name = "btrfs",
.mount = btrfs_mount,
.kill_sb = btrfs_kill_super,
- .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA,
+ .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME,
};
static struct file_system_type btrfs_root_fs_type = {
@@ -2152,7 +2152,8 @@ static struct file_system_type btrfs_root_fs_type = {
.name = "btrfs",
.mount = btrfs_mount_root,
.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");
--
2.41.0
prev parent reply other threads:[~2023-07-13 23:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 23:00 [Cluster-devel] [PATCH v5 0/8] fs: implement multigrain timestamps Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 1/8] fs: pass the request_mask to generic_fillattr Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 2/8] fs: add infrastructure for multigrain timestamps Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 3/8] tmpfs: bump the mtime/ctime/iversion when page becomes writeable Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 4/8] tmpfs: add support for multigrain timestamps Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 5/8] xfs: XFS_ICHGTIME_CREATE is unused Jeff Layton
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 6/8] xfs: switch to multigrain timestamps Jeff Layton
2023-07-19 1:35 ` Dave Chinner
2023-07-13 23:00 ` [Cluster-devel] [PATCH v5 7/8] ext4: " Jeff Layton
2023-07-13 23:00 ` Jeff Layton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230713-mgctime-v5-8-9eb795d2ae37@kernel.org \
--to=jlayton@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).