forked from Mirrors/btrfs-progs
btrfs-progs: btrfstune: use on-stack path buffer in change_extents_uuid
We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>master
parent
a75e84a819
commit
ac2a089560
19
btrfstune.c
19
btrfstune.c
|
@ -118,19 +118,16 @@ static int change_header_uuid(struct btrfs_root *root, struct extent_buffer *eb)
|
||||||
static int change_extents_uuid(struct btrfs_fs_info *fs_info)
|
static int change_extents_uuid(struct btrfs_fs_info *fs_info)
|
||||||
{
|
{
|
||||||
struct btrfs_root *root = fs_info->extent_root;
|
struct btrfs_root *root = fs_info->extent_root;
|
||||||
struct btrfs_path *path;
|
struct btrfs_path path;
|
||||||
struct btrfs_key key = {0, 0, 0};
|
struct btrfs_key key = {0, 0, 0};
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
btrfs_init_path(&path);
|
||||||
if (!path)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we don't use transaction as it will takes a lot of reserve
|
* Here we don't use transaction as it will takes a lot of reserve
|
||||||
* space, and that will make a near-full btrfs unable to change uuid
|
* space, and that will make a near-full btrfs unable to change uuid
|
||||||
*/
|
*/
|
||||||
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -140,13 +137,13 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info)
|
||||||
u64 flags;
|
u64 flags;
|
||||||
u64 bytenr;
|
u64 bytenr;
|
||||||
|
|
||||||
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
|
btrfs_item_key_to_cpu(path.nodes[0], &key, path.slots[0]);
|
||||||
if (key.type != BTRFS_EXTENT_ITEM_KEY &&
|
if (key.type != BTRFS_EXTENT_ITEM_KEY &&
|
||||||
key.type != BTRFS_METADATA_ITEM_KEY)
|
key.type != BTRFS_METADATA_ITEM_KEY)
|
||||||
goto next;
|
goto next;
|
||||||
ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
|
ei = btrfs_item_ptr(path.nodes[0], path.slots[0],
|
||||||
struct btrfs_extent_item);
|
struct btrfs_extent_item);
|
||||||
flags = btrfs_extent_flags(path->nodes[0], ei);
|
flags = btrfs_extent_flags(path.nodes[0], ei);
|
||||||
if (!(flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
|
if (!(flags & BTRFS_EXTENT_FLAG_TREE_BLOCK))
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
|
@ -165,7 +162,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
ret = btrfs_next_item(root, path);
|
ret = btrfs_next_item(root, &path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
|
@ -175,7 +172,7 @@ next:
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
btrfs_free_path(path);
|
btrfs_release_path(&path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue