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
F102824908: D37198.diff
Sun, Nov 17, 4:28 PM
F102797804: D37198.id112340.diff
Sun, Nov 17, 8:10 AM
Unknown Object (File)
Fri, Nov 15, 2:51 PM
Unknown Object (File)
Thu, Nov 14, 2:34 AM
Unknown Object (File)
Sun, Nov 10, 2:32 PM
Unknown Object (File)
Sat, Nov 9, 1:37 PM
Unknown Object (File)
Sat, Nov 9, 11:41 AM
Unknown Object (File)
Sat, Nov 9, 10:16 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

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