Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp170293pxf; Wed, 31 Mar 2021 20:35:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjAUzqaCeApMTjkoqyCJURcbD6Dv8AW8aYDoJ6Cy9lqDbikk0L7lChbcDHcD62Tc9N2rVe X-Received: by 2002:a17:906:3b48:: with SMTP id h8mr6890542ejf.261.1617248126804; Wed, 31 Mar 2021 20:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617248126; cv=none; d=google.com; s=arc-20160816; b=mFEGkJfILDiXJYZnAPwx622azaJMtV6PyIjA5xZXr9Hmc5h7wSUGf1CDvRFLzCppI2 qHG3yfK9vgvjEaWqQs5huhlbnOmXw7AAmU0dJJmEgzdP9iAshzZy5sA0kCAT6fh51Itm imR31APF+COGR6Lkt6q9peIE9Yd9HzlPOz+j3SdNMM7/gcSnKfb/ucpRU2YvwtXlpIdk 8iMOE7x5Zh+RjWvqJhwYrKBcNVLkXyvEc9rwe8qp5Oa+Mhrrk+PMFlOJ/R54/NZ52IPC zkZHZKMvBUBNsUXLnNrWhc8UaBsQB/cRJxcIMDFp3pwFkZ/ioTVTnyM3QMMjPIp7e8+C LhXA== 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=3R1xhPrnPHD3kS4ZMACrkPZh2W/KwmHNvT4VFLspK4k=; b=NtX64BCwvWXk0lH16/BOF7rrclZ6y5Kaw/BZHBIODtMqIszEuoVUW0oPmD+eDRpb/w bI9jabhv5lc+Lf9jy9KegtMZPEvYrWxB6Wu89zOJpaLZ/gU7Jc5Eu6CrpaUxgb2wNgl4 RDIJjSj03qPEgEB5e3VC4IXke8ZovKnVmuI/Ln/OoBrdf6d0kEByQ8bVd8V+T6hL1KI2 38ZkNowFpgtlmy0LS4DJ1todpg8R19U4kpsJdDKK/63c+VGt3EXNziZLYrJ4mYtIWbHP WoAUP6OtCririP7rAFL+xk4zRQ0pxvcbdkm/82PvspEobVWK+DcGidTsG3RjwgLeuEfb ZuZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WH4G9nIv; 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 d11si3418152ede.364.2021.03.31.20.35.05; Wed, 31 Mar 2021 20:35:26 -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=WH4G9nIv; 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 S233491AbhDADav (ORCPT + 99 others); Wed, 31 Mar 2021 23:30:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:37824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233427AbhDADaQ (ORCPT ); Wed, 31 Mar 2021 23:30:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50A91610D2; Thu, 1 Apr 2021 03:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617247815; bh=QEUBS2zczij3ArtTdghjLRfheNOhvp84S+Ht6X8gywM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WH4G9nIv93zRV3ciwcmNXinfPXtcE+6uD6mBMwLHmuhMX7PDfSscq2+hq20okXjq2 Ets5ds9Q7aKvMMwvR8TpHSk4po54iaf6Kah3RemTNBLfEyZK87JCpV3kBQPINe3bP7 qH+ymFKaeuHP/MpztC9gqZapSzShBmm0/RHCMJ2BsqdTJZkitv2fzVF8+l95QwWd9E QX48rWX95ltT8JwLFhVJWAeeS7vHgZXL1k4ktYMsrjVEvoPOWNwwXZgr9VKL8IsoFJ Fb0W/ywAuKYzY4c9StnNGXqO4KisY5eBsCNK0jQsgsVZa21KxWjPj+6MiDi0meJQSX L4ZhlXVAuJI0Q== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Chao Yu Cc: LKML , Gao Xiang Subject: [PATCH v2 06/10] erofs: adjust per-CPU buffers according to max_pclusterblks Date: Thu, 1 Apr 2021 11:29:50 +0800 Message-Id: <20210401032954.20555-7-xiang@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210401032954.20555-1-xiang@kernel.org> References: <20210401032954.20555-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 Adjust per-CPU buffers on demand since big pcluster definition is available. Also, bail out unsupported pcluster size according to Z_EROFS_PCLUSTER_MAX_SIZE. Signed-off-by: Gao Xiang --- fs/erofs/decompressor.c | 16 ++++++++++++---- fs/erofs/internal.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index fb4838c0f0df..5d9f9dbd3681 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -32,6 +32,7 @@ int z_erofs_load_lz4_config(struct super_block *sb, struct erofs_super_block *dsb, struct z_erofs_lz4_cfgs *lz4, int size) { + struct erofs_sb_info *sbi = EROFS_SB(sb); u16 distance; if (lz4) { @@ -40,16 +41,23 @@ int z_erofs_load_lz4_config(struct super_block *sb, return -EINVAL; } distance = le16_to_cpu(lz4->max_distance); + + sbi->lz4.max_pclusterblks = le16_to_cpu(lz4->max_pclusterblks); + if (sbi->lz4.max_pclusterblks > + Z_EROFS_PCLUSTER_MAX_SIZE / EROFS_BLKSIZ) { + erofs_err(sb, "too large lz4 pcluster blocks %u", + sbi->lz4.max_pclusterblks); + return -EINVAL; + } } else { distance = le16_to_cpu(dsb->u1.lz4_max_distance); + sbi->lz4.max_pclusterblks = 1; } - EROFS_SB(sb)->lz4.max_distance_pages = distance ? + sbi->lz4.max_distance_pages = distance ? DIV_ROUND_UP(distance, PAGE_SIZE) + 1 : LZ4_MAX_DISTANCE_PAGES; - - /* TODO: use max pclusterblks after bigpcluster is enabled */ - return erofs_pcpubuf_growsize(1); + return erofs_pcpubuf_growsize(sbi->lz4.max_pclusterblks); } static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq, diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index c4b3938a7e56..f1305af50f67 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -63,6 +63,8 @@ struct erofs_fs_context { struct erofs_sb_lz4_info { /* # of pages needed for EROFS lz4 rolling decompression */ u16 max_distance_pages; + /* maximum possible blocks for pclusters in the filesystem */ + u16 max_pclusterblks; }; struct erofs_sb_info { -- 2.20.1