Page MenuHomeFreeBSD

Don't use sleeping allocations for ufs dirhash blocks when holding directory vnode

Authored by on Mar 3 2021, 6:37 PM.
Referenced Files
Unknown Object (File)
Mon, May 15, 7:28 PM
Unknown Object (File)
Mon, May 8, 12:10 AM
Unknown Object (File)
Apr 2 2023, 6:02 PM
Unknown Object (File)
Apr 2 2023, 6:00 PM
Unknown Object (File)
Apr 2 2023, 6:00 PM
Unknown Object (File)
Mar 31 2023, 2:11 AM
Unknown Object (File)
Mar 31 2023, 2:00 AM
Unknown Object (File)
Mar 27 2023, 2:30 PM



System with a based-on-FreeBSD-12 kernel but with a timeout panic for the UFS root vnode lock paniced due to a ufsdirhash_build() call with M_WAITOK, UMA_ZONE_FIRSTTOUCH (the default) and a domain which was OOM. The ufsdirhash_build() code is invoked with the directory vnode exclusively locked (per ufs_lookup.c / the caller) and in all other places takes care to allocate M_NOWAIT to avoid such issues.

So it seems reasonable to make this one allocation also M_NOWAIT instead of M_WAITOK, especially given the FIRSTTOUCH default behavior where only the calling cpu's domain can satisfy the request.

Test Plan

Organizational stress testing, no unit test planned -- change is pretty straightforward.

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Mar 3 2021, 7:50 PM
markj added reviewers: mckusick, kib.
markj added inline comments.

I would just drop the NOWAIT suffix, or get rid of the UMA wrappers entirely.

Took Mark's suggestion on dropping _NOWAIT suffix on allocation macro.
Left the macro for symmetry with the FREE macros in the file.

This revision now requires review to proceed.Mar 3 2021, 8:09 PM

This seems like a reasonable solution to the problem. The allocation will fail in a few cases where it previously would have succeeded, but hopefully those will be rare. The effect of failing will simply be slower lookups rather than unexpected errors to applications.

This revision is now accepted and ready to land.Mar 3 2021, 9:19 PM