diff mbox series

[v2,3/4] btrfs: relocation: Check cancel request after each extent found

Message ID 20200211053729.20807-4-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: Make balance cancelling response faster | expand

Commit Message

Qu Wenruo Feb. 11, 2020, 5:37 a.m. UTC
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>
---
 fs/btrfs/relocation.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Josef Bacik Feb. 13, 2020, 8:05 p.m. UTC | #1
On 2/11/20 12:37 AM, Qu Wenruo wrote:
> 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>
> ---
Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 23b279872641..3379850d7695 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4181,6 +4181,10 @@  static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 				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);