Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp910666pxb; Sun, 10 Oct 2021 15:02:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfzmnwwvPJgDz5GKilskD1vxq+UKsYLxkZ7TzoBdcL+P/ts8WSR5uyKyrJddxzAOLThyVD X-Received: by 2002:a05:6402:5193:: with SMTP id q19mr36246646edd.397.1633903328612; Sun, 10 Oct 2021 15:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633903328; cv=none; d=google.com; s=arc-20160816; b=E4r1s+fYkth7B+SYj+yvFtDeaGUICOYfSXA8HBWnu5YOp0O0Q5NNdntEeYAx3RYuXw /lP5brGJlq5KetHbmpT1LqN0YYkHlj6qSd8NPtjDMfwJOm192/44L+tAIaPtYWptjy22 nlTqETnbrKsxsbr84JkKPWLK1QzJ4A1MRGmJ5rFfANN41kDsJ6/AbnmVLf6htNcrJDpg Cxh5tF41sYs6ZO7fi4gaVR7znTQhbRu8T7i1t751TN44IMFoZXPt5poly6AF3nIreeQz hjKG5P7ViwmKfCSwhb9wq8sbhQULnCCQ1JdtMw4sbzZNOw53HAhDfE9Ap9ZXDAZnCg52 4Fuw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nL3HogNKuFXvLNFy/aXeA0N9ZyIAEDpYOdex4lYU2Do=; b=QsqCoLREa20CsfgndqI7CY/+OpeSBB8l+ILFS1clyLN++GGzxO8HRvBTfEuXa+St+X wSyjbk6tuarNXOWm6YT5MMOFjXe7pipSS0WN9LyqeU0kXoi2zJ05uC2ej/SXeCWCihLG UY0rNM61z9ST1odmN+4GcBQ0fckuvNNjgfMYQOvWZnzzayvloASZsnb3vDdnUer3rTFE rdIjL9ctQSXKakusMcaZgK5NO+aqE+sxJbznu95cDjf6DpTY+/lqQM/bRc8pE8wmAzL1 mcLh1zBQa5CVhmJuGJFMmvTOUpaQYFe9qh4Mt0MMiEAzlbACho2YEqO57qM/HnV6sovV rh9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bmPJVWO5; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si9211063eda.546.2021.10.10.15.01.45; Sun, 10 Oct 2021 15:02:08 -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=@kernel.org header.s=k20201202 header.b=bmPJVWO5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbhJJVex (ORCPT + 99 others); Sun, 10 Oct 2021 17:34:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:58872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbhJJVeu (ORCPT ); Sun, 10 Oct 2021 17:34:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ACDCE610A4; Sun, 10 Oct 2021 21:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633901571; bh=EdTe58Z93d8p2+g9qWxuiL0mLrdMImIRJz89rzGB5nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bmPJVWO5fxg9eagNTae2c6AagTqrP0etuWyFdEakN0BmyBdrtrdVvtjQ3rtW/Vd0+ G2+yud6TCclWNpu8YBhwsgQyVfF7pCTU1hUgLo1CUHz+U3TAI2aUC+E6DfEJ8CZC2W cfBgcFNwmPnlx7y00En5CG7JG0QIR3zP2KUF52qrE9mmSOMS8ThNrXVhqMW75xa4Ix soDi4RsCr95lkCNTq+KIyVoBeK84wcVm0AiFo8N0CgwdO1zQN+2zp0f8DQKPShkTka IZFTQcP9K4bz9ileL5mLR3nYBVjvS6FvLaYvLEExiTX01Co6/6AJO43yf4IMgQtdOd 2I2e3c87VFbUA== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, LKML Cc: Lasse Collin , Chao Yu , Andrew Morton , Greg KH , Linus Torvalds , Gao Xiang Subject: [PATCH 6/7] erofs: rename some generic methods in decompressor Date: Mon, 11 Oct 2021 05:31:44 +0800 Message-Id: <20211010213145.17462-7-xiang@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211010213145.17462-1-xiang@kernel.org> References: <20211010213145.17462-1-xiang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Previously, some LZ4 methods were named with `generic'. However, while evaluating the effective LZMA approach, it seems they aren't quite generic at all (e.g. no need preparing dstpages for most LZMA cases.) Avoid such naming instead. Signed-off-by: Gao Xiang --- fs/erofs/decompressor.c | 65 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index a5bc4b1b7813..bceaa2b06b17 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -17,13 +17,8 @@ #endif struct z_erofs_decompressor { - /* - * if destpages have sparsed pages, fill them with bounce pages. - * it also check whether destpages indicate continuous physical memory. - */ - int (*prepare_destpages)(struct z_erofs_decompress_req *rq, - struct list_head *pagepool); - int (*decompress)(struct z_erofs_decompress_req *rq, u8 *out); + int (*decompress)(struct z_erofs_decompress_req *rq, + struct list_head *pagepool); char *name; }; @@ -63,8 +58,12 @@ int z_erofs_load_lz4_config(struct super_block *sb, return erofs_pcpubuf_growsize(sbi->lz4.max_pclusterblks); } -static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq, - struct list_head *pagepool) +/* + * Fill all gaps with bounce pages if it's a sparse page list. Also check if + * all physical pages are consecutive, which can be seen for moderate CR. + */ +static int z_erofs_lz4_prepare_dstpages(struct z_erofs_decompress_req *rq, + struct list_head *pagepool) { const unsigned int nr = PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; @@ -119,7 +118,7 @@ static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq, return kaddr ? 1 : 0; } -static void *z_erofs_handle_inplace_io(struct z_erofs_decompress_req *rq, +static void *z_erofs_lz4_handle_inplace_io(struct z_erofs_decompress_req *rq, void *inpage, unsigned int *inputmargin, int *maptype, bool support_0padding) { @@ -189,7 +188,8 @@ static void *z_erofs_handle_inplace_io(struct z_erofs_decompress_req *rq, return src; } -static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) +static int z_erofs_lz4_decompress_mem(struct z_erofs_decompress_req *rq, + u8 *out) { unsigned int inputmargin; u8 *headpage, *src; @@ -216,8 +216,8 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) } rq->inputsize -= inputmargin; - src = z_erofs_handle_inplace_io(rq, headpage, &inputmargin, &maptype, - support_0padding); + src = z_erofs_lz4_handle_inplace_io(rq, headpage, &inputmargin, + &maptype, support_0padding); if (IS_ERR(src)) return PTR_ERR(src); @@ -257,17 +257,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) return ret; } -static struct z_erofs_decompressor decompressors[] = { - [Z_EROFS_COMPRESSION_SHIFTED] = { - .name = "shifted" - }, - [Z_EROFS_COMPRESSION_LZ4] = { - .prepare_destpages = z_erofs_lz4_prepare_destpages, - .decompress = z_erofs_lz4_decompress, - .name = "lz4" - }, -}; - static void copy_from_pcpubuf(struct page **out, const char *dst, unsigned short pageofs_out, unsigned int outputsize) @@ -295,12 +284,11 @@ static void copy_from_pcpubuf(struct page **out, const char *dst, } } -static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, - struct list_head *pagepool) +static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, + struct list_head *pagepool) { const unsigned int nrpages_out = PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; - const struct z_erofs_decompressor *alg = decompressors + rq->alg; unsigned int dst_maptype; void *dst; int ret; @@ -325,7 +313,7 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, return PTR_ERR(dst); rq->inplace_io = false; - ret = alg->decompress(rq, dst); + ret = z_erofs_lz4_decompress_mem(rq, dst); if (!ret) copy_from_pcpubuf(rq->out, dst, rq->pageofs_out, rq->outputsize); @@ -336,7 +324,7 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, } /* general decoding path which can be used for all cases */ - ret = alg->prepare_destpages(rq, pagepool); + ret = z_erofs_lz4_prepare_dstpages(rq, pagepool); if (ret < 0) return ret; if (ret) { @@ -351,7 +339,7 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, dst_maptype = 2; dstmap_out: - ret = alg->decompress(rq, dst + rq->pageofs_out); + ret = z_erofs_lz4_decompress_mem(rq, dst + rq->pageofs_out); if (!dst_maptype) kunmap_atomic(dst); @@ -360,7 +348,7 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq, return ret; } -static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq, +static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq, struct list_head *pagepool) { const unsigned int nrpages_out = @@ -399,10 +387,19 @@ static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq, return 0; } +static struct z_erofs_decompressor decompressors[] = { + [Z_EROFS_COMPRESSION_SHIFTED] = { + .decompress = z_erofs_shifted_transform, + .name = "shifted" + }, + [Z_EROFS_COMPRESSION_LZ4] = { + .decompress = z_erofs_lz4_decompress, + .name = "lz4" + }, +}; + int z_erofs_decompress(struct z_erofs_decompress_req *rq, struct list_head *pagepool) { - if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED) - return z_erofs_shifted_transform(rq, pagepool); - return z_erofs_decompress_generic(rq, pagepool); + return decompressors[rq->alg].decompress(rq, pagepool); } -- 2.20.1