Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] Revert "btrfs: compression: don't try to compress if we don't have enough pages"
@ 2021-08-25  5:41 Qu Wenruo
  2021-08-25 11:55 ` David Sterba
  2021-08-27  3:41 ` Wang Yugui
  0 siblings, 2 replies; 10+ messages in thread
From: Qu Wenruo @ 2021-08-25  5:41 UTC (permalink / raw)
  To: linux-btrfs

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.

- 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.

[FIX]
Fix it by reverting the offending commit.

Fixes: f2165627319f ("btrfs: compression: don't try to compress if we don't have enough pages")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2aa9646bce56..2b7fe98adec2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -632,7 +632,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	 * 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(BTRFS_I(inode), start, end)) {
+	if (inode_need_compress(BTRFS_I(inode), start, end)) {
 		WARN_ON(pages);
 		pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
 		if (!pages) {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-27 10:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-25  5:41 [PATCH] Revert "btrfs: compression: don't try to compress if we don't have enough pages" Qu Wenruo
2021-08-25 11:55 ` David Sterba
2021-08-25 12:06   ` Qu Wenruo
2021-08-25 13:04     ` David Sterba
2021-08-27  3:41 ` Wang Yugui
2021-08-27  4:03   ` Wang Yugui
2021-08-27  5:04   ` Qu Wenruo
2021-08-27  8:35     ` David Sterba
2021-08-27  9:31       ` Qu Wenruo
2021-08-27 10:12         ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox