btrfs: compression: don't try to compress if we don't have enough pages
authorDavid Sterba <dsterba@suse.com>
Mon, 14 Jun 2021 10:45:18 +0000 (12:45 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 22 Jun 2021 12:11:57 +0000 (14:11 +0200)
commitf2165627319ffd33a6217275e5690b1ab5c45763
treee50aa6f191623b4a05bf4970425d80f7ae7ff19b
parent44365827cccc1441d4187509257e5276af133a49
btrfs: compression: don't try to compress if we don't have enough pages

The early check if we should attempt compression does not take into
account the number of input pages. It can happen that there's only one
page, eg. a tail page after some ranges of the BTRFS_MAX_UNCOMPRESSED
have been processed, or an isolated page that won't be converted to an
inline extent.

The single page would be compressed but a later check would drop it
again because the result size must be at least one block shorter than
the input. That can never work with just one page.

CC: stable@vger.kernel.org # 4.4+
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c