From patchwork Fri Feb 17 18:06:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 9580483 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 688D16042F for ; Fri, 17 Feb 2017 18:06:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BF4C28768 for ; Fri, 17 Feb 2017 18:06:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50DFF2876B; Fri, 17 Feb 2017 18:06:36 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 C064E28768 for ; Fri, 17 Feb 2017 18:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934474AbdBQSGd (ORCPT ); Fri, 17 Feb 2017 13:06:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:46465 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934096AbdBQSGc (ORCPT ); Fri, 17 Feb 2017 13:06:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 52477AC17 for ; Fri, 17 Feb 2017 18:06:31 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 037B5DA98A; Fri, 17 Feb 2017 19:06:01 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 5/5] btrfs: derive maximum output size in the compression implementation Date: Fri, 17 Feb 2017 19:06:01 +0100 Message-Id: X-Mailer: git-send-email 2.10.1 In-Reply-To: References: 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 The value of max_out can be calculated from the parameters passed to the compressors, which is number of pages and the page size, and we don't have to needlessly pass it around. Signed-off-by: David Sterba --- fs/btrfs/compression.c | 6 ++---- fs/btrfs/compression.h | 6 ++---- fs/btrfs/inode.c | 3 +-- fs/btrfs/lzo.c | 4 ++-- fs/btrfs/zlib.c | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 3a05c7576a7f..75e4e61d338b 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -932,8 +932,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, u64 start, struct page **pages, unsigned long *out_pages, unsigned long *total_in, - unsigned long *total_out, - unsigned long max_out) + unsigned long *total_out) { struct list_head *workspace; int ret; @@ -943,8 +942,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, ret = btrfs_compress_op[type-1]->compress_pages(workspace, mapping, start, pages, out_pages, - total_in, total_out, - max_out); + total_in, total_out); free_workspace(type, workspace); return ret; } diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index c9d7e552cfa8..0f53410f755c 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -41,8 +41,7 @@ int btrfs_compress_pages(int type, struct address_space *mapping, u64 start, struct page **pages, unsigned long *out_pages, unsigned long *total_in, - unsigned long *total_out, - unsigned long max_out); + unsigned long *total_out); int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page, unsigned long start_byte, size_t srclen, size_t destlen); int btrfs_decompress_buf2page(char *buf, unsigned long buf_start, @@ -76,8 +75,7 @@ struct btrfs_compress_op { struct page **pages, unsigned long *out_pages, unsigned long *total_in, - unsigned long *total_out, - unsigned long max_out); + unsigned long *total_out); int (*decompress_bio)(struct list_head *workspace, struct page **pages_in, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9533a516bace..e9d589944d23 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -509,8 +509,7 @@ static noinline void compress_file_range(struct inode *inode, pages, &nr_pages, &total_in, - &total_compressed, - BTRFS_MAX_COMPRESSED); + &total_compressed); if (!ret) { unsigned long offset = total_compressed & diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 72b07f0bb80a..23402dde8b0a 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -90,8 +90,7 @@ static int lzo_compress_pages(struct list_head *ws, struct page **pages, unsigned long *out_pages, unsigned long *total_in, - unsigned long *total_out, - unsigned long max_out) + unsigned long *total_out) { struct workspace *workspace = list_entry(ws, struct workspace, list); int ret = 0; @@ -103,6 +102,7 @@ static int lzo_compress_pages(struct list_head *ws, unsigned long bytes_left; unsigned long len = *total_out; unsigned long nr_dest_pages = *out_pages; + const unsigned long max_out = nr_dest_pages * PAGE_SIZE; size_t in_len; size_t out_len; char *buf; diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index e7f2020f8ee7..135b10823c6d 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -77,8 +77,7 @@ static int zlib_compress_pages(struct list_head *ws, struct page **pages, unsigned long *out_pages, unsigned long *total_in, - unsigned long *total_out, - unsigned long max_out) + unsigned long *total_out) { struct workspace *workspace = list_entry(ws, struct workspace, list); int ret; @@ -90,6 +89,7 @@ static int zlib_compress_pages(struct list_head *ws, unsigned long bytes_left; unsigned long len = *total_out; unsigned long nr_dest_pages = *out_pages; + const unsigned long max_out = nr_dest_pages * PAGE_SIZE; *out_pages = 0; *total_out = 0;