]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - fs/btrfs/scrub.c
btrfs: scrub: reduce width of extent_len/stripe_len from 64 to 32 bits
authorQu Wenruo <wqu@suse.com>
Wed, 2 Dec 2020 06:48:07 +0000 (14:48 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Dec 2020 18:16:11 +0000 (19:16 +0100)
commitfa485d21a7ae712fef8e943d1dd3ca7b27cb392e
tree0d1d7f6d299f91870f9709a580c88fc05ed4880c
parent6275193ef19033d0cca88df6209556462bbedee2
btrfs: scrub: reduce width of extent_len/stripe_len from 64 to 32 bits

Btrfs on-disk format chose to use u64 for almost everything, but there
are a other restrictions that won't let us use more than u32 for things
like extent length (the maximum length is 128MiB for non-hole extents),
or stripe length (we have device number limit).

This means if we don't have extra handling to convert u64 to u32, we
will always have some questionable operations like
"u32 = u64 >> sectorsize_bits" in the code.

This patch will try to address the problem by reducing the width for the
following members/parameters:

- scrub_parity::stripe_len
- @len of scrub_pages()
- @extent_len of scrub_remap_extent()
- @len of scrub_parity_mark_sectors_error()
- @len of scrub_parity_mark_sectors_data()
- @len of scrub_extent()
- @len of scrub_pages_for_parity()
- @len of scrub_extent_for_parity()

For members extracted from on-disk structure, like map->stripe_len, they
will be kept as is. Since that modification would require on-disk format
change.

There will be cases like "u32 = u64 - u64" or "u32 = u64", for such call
sites, extra ASSERT() is added to be extra safe for debug builds.

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/scrub.c