btrfs-progs: check: use on-stack path buffer in check_fs_roots_v2
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>
This commit is contained in:
parent
e42f8c6a3c
commit
4e2275bd27
17
cmds-check.c
17
cmds-check.c
|
@ -5131,7 +5131,7 @@ static int check_fs_roots_v2(struct btrfs_fs_info *fs_info)
|
||||||
{
|
{
|
||||||
struct btrfs_root *tree_root = fs_info->tree_root;
|
struct btrfs_root *tree_root = fs_info->tree_root;
|
||||||
struct btrfs_root *cur_root = NULL;
|
struct btrfs_root *cur_root = NULL;
|
||||||
struct btrfs_path *path;
|
struct btrfs_path path;
|
||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
struct extent_buffer *node;
|
struct extent_buffer *node;
|
||||||
unsigned int ext_ref;
|
unsigned int ext_ref;
|
||||||
|
@ -5141,15 +5141,12 @@ static int check_fs_roots_v2(struct btrfs_fs_info *fs_info)
|
||||||
|
|
||||||
ext_ref = btrfs_fs_incompat(fs_info, EXTENDED_IREF);
|
ext_ref = btrfs_fs_incompat(fs_info, EXTENDED_IREF);
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
btrfs_init_path(&path);
|
||||||
if (!path)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
key.objectid = BTRFS_FS_TREE_OBJECTID;
|
key.objectid = BTRFS_FS_TREE_OBJECTID;
|
||||||
key.offset = 0;
|
key.offset = 0;
|
||||||
key.type = BTRFS_ROOT_ITEM_KEY;
|
key.type = BTRFS_ROOT_ITEM_KEY;
|
||||||
|
|
||||||
ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, tree_root, &key, &path, 0, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
err = ret;
|
err = ret;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -5159,8 +5156,8 @@ static int check_fs_roots_v2(struct btrfs_fs_info *fs_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
node = path->nodes[0];
|
node = path.nodes[0];
|
||||||
slot = path->slots[0];
|
slot = path.slots[0];
|
||||||
btrfs_item_key_to_cpu(node, &key, slot);
|
btrfs_item_key_to_cpu(node, &key, slot);
|
||||||
if (key.objectid > BTRFS_LAST_FREE_OBJECTID)
|
if (key.objectid > BTRFS_LAST_FREE_OBJECTID)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -5192,7 +5189,7 @@ static int check_fs_roots_v2(struct btrfs_fs_info *fs_info)
|
||||||
err |= ret;
|
err |= ret;
|
||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
ret = btrfs_next_item(tree_root, path);
|
ret = btrfs_next_item(tree_root, &path);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
goto out;
|
goto out;
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -5202,7 +5199,7 @@ next:
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
btrfs_free_path(path);
|
btrfs_release_path(&path);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue