[PATCH 4/4] btrfs: relocation: Work around dead relocation stage loop

Qu Wenruo
2019-12-03T06:43:09Z

There are some reports of dead relocation stage loop, where dmesg is
flooded by "Found X extents".

The root cause of it is still uncertain, but we can work around such bug
by checking cancelling request so user can at least cancel such dead
loop.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/relocation.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 161d66f70190..23aa630f04c9 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4417,6 +4417,10 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)

btrfs_info(fs_info, "found %llu extents", rc->extents_found);

+ if (should_cancel_balance(fs_info)) {
+ err = -ECANCELED;
+ goto out;
+ }
}

WARN_ON(rc->block_group->pinned > 0);
--
2.24.0