]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit96d22bfc69cb2e404e46cfecb0e5b39cc7ba0507
tree219838815a6ce07590b6d239cf5ff540e737a51d
parentf5c3c8724ca1f1d57ed008b533b8ff9f23825be2
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