mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
btrfs: convert to multigrain timestamps
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 <josef@toxicpanda.com> Tested-by: Randy Dunlap <rdunlap@infradead.org> # documentation bits Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://lore.kernel.org/r/20241002-mgtime-v10-11-d1c4717f5284@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
d0382c698f
commit
e2e801d6e6
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user