diff options
author | Josef Bacik <josef@toxicpanda.com> | 2021-03-12 15:25:31 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-04-19 17:25:22 +0200 |
commit | e0b085b0b03fa5c435b7240668f144199ed989c4 (patch) | |
tree | cffee4da005e3944c06e58b5e855c7365a709296 /fs/btrfs | |
parent | 57a304cfd43b2b4a5b44b8f5dc026abb34183068 (diff) |
btrfs: cleanup error handling in prepare_to_merge
This probably can't happen even with a corrupt file system, because we
would have failed much earlier on than here. However there's no reason
we can't just check and bail out as appropriate, so do that and convert
the correctness BUG_ON() to an ASSERT().
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/relocation.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 7d68abebf1e2..01c393757721 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1885,8 +1885,18 @@ again: root = btrfs_get_fs_root(fs_info, reloc_root->root_key.offset, false); - BUG_ON(IS_ERR(root)); - BUG_ON(root->reloc_root != reloc_root); + if (IS_ERR(root)) { + /* + * Even if we have an error we need this reloc root + * back on our list so we can clean up properly. + */ + list_add(&reloc_root->root_list, &reloc_roots); + btrfs_abort_transaction(trans, (int)PTR_ERR(root)); + if (!err) + err = PTR_ERR(root); + break; + } + ASSERT(root->reloc_root == reloc_root); /* * set reference count to 1, so btrfs_recover_relocation |