btrfs: make btrfs_verify_data_csum follow sector size
authorQu Wenruo <wqu@suse.com>
Wed, 2 Dec 2020 06:47:59 +0000 (14:47 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Dec 2020 18:16:09 +0000 (19:16 +0100)
commitf44cf41075b05660d61efa7bfa8350b45286f065
tree219838815a6ce07590b6d239cf5ff540e737a51d
parent7ffd27e378d2541059b9ba49868c32d90ad5ae91
btrfs: make btrfs_verify_data_csum follow sector size

Currently btrfs_verify_data_csum() just passes the whole page to
check_data_csum(), which is fine since we only support sectorsize ==
PAGE_SIZE.

To support subpage, we need to properly honor per-sector
checksum verification, just like what we did in dio read path.

This patch will do the csum verification in a for loop, starts with
pg_off == start - page_offset(page), with sectorsize increase for
each loop.

For sectorsize == PAGE_SIZE case, the pg_off will always be 0, and we
will only loop once.

For subpage case, we do the iterate over each sector and if we found any
error, we return error.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.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/inode.c