From: pangliyuan Date: Tue, 10 Dec 2024 09:08:42 +0000 (+0800) Subject: Squashfs: don't allocate fragment caches more than fragments X-Git-Tag: v6.14-rc1~78^2~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78188dd1d24b9d4cd78431feaa13120cfa37ca6a;p=thirdparty%2Fkernel%2Flinux.git Squashfs: don't allocate fragment caches more than fragments Sometimes the actual number of fragments in image is between 0 and SQUASHFS_CACHED_FRAGMENTS, which cause additional fragment caches to be allocated. Sets the number of fragment caches to the minimum of fragments and SQUASHFS_CACHED_FRAGMENTS. Link: https://lkml.kernel.org/r/20241210090842.160853-1-pangliyuan1@huawei.com Signed-off-by: pangliyuan Reviewed-by: Phillip Lougher Cc: Signed-off-by: Andrew Morton --- diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 22e812808e5cf..269c6d61bc297 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -405,7 +405,7 @@ handle_fragments: goto check_directory_table; msblk->fragment_cache = squashfs_cache_init("fragment", - SQUASHFS_CACHED_FRAGMENTS, msblk->block_size); + min(SQUASHFS_CACHED_FRAGMENTS, fragments), msblk->block_size); if (msblk->fragment_cache == NULL) { err = -ENOMEM; goto failed_mount;