From: Yury Khmel <khmel@google.com>
To: Phillip Lougher <phillip@squashfs.org.uk>
Cc: linux-kernel@vger.kernel.org, Yury Khmel <khmel@google.com>
Subject: [PATCH] squashfs: Customize squashfs metadata cache size
Date: Mon, 8 Aug 2022 13:58:22 -0700 [thread overview]
Message-ID: <20220808205822.1350030-1-khmel@google.com> (raw)
It provides customization using module params.
In some use-cases reading metadata may take comparable time reading data
itself. Increasing the cache size in such cases helps to eliminate that
bottleneck and increase the overall performance.
Signed-off-by: Yury Khmel <khmel@google.com>
---
fs/squashfs/file.c | 4 ++--
fs/squashfs/squashfs_fs.h | 2 +-
fs/squashfs/super.c | 12 +++++++++++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 98e64fec75b7..fc8859741f59 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -207,7 +207,7 @@ static long long read_indexes(struct super_block *sb, int n,
* to distribute these over the length of the file, entry[0] maps index x,
* entry[1] maps index x + skip, entry[2] maps index x + 2 * skip, and so on.
* The larger the file, the greater the skip factor. The skip factor is
- * limited to the size of the metadata cache (SQUASHFS_CACHED_BLKS) to ensure
+ * limited to the size of the metadata cache (squashfs_cached_blks) to ensure
* the number of metadata blocks that need to be read fits into the cache.
* If the skip factor is limited in this way then the file will use multiple
* slots.
@@ -216,7 +216,7 @@ static inline int calculate_skip(u64 blocks)
{
u64 skip = blocks / ((SQUASHFS_META_ENTRIES + 1)
* SQUASHFS_META_INDEXES);
- return min((u64) SQUASHFS_CACHED_BLKS - 1, skip + 1);
+ return min((u64) squashfs_cached_blks() - 1, skip + 1);
}
diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h
index b3fdc8212c5f..b42aaf51de28 100644
--- a/fs/squashfs/squashfs_fs.h
+++ b/fs/squashfs/squashfs_fs.h
@@ -202,7 +202,7 @@ static inline int squashfs_block_size(__le32 raw)
#define SQUASHFS_XATTR_OFFSET(A) ((unsigned int) ((A) & 0xffff))
/* cached data constants for filesystem */
-#define SQUASHFS_CACHED_BLKS 8
+unsigned int squashfs_cached_blks(void);
/* meta index cache */
#define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int))
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 32565dafa7f3..939a5eb017c2 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -27,6 +27,7 @@
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/magic.h>
#include <linux/xattr.h>
@@ -85,6 +86,15 @@ static int squashfs_parse_param(struct fs_context *fc, struct fs_parameter *para
return 0;
}
+static unsigned int cached_blks = 8;
+module_param(cached_blks, uint, 0644);
+MODULE_PARM_DESC(cached_blks, "Metadata squashfs cache size");
+
+unsigned int squashfs_cached_blks(void)
+{
+ return cached_blks;
+}
+
static const struct squashfs_decompressor *supported_squashfs_filesystem(
struct fs_context *fc,
short major, short minor, short id)
@@ -246,7 +256,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
err = -ENOMEM;
msblk->block_cache = squashfs_cache_init("metadata",
- SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE);
+ squashfs_cached_blks(), SQUASHFS_METADATA_SIZE);
if (msblk->block_cache == NULL)
goto failed_mount;
--
2.37.1.559.g78731f0fdb-goog
reply other threads:[~2022-08-08 20:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220808205822.1350030-1-khmel@google.com \
--to=khmel@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@squashfs.org.uk \
/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.