@@ -109,7 +109,7 @@ static const struct file_operations btrfs_dir_file_operations;
static struct kmem_cache *btrfs_inode_cachep;
static int btrfs_setsize(struct inode *inode, struct iattr *attr);
-static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback);
+static int btrfs_truncate(struct btrfs_inode *inode);
static noinline int cow_file_range(struct btrfs_inode *inode,
struct page *locked_page,
u64 start, u64 end, int *page_started,
@@ -5084,7 +5084,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
} else {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
- if (btrfs_is_zoned(fs_info)) {
+ if (btrfs_is_zoned(fs_info) || (newsize < oldsize)) {
ret = btrfs_wait_ordered_range(inode,
ALIGN(newsize, fs_info->sectorsize),
(u64)-1);
@@ -5105,7 +5105,8 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
inode_dio_wait(inode);
- ret = btrfs_truncate(BTRFS_I(inode), newsize == oldsize);
+ ret = btrfs_truncate(BTRFS_I(inode));
+
if (ret && inode->i_nlink) {
int err;
@@ -8241,7 +8242,7 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
return ret;
}
-static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
+static int btrfs_truncate(struct btrfs_inode *inode)
{
struct btrfs_truncate_control control = {
.inode = inode,
@@ -8254,17 +8255,8 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
struct btrfs_block_rsv *rsv;
int ret;
struct btrfs_trans_handle *trans;
- u64 mask = fs_info->sectorsize - 1;
u64 min_size = btrfs_calc_metadata_size(fs_info, 1);
- if (!skip_writeback) {
- ret = btrfs_wait_ordered_range(&inode->vfs_inode,
- inode->vfs_inode.i_size & (~mask),
- (u64)-1);
- if (ret)
- return ret;
- }
-
/*
* Yes ladies and gentlemen, this is indeed ugly. We have a couple of
* things going on here: