Page MenuHomeFreeBSD

Make root_mount_hold() work after boot.
ClosedPublic

Authored by trasz on Jan 30 2017, 6:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 7 2024, 10:53 PM
Unknown Object (File)
Jan 31 2024, 2:15 PM
Unknown Object (File)
Dec 20 2023, 2:26 AM
Unknown Object (File)
Dec 18 2023, 11:13 AM
Unknown Object (File)
Sep 7 2023, 4:37 AM
Unknown Object (File)
Sep 7 2023, 4:35 AM
Unknown Object (File)
Sep 7 2023, 4:35 AM
Unknown Object (File)
Sep 7 2023, 4:33 AM
Subscribers

Details

Summary

Make root_mount_hold() work after boot. This is important for two
reasons. First is rerooting into USB-mounted device that happens
to be not yet enumerated. The second is when mounting with (non-root)
filesystem on USB device on a hub that's enumerated later than the root
mount: the rc scripts explicitly mount for the root mount holds to be
released, but each USB bus takes the hold asynchronously, and if that
happens after root mount, it would just get ignored.

Diff Detail

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

Event Timeline

trasz retitled this revision from to Make root_mount_hold() work after boot..
trasz updated this object.
trasz edited the test plan for this revision. (Show Details)

Marcel, "svn ann" suggests it was there when you wrote it. What do you think about the change? Thanks!

First of all: You may want to change root_mount_rel() as well: h cannot be NULL anymore. A KASSERT would be appropriate...

The purpose of root_mount_hold() is to delay mounting the root file system because device enumeration isn't complete. It's a harmless and needless operation when the root file system is mounted already, but to your point, can still help for the root re-mount cases. I just don't know how such would actually work, because rc.d scripts run only after we have mounted the root disk and I'm not aware of a way to re-invoke the root mount logic again. It's the root mount logic that waits for any holds -- I don't think there's any other place that does that.

Can you elaborate on the scenario a bit more so that I can understand exactly what is happening in your case?

Good point with root_mount_rel(), I'll fix that.

Now, regarding the point of this: the r290196 changed the mechanism so that if you're eg waiting for "usbus0 usbus1 usbus2", but your root path is ufs:/dev/ada0p2, the root mount won't wait for the holds to be released - because the device already exists. However, the list of the holds is still exported to the userland via vfs.root_mount_holds sysctl, so that, should the mountcritlocal fail, it (the rc script) can wait for the root mount holds to be released and then retry the mount. This is for eg an USB disk mounted on /var. To see how it works grep for "root_hold_wait" in /etc/rc.d/*.

Now, currently, it looks like things can fail like this: USB holds usbus0, root mount succeeds, because it's not on an USB device, USB discovers a new hub, obtains hold on usbus1, and releases the hold on usbus0. The rc scripts should work for usbus1 - but they don't, because root_mount_hold() didn't do anything. The patch intends to fix the last part.

Got it! Thanks for the explanation.

trasz edited edge metadata.

Don't allow NULL pointer in root_mount_rel().

marcel edited edge metadata.
This revision is now accepted and ready to land.Feb 5 2017, 9:32 PM
This revision was automatically updated to reflect the committed changes.