Page MenuHomeFreeBSD

(pwd 2/3) fd: move vnodes out of filedesc into a dedicated structure
ClosedPublic

Authored by mjg on Feb 28 2020, 7:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 3:07 AM
Unknown Object (File)
Oct 22 2024, 10:21 AM
Unknown Object (File)
Oct 22 2024, 4:55 AM
Unknown Object (File)
Oct 14 2024, 2:03 PM
Unknown Object (File)
Sep 27 2024, 7:23 AM
Unknown Object (File)
Sep 24 2024, 11:38 PM
Unknown Object (File)
Sep 12 2024, 7:06 PM
Unknown Object (File)
Sep 12 2024, 2:59 AM
Subscribers

Details

Summary

The new structure is copy-on-write. With the assumption that path lookups are significantly more frequent than chdirs and chrooting this is a win.

This provides stable root and jail root vnodes without the need to reference them on lookup, which in turn means less work on globally shared structures. Note this also happens to fix a bug where jail vnode was never referenced, meaning subsequent access on lookup could run into use-after-free.

Currently starting and ending lookup ends up refing and unrefing the struct. Refing takes the filedesc lock to provide safe access, but with SMR we can get away without it. Moreover, should the struct become cached per-thread like struct cred there would be no need to do anything here. However, the latter runs into potential issues with unmount, so I think SMR is the way to go. I had another idea where liveness itself would be provided by per-thread refs but access to vnodes would require per-cpu refs (or it can use rms locks). This can wait.

Note that there is no effort to actively unshare the struct due to pending SMR work.

The motivation for the change is provide fast path lookup later, but I think it is an improvement in its own right.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Mar 1 2020, 5:49 PM
head/sys/sys/filedesc.h
81

can you document the synchronization for these