Page MenuHomeFreeBSD

Add clearing function for unr(9), call it from tmpfs.

Authored by mjoras on Oct 4 2017, 6:38 PM.
Referenced Files
Unknown Object (File)
Sun, Nov 12, 7:28 AM
Unknown Object (File)
Nov 10 2023, 12:13 PM
Unknown Object (File)
Nov 5 2023, 10:47 PM
Unknown Object (File)
Nov 1 2023, 6:25 AM
Unknown Object (File)
Oct 20 2023, 9:23 PM
Unknown Object (File)
Oct 17 2023, 10:15 AM
Unknown Object (File)
Oct 13 2023, 6:14 PM
Unknown Object (File)
Oct 13 2023, 8:09 AM



Previously before you could call unrhdr_delete you needed to
individually free every allocated unit. It is useful to be able to tear
down the unr without having to go through this process, as it is
significantly faster than freeing the individual units.

When unmounting a tmpfs, do not call free_unr.

tmpfs uses unr(9) to allocate inodes. Previously when unmounting it
would individually free the units when it freed each vnode. This is
unnecessary as we can use the newly-added unrhdr_clear function to clear
out the unr in onde go. This measurably reduces the time to unmount a
tmpfs with many files.

This will be committed as two pieces, one for the unr(9) change, one for the
tmpfs usage change.

Test Plan

I tested this using a kld that uses unr, and I also tested it by repeatedly
extracting a ports tree to a tmpfs and umounting that tmpfs. In my testing
the unmount is sped up from ~.31s to ~.24s, on average. Memory does not
appear to be leaking given the output of vmstat -m | grep Unit

Diff Detail

rS FreeBSD src repository - subversion
Lint Not Applicable
Tests Not Applicable

Event Timeline

cem added inline comments.
77 ↗(On Diff #33700)

Sentences should start on their own line in man page format. A suggestion: use igor from ports to check man pages you write/edit; it should flag this.

365 ↗(On Diff #33700)

Why does this become conditional?

386–387 ↗(On Diff #33700)

Why not move the assert to the top of the routine? It doesn't seem like the rest of the function affects ppfree.

77 ↗(On Diff #33700)

Thanks, I knew I'd commit some sort of manpage faux pas on my first manpage change :).

365 ↗(On Diff #33700)

detach -> unmount, so in the unmount case we don't want to bother freeing the unit for every single inode. Instead we clear it out all at once. Should I add a comment? There's basically no comments in tmpfs, it's pretty sad.

365 ↗(On Diff #33700)

Ah, that makes sense. Yeah, please add a comment.

  • Fixup manpage.
  • Move KASSERT.

I'd like a comment about the !detach-only free_unr but otherwise LGTM.

mjoras marked 2 inline comments as done.
  • Add comment explaining the conditional free_unr
This revision is now accepted and ready to land.Oct 4 2017, 8:19 PM
This revision was automatically updated to reflect the committed changes.