Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1420091pxb; Fri, 10 Sep 2021 05:40:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfoBK1sawHFvV0m9vcMuGqbFtQ3/v0vXx3vjzRFkCWFWdJPPHrVt1NaOKpwTj/bSj8wZk7 X-Received: by 2002:a05:6e02:1a0e:: with SMTP id s14mr6134817ild.49.1631277627365; Fri, 10 Sep 2021 05:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631277627; cv=none; d=google.com; s=arc-20160816; b=r+aBy+HStD3nZe2eNL8cXMCizpwJdueLC9o580lXj8IPuLpPKOSEtSJ5sv+1cKPkAG 5k+0qUv4DIf3jeDLLEvbk7EsZFMxS/cMaXJMGG+kLx1V8kvYsF9YabRNwCXntmJh+ecW c1KYgnkK/N+lVJAmoWS08VQRODfjGVmOZUG8CPhfqapkZwD3fHZja7t3AQYZeixDSqrJ 8K0VLd/ztbZvKD3sVBc3V2+usFWsk0r4bXI4mn6R2IrHjfIh1c9V/n/jdoyELs3laOVB tI/2u3fg88pDgDMsBSuvhEi8E1NrkZXfP5O8Z0h4H+bub9s3KfmAN9GN+bmaf5k1OLt2 JK3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DyycI4lx9bXyfx5q8AaARFzVSYjXj5qQxhK4+q1KA8Q=; b=UrMkF64xYYqmdovU5jhoVsaDVi/tI8mSs3WmnPSxhf0aqfV4iLiYVtpTF4T1Z8R7EE 6y4kChy7DjXzgZtdyfbJ12ATxUPF3zwhU5i2Oat/b7RnbXINrVEG1ysVeGTyszWnVF/T mj+lQUtijOmtUNjsSqgbB3S5kXogNmG8Us6tPawluijoy1FIxaU1iG9ftZNOK0gS3Rcs WtCQqfNnhnB4DxTurslJ0yYxG7j1nCnuTmTn/HnZSHybnR9eW+v/Im1cs9FuVblwankj YS6ro9f1xKr34ztLYcL1zfzHXUEItkM5oV4jBzGiuJ8YF0mSgDSEtee9MavBqMmP6wcO nmoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQujuAl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si4210214iot.49.2021.09.10.05.40.15; Fri, 10 Sep 2021 05:40:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQujuAl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234513AbhIJMjB (ORCPT + 99 others); Fri, 10 Sep 2021 08:39:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:55078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbhIJMhN (ORCPT ); Fri, 10 Sep 2021 08:37:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43C0361208; Fri, 10 Sep 2021 12:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631277351; bh=/v4v22CM7U+Gp/QjXQesJzBod3HEdjwsCmkVXAzn4S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQujuAl5oy2u1OMOmjwYPcbm0pxxTH+dIsbzi1nyDYUNAbpKy2ydcNd2Wl6l8auhX mZ9cTgfQCLTRvkdrK5wFIYHdKUjHK3nefromP20kfjekeAfe//wAS67p7DXasZ1etP oFolxL3LrwgsEpHgWqMHTbTZC6VSZedKodRibONc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zygo Blaxell , Qu Wenruo , David Sterba Subject: [PATCH 5.4 30/37] Revert "btrfs: compression: dont try to compress if we dont have enough pages" Date: Fri, 10 Sep 2021 14:30:33 +0200 Message-Id: <20210910122918.156425925@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210910122917.149278545@linuxfoundation.org> References: <20210910122917.149278545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 @@ -543,7 +543,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) {