btrfs-progs: handle errors from btrfs_alloc_path
All functions already return an error condition, so the callers should expect that. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b318553f33
commit
1ef93ea863
4
ctree.c
4
ctree.c
|
@ -2580,7 +2580,9 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||||
unsigned long ptr;
|
unsigned long ptr;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
|
ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
|
|
|
@ -739,7 +739,11 @@ struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info,
|
||||||
root, fs_info, location->objectid);
|
root, fs_info, location->objectid);
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path) {
|
||||||
|
free(root);
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
|
ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
|
|
|
@ -2714,7 +2714,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
|
||||||
size += sizeof(*block_info);
|
size += sizeof(*block_info);
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
|
ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
|
||||||
ins, size);
|
ins, size);
|
||||||
|
|
|
@ -42,7 +42,9 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
|
||||||
struct extent_buffer *leaf;
|
struct extent_buffer *leaf;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
file_key.objectid = objectid;
|
file_key.objectid = objectid;
|
||||||
file_key.offset = pos;
|
file_key.offset = pos;
|
||||||
btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
|
btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
|
||||||
|
@ -188,7 +190,8 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
|
||||||
btrfs_super_csum_size(root->fs_info->super_copy);
|
btrfs_super_csum_size(root->fs_info->super_copy);
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
|
file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
|
||||||
file_key.offset = bytenr;
|
file_key.offset = bytenr;
|
||||||
|
|
|
@ -39,7 +39,9 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
|
||||||
u64 search_start = dirid;
|
u64 search_start = dirid;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
search_start = root->last_inode_alloc;
|
search_start = root->last_inode_alloc;
|
||||||
search_start = max((unsigned long long)search_start,
|
search_start = max((unsigned long long)search_start,
|
||||||
BTRFS_FIRST_FREE_OBJECTID);
|
BTRFS_FIRST_FREE_OBJECTID);
|
||||||
|
|
10
root-tree.c
10
root-tree.c
|
@ -31,12 +31,14 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
|
||||||
int ret;
|
int ret;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
|
path = btrfs_alloc_path();
|
||||||
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
search_key.objectid = objectid;
|
search_key.objectid = objectid;
|
||||||
search_key.type = BTRFS_ROOT_ITEM_KEY;
|
search_key.type = BTRFS_ROOT_ITEM_KEY;
|
||||||
search_key.offset = (u64)-1;
|
search_key.offset = (u64)-1;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
|
||||||
BUG_ON(!path);
|
|
||||||
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -74,7 +76,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||||
u32 old_len;
|
u32 old_len;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
|
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -459,7 +459,8 @@ static int find_next_chunk(struct btrfs_root *root, u64 objectid, u64 *offset)
|
||||||
struct btrfs_key found_key;
|
struct btrfs_key found_key;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
if (!path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
key.objectid = objectid;
|
key.objectid = objectid;
|
||||||
key.offset = (u64)-1;
|
key.offset = (u64)-1;
|
||||||
|
|
Loading…
Reference in New Issue