summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-03 00:37:51 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-09 13:47:31 +0100
commita34b3b92732ed7fc26ea1f5d06ef70142ad7d24b (patch)
tree744d8a0cbb86afc237de5ec6db9632006e018168 /mkfs.c
parent5a0645afb8f124fc4acffaaa96e31d1f841061fb (diff)
btrfs-progs: mkfs: use on-stack path buffer in cleanup_temp_chunks
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>
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/mkfs.c b/mkfs.c
index 1e66f552..65662986 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1310,15 +1310,10 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info,
struct btrfs_root *root = fs_info->extent_root;
struct btrfs_key key;
struct btrfs_key found_key;
- struct btrfs_path *path;
+ struct btrfs_path path;
int ret = 0;
- path = btrfs_alloc_path();
- if (!path) {
- ret = -ENOMEM;
- goto out;
- }
-
+ btrfs_init_path(&path);
trans = btrfs_start_transaction(root, 1);
key.objectid = 0;
@@ -1330,32 +1325,32 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info,
* as the rest of the loop may modify the tree, we need to
* start a new search each time.
*/
- ret = btrfs_search_slot(trans, root, &key, path, 0, 0);
+ ret = btrfs_search_slot(trans, root, &key, &path, 0, 0);
if (ret < 0)
goto out;
- btrfs_item_key_to_cpu(path->nodes[0], &found_key,
- path->slots[0]);
+ btrfs_item_key_to_cpu(path.nodes[0], &found_key,
+ path.slots[0]);
if (found_key.objectid < key.objectid)
goto out;
if (found_key.type != BTRFS_BLOCK_GROUP_ITEM_KEY) {
- ret = next_block_group(root, path);
+ ret = next_block_group(root, &path);
if (ret < 0)
goto out;
if (ret > 0) {
ret = 0;
goto out;
}
- btrfs_item_key_to_cpu(path->nodes[0], &found_key,
- path->slots[0]);
+ btrfs_item_key_to_cpu(path.nodes[0], &found_key,
+ path.slots[0]);
}
- bgi = btrfs_item_ptr(path->nodes[0], path->slots[0],
+ bgi = btrfs_item_ptr(path.nodes[0], path.slots[0],
struct btrfs_block_group_item);
- if (is_temp_block_group(path->nodes[0], bgi,
+ if (is_temp_block_group(path.nodes[0], bgi,
data_profile, meta_profile,
sys_profile)) {
- u64 flags = btrfs_disk_block_group_flags(path->nodes[0],
+ u64 flags = btrfs_disk_block_group_flags(path.nodes[0],
bgi);
ret = btrfs_free_block_group(trans, fs_info,
@@ -1377,13 +1372,13 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info,
BTRFS_BLOCK_GROUP_DATA))
alloc->mixed -= found_key.offset;
}
- btrfs_release_path(path);
+ btrfs_release_path(&path);
key.objectid = found_key.objectid + found_key.offset;
}
out:
if (trans)
btrfs_commit_transaction(trans, root);
- btrfs_free_path(path);
+ btrfs_release_path(&path);
return ret;
}