]> git.hungrycats.org Git - linux/commit
btrfs: make btrfs_submit_compressed_read() subpage compatible
authorQu Wenruo <wqu@suse.com>
Thu, 4 Feb 2021 07:03:23 +0000 (15:03 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 16 Feb 2021 13:55:56 +0000 (14:55 +0100)
commitd64f5358a5be8966d9faea9812bb9b46e490e16f
tree217cd8af192675a31e05f658929c766d4686dc9b
parent4292b233d3cce5b2f9e57adbcd602e4d4df721e7
btrfs: make btrfs_submit_compressed_read() subpage compatible

For compressed read, we always submit page read using page size.  This
doesn't work well with subpage, as for subpage one page can contain
several sectors.  Such submission will read range out of what we want,
and cause problems.

Thankfully to make it subpage compatible, we only need to change how the
last page of the compressed extent is read.

Instead of always adding a full page to the compressed read bio, if we're
at the last page, calculate the size using compressed length, so that we
only add part of the range into the compressed read bio.

Since we are here, also change the PAGE_SIZE used in
lookup_extent_mapping() to sectorsize.
This modification won't cause any functional change, as
lookup_extent_mapping() can handle the case where the search range is
larger than found extent range.

Reviewed-by: Anand Jain <anand.jain@oracle.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/compression.c