From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935719AbdJRHqw (ORCPT ); Wed, 18 Oct 2017 03:46:52 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8530 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932533AbdJRHqu (ORCPT ); Wed, 18 Oct 2017 03:46:50 -0400 From: Qixuan Wu To: , CC: , , , , , , , , , , , , Chen Jie Subject: [PATCH 1/2] Squashfs: Let the number of fragments cached configurable Date: Thu, 19 Oct 2017 07:50:59 +0800 Message-ID: <1508370660-6343-2-git-send-email-wuqixuan@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508370660-6343-1-git-send-email-wuqixuan@huawei.com> References: <1508370660-6343-1-git-send-email-wuqixuan@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.54.50] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.59E706E4.004F,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b09dd50e47917345acb3e9d58bc3c1b0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, squashfs fragments' cache size is only determined by config option CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE. Users have no way to change the value when they get the binary kernel. Now make it be configured during booting or inserting module. Signed-off-by: Qixuan Wu Signed-off-by: Chen Jie --- fs/squashfs/super.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index cf01e15..82f9e46 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "squashfs_fs.h" #include "squashfs_fs_sb.h" @@ -49,6 +50,37 @@ static struct file_system_type squashfs_fs_type; static const struct super_operations squashfs_super_ops; +static unsigned int squashfs_frags_cache_size = SQUASHFS_CACHED_FRAGMENTS; + +#ifndef MODULE +static int __init squashfs_frags_cachesize_setup(char *buf) +{ + unsigned int arg; + + if (!buf || kstrtouint(buf, 10, &arg) < 0) { + pr_err("Bad squashfs fragments' cache size, let it be %d\n", + SQUASHFS_CACHED_FRAGMENTS); + return 0; + } + + if (arg < 3 || arg > 99) { + pr_warn("Squashfs fragments' cache size should be in the range " + "of [3,99]. Let it be %d\n", SQUASHFS_CACHED_FRAGMENTS); + return 0; + } + + squashfs_frags_cache_size = arg; + + return 0; +} +early_param("squashfs.frags_cache_size", squashfs_frags_cachesize_setup); + +#else +module_param(squashfs_frags_cache_size, uint, 0444); +MODULE_PARM_DESC(squashfs_frags_cache_size, + "Squashfs fragments' cache size, it should be in the range of [3,99]"); +#endif + static const struct squashfs_decompressor *supported_squashfs_filesystem(short major, short minor, short id) { @@ -276,8 +308,17 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) if (fragments == 0) goto check_directory_table; + if ((squashfs_frags_cache_size < 3) + || (squashfs_frags_cache_size > 99)) { + ERROR("Fragments' cache size should be in the range of[3,99]." + "Let it be %d\n", SQUASHFS_CACHED_FRAGMENTS); + squashfs_frags_cache_size = SQUASHFS_CACHED_FRAGMENTS; + } + + TRACE("Fragments' cache size %d\n", squashfs_frags_cache_size); + msblk->fragment_cache = squashfs_cache_init("fragment", - SQUASHFS_CACHED_FRAGMENTS, msblk->block_size); + squashfs_frags_cache_size, msblk->block_size); if (msblk->fragment_cache == NULL) { err = -ENOMEM; goto failed_mount; -- 2.7.4