Commit dc2e724e authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: rename btrfs_item_end_nr to btrfs_item_data_end

The name btrfs_item_end_nr() is a bit of a misnomer, as it's actually
the offset of the end of the data the item points to.  In fact all of
the helpers that we use btrfs_item_end_nr() use data in their name, like
BTRFS_LEAF_DATA_SIZE() and leaf_data().  Rename to btrfs_item_data_end()
to make it clear what this helper is giving us.
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 5a08663d
...@@ -2720,7 +2720,7 @@ static noinline int __push_leaf_right(struct btrfs_path *path, ...@@ -2720,7 +2720,7 @@ static noinline int __push_leaf_right(struct btrfs_path *path,
/* push left to right */ /* push left to right */
right_nritems = btrfs_header_nritems(right); right_nritems = btrfs_header_nritems(right);
push_space = btrfs_item_end_nr(left, left_nritems - push_items); push_space = btrfs_item_data_end(left, left_nritems - push_items);
push_space -= leaf_data_end(left); push_space -= leaf_data_end(left);
/* make room in the right data area */ /* make room in the right data area */
...@@ -3120,7 +3120,7 @@ static noinline void copy_for_split(struct btrfs_trans_handle *trans, ...@@ -3120,7 +3120,7 @@ static noinline void copy_for_split(struct btrfs_trans_handle *trans,
nritems = nritems - mid; nritems = nritems - mid;
btrfs_set_header_nritems(right, nritems); btrfs_set_header_nritems(right, nritems);
data_copy_size = btrfs_item_end_nr(l, mid) - leaf_data_end(l); data_copy_size = btrfs_item_data_end(l, mid) - leaf_data_end(l);
copy_extent_buffer(right, l, btrfs_item_nr_offset(0), copy_extent_buffer(right, l, btrfs_item_nr_offset(0),
btrfs_item_nr_offset(mid), btrfs_item_nr_offset(mid),
...@@ -3131,7 +3131,7 @@ static noinline void copy_for_split(struct btrfs_trans_handle *trans, ...@@ -3131,7 +3131,7 @@ static noinline void copy_for_split(struct btrfs_trans_handle *trans,
data_copy_size, BTRFS_LEAF_DATA_OFFSET + data_copy_size, BTRFS_LEAF_DATA_OFFSET +
leaf_data_end(l), data_copy_size); leaf_data_end(l), data_copy_size);
rt_data_off = BTRFS_LEAF_DATA_SIZE(fs_info) - btrfs_item_end_nr(l, mid); rt_data_off = BTRFS_LEAF_DATA_SIZE(fs_info) - btrfs_item_data_end(l, mid);
btrfs_init_map_token(&token, right); btrfs_init_map_token(&token, right);
for (i = 0; i < nritems; i++) { for (i = 0; i < nritems; i++) {
...@@ -3683,7 +3683,7 @@ void btrfs_extend_item(struct btrfs_path *path, u32 data_size) ...@@ -3683,7 +3683,7 @@ void btrfs_extend_item(struct btrfs_path *path, u32 data_size)
BUG(); BUG();
} }
slot = path->slots[0]; slot = path->slots[0];
old_data = btrfs_item_end_nr(leaf, slot); old_data = btrfs_item_data_end(leaf, slot);
BUG_ON(slot < 0); BUG_ON(slot < 0);
if (slot >= nritems) { if (slot >= nritems) {
...@@ -3770,7 +3770,7 @@ static void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *p ...@@ -3770,7 +3770,7 @@ static void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *p
btrfs_init_map_token(&token, leaf); btrfs_init_map_token(&token, leaf);
if (slot != nritems) { if (slot != nritems) {
unsigned int old_data = btrfs_item_end_nr(leaf, slot); unsigned int old_data = btrfs_item_data_end(leaf, slot);
if (old_data < data_end) { if (old_data < data_end) {
btrfs_print_leaf(leaf); btrfs_print_leaf(leaf);
......
...@@ -2003,7 +2003,7 @@ static inline void btrfs_set_token_item_##member(struct btrfs_map_token *token, ...@@ -2003,7 +2003,7 @@ static inline void btrfs_set_token_item_##member(struct btrfs_map_token *token,
BTRFS_ITEM_SETGET_FUNCS(offset) BTRFS_ITEM_SETGET_FUNCS(offset)
BTRFS_ITEM_SETGET_FUNCS(size); BTRFS_ITEM_SETGET_FUNCS(size);
static inline u32 btrfs_item_end_nr(const struct extent_buffer *eb, int nr) static inline u32 btrfs_item_data_end(const struct extent_buffer *eb, int nr)
{ {
return btrfs_item_offset(eb, nr) + btrfs_item_size(eb, nr); return btrfs_item_offset(eb, nr) + btrfs_item_size(eb, nr);
} }
......
...@@ -1691,10 +1691,10 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data) ...@@ -1691,10 +1691,10 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
else else
item_end_expected = btrfs_item_offset(leaf, item_end_expected = btrfs_item_offset(leaf,
slot - 1); slot - 1);
if (unlikely(btrfs_item_end_nr(leaf, slot) != item_end_expected)) { if (unlikely(btrfs_item_data_end(leaf, slot) != item_end_expected)) {
generic_err(leaf, slot, generic_err(leaf, slot,
"unexpected item end, have %u expect %u", "unexpected item end, have %u expect %u",
btrfs_item_end_nr(leaf, slot), btrfs_item_data_end(leaf, slot),
item_end_expected); item_end_expected);
return -EUCLEAN; return -EUCLEAN;
} }
...@@ -1704,11 +1704,11 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data) ...@@ -1704,11 +1704,11 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
* just in case all the items are consistent to each other, but * just in case all the items are consistent to each other, but
* all point outside of the leaf. * all point outside of the leaf.
*/ */
if (unlikely(btrfs_item_end_nr(leaf, slot) > if (unlikely(btrfs_item_data_end(leaf, slot) >
BTRFS_LEAF_DATA_SIZE(fs_info))) { BTRFS_LEAF_DATA_SIZE(fs_info))) {
generic_err(leaf, slot, generic_err(leaf, slot,
"slot end outside of leaf, have %u expect range [0, %u]", "slot end outside of leaf, have %u expect range [0, %u]",
btrfs_item_end_nr(leaf, slot), btrfs_item_data_end(leaf, slot),
BTRFS_LEAF_DATA_SIZE(fs_info)); BTRFS_LEAF_DATA_SIZE(fs_info));
return -EUCLEAN; return -EUCLEAN;
} }
......
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