Skip to content

Commit f31ea08

Browse files
adam900710kdave
authored andcommitted
btrfs: relocation: Check cancel request after each extent found
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. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7f913c7 commit f31ea08

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/btrfs/relocation.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,6 +4232,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
42324232
break;
42334233
}
42344234
}
4235+
if (btrfs_should_cancel_balance(fs_info)) {
4236+
err = -ECANCELED;
4237+
break;
4238+
}
42354239
}
42364240
if (trans && progress && err == -ENOSPC) {
42374241
ret = btrfs_force_chunk_alloc(trans, rc->block_group->flags);

0 commit comments

Comments
 (0)