libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory
authortsoome <tsoome@FreeBSD.org>
Thu, 6 Apr 2017 20:12:39 +0000 (20:12 +0000)
committertsoome <tsoome@FreeBSD.org>
Thu, 6 Apr 2017 20:12:39 +0000 (20:12 +0000)
commit4541a7b704e46907ca71f620f42f43503432c561
tree1fcf8ca6d75f65e43acbcbde037eda53d4fa4f6e
parent4c6181475a4d7bf2a21c525421a454d6a1b5d154
libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory

Current implementation of dosfs in libstand reads full File Allocation Table to
the RAM in the initialization code. In the extreme case of FAT32 filesystem,
this structure will take up to 256-1024 Mb of loader memory, depending on the
cluster size.

Proposed patch reduces libstands/dosfs memory requirements to 128 Kb for all
variants of dosfs filesystem. For FAT12 and FAT16 filesystems, File Allocation
Table is cached in full, as before. For FAT32, File Allocation Table is broken
into the equal blocks of 128 Kilobytes (32768 entries), and only current block
is cached.

Because per-filesystem context is now small, global FAT cache (for all
instances of dosfs filesystem) is replaced by local per-instance cache.

Submitted by: Mikhail.Kupchik_gmail.com
Reviewed by: tsoome, allanjude
Differential Revision: https://reviews.freebsd.org/D9547
lib/libstand/dosfs.c
lib/libstand/dosfs.h