btrfs: make check_compressed_csum() to be subpage compatible
authorQu Wenruo <wqu@suse.com>
Thu, 4 Feb 2021 07:03:24 +0000 (15:03 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 22 Feb 2021 16:15:27 +0000 (17:15 +0100)
commit04d4ba4c90759844fb4ffa735214c1c41508d2f7
tree5051352ad48a4aa9310497d1448ec0fad103d144
parentbe6a13613fd35602ea9e65d6634cf7af79f0a93d
btrfs: make check_compressed_csum() to be subpage compatible

Currently check_compressed_csum() completely relies on sectorsize ==
PAGE_SIZE to do checksum verification for compressed extents.

To make it subpage compatible, this patch will:
- Do extra calculation for the csum range
  Since we have multiple sectors inside a page, we need to only hash
  the range we want, not the full page anymore.

- Do sector-by-sector hash inside the page

With this patch and previous conversion on
btrfs_submit_compressed_read(), now we can read subpage compressed
extents properly, and do proper csum verification.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c