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, Apr 7, 8:32 AM
Unknown Object (File)
Thu, Mar 28, 12:23 PM
Unknown Object (File)
Jan 14 2024, 10:33 AM
Unknown Object (File)
Dec 22 2023, 11:34 PM
Unknown Object (File)
Dec 14 2023, 8:38 PM
Unknown Object (File)
Dec 7 2023, 2:42 AM
Unknown Object (File)
Aug 31 2023, 10:19 PM
Unknown Object (File)
Aug 31 2023, 10:16 PM
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