Re: [PATCH v2 17/22] Squashfs: don't store large export table indexes in memory
From: Phillip Lougher
Date: Sun Nov 22 2026 - 22:24:33 EST
On Thu, 12 Nov 2026 11:09:27 -0800
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, 11 Nov 2026 23:43:57 +0000 Phillip Lougher <phillip@xxxxxxxxxxxxxxx> wrote:
>
> > When mounting a Squashfs filesystem, the code reads the entire
> > export table indexes into memory. Their size is determined by the
> > number of inodes in the filesystem. For the maximum inode
> > count of 2^32, this will allocate and read 32 MiB.
> >
> > This is an excessive and unnecessary amount of memory because the
> > indexes do not need to be read into memory in their entirety. In
> > addition kmalloc() is used to allocate memory, and this can fail when
> > large amounts of memory are requested. Kmalloc() on modern kernels is
> > usually limited to 4096 KiB. If panic-on-warn is set, then failure to
> > allocate memory will result in a kernel panic.
> >
> > This commit uses a 4 page cache if the size of the export table indexes
> > are 4 pages in size or larger. A simple and fast lookup array is
> > retained where the total index size is less than 4 pages in size, which
> > is the vast majority of Squashfs filesystems.
>
> Thanks. This patch didn't anticipate the presence of Christian's
> "squashfs: identify device in mount errors". To make life easier I've
> staged Christian's patch behind this 22-patch series.
>
> This required a bit of rework of Christian's patch. While in there I
> filled in a few more places which needed Christian's treatment and I
> made the whole thing more 80-column friendly where that made sense.
>
> Please check:
Thanks. It looks good to me.
Phillip