Commit fc0d82e1 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: sink total_data parameter in setup_items_for_insert

That parameter can easily be derived based on the "data_size" and "nr"
parameters exploit this fact to simply the function's signature. No
functional changes.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3dc9dc89
...@@ -4580,7 +4580,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, ...@@ -4580,7 +4580,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
return ret; return ret;
path->slots[0]++; path->slots[0]++;
setup_items_for_insert(root, path, new_key, &item_size, item_size, 1); setup_items_for_insert(root, path, new_key, &item_size, 1);
leaf = path->nodes[0]; leaf = path->nodes[0];
memcpy_extent_buffer(leaf, memcpy_extent_buffer(leaf,
btrfs_item_ptr_offset(leaf, path->slots[0]), btrfs_item_ptr_offset(leaf, path->slots[0]),
...@@ -4760,7 +4760,7 @@ void btrfs_extend_item(struct btrfs_path *path, u32 data_size) ...@@ -4760,7 +4760,7 @@ void btrfs_extend_item(struct btrfs_path *path, u32 data_size)
*/ */
void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
const struct btrfs_key *cpu_key, u32 *data_size, const struct btrfs_key *cpu_key, u32 *data_size,
u32 total_data, int nr) int nr)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_item *item; struct btrfs_item *item;
...@@ -4771,7 +4771,12 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, ...@@ -4771,7 +4771,12 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
struct extent_buffer *leaf; struct extent_buffer *leaf;
int slot; int slot;
struct btrfs_map_token token; struct btrfs_map_token token;
const u32 total_size = total_data + (nr * sizeof(struct btrfs_item)); u32 total_size;
u32 total_data = 0;
for (i = 0; i < nr; i++)
total_data += data_size[i];
total_size = total_data + (nr * sizeof(struct btrfs_item));
if (path->slots[0] == 0) { if (path->slots[0] == 0) {
btrfs_cpu_key_to_disk(&disk_key, cpu_key); btrfs_cpu_key_to_disk(&disk_key, cpu_key);
...@@ -4874,7 +4879,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, ...@@ -4874,7 +4879,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
slot = path->slots[0]; slot = path->slots[0];
BUG_ON(slot < 0); BUG_ON(slot < 0);
setup_items_for_insert(root, path, cpu_key, data_size, total_data, nr); setup_items_for_insert(root, path, cpu_key, data_size, nr);
return 0; return 0;
} }
......
...@@ -2744,7 +2744,7 @@ static inline int btrfs_del_item(struct btrfs_trans_handle *trans, ...@@ -2744,7 +2744,7 @@ static inline int btrfs_del_item(struct btrfs_trans_handle *trans,
void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
const struct btrfs_key *cpu_key, u32 *data_size, const struct btrfs_key *cpu_key, u32 *data_size,
u32 total_data, int nr); int nr);
int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
const struct btrfs_key *key, void *data, u32 data_size); const struct btrfs_key *key, void *data, u32 data_size);
int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
......
...@@ -768,8 +768,7 @@ static int btrfs_batch_insert_items(struct btrfs_root *root, ...@@ -768,8 +768,7 @@ static int btrfs_batch_insert_items(struct btrfs_root *root,
} }
/* insert the keys of the items */ /* insert the keys of the items */
setup_items_for_insert(root, path, keys, data_size, total_data_size, setup_items_for_insert(root, path, keys, data_size, nitems);
nitems);
/* insert the dir index items */ /* insert the dir index items */
slot = path->slots[0]; slot = path->slots[0];
......
...@@ -1057,8 +1057,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -1057,8 +1057,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (btrfs_comp_cpu_keys(&key, &slot_key) > 0) if (btrfs_comp_cpu_keys(&key, &slot_key) > 0)
path->slots[0]++; path->slots[0]++;
} }
setup_items_for_insert(root, path, &key, &extent_item_size, setup_items_for_insert(root, path, &key, &extent_item_size, 1);
extent_item_size, 1);
*key_inserted = 1; *key_inserted = 1;
} }
......
...@@ -60,7 +60,7 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize) ...@@ -60,7 +60,7 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
key.type = BTRFS_EXTENT_CSUM_KEY; key.type = BTRFS_EXTENT_CSUM_KEY;
key.offset = 0; key.offset = 0;
setup_items_for_insert(root, path, &key, &value_len, value_len, 1); setup_items_for_insert(root, path, &key, &value_len, 1);
item = btrfs_item_nr(0); item = btrfs_item_nr(0);
write_extent_buffer(eb, value, btrfs_item_ptr_offset(eb, 0), write_extent_buffer(eb, value, btrfs_item_ptr_offset(eb, 0),
value_len); value_len);
......
...@@ -33,7 +33,7 @@ static void insert_extent(struct btrfs_root *root, u64 start, u64 len, ...@@ -33,7 +33,7 @@ static void insert_extent(struct btrfs_root *root, u64 start, u64 len,
key.type = BTRFS_EXTENT_DATA_KEY; key.type = BTRFS_EXTENT_DATA_KEY;
key.offset = start; key.offset = start;
setup_items_for_insert(root, &path, &key, &value_len, value_len, 1); setup_items_for_insert(root, &path, &key, &value_len, 1);
fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item); fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
btrfs_set_file_extent_generation(leaf, fi, 1); btrfs_set_file_extent_generation(leaf, fi, 1);
btrfs_set_file_extent_type(leaf, fi, type); btrfs_set_file_extent_type(leaf, fi, type);
...@@ -63,7 +63,7 @@ static void insert_inode_item_key(struct btrfs_root *root) ...@@ -63,7 +63,7 @@ static void insert_inode_item_key(struct btrfs_root *root)
key.type = BTRFS_INODE_ITEM_KEY; key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0; key.offset = 0;
setup_items_for_insert(root, &path, &key, &value_len, value_len, 1); setup_items_for_insert(root, &path, &key, &value_len, 1);
} }
/* /*
......
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