Commit 00bb36a0 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: have proper error handling in btrfs_init_reloc_root

create_reloc_root will return errors in the future, and __add_reloc_root
can return ENOMEM or EEXIST, so handle these errors properly.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 03a7e111
...@@ -856,9 +856,15 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, ...@@ -856,9 +856,15 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
reloc_root = create_reloc_root(trans, root, root->root_key.objectid); reloc_root = create_reloc_root(trans, root, root->root_key.objectid);
if (clear_rsv) if (clear_rsv)
trans->block_rsv = rsv; trans->block_rsv = rsv;
if (IS_ERR(reloc_root))
return PTR_ERR(reloc_root);
ret = __add_reloc_root(reloc_root); ret = __add_reloc_root(reloc_root);
BUG_ON(ret < 0); if (ret) {
/* Pairs with create_reloc_root */
btrfs_put_root(reloc_root);
return ret;
}
root->reloc_root = btrfs_grab_root(reloc_root); root->reloc_root = btrfs_grab_root(reloc_root);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment