Blob Blame History Raw
From 6740f37d2edb169a5019229ad676593880ad4441 Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
Date: Mon, 11 May 2020 13:10:06 +0800
Patch-mainline: Never, will fix the root cause in upstream
References: bsc#1171417
Subject: [PATCH] btrfs: relocation: Work around dead relocation stage loop

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 |    5 +++++
 1 file changed, 5 insertions(+)

--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4602,6 +4602,11 @@ int btrfs_relocate_block_group(struct bt
 			rc->stage = UPDATE_DATA_PTRS;
 		}
 
+		if (btrfs_should_cancel_balance(fs_info)) {
+			err = -ECANCELED;
+			goto out;
+		}
+
 		if (err < 0)
 			goto out;