[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1508370660-6343-2-git-send-email-wuqixuan@huawei.com>
Date: Thu, 19 Oct 2017 07:50:59 +0800
From: Qixuan Wu <wuqixuan@...wei.com>
To: <phillip@...ashfs.org.uk>, <corbet@....net>
CC: <paulmck@...ux.vnet.ibm.com>, <akpm@...ux-foundation.org>,
<tglx@...utronix.de>, <cdall@...aro.org>, <mingo@...nel.org>,
<marc.zyngier@....com>, <mchehab@...nel.org>,
<zohar@...ux.vnet.ibm.com>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<squashfs-devel@...ts.sourceforge.net>, <wuqixuan@...wei.com>,
Chen Jie <chenjie6@...wei.com>
Subject: [PATCH 1/2] Squashfs: Let the number of fragments cached configurable
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 <wuqixuan@...wei.com>
Signed-off-by: Chen Jie <chenjie6@...wei.com>
---
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 <linux/module.h>
#include <linux/magic.h>
#include <linux/xattr.h>
+#include <linux/ctype.h>
#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
Powered by blists - more mailing lists