From f3be0ff01acc55a257ff3102e7e433cbce6c9436 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 22 Feb 2022 17:26:19 -0500 Subject: [PATCH] btrfs-progs: rename btrfs_item_end_nr to btrfs_item_end All callers use the btrfs_item_end_nr() variation, simply drop btrfs_item_end() and make btrfs_item_end_nr() use the _nr() variations of the item get helpers. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik Signed-off-by: David Sterba --- check/main.c | 12 ++++++------ kernel-shared/ctree.c | 20 ++++++++++---------- kernel-shared/ctree.h | 16 +++++----------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/check/main.c b/check/main.c index 95ed4be5..4af5edb1 100644 --- a/check/main.c +++ b/check/main.c @@ -4327,9 +4327,9 @@ again: for (i = 0; i < btrfs_header_nritems(buf); i++) { unsigned int shift = 0, offset; - if (i == 0 && btrfs_item_end_nr(buf, i) != + if (i == 0 && btrfs_item_end(buf, i) != BTRFS_LEAF_DATA_SIZE(gfs_info)) { - if (btrfs_item_end_nr(buf, i) > + if (btrfs_item_end(buf, i) > BTRFS_LEAF_DATA_SIZE(gfs_info)) { ret = delete_bogus_item(root, path, buf, i); if (!ret) @@ -4340,10 +4340,10 @@ again: break; } shift = BTRFS_LEAF_DATA_SIZE(gfs_info) - - btrfs_item_end_nr(buf, i); - } else if (i > 0 && btrfs_item_end_nr(buf, i) != + btrfs_item_end(buf, i); + } else if (i > 0 && btrfs_item_end(buf, i) != btrfs_item_offset_nr(buf, i - 1)) { - if (btrfs_item_end_nr(buf, i) > + if (btrfs_item_end(buf, i) > btrfs_item_offset_nr(buf, i - 1)) { ret = delete_bogus_item(root, path, buf, i); if (!ret) @@ -4353,7 +4353,7 @@ again: break; } shift = btrfs_item_offset_nr(buf, i - 1) - - btrfs_item_end_nr(buf, i); + btrfs_item_end(buf, i); } if (!shift) continue; diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index 81a438c8..d18c91d1 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -730,10 +730,10 @@ btrfs_check_leaf(struct btrfs_fs_info *fs_info, else item_end_expected = btrfs_item_offset_nr(leaf, slot - 1); - if (btrfs_item_end_nr(leaf, slot) != item_end_expected) { + if (btrfs_item_end(leaf, slot) != item_end_expected) { generic_err(leaf, slot, "unexpected item end, have %u expect %u", - btrfs_item_end_nr(leaf, slot), + btrfs_item_end(leaf, slot), item_end_expected); ret = BTRFS_TREE_BLOCK_INVALID_OFFSETS; goto fail; @@ -744,11 +744,11 @@ btrfs_check_leaf(struct btrfs_fs_info *fs_info, * just in case all the items are consistent to each other, but * all point outside of the leaf. */ - if (btrfs_item_end_nr(leaf, slot) > + if (btrfs_item_end(leaf, slot) > BTRFS_LEAF_DATA_SIZE(fs_info)) { generic_err(leaf, slot, "slot end outside of leaf, have %u expect range [0, %u]", - btrfs_item_end_nr(leaf, slot), + btrfs_item_end(leaf, slot), BTRFS_LEAF_DATA_SIZE(fs_info)); ret = BTRFS_TREE_BLOCK_INVALID_OFFSETS; goto fail; @@ -1931,7 +1931,7 @@ static int leaf_space_used(struct extent_buffer *l, int start, int nr) if (!nr) return 0; - data_len = btrfs_item_end_nr(l, start); + data_len = btrfs_item_end(l, start); data_len = data_len - btrfs_item_offset_nr(l, end); data_len += sizeof(struct btrfs_item) * nr; WARN_ON(data_len < 0); @@ -2059,7 +2059,7 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root /* push left to right */ right_nritems = btrfs_header_nritems(right); - push_space = btrfs_item_end_nr(left, left_nritems - push_items); + push_space = btrfs_item_end(left, left_nritems - push_items); push_space -= leaf_data_end(left); /* make room in the right data area */ @@ -2294,7 +2294,7 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, nritems = nritems - mid; btrfs_set_header_nritems(right, nritems); - data_copy_size = btrfs_item_end_nr(l, mid) - leaf_data_end(l); + data_copy_size = btrfs_item_end(l, mid) - leaf_data_end(l); copy_extent_buffer(right, l, btrfs_item_nr_offset(0), btrfs_item_nr_offset(mid), @@ -2306,7 +2306,7 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, btrfs_leaf_data(l) + leaf_data_end(l), data_copy_size); rt_data_off = BTRFS_LEAF_DATA_SIZE(root->fs_info) - - btrfs_item_end_nr(l, mid); + btrfs_item_end(l, mid); for (i = 0; i < nritems; i++) { u32 ioff = btrfs_item_offset_nr(right, i); @@ -2727,7 +2727,7 @@ int btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path, BUG(); } slot = path->slots[0]; - old_data = btrfs_item_end_nr(leaf, slot); + old_data = btrfs_item_end(leaf, slot); BUG_ON(slot < 0); if (slot >= nritems) { @@ -2816,7 +2816,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, BUG_ON(slot < 0); if (slot < nritems) { - unsigned int old_data = btrfs_item_end_nr(leaf, slot); + unsigned int old_data = btrfs_item_end(leaf, slot); if (old_data < data_end) { btrfs_print_leaf(leaf, BTRFS_PRINT_TREE_DEFAULT); diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 7fb66049..befa244f 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -1994,17 +1994,6 @@ static inline struct btrfs_item *btrfs_item_nr(int nr) return (struct btrfs_item *)btrfs_item_nr_offset(nr); } -static inline u32 btrfs_item_end(struct extent_buffer *eb, - struct btrfs_item *item) -{ - return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item); -} - -static inline u32 btrfs_item_end_nr(struct extent_buffer *eb, int nr) -{ - return btrfs_item_end(eb, btrfs_item_nr(nr)); -} - static inline void btrfs_set_item_size_nr(struct extent_buffer *eb, int nr, u32 size) { @@ -2027,6 +2016,11 @@ static inline u32 btrfs_item_size_nr(struct extent_buffer *eb, int nr) return btrfs_item_size(eb, btrfs_item_nr(nr)); } +static inline u32 btrfs_item_end(struct extent_buffer *eb, int nr) +{ + return btrfs_item_offset_nr(eb, nr) + btrfs_item_size_nr(eb, nr); +} + static inline void btrfs_item_key(struct extent_buffer *eb, struct btrfs_disk_key *disk_key, int nr) {