Skip to content

Commit b45a9d8

Browse files
jeffmahoneykdave
authored andcommitted
btrfs: btrfs_update_root error push-up
btrfs_update_root BUG's when it can't alloc a path, yet it can recover from a search error. This patch returns -ENOMEM instead. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
1 parent 200a5c1 commit b45a9d8

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎fs/btrfs/ctree.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,9 +2724,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
27242724
int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
27252725
*root, struct btrfs_key *key, struct btrfs_root_item
27262726
*item);
2727-
int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
2728-
*root, struct btrfs_key *key, struct btrfs_root_item
2729-
*item);
2727+
int __must_check btrfs_update_root(struct btrfs_trans_handle *trans,
2728+
struct btrfs_root *root,
2729+
struct btrfs_key *key,
2730+
struct btrfs_root_item *item);
27302731
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
27312732
btrfs_root_item *item, struct btrfs_key *key);
27322733
int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid);

‎fs/btrfs/root-tree.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
9393
unsigned long ptr;
9494

9595
path = btrfs_alloc_path();
96-
BUG_ON(!path);
96+
if (!path)
97+
return -ENOMEM;
98+
9799
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
98100
if (ret < 0)
99101
goto out;

0 commit comments

Comments
 (0)