Btrfs: return gracefully from balance if fs tree is corrupted
authorLiu Bo <bo.li.liu@oracle.com>
Wed, 14 Sep 2016 15:51:46 +0000 (08:51 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Jan 2017 10:16:10 +0000 (11:16 +0100)
commit8ca6845a58cda0cda9359eb313af35c2f88df073
tree6741d562d70b46dc8660954e08174c79a91719fd
parent78a587c608f9ef0b0f7bd0bb5f4165a61a782862
Btrfs: return gracefully from balance if fs tree is corrupted

commit 3561b9db70928f207be4570b48fc19898eeaef54 upstream.

When relocating tree blocks, we firstly get block information from
back references in the extent tree, we then search fs tree to try to
find all parents of a block.

However, if fs tree is corrupted, eg. if there're some missing
items, we could come across these WARN_ONs and BUG_ONs.

This makes us print some error messages and return gracefully
from balance.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/relocation.c