@@ -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;
}
/*
@@ -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);
@@ -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();
}
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(-)