]> git.hungrycats.org Git - linux/commitdiff
btrfs: relocation: Check cancel request after each extent found
authorQu Wenruo <wqu@suse.com>
Tue, 3 Dec 2019 06:42:53 +0000 (14:42 +0800)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 9 Dec 2019 16:14:13 +0000 (11:14 -0500)
When relocating data block groups with tons of small extents, or
large metadata block groups, there can be over 200,000 extents.

We will iterate all extents of such block group in relocate_block_group(),
where iteration itself can be kinda time-consuming.

So when user want to cancel the balance, the extent iteration loop can
be another target.

This patch will add the cancelling check in the extent iteration loop of
relocate_block_group() to make balance cancelling faster.

Signed-off-by: Qu Wenruo <wqu@suse.com>
(cherry picked from commit 400faee53af2f9f1d0d4a0e0f92ea3d08fe53d59)
(cherry picked from commit 3e0b705ea6ce42941083c89b56273ae160cf9ce6)
(cherry picked from commit 67f04025608f154b002c94d477946011c3c16ccb)
(cherry picked from commit fd66a3b01ebe13af88dc59f669d444230386042c)

fs/btrfs/relocation.c

index 8d7b0dd4927e98a8acdb1c945d69fe9c82f02b8a..ad91996b52dce377d13c61ca8a30bd808f4e6b03 100644 (file)
@@ -4037,6 +4037,10 @@ restart:
                                break;
                        }
                }
+               if (should_cancel_balance(fs_info)) {
+                       err = -ECANCELED;
+                       break;
+               }
        }
        if (trans && progress && err == -ENOSPC) {
                ret = btrfs_force_chunk_alloc(trans, rc->block_group->flags);