Page MenuHomeFreeBSD

Add more inodes to VM images by having makefs allocate extra inodes when making images with free space.
ClosedPublic

Authored by nwhitehorn on Mar 29 2021, 9:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 5:49 PM
Unknown Object (File)
Sat, Nov 16, 6:43 PM
Unknown Object (File)
Thu, Nov 14, 8:59 AM
Unknown Object (File)
Thu, Nov 14, 1:49 AM
Unknown Object (File)
Tue, Nov 12, 5:26 PM
Unknown Object (File)
Tue, Nov 12, 4:45 AM
Unknown Object (File)
Mon, Nov 11, 3:30 AM
Unknown Object (File)
Mon, Nov 11, 1:31 AM
Subscribers

Details

Summary

By default, makefs(8) has very few spare inodes in its output images, which is fine for static filesystems, but not so great for VM images where many more files will be added. Make makefs(8) use the same default settings as newfs(8) when creating images with free space -- there isn't much point to leaving free space on the image if you can't put files there. If no free space is requested, use current behavior.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

nwhitehorn created this revision.

I agree with the suggestion this would be better to fix in makefs itself.

This appears to be the source of the discrepancy between newfs and makefs:

sbin/newfs/mkfs.c
338:            density = MAX(NFPI, minfragsperinode) * fsize;
341:            density = minfragsperinode * fsize;

usr.sbin/makefs/ffs.c
429:            ffs_opts->density = fsopts->size / fsopts->inodes + 1;

usr.sbin/makefs/ffs/mkfs.c
138:    density =       ffs_opts->density;

Fixing this here too for older makefs building images from newer sources might be reasonable, but I wonder if makefs should be made a bootstrap tool instead, along with its default being improved.

So makefs(8), by default, creates a file system that can exactly hold the input tree (no extra space, no extra inodes, no extra anything). If we change the defaults in makefs(8), it seems like there are a few options:

  • Unconditionally allocate extra inodes. I'm not sure this makes sense to leave inodes around in a universe where the default is no extra space.
  • If the user asks for extra space, add extra inodes as well, using the same default density as newfs(8) does.

The latter is nice in some ways (no obvious POLA issues, at least), so I think I prefer it. growfs adds extra inodes if the filesystem is later expanded, so that should be fine as well. I can rework this patch to do that; I can also commit this now as a stopgap since it is less work and should be functionally equivalent so that users don't have to wait.

nwhitehorn retitled this revision from Add more inodes to VM images to Add more inodes to VM images by having makefs allocate extra inodes when making images with free space..
nwhitehorn edited the summary of this revision. (Show Details)

Instead of adjusting parameters when generating VM images, adjust makefs to make free inodes when making free space. Relevant code copied from newfs(8).

Fix some fat-fingering and rename an argument to better reflect what it does.

More diff context, no functional changes.

manu added a subscriber: manu.

Small nits but otherwise lgtm

usr.sbin/makefs/ffs.c
193

Should be = false as it's a bool

273

true

This revision is now accepted and ready to land.Apr 6 2021, 1:09 PM

Thanks, fixed 0/1->false/true.

Thank you. I hoped to test this but have been stumbling over how to build an AMI with make release. It's not part of my usual workflow. We'll see if the snapshots this week are fixed!

The snapshot AMIs built this week do work. Thanks again!