Re: [PATCH 07/17] btrfs: make csum_tree_block() handle sectorsize smaller than page size

Nikolay Borisov
2020-09-11T11:10:19Z

On 8.09.20 г. 10:52 ч., Qu Wenruo wrote:
> For subpage size support, we only need to handle the first page.
>
> To make the code work for both cases, we modify the following behaviors:
>
> - num_pages calcuation
> Instead of "nodesize >> PAGE_SHIFT", we go
> "DIV_ROUND_UP(nodesize, PAGE_SIZE)", this ensures we get at least one
> page for subpage size support, while still get the same result for
> reguar page size.
>
> - The length for the first run
> Instead of PAGE_SIZE - BTRFS_CSUM_SIZE, we go min(PAGE_SIZE, nodesize)
> - BTRFS_CSUM_SIZE.
> This allows us to handle both cases well.
>
> - The start location of the first run
> Instead of always use BTRFS_CSUM_SIZE as csum start position, add
> offset_in_page(eb->start) to get proper offset for both cases.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>