All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qixuan Wu <wuqixuan@huawei.com>
To: <phillip@squashfs.org.uk>, <corbet@lwn.net>
Cc: <paulmck@linux.vnet.ibm.com>, <akpm@linux-foundation.org>,
	<tglx@linutronix.de>, <cdall@linaro.org>, <mingo@kernel.org>,
	<marc.zyngier@arm.com>, <mchehab@kernel.org>,
	<zohar@linux.vnet.ibm.com>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<squashfs-devel@lists.sourceforge.net>, <wuqixuan@huawei.com>,
	Chen Jie <chenjie6@huawei.com>
Subject: [PATCH 1/2] Squashfs: Let the number of fragments cached configurable
Date: Thu, 19 Oct 2017 07:50:59 +0800	[thread overview]
Message-ID: <1508370660-6343-2-git-send-email-wuqixuan@huawei.com> (raw)
In-Reply-To: <1508370660-6343-1-git-send-email-wuqixuan@huawei.com>

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@huawei.com>
Signed-off-by: Chen Jie <chenjie6@huawei.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

  reply	other threads:[~2017-10-18  7:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 23:50 [PATCH 0/2] Make squashfs fragments' cache size more configurable Qixuan Wu
2017-10-18 23:50 ` Qixuan Wu [this message]
2017-10-18 23:51 ` [PATCH 2/2] Documentation/kernel-parameters.txt: Add kernel parameter of squashfs fragments' cache size Qixuan Wu
2017-10-20  6:18 ` [PATCH 0/2] Make squashfs fragments' cache size more configurable Phillip Lougher
2017-10-20 10:45   ` Wuqixuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508370660-6343-2-git-send-email-wuqixuan@huawei.com \
    --to=wuqixuan@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=cdall@linaro.org \
    --cc=chenjie6@huawei.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mchehab@kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=phillip@squashfs.org.uk \
    --cc=squashfs-devel@lists.sourceforge.net \
    --cc=tglx@linutronix.de \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.