diff mbox series

[11/13] btrfs-progs: replace btrfs_item_nr_offset(0)

Message ID a597a4dcd96aa815ab999b72af722c37c1eda19e.1645568701.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: cleanup btrfs_item* accessors | expand

Commit Message

Josef Bacik Feb. 22, 2022, 10:26 p.m. UTC
btrfs_item_nr_offset(0) is simply offsetof(struct btrfs_leaf, items),
which is the same thing as btrfs_leaf_data(), so replace all calls of
btrfs_item_nr_offset(0) with btrfs_leaf_data().

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/ctree.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Nikolay Borisov March 9, 2022, 12:42 p.m. UTC | #1
On 23.02.22 г. 0:26 ч., Josef Bacik wrote:
> btrfs_item_nr_offset(0) is simply offsetof(struct btrfs_leaf, items),
> which is the same thing as btrfs_leaf_data(), so replace all calls of
> btrfs_item_nr_offset(0) with btrfs_leaf_data().
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>


nit: The patch itself is fine, however in the kernel we don't have 
btrfs_leaf_data() func, instead we have BTRFS_LEAF_DATA_OFFSET macro 
which is used in a lot of places in the kernel. So why not make the 
btrfs-progs follow the kernel style to reduce future clashes when we 
start factoring out common code between user/kernel?
diff mbox series

Patch

diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 04847cd5..e164492b 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -2075,11 +2075,11 @@  static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
 		     btrfs_leaf_data(left) + leaf_data_end(left), push_space);
 
 	memmove_extent_buffer(right, btrfs_item_nr_offset(push_items),
-			      btrfs_item_nr_offset(0),
+			      btrfs_leaf_data(right),
 			      right_nritems * sizeof(struct btrfs_item));
 
 	/* copy the items from left to right */
-	copy_extent_buffer(right, left, btrfs_item_nr_offset(0),
+	copy_extent_buffer(right, left, btrfs_leaf_data(right),
 		   btrfs_item_nr_offset(left_nritems - push_items),
 		   push_items * sizeof(struct btrfs_item));
 
@@ -2198,7 +2198,7 @@  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(btrfs_header_nritems(left)),
-			   btrfs_item_nr_offset(0),
+			   btrfs_leaf_data(right),
 			   push_items * sizeof(struct btrfs_item));
 
 	push_space = BTRFS_LEAF_DATA_SIZE(root->fs_info) -
@@ -2238,7 +2238,7 @@  static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
 				      btrfs_leaf_data(right) +
 				      leaf_data_end(right), push_space);
 
-		memmove_extent_buffer(right, btrfs_item_nr_offset(0),
+		memmove_extent_buffer(right, btrfs_leaf_data(right),
 			      btrfs_item_nr_offset(push_items),
 			     (btrfs_header_nritems(right) - push_items) *
 			     sizeof(struct btrfs_item));
@@ -2296,7 +2296,7 @@  static noinline int copy_for_split(struct btrfs_trans_handle *trans,
 	btrfs_set_header_nritems(right, nritems);
 	data_copy_size = btrfs_item_end(l, mid) - leaf_data_end(l);
 
-	copy_extent_buffer(right, l, btrfs_item_nr_offset(0),
+	copy_extent_buffer(right, l, btrfs_leaf_data(right),
 			   btrfs_item_nr_offset(mid),
 			   nritems * sizeof(struct btrfs_item));