diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-04-28 19:36:12 -0400 |
---|---|---|
committer | Stijn Tintel <stijn@linux-ipv6.be> | 2021-05-24 15:36:44 +0300 |
commit | 20f28e349d97edbff5e4ba86897c970c5ee4b577 (patch) | |
tree | 6210f56167991e0c68238609549774da4ff72bc9 | |
parent | 29b6896bc40e8be035778612a2201a038809fc20 (diff) |
bcachefs: Ensure that fpunch updates inode timestamps
Fixes xfstests generic/059
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/fs-io.c | 14 | ||||
-rw-r--r-- | fs/bcachefs/fs.c | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 851517a4f809..d707cabd7536 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2394,6 +2394,15 @@ err: /* fallocate: */ +static int inode_update_times_fn(struct bch_inode_info *inode, + struct bch_inode_unpacked *bi, void *p) +{ + struct bch_fs *c = inode->v.i_sb->s_fs_info; + + bi->bi_mtime = bi->bi_ctime = bch2_current_time(c); + return 0; +} + static long bchfs_fpunch(struct bch_inode_info *inode, loff_t offset, loff_t len) { struct bch_fs *c = inode->v.i_sb->s_fs_info; @@ -2431,6 +2440,11 @@ static long bchfs_fpunch(struct bch_inode_info *inode, loff_t offset, loff_t len &i_sectors_delta); i_sectors_acct(c, inode, NULL, i_sectors_delta); } + + mutex_lock(&inode->ei_update_lock); + ret = bch2_write_inode(c, inode, inode_update_times_fn, NULL, + ATTR_MTIME|ATTR_CTIME) ?: ret; + mutex_unlock(&inode->ei_update_lock); err: bch2_pagecache_block_put(&inode->ei_pagecache_lock); inode_unlock(&inode->v); diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 31c9c0be9c36..4e5da2a0b359 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -143,7 +143,7 @@ int __must_check bch2_write_inode(struct bch_fs *c, struct bch_inode_unpacked inode_u; int ret; - bch2_trans_init(&trans, c, 0, 0); + bch2_trans_init(&trans, c, 0, 256); retry: bch2_trans_begin(&trans); |