mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-25 23:52:17 +00:00
btrfs-progs: update btrfs_set_item_key_safe to match kernel definition
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> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
05f4b61206
commit
8ea15251e7
@ -1514,8 +1514,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;
|
||||
@ -1525,13 +1526,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);
|
||||
@ -1539,7 +1538,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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1063,8 +1063,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);
|
||||
|
@ -379,8 +379,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();
|
||||
}
|
||||
|
@ -459,13 +459,7 @@ static int change_csum_objectids(struct btrfs_fs_info *fs_info)
|
||||
btrfs_item_key_to_cpu(path.nodes[0], &found_key, i);
|
||||
found_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
|
||||
path.slots[0] = i;
|
||||
ret = btrfs_set_item_key_safe(csum_root, &path, &found_key);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
error("failed to set item key for data csum at logical %llu: %m",
|
||||
found_key.offset);
|
||||
goto out;
|
||||
}
|
||||
btrfs_set_item_key_safe(fs_info, &path, &found_key);
|
||||
}
|
||||
btrfs_release_path(&path);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user