diff mbox series

[08/26] btrfs-progs: update btrfs_set_item_key_safe to match kernel definition

Message ID 83d99b43f200e65bd4ff9719da3128ca21a14424.1682799405.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: sync ctree.c into btrfs-progs | expand

Commit Message

Josef Bacik April 29, 2023, 8:19 p.m. UTC
In the kernel we just pass the btrfs_fs_info, and we const'ify the
new_key.  Update the btrfs-progs definition to make syncing ctree.c
easier.

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

Patch

diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 2e7b6c9a..94aa45a3 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -1355,8 +1355,9 @@  void btrfs_fixup_low_keys( struct btrfs_path *path, struct btrfs_disk_key *key,
  * This function isn't completely safe. It's the caller's responsibility
  * that the new key won't break the order
  */
-int btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path,
-			    struct btrfs_key *new_key)
+void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
+			     struct btrfs_path *path,
+			     const struct btrfs_key *new_key)
 {
 	struct btrfs_disk_key disk_key;
 	struct extent_buffer *eb;
@@ -1366,13 +1367,11 @@  int btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path,
 	slot = path->slots[0];
 	if (slot > 0) {
 		btrfs_item_key(eb, &disk_key, slot - 1);
-		if (btrfs_comp_keys(&disk_key, new_key) >= 0)
-			return -1;
+		BUG_ON(btrfs_comp_keys(&disk_key, new_key) >= 0);
 	}
 	if (slot < btrfs_header_nritems(eb) - 1) {
 		btrfs_item_key(eb, &disk_key, slot + 1);
-		if (btrfs_comp_keys(&disk_key, new_key) <= 0)
-			return -1;
+		BUG_ON(btrfs_comp_keys(&disk_key, new_key) <= 0);
 	}
 
 	btrfs_cpu_key_to_disk(&disk_key, new_key);
@@ -1380,7 +1379,6 @@  int btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path,
 	btrfs_mark_buffer_dirty(eb);
 	if (slot == 0)
 		btrfs_fixup_low_keys(path, &disk_key, 1);
-	return 0;
 }
 
 /*
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index d5797d09..e54d3bc3 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -1055,8 +1055,9 @@  int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
 int btrfs_leaf_free_space(struct extent_buffer *leaf);
 void btrfs_fixup_low_keys(struct btrfs_path *path, struct btrfs_disk_key *key,
 		int level);
-int btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path,
-			    struct btrfs_key *new_key);
+void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
+			     struct btrfs_path *path,
+			     const struct btrfs_key *new_key);
 void btrfs_set_item_key_unsafe(struct btrfs_root *root,
 			       struct btrfs_path *path,
 			       struct btrfs_key *new_key);
diff --git a/kernel-shared/file-item.c b/kernel-shared/file-item.c
index 9f8a3296..87f80bfe 100644
--- a/kernel-shared/file-item.c
+++ b/kernel-shared/file-item.c
@@ -389,8 +389,7 @@  static noinline int truncate_one_csum(struct btrfs_root *root,
 		BUG_ON(ret);
 
 		key->offset = end_byte;
-		ret = btrfs_set_item_key_safe(root, path, key);
-		BUG_ON(ret);
+		btrfs_set_item_key_safe(root->fs_info, path, key);
 	} else {
 		BUG();
 	}