Page MenuHomeFreeBSD

vfs_domount(): ensure that v_mountedhere and VIRF_MOUNTPOINT are set under the vnode lock
ClosedPublic

Authored by kib on Oct 28 2022, 3:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 8:18 AM
Unknown Object (File)
Dec 12 2023, 1:39 PM
Unknown Object (File)
Oct 30 2023, 10:31 PM
Unknown Object (File)
Oct 30 2023, 10:30 PM
Unknown Object (File)
Oct 9 2023, 3:13 PM
Unknown Object (File)
Aug 9 2023, 1:49 AM
Unknown Object (File)
Aug 9 2023, 1:47 AM
Unknown Object (File)
Aug 6 2023, 3:14 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Oct 28 2022, 3:00 PM
kib edited the summary of this revision. (Show Details)

Oops, I didn't realize that the mount path doesn't hold the covered vnode lock while updating the relevant fields.
It looks as though the unmount path does hold the lock across the relevant operations, so we should be safe from these fields being cleared out from under us, correct?
Would it make sense to add a comment here to that effect?

sys/kern/vfs_lookup.c
1263 ↗(On Diff #112340)

v_mounthere -> v_mountedhere

This revision is now accepted and ready to land.Oct 28 2022, 3:32 PM
sys/kern/vfs_lookup.c
1267 ↗(On Diff #112340)

Hmm, thinking about it a little more:
Given the potential cost of a load-load barrier on this path, would it make more sense to instead just replace the KASSERT below with a check that exits the loop if mp is NULL?

kib marked 2 inline comments as done.
kib retitled this revision from vfs_lookup(): ensure that v_mountedhere write is seen if VIRF_MOUNTPOINT was read to vfs_domount(): ensure that v_mountedhere and VIRF_MOUNTPOINT are set under the vnode lock.
This revision now requires review to proceed.Oct 28 2022, 4:09 PM
This revision is now accepted and ready to land.Oct 28 2022, 4:47 PM
sys/kern/vfs_lookup.c
1267 ↗(On Diff #112340)

The cost of acquire fence is zero on amd64, and somewhat more on arm64.

But if this causes questions, I think we can just extend the lock region in vfs_domount().

cache_purge() should not be called with the vnode locked, it does vdrop() for unrelated vnodes

This revision now requires review to proceed.Oct 28 2022, 11:53 PM
This revision is now accepted and ready to land.Oct 29 2022, 12:03 AM