btrfs: compression: add error handling for missed page cache
authorQu Wenruo <wqu@suse.com>
Mon, 29 Jan 2024 09:46:06 +0000 (20:16 +1030)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:02 +0000 (21:31 +0200)
commit6de3595473b0bae11102ef6db40e6f2334f13ed2
treeeda606a551da51c5cb017e94ecb6683cc25a332a
parent5d6f0e9890ed857a0bafb7fa73c85bf49bbe1e14
btrfs: compression: add error handling for missed page cache

For all the supported compression algorithms, the compression path would
always need to grab the page cache, then do the compression.

Normally we would get a page reference without any problem, since the
write path should have already locked the pages in the write range.
For the sake of error handling, we should handle the page cache miss
case.

Adds a common wrapper, btrfs_compress_find_get_page(), which calls
find_get_page(), and do the error handling along with an error message.

Callers inside compression path would only need to call
btrfs_compress_find_get_page(), and error out if it returned any error.

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
fs/btrfs/compression.h
fs/btrfs/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c