[LEDE-DEV] [PATCH] include: image.mk: ext4: double the default inode counter

David Lang david at lang.hm
Tue Nov 22 06:41:36 PST 2016


On Tue, 22 Nov 2016, Jo-Philipp Wich wrote:

>> 1)
>> detect via makefile if PARTITION is small and autoadjust BLOCKSIZE
>> (if not given)
>
> iirc the blocksize setting is a choice menu, so it is always defined.
>
>> 2)
>> set BLOCKSIZE default to 1K via x86/UML-Makefile
>
> It was explicitly raised to 4k for x86 to reduce wear on MMC storage
> which is common on non-virtual x86 targets (Alix/APU boards etc.)
>
>> 3)
>> the first approach by changing 'make_ext4fs.c'
>
> That would be preferred. Our make_ext4fs variant is forked anyway
> already so there is no upstream we need to adhere to.

changing the blocksize doesn't really address the problem of too few inodes, 
except indirectly in that the default number of inodes is calculated from the 
number of blocks on the filesystem.

In the case of LEDE, we tend to have fewer large files on the ext4 partition 
than most distros, for a couple of reasons. First we are always concerned with 
space, so we tend to have smaller files to start with, and then we tend to have 
most of the larger files in a system on jffs2/squashfs with ext4 being used only 
to track the config files (which tend to be tiny)

Setting these involve trade-offs that don't matter much at the typical desktop 
drive size, but matter a lot when space is really tight.

on a 16M filesystem, 1024 inodes means that you are assuming that your average 
file size is going to be ~16K, that's larger than what we are going to use on an 
overlay filesystem. with a 4K block size, your minimum filesize is effectivly 4K

However, on a very large filesystem, you are probably going to be filling that 
space with large files (audio files at multiple MB each, video files at multiple 
GB each, iso images at multiple GB, etc), so having a small blocksize and an 
inode for every 4K of disk space ends up wasting a fair amount of space (a 4T 
filesystem with one inode per 4K block uses 128GB just in inodes)


Having gone through all of this, I think we need to step back a bit and change 
the kconfig settings.

Instead of specifying blocksize by default, we should have a 'useage pattern' 
for the filesystem (lots of small files, default, large files, gigantic files, 
custom) and set the filesystem blocksize based on the combination of the usage 
pattern and the filesystem size.

mkfs.ext* has the -T flag to specify usage type (lots of small files, default, 
lots of large file, gigantic files) to set the blocksize and number of inodes on 
the filesystem. The definitions are in /etc/mke2fs.conf

We should leverage this (and possibly add our own definitions)

On a 16M filesystem, we probably want to use a 1K block size and have an inode 
for every couple of blocks.

On a 10TB filesystem, we probably want 4K block size and an inode for every few 
K blocks

A menu to customize these rather than calculating them will allow people to 
tweak them to fit the uncommon cases that LEDE is likely to be used for.

David Lang



More information about the Lede-dev mailing list