Skip to content

Commit efd34f0

Browse files
committed
Revert "btrfs: convert to multigrain timestamps"
This reverts commit 50e9cee. Users reported regressions due to enabling multi-grained timestamps unconditionally. As no clear consensus on a solution has come up and the discussion has gone back to the drawing board revert the infrastructure changes for. If it isn't code that's here to stay, make it go away. Message-ID: <20230920-keine-eile-c9755b5825db@brauner> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 50ec1d7 commit efd34f0

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

fs/btrfs/file.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,25 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode)
11061106
btrfs_drew_write_unlock(&inode->root->snapshot_lock);
11071107
}
11081108

1109+
static void update_time_for_write(struct inode *inode)
1110+
{
1111+
struct timespec64 now, ctime;
1112+
1113+
if (IS_NOCMTIME(inode))
1114+
return;
1115+
1116+
now = current_time(inode);
1117+
if (!timespec64_equal(&inode->i_mtime, &now))
1118+
inode->i_mtime = now;
1119+
1120+
ctime = inode_get_ctime(inode);
1121+
if (!timespec64_equal(&ctime, &now))
1122+
inode_set_ctime_to_ts(inode, now);
1123+
1124+
if (IS_I_VERSION(inode))
1125+
inode_inc_iversion(inode);
1126+
}
1127+
11091128
static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from,
11101129
size_t count)
11111130
{
@@ -1137,10 +1156,7 @@ static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from,
11371156
* need to start yet another transaction to update the inode as we will
11381157
* update the inode when we finish writing whatever data we write.
11391158
*/
1140-
if (!IS_NOCMTIME(inode)) {
1141-
inode->i_mtime = inode_set_ctime_current(inode);
1142-
inode_inc_iversion(inode);
1143-
}
1159+
update_time_for_write(inode);
11441160

11451161
start_pos = round_down(pos, fs_info->sectorsize);
11461162
oldsize = i_size_read(inode);

fs/btrfs/super.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,16 +2150,15 @@ static struct file_system_type btrfs_fs_type = {
21502150
.name = "btrfs",
21512151
.mount = btrfs_mount,
21522152
.kill_sb = btrfs_kill_super,
2153-
.fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME,
2153+
.fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA,
21542154
};
21552155

21562156
static struct file_system_type btrfs_root_fs_type = {
21572157
.owner = THIS_MODULE,
21582158
.name = "btrfs",
21592159
.mount = btrfs_mount_root,
21602160
.kill_sb = btrfs_kill_super,
2161-
.fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA |
2162-
FS_ALLOW_IDMAP | FS_MGTIME,
2161+
.fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP,
21632162
};
21642163

21652164
MODULE_ALIAS_FS("btrfs");

0 commit comments

Comments
 (0)