btrfs-progs: don't use write_extent_to_disk() directly

There are two call sites using write_extent_to_disk() directly:

- debug_corrupt_block() in btrfs-corrupt-block.c
- corrupt_keys() in btrfs-corrupt-block.c

The problem of write_extent_to_disk() is, it can only handle plain
profiles (All profiles except P/Q stripes of RAID56).

Calling it directly can corrupted RAID56 P/Q, and in the future we're
going to remove eb::fd/eb::dev_bytes, so remove such call sites with
write_and_map_eb().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2022-04-05 20:48:25 +08:00 committed by David Sterba
parent 01c25d73f1
commit 3816a861d0

View File

@ -79,7 +79,7 @@ static int debug_corrupt_block(struct extent_buffer *eb,
printf("corrupting %llu copy %d\n", eb->start,
mirror_num);
memset(eb->data, 0, eb->len);
ret = write_extent_to_disk(eb);
ret = write_and_map_eb(eb->fs_info, eb);
if (ret < 0) {
errno = -ret;
error("cannot write eb bytenr %llu: %m",
@ -162,7 +162,7 @@ static void corrupt_keys(struct btrfs_trans_handle *trans,
u16 csum_type = fs_info->csum_type;
csum_tree_block_size(eb, csum_size, 0, csum_type);
write_extent_to_disk(eb);
write_and_map_eb(eb->fs_info, eb);
}
}