1

bcachefs: Ensure that fpunch updates inode timestamps

Fixes xfstests generic/059

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2021-04-28 19:36:12 -04:00 committed by Kent Overstreet
parent d4b4422345
commit 050197b1c1
2 changed files with 15 additions and 1 deletions

View File

@ -2407,6 +2407,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;
@ -2444,6 +2453,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);

View File

@ -145,7 +145,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);