From bc7ecb27946e3f478f34ec5cecafe5390635e07b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 9 Sep 2021 15:33:21 +0200 Subject: [PATCH] 4.14-stable patches added patches: revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch --- ...mpress-if-we-don-t-have-enough-pages.patch | 61 +++++++++++++++++++ queue-4.14/series | 1 + 2 files changed, 62 insertions(+) create mode 100644 queue-4.14/revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch diff --git a/queue-4.14/revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch b/queue-4.14/revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch new file mode 100644 index 00000000000..c1e2664a193 --- /dev/null +++ b/queue-4.14/revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch @@ -0,0 +1,61 @@ +From 4e9655763b82a91e4c341835bb504a2b1590f984 Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Wed, 25 Aug 2021 13:41:42 +0800 +Subject: Revert "btrfs: compression: don't try to compress if we don't have enough pages" + +From: Qu Wenruo + +commit 4e9655763b82a91e4c341835bb504a2b1590f984 upstream. + +This reverts commit f2165627319ffd33a6217275e5690b1ab5c45763. + +[BUG] +It's no longer possible to create compressed inline extent after commit +f2165627319f ("btrfs: compression: don't try to compress if we don't +have enough pages"). + +[CAUSE] +For compression code, there are several possible reasons we have a range +that needs to be compressed while it's no more than one page. + +- Compressed inline write + The data is always smaller than one sector and the test lacks the + condition to properly recognize a non-inline extent. + +- Compressed subpage write + For the incoming subpage compressed write support, we require page + alignment of the delalloc range. + And for 64K page size, we can compress just one page into smaller + sectors. + +For those reasons, the requirement for the data to be more than one page +is not correct, and is already causing regression for compressed inline +data writeback. The idea of skipping one page to avoid wasting CPU time +could be revisited in the future. + +[FIX] +Fix it by reverting the offending commit. + +Reported-by: Zygo Blaxell +Link: https://lore.kernel.org/linux-btrfs/afa2742.c084f5d6.17b6b08dffc@tnonline.net +Fixes: f2165627319f ("btrfs: compression: don't try to compress if we don't have enough pages") +CC: stable@vger.kernel.org # 4.4+ +Signed-off-by: Qu Wenruo +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/inode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -540,7 +540,7 @@ again: + * inode has not been flagged as nocompress. This flag can + * change at any time if we discover bad compression ratios. + */ +- if (nr_pages > 1 && inode_need_compress(inode, start, end)) { ++ if (inode_need_compress(inode, start, end)) { + WARN_ON(pages); + pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS); + if (!pages) { diff --git a/queue-4.14/series b/queue-4.14/series index 8e2ab3a2c2c..ec5a2cb6ef2 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -22,3 +22,4 @@ powerpc-module64-fix-comment-in-r_ppc64_entry-handling.patch powerpc-boot-delete-unneeded-.globl-_zimage_start.patch net-ll_temac-remove-left-over-debug-message.patch mm-page_alloc-speed-up-the-iteration-of-max_order.patch +revert-btrfs-compression-don-t-try-to-compress-if-we-don-t-have-enough-pages.patch -- 2.47.3