Commit 7097a941 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: remove found_extent from btrfs_truncate_inode_items

We only set this if we find a normal file extent, del_item == 1, and the
file extent points to a real extent and isn't a hole extent.  We can use
del_item == 1 && extent_start != 0 to get the same information that
found_extent provides, so remove this variable and use the other
variables instead.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2adc75d6
...@@ -457,13 +457,11 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -457,13 +457,11 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_file_extent_item *fi; struct btrfs_file_extent_item *fi;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_key found_key; struct btrfs_key found_key;
u64 extent_start = 0;
u64 extent_num_bytes = 0; u64 extent_num_bytes = 0;
u64 extent_offset = 0; u64 extent_offset = 0;
u64 item_end = 0; u64 item_end = 0;
u64 last_size = new_size; u64 last_size = new_size;
u32 found_type = (u8)-1; u32 found_type = (u8)-1;
int found_extent;
int del_item; int del_item;
int pending_del_nr = 0; int pending_del_nr = 0;
int pending_del_slot = 0; int pending_del_slot = 0;
...@@ -517,7 +515,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -517,7 +515,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
} }
while (1) { while (1) {
u64 clear_start = 0, clear_len = 0; u64 clear_start = 0, clear_len = 0, extent_start = 0;
fi = NULL; fi = NULL;
leaf = path->nodes[0]; leaf = path->nodes[0];
...@@ -560,7 +558,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -560,7 +558,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
else else
del_item = 0; del_item = 0;
} }
found_extent = 0;
/* FIXME, shrink the extent if the ref count is only 1 */ /* FIXME, shrink the extent if the ref count is only 1 */
if (found_type != BTRFS_EXTENT_DATA_KEY) if (found_type != BTRFS_EXTENT_DATA_KEY)
goto delete; goto delete;
...@@ -598,7 +596,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -598,7 +596,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
/* FIXME blocksize != 4096 */ /* FIXME blocksize != 4096 */
num_dec = btrfs_file_extent_num_bytes(leaf, fi); num_dec = btrfs_file_extent_num_bytes(leaf, fi);
if (extent_start != 0) { if (extent_start != 0) {
found_extent = 1;
if (test_bit(BTRFS_ROOT_SHAREABLE, if (test_bit(BTRFS_ROOT_SHAREABLE,
&root->state)) &root->state))
inode_sub_bytes(&inode->vfs_inode, inode_sub_bytes(&inode->vfs_inode,
...@@ -677,7 +674,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -677,7 +674,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
} }
should_throttle = false; should_throttle = false;
if (found_extent && if (del_item && extent_start != 0 &&
root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
struct btrfs_ref ref = { 0 }; struct btrfs_ref ref = { 0 };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment