From patchwork Mon May 29 23:18:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9753713 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 69173603F7 for ; Mon, 29 May 2017 23:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52C4126E40 for ; Mon, 29 May 2017 23:18:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47EFB26E5D; Mon, 29 May 2017 23:18:44 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 ECB5A26E51 for ; Mon, 29 May 2017 23:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbdE2XSf (ORCPT ); Mon, 29 May 2017 19:18:35 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33331 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbdE2XSe (ORCPT ); Mon, 29 May 2017 19:18:34 -0400 Received: by mail-wm0-f67.google.com with SMTP id b84so21118087wmh.0 for ; Mon, 29 May 2017 16:18:33 -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:in-reply-to:references; bh=DVFiBuALdjf0a+DLo3uW/FI30sGR2NUg3kw238jBjFY=; b=AxvQdalonnj2Ct4z4771oZRS9rV0zkxFQQ9j3lWiEN115YLMz2C7Xq9HBq4m8L5pkl 9zeV6KkOy4Tw8ABgSWfNoUNc70vXyFaqiVs97hZzbUXfMWmPn9Zf+kyt5tpTbFQV4qyV OQeLKevSbJsGWV6mcZMRbGHNEGVoEvTzA/Xw0laPIie08Mfn3VR9OYIv7eFyYY6vwD0e E6gK/9utdpQBcMil/0a7SYJJrLaAvwg72GAaEN7Aw3029ojlnieUr7l72yO25OSRDHW3 O2sbMml/fIB7Xl6GnTJIyseoFjXUfmT+pHSxQbwzwKZLcazQk3ldS01RyV6efG7RUVlv x1sQ== 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:in-reply-to :references; bh=DVFiBuALdjf0a+DLo3uW/FI30sGR2NUg3kw238jBjFY=; b=KWlUrGMKanV3YHSoybkgqHSwospXRRlHF66hcQ3BdqspJ97CVCxpFHJbtyGc66GR2d uuuaF4+NwepUoxVMyBs15K9EibFnAl4gj8CbaKjM1usCFiypMREKg219Lf6/SRg+bA5p unPMIEKIF3ee1V7h/5a30sHw10sFI2AC7wfe9YrpMcD/Bjdfi+tR30YTfcVTsexT8HeZ 9w6/hNDh/UYNlNSTzJD1azzu52i1fdkRUMGZsO2hUzZlxVMbFLQBNsuorRSiaxitWT/U jTnw9UA04Ib2hQLcIabFOChv9RIbikQNAkrTr32m/0eZsgPqxa59YhGyF+4gm0WPH6a5 aReA== X-Gm-Message-State: AODbwcBzvEEab4Lr3lp/Kv6AFMraqeF43cjHuHUNfKuqwaMVptOhbVNA b0UBuMKXbTUaVC67 X-Received: by 10.28.99.9 with SMTP id x9mr21776121wmb.102.1496099912657; Mon, 29 May 2017 16:18:32 -0700 (PDT) Received: from localhost.localdomain ([91.215.176.151]) by smtp.gmail.com with ESMTPSA id l190sm15380953wmb.18.2017.05.29.16.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 May 2017 16:18:32 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH v5 2/2] Btrfs: compression must free at least one sector size Date: Tue, 30 May 2017 02:18:05 +0300 Message-Id: <20170529231805.4797-3-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170529231805.4797-1-nefelim4ag@gmail.com> References: <20170529231805.4797-1-nefelim4ag@gmail.com> 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 --- fs/btrfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 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..2793007b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -609,9 +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) { + if (total_compressed + blocksize > total_in) { will_compress = 0; } else { num_bytes = total_in;