summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2021-12-03 23:18:11 +0100
committerDavid Sterba <dsterba@suse.com>2022-01-07 14:18:24 +0100
commit462b728ea83fa85f1c0d2b79efb6187745444ce5 (patch)
treee97daadf86d3bfc35957fa077c580470f6ebbce5 /fs/btrfs/free-space-cache.c
parentbtrfs: only update i_size in truncate paths that care (diff)
downloadlinux-462b728ea83fa85f1c0d2b79efb6187745444ce5.tar.xz
linux-462b728ea83fa85f1c0d2b79efb6187745444ce5.zip
btrfs: only call inode_sub_bytes in truncate paths that care
We currently have a bunch of awkward checks to make sure we only update the inode i_bytes if we're truncating the real inode. Instead keep track of the number of bytes we need to sub in the btrfs_truncate_control, and then do the appropriate adjustment in the truncate paths that care. Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index fd469beb0985..d2f4716f8485 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -339,6 +339,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
*/
ret = btrfs_truncate_inode_items(trans, root, inode, &control);
+ inode_sub_bytes(&inode->vfs_inode, control.sub_bytes);
btrfs_inode_safe_disk_i_size_write(inode, control.last_size);
unlock_extent_cached(&inode->io_tree, 0, (u64)-1, &cached_state);