Commit 8b8bbd46 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: only require sector size alignment for page read

If we're reading partial page, btrfs will warn about this as read/write
is always done in sector size, which now equals page size.

But for the upcoming subpage read-only support, our data read is only
aligned to sectorsize, which can be smaller than page size.

Thus here we change the warning condition to check it against
sectorsize, the behavior is not changed for regular sectorsize ==
PAGE_SIZE case, and won't report error for subpage read.

Also, pass the proper start/end with bv_offset for check_data_csum() to
handle.
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 12e3360f
...@@ -2823,6 +2823,7 @@ static void end_bio_extent_readpage(struct bio *bio) ...@@ -2823,6 +2823,7 @@ static void end_bio_extent_readpage(struct bio *bio)
struct page *page = bvec->bv_page; struct page *page = bvec->bv_page;
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
u32 sectorsize = fs_info->sectorsize;
btrfs_debug(fs_info, btrfs_debug(fs_info,
"end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u", "end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u",
...@@ -2831,24 +2832,25 @@ static void end_bio_extent_readpage(struct bio *bio) ...@@ -2831,24 +2832,25 @@ static void end_bio_extent_readpage(struct bio *bio)
tree = &BTRFS_I(inode)->io_tree; tree = &BTRFS_I(inode)->io_tree;
failure_tree = &BTRFS_I(inode)->io_failure_tree; failure_tree = &BTRFS_I(inode)->io_failure_tree;
/* We always issue full-page reads, but if some block /*
* in a page fails to read, blk_update_request() will * We always issue full-sector reads, but if some block in a
* advance bv_offset and adjust bv_len to compensate. * page fails to read, blk_update_request() will advance
* Print a warning for nonzero offsets, and an error * bv_offset and adjust bv_len to compensate. Print a warning
* if they don't add up to a full page. */ * for unaligned offsets, and an error if they don't add up to
if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) { * a full sector.
if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE) */
btrfs_err(fs_info, if (!IS_ALIGNED(bvec->bv_offset, sectorsize))
"partial page read in btrfs with offset %u and length %u", btrfs_err(fs_info,
bvec->bv_offset, bvec->bv_len); "partial page read in btrfs with offset %u and length %u",
else bvec->bv_offset, bvec->bv_len);
btrfs_info(fs_info, else if (!IS_ALIGNED(bvec->bv_offset + bvec->bv_len,
"incomplete page read in btrfs with offset %u and length %u", sectorsize))
bvec->bv_offset, bvec->bv_len); btrfs_info(fs_info,
} "incomplete page read with offset %u and length %u",
bvec->bv_offset, bvec->bv_len);
start = page_offset(page);
end = start + bvec->bv_offset + bvec->bv_len - 1; start = page_offset(page) + bvec->bv_offset;
end = start + bvec->bv_len - 1;
len = bvec->bv_len; len = bvec->bv_len;
mirror = io_bio->mirror_num; mirror = io_bio->mirror_num;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment