Page MenuHomeFreeBSD

vfs: try to set time from the RTC prior to mountroot
Needs ReviewPublic

Authored by kevans on Jun 10 2026, 4:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 1, 10:22 PM
Unknown Object (File)
Thu, Oct 1, 7:45 PM
Unknown Object (File)
Thu, Sep 17, 2:09 AM
Unknown Object (File)
Fri, Sep 11, 5:44 PM
Unknown Object (File)
Thu, Sep 10, 11:45 AM
Unknown Object (File)
Sep 8 2026, 8:28 PM
Unknown Object (File)
Sep 8 2026, 12:08 AM
Unknown Object (File)
Sep 6 2026, 6:17 PM
Subscribers

Details

Summary

Noticed while writing a patch to grab time from the ZFS uberblock so
that ZFS rootfs systems without an RTC can have a reasonable starting
time: upon importing the pool, it will (always?) update the uberblock
in-memory immediately and grab a bogus timestamp of 1 because the
kernel clock isn't set yet. I haven't followed through ZFS enough to
understand the ramifications, but if this uberblock gets persisted to
disk then it will be subsequently ignored because it looks very old,
which seems like a good opportunity to lose some writes if we panic
early on.

Move the RTC-read earlier to avoid the problem entirely using the new
inittodr_{early,late} split.

ZFS should likely also avoid stamping a time earlier than the current
ub_timestamp as a defense mechanism and for systems without an RTC in
particular, but we can at least ensure that it gets a valid timestamp
for systems that *do* have an RTC.

I haven't spent any time looking at whether UFS/FFS might do something
similar, or if the clock isn't relevant until a write occurs later.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 73810
Build 70693: arc lint + arc unit