diff options
author | Josef Bacik <josef@toxicpanda.com> | 2021-12-03 23:18:10 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-01-07 14:18:24 +0100 |
commit | c2ddb612a8b320dde8641a74c35e107aa496d5f3 (patch) | |
tree | 77fc91acdf9b46ed29462609a5dffe677ebc1762 /fs/btrfs/inode-item.c | |
parent | btrfs: add truncate control struct (diff) | |
download | linux-c2ddb612a8b320dde8641a74c35e107aa496d5f3.tar.xz linux-c2ddb612a8b320dde8641a74c35e107aa496d5f3.zip |
btrfs: only update i_size in truncate paths that care
We currently will update the i_size of the inode as we truncate it down,
however we skip this if we're calling btrfs_truncate_inode_items from
the tree log code. However we also don't care about this in the case of
evict. Instead keep track of this value in the btrfs_truncate_control
and then have btrfs_truncate() and the free space cache truncate path
both do the i_size update themselves.
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/inode-item.c')
-rw-r--r-- | fs/btrfs/inode-item.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index 0946a3912afd..7bb9f557ee3d 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c @@ -452,7 +452,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, u64 extent_num_bytes = 0; u64 extent_offset = 0; u64 item_end = 0; - u64 last_size = new_size; u32 found_type = (u8)-1; int del_item; int pending_del_nr = 0; @@ -466,6 +465,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, BUG_ON(new_size > 0 && control->min_type != BTRFS_EXTENT_DATA_KEY); + control->last_size = new_size; + /* * For shareable roots we want to back off from time to time, this turns * out to be subvolume roots, reloc roots, and data reloc roots. @@ -644,9 +645,9 @@ delete: } if (del_item) - last_size = found_key.offset; + control->last_size = found_key.offset; else - last_size = new_size; + control->last_size = new_size; if (del_item) { if (!pending_del_nr) { /* No pending yet, add ourselves */ @@ -739,12 +740,10 @@ out: ret = err; } } - if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { - ASSERT(last_size >= new_size); - if (!ret && last_size > new_size) - last_size = new_size; - btrfs_inode_safe_disk_i_size_write(inode, last_size); - } + + ASSERT(control->last_size >= new_size); + if (!ret && control->last_size > new_size) + control->last_size = new_size; btrfs_free_path(path); return ret; |