diff mbox series

[08/10] btrfs-progs: cleanup args for btrfs_set_disk_extent_flags

Message ID 346af6d7b9a7b23f475a090f4e4fc0d318048a57.1681939107.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: prep work for syncing ctree.c | expand

Commit Message

Josef Bacik April 19, 2023, 9:20 p.m. UTC
In the kernel we just pass in the extent_buffer and get the fields we
need from that to update the extent ref flags.  Update this helper to
match the kernel to make syncing ctree.c easier.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/ctree.c       |  4 +---
 kernel-shared/ctree.h       |  4 ++--
 kernel-shared/extent-tree.c | 11 +++++++----
 3 files changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index e95dcc79..ea2a7af3 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -419,9 +419,7 @@  static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 			BUG_ON(ret);
 		}
 		if (new_flags != 0) {
-			ret = btrfs_set_disk_extent_flags(trans, buf->start,
-							  btrfs_header_level(buf),
-							  new_flags);
+			ret = btrfs_set_disk_extent_flags(trans, buf, new_flags);
 			BUG_ON(ret);
 		}
 	} else {
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index aaace45e..069e000d 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -859,8 +859,8 @@  struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 			     struct btrfs_fs_info *fs_info, u64 bytenr,
 			     u64 offset, int metadata, u64 *refs, u64 *flags);
-int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
-				int level, u64 flags);
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
+				struct extent_buffer *eb, u64 flags);
 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		  struct extent_buffer *buf, int record_parent);
 int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 8a6ab996..cfce4426 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1375,26 +1375,29 @@  out:
 	return ret;
 }
 
-int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
-				int level, u64 flags)
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
+				struct extent_buffer *eb, u64 flags)
 {
 	struct btrfs_fs_info *fs_info = trans->fs_info;
-	struct btrfs_root *extent_root = btrfs_extent_root(fs_info, bytenr);
+	struct btrfs_root *extent_root;
 	struct btrfs_path *path;
 	int ret;
 	struct btrfs_key key;
 	struct extent_buffer *l;
 	struct btrfs_extent_item *item;
 	u32 item_size;
+	u64 bytenr = eb->start;
 	int skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
 
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
 
+	extent_root = btrfs_extent_root(fs_info, bytenr);
+
 	key.objectid = bytenr;
 	if (skinny_metadata) {
-		key.offset = level;
+		key.offset = btrfs_header_level(eb);
 		key.type = BTRFS_METADATA_ITEM_KEY;
 	} else {
 		key.offset = fs_info->nodesize;