From patchwork Tue Jun 6 11:41:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9768715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 38B7260364 for ; Tue, 6 Jun 2017 11:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 267732846F for ; Tue, 6 Jun 2017 11:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19BB328498; Tue, 6 Jun 2017 11:41:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BC502846F for ; Tue, 6 Jun 2017 11:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751422AbdFFLl2 (ORCPT ); Tue, 6 Jun 2017 07:41:28 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34747 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbdFFLl1 (ORCPT ); Tue, 6 Jun 2017 07:41:27 -0400 Received: by mail-wm0-f65.google.com with SMTP id 70so9949368wme.1 for ; Tue, 06 Jun 2017 04:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4zl8JnLt2+LhbPo4q1wW99AWyopUulT3+UsiumaEm7I=; b=t70miy/kk8P4sf0ZszCMqr7q8BPguaueD5ZevPq+WPjw7FOmEk89ED629xehP+m6Mx lMtZEZq4uGS1nZN2C5ACvRUDgyUXzCgcIW8/rRVGGOT7RyyK6LhkM2AsR8UnsbZ3R0te 33KrunVO4deyi60YynOeMxHSZaSwW3XDp/QS65nfAvrijsDAKlaXJD7sN2aTIKMt6C1m Pgzn9MW3H2qwKCaKMyeJrCWHXi/EFfHOuVULYeaREByFYNf3XyjfisjCW6I3Loo0HPfl ZZgrIi96jYHtzZx3Gw3/tkbXkJylmbIrxvYh+XNXWLPXLin421dkS4UTji1r2N7uY2R9 xuEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4zl8JnLt2+LhbPo4q1wW99AWyopUulT3+UsiumaEm7I=; b=mBurbPnMHOF3ovoArqcFxc4FoT59/mrtXcjQnYC+xCZ+vY3Pmvl/j2OmVlqUbAvcwn E1GreGwJ3+Q6RRByz+OkQyyFX/9eywDte8InEr8a2YHgzwotVNGHk0Brc1NdM6qxCGau dxq6Vtap2QDEr8wYSTYg8QEx89ZoMiFSlA1wchrGDqQ74h7rFU8ThtV8a9HCrZkknyZg QUacR0DuTqbIZt4ghbu3qpoD5VBjPGHTrHFCW5ZClSCSD/UlTcJwajn10utZUWAiKOYm HCjYfjpt71I7kiGKleeyo4Wh+IQCxiHdAnU/00PHSDvFyaYknrFWyfUOERaKZ3Hbih1p bfYw== X-Gm-Message-State: AODbwcA61tfpJTx76sXhgV6UUt3V0Id+YJJWj14XTujyP6lQ0u9sJr3g t8dyuOKEjTj7IiWJ X-Received: by 10.28.175.136 with SMTP id y130mr12000968wme.112.1496749285423; Tue, 06 Jun 2017 04:41:25 -0700 (PDT) Received: from titovetst-beplan.itransition.corp ([93.171.6.183]) by smtp.gmail.com with ESMTPSA id 49sm9843431wrz.8.2017.06.06.04.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 04:41:24 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets , David Sterba Subject: [PATCH v6] Btrfs: compression must free at least one sector size Date: Tue, 6 Jun 2017 14:41:15 +0300 Message-Id: <20170606114115.21602-1-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.13.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Btrfs already skip store of data where compression didn't free at least one byte. Let's make logic better and make check that compression free at least one sector size because in another case it useless to store this data compressed Signed-off-by: Timofey Titovets Cc: David Sterba Reviewed-by: David Sterba --- fs/btrfs/inode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 17cbe930..7646f46b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -609,11 +609,10 @@ static noinline void compress_file_range(struct inode *inode, /* * one last check to make sure the compression is really a * win, compare the page count read with the blocks on disk + * compression must free at least one sector size */ total_in = ALIGN(total_in, PAGE_SIZE); - if (total_compressed >= total_in) { - will_compress = 0; - } else { + if (total_compressed + blocksize <= total_in) { num_bytes = total_in; *num_added += 1;