btrfs-progs: replace btrfs_leaf_data with btrfs_item_nr_offset

We're using btrfs_item_nr_offset(leaf, 0) to get the start of the leaf
data in the kernel, we don't have btrfs_leaf_data.  Replace all
occurrences of btrfs_leaf_data() with btrfs_item_nr_offset(leaf, 0) in
order to make syncing accessors.[ch] easier.  ctree.c will be synced
later, so this is simply an intermediate step.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2022-11-23 17:37:31 -05:00 committed by David Sterba
parent 788a71c16a
commit 405b5cadd3
4 changed files with 33 additions and 33 deletions

View File

@ -844,8 +844,8 @@ static void shift_items(struct btrfs_root *root, struct extent_buffer *eb)
unsigned int data_end = btrfs_item_offset(eb, nritems - 1);
/* Shift the item data up to and including slot back by shift space */
memmove_extent_buffer(eb, btrfs_leaf_data(eb) + data_end - shift_space,
btrfs_leaf_data(eb) + data_end,
memmove_extent_buffer(eb, btrfs_item_nr_offset(eb, 0) + data_end - shift_space,
btrfs_item_nr_offset(eb, 0) + data_end,
btrfs_item_offset(eb, slot - 1) - data_end);
/* Now update the item pointers. */

View File

@ -4428,8 +4428,8 @@ again:
i, shift, (unsigned long long)buf->start);
offset = btrfs_item_offset(buf, i);
memmove_extent_buffer(buf,
btrfs_leaf_data(buf) + offset + shift,
btrfs_leaf_data(buf) + offset,
btrfs_item_nr_offset(buf, 0) + offset + shift,
btrfs_item_nr_offset(buf, 0) + offset,
btrfs_item_size(buf, i));
btrfs_set_item_offset(buf, i, offset + shift);
btrfs_mark_buffer_dirty(buf);

View File

@ -322,7 +322,7 @@ static void zero_items(struct metadump_struct *md, u8 *dst,
btrfs_item_key_to_cpu(src, &key, i);
if (key.type == BTRFS_CSUM_ITEM_KEY) {
size = btrfs_item_size(src, i);
memset(dst + btrfs_leaf_data(src) +
memset(dst + btrfs_item_nr_offset(src, 0) +
btrfs_item_offset(src, i), 0, size);
continue;
}
@ -368,7 +368,7 @@ static void copy_buffer(struct metadump_struct *md, u8 *dst,
size = sizeof(struct btrfs_header);
memset(dst + size, 0, src->len - size);
} else if (level == 0) {
size = btrfs_leaf_data(src) +
size = btrfs_item_nr_offset(src, 0) +
btrfs_item_offset(src, nritems - 1) -
btrfs_item_nr_offset(src, nritems);
memset(dst + btrfs_item_nr_offset(src, nritems), 0, size);
@ -1247,8 +1247,8 @@ static void truncate_item(struct extent_buffer *eb, int slot, u32 new_size)
btrfs_set_item_offset(eb, i, ioff + size_diff);
}
memmove_extent_buffer(eb, btrfs_leaf_data(eb) + data_end + size_diff,
btrfs_leaf_data(eb) + data_end,
memmove_extent_buffer(eb, btrfs_item_nr_offset(eb, 0) + data_end + size_diff,
btrfs_item_nr_offset(eb, 0) + data_end,
old_data_start + new_size - data_end);
btrfs_set_item_size(eb, slot, new_size);
}

View File

@ -2072,21 +2072,21 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
/* make room in the right data area */
data_end = leaf_data_end(right);
memmove_extent_buffer(right,
btrfs_leaf_data(right) + data_end - push_space,
btrfs_leaf_data(right) + data_end,
btrfs_item_nr_offset(right, 0) + data_end - push_space,
btrfs_item_nr_offset(right, 0) + data_end,
BTRFS_LEAF_DATA_SIZE(root->fs_info) - data_end);
/* copy from the left data area */
copy_extent_buffer(right, left, btrfs_leaf_data(right) +
copy_extent_buffer(right, left, btrfs_item_nr_offset(right, 0) +
BTRFS_LEAF_DATA_SIZE(root->fs_info) - push_space,
btrfs_leaf_data(left) + leaf_data_end(left), push_space);
btrfs_item_nr_offset(left, 0) + leaf_data_end(left), push_space);
memmove_extent_buffer(right, btrfs_item_nr_offset(right, push_items),
btrfs_leaf_data(right),
btrfs_item_nr_offset(right, 0),
right_nritems * sizeof(struct btrfs_item));
/* copy the items from left to right */
copy_extent_buffer(right, left, btrfs_leaf_data(right),
copy_extent_buffer(right, left, btrfs_item_nr_offset(right, 0),
btrfs_item_nr_offset(left, left_nritems - push_items),
push_items * sizeof(struct btrfs_item));
@ -2205,15 +2205,15 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
/* push data from right to left */
copy_extent_buffer(left, right,
btrfs_item_nr_offset(left, btrfs_header_nritems(left)),
btrfs_leaf_data(right),
btrfs_item_nr_offset(right, 0),
push_items * sizeof(struct btrfs_item));
push_space = BTRFS_LEAF_DATA_SIZE(root->fs_info) -
btrfs_item_offset(right, push_items -1);
copy_extent_buffer(left, right, btrfs_leaf_data(left) +
copy_extent_buffer(left, right, btrfs_item_nr_offset(left, 0) +
leaf_data_end(left) - push_space,
btrfs_leaf_data(right) +
btrfs_item_nr_offset(right, 0) +
btrfs_item_offset(right, push_items - 1),
push_space);
old_left_nritems = btrfs_header_nritems(left);
@ -2239,13 +2239,13 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
if (push_items < right_nritems) {
push_space = btrfs_item_offset(right, push_items - 1) -
leaf_data_end(right);
memmove_extent_buffer(right, btrfs_leaf_data(right) +
memmove_extent_buffer(right, btrfs_item_nr_offset(right, 0) +
BTRFS_LEAF_DATA_SIZE(root->fs_info) -
push_space,
btrfs_leaf_data(right) +
btrfs_item_nr_offset(right, 0) +
leaf_data_end(right), push_space);
memmove_extent_buffer(right, btrfs_leaf_data(right),
memmove_extent_buffer(right, btrfs_item_nr_offset(right, 0),
btrfs_item_nr_offset(right, push_items),
(btrfs_header_nritems(right) - push_items) *
sizeof(struct btrfs_item));
@ -2303,14 +2303,14 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans,
btrfs_set_header_nritems(right, nritems);
data_copy_size = btrfs_item_data_end(l, mid) - leaf_data_end(l);
copy_extent_buffer(right, l, btrfs_leaf_data(right),
copy_extent_buffer(right, l, btrfs_item_nr_offset(right, 0),
btrfs_item_nr_offset(l, mid),
nritems * sizeof(struct btrfs_item));
copy_extent_buffer(right, l,
btrfs_leaf_data(right) +
btrfs_item_nr_offset(right, 0) +
BTRFS_LEAF_DATA_SIZE(root->fs_info) - data_copy_size,
btrfs_leaf_data(l) + leaf_data_end(l), data_copy_size);
btrfs_item_nr_offset(l, 0) + leaf_data_end(l), data_copy_size);
rt_data_off = BTRFS_LEAF_DATA_SIZE(root->fs_info) -
btrfs_item_data_end(l, mid);
@ -2662,8 +2662,8 @@ int btrfs_truncate_item(struct btrfs_path *path, u32 new_size, int from_end)
/* shift the data */
if (from_end) {
memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) +
data_end + size_diff, btrfs_leaf_data(leaf) +
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, 0) +
data_end + size_diff, btrfs_item_nr_offset(leaf, 0) +
data_end, old_data_start + new_size - data_end);
} else {
struct btrfs_disk_key disk_key;
@ -2690,8 +2690,8 @@ int btrfs_truncate_item(struct btrfs_path *path, u32 new_size, int from_end)
}
}
memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) +
data_end + size_diff, btrfs_leaf_data(leaf) +
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, 0) +
data_end + size_diff, btrfs_item_nr_offset(leaf, 0) +
data_end, old_data_start - data_end);
offset = btrfs_disk_key_offset(&disk_key);
@ -2754,8 +2754,8 @@ int btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path,
}
/* shift the data */
memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) +
data_end - data_size, btrfs_leaf_data(leaf) +
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, 0) +
data_end - data_size, btrfs_item_nr_offset(leaf, 0) +
data_end, old_data - data_end);
data_end = old_data;
@ -2848,8 +2848,8 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
(nritems - slot) * sizeof(struct btrfs_item));
/* shift the data */
memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) +
data_end - total_data, btrfs_leaf_data(leaf) +
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, 0) +
data_end - total_data, btrfs_item_nr_offset(leaf, 0) +
data_end, old_data - data_end);
data_end = old_data;
}
@ -3002,9 +3002,9 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
if (slot + nr != nritems) {
int data_end = leaf_data_end(leaf);
memmove_extent_buffer(leaf, btrfs_leaf_data(leaf) +
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, 0) +
data_end + dsize,
btrfs_leaf_data(leaf) + data_end,
btrfs_item_nr_offset(leaf, 0) + data_end,
last_off - data_end);
for (i = slot + nr; i < nritems; i++) {