Re: [PATCH 12/17] btrfs: remove the unnecessary parameter @start and @len for check_data_csum()

Nikolay Borisov
2020-09-11T16:36:50Z

On 8.09.20 г. 10:52 ч., Qu Wenruo wrote:
> For check_data_csum(), the page we're using is directly from inode
> mapping, thus it has valid page_offset().
>
> We can use (page_offset() + pg_off) to replace @start parameter
> completely, while the @len should always be sectorsize.
>
> Since we're here, also add some comment, since there are quite some
> confusion in words like start/offset, without explaining whether it's
> file_offset or logical bytenr.
>
> This should not affect the existing behavior, as for current sectorsize
> == PAGE_SIZE case, @pgoff should always be 0, and len is always
> PAGE_SIZE (or sectorsize from the dio read path).
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>

<snip>

> @@ -2857,8 +2870,7 @@ static int btrfs_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
> }
>
> phy_offset >>= inode->i_sb->s_blocksize_bits;
> - return check_data_csum(inode, io_bio, phy_offset, page, offset, start,
> - (size_t)(end - start + 1));
> + return check_data_csum(inode, io_bio, phy_offset, page, offset);

offset in this function is calculated as:
size_t offset = start - page_offset(page);

Where stat is an input parameter that's derived in end_bio_extent_readpage:

start = page_offset(page);

So it seems to be always set to 0 and can simply be removed.

> }
>
> /*

<snip>