Commit 050197b1 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet
Browse files

bcachefs: Ensure that fpunch updates inode timestamps



Fixes xfstests generic/059

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d4b44223
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -2407,6 +2407,15 @@ int bch2_truncate(struct bch_inode_info *inode, struct iattr *iattr)

/* 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);
+1 −1
Original line number Diff line number Diff line
@@ -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);