OSDN Git Service

btrfs: relocation: add error injection points for cancelling balance
authorQu Wenruo <wqu@suse.com>
Mon, 17 Feb 2020 06:16:52 +0000 (14:16 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:54 +0000 (17:01 +0100)
commit726a342120eba8197b3bc5e01af1bd2dbf80f77f
treefdaa19c4ccb98cae139dd263960ec537aa44ac6e
parent05a5a7621ce66c142e081ffc24dd6ade6e912061
btrfs: relocation: add error injection points for cancelling balance

Introduce a new error injection point, should_cancel_balance().

It's just a wrapper of atomic_read(&fs_info->balance_cancel_req), but
allows us to override the return value.

Currently there are only one locations using this function:

- btrfs_balance()
  It checks cancel before each block group.

There are other locations checking fs_info->balance_cancel_req, but they
are not used as an indicator to exit, so there is no need to use the
wrapper.

But there will be more locations coming, and some locations can cause
kernel panic if not handled properly.  So introduce this error injection
to provide better test interface.

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>
fs/btrfs/ctree.h
fs/btrfs/relocation.c
fs/btrfs/volumes.c