From: Phillip Lougher <phillip@squashfs.org.uk>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
akpm@linux-foundation.org
Cc: Phillip Lougher <phillip@squashfs.org.uk>
Subject: [PATCH 2/4] squashfs: don't allocate read_page cache if SQUASHFS_FILE_DIRECT configured
Date: Sun, 29 Dec 2024 23:37:50 +0000 [thread overview]
Message-ID: <20241229233752.54481-3-phillip@squashfs.org.uk> (raw)
In-Reply-To: <20241229233752.54481-1-phillip@squashfs.org.uk>
If Squashfs has been configured to directly read datablocks into the
page cache (SQUASHFS_FILE_DIRECT), then the read_page cache is unnecessary.
This improvement is due to the following two commits, which added the
ability to read datablocks into the page cache when pages were
missing, enabling the fallback which used an intermediate buffer
to be removed.
commit f268eedddf359 ("squashfs: extend "page actor" to handle missing pages")
commit 1bb1a07afad97 ("squashfs: don't use intermediate buffer if pages missing")
This reduces the amount of memory used when mounting a filesystem by
block_size * maximum number of threads.
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
fs/squashfs/squashfs.h | 6 ++++++
fs/squashfs/super.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index 37f3518a804a..218868b20f16 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -14,6 +14,12 @@
#define WARNING(s, args...) pr_warn("SQUASHFS: "s, ## args)
+#ifdef CONFIG_SQUASHFS_FILE_CACHE
+#define SQUASHFS_READ_PAGES msblk->max_thread_num
+#else
+#define SQUASHFS_READ_PAGES 0
+#endif
+
/* block.c */
extern int squashfs_read_data(struct super_block *, u64, int, u64 *,
struct squashfs_page_actor *);
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index fedae8dbc5de..67c55fe32ce8 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -323,7 +323,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
/* Allocate read_page block */
msblk->read_page = squashfs_cache_init("data",
- msblk->max_thread_num, msblk->block_size);
+ SQUASHFS_READ_PAGES, msblk->block_size);
if (IS_ERR(msblk->read_page)) {
errorf(fc, "Failed to allocate read_page block");
err = PTR_ERR(msblk->read_page);
--
2.39.5
next prev parent reply other threads:[~2024-12-29 23:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-29 23:37 [PATCH 0/4] squashfs: reduce memory usage and update docs Phillip Lougher
2024-12-29 23:37 ` [PATCH 1/4] squashfs: make squashfs_cache_init() return ERR_PTR(-ENOMEM) Phillip Lougher
2024-12-29 23:37 ` Phillip Lougher [this message]
2024-12-29 23:37 ` [PATCH 3/4] Documentation: update the Squashfs filesystem documentation Phillip Lougher
2024-12-29 23:37 ` [PATCH 4/4] squashfs: update Kconfig information Phillip Lougher
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=20241229233752.54481-3-phillip@squashfs.org.uk \
--to=phillip@squashfs.org.uk \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®