freebsd: set mnt_time on the rootfs at mountroot time

FreeBSD's vfs_mountroot() will collect `mnt_time` from every filesystem
that we mounted and use the highest timestamp as a source for the system
time if we didn't get anything from an attached RTC.

Use the rrd mechanism added to gather up a notion of the latest time
and set it on mnt_time.  If the timestamp db is empty, we just fallback
to the uberblock timestamp and hope that that is in the right ballpark.

Relevant: FreeBSD PR254058[0] reporting the problem downstream

[0] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254058

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Chris Longros <[email protected]>
Signed-off-by: Kyle Evans <[email protected]>
Closes #18645
This commit is contained in:
Kyle Evans authored and Brian Behlendorf committed 2026-06-24 15:48:14 -07:00
1 parent ee13f5af5b
commit e3082b923b
1 file changed
+7 -1
+7 -1
View File
@@ -51,7 +51,7 @@
#include <sys/dsl_prop.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_deleg.h>
#include <sys/spa.h>
#include <sys/spa_impl.h>
#include <sys/zap.h>
#include <sys/sa.h>
#include <sys/sa_impl.h>
@@ -69,6 +69,7 @@
#include <sys/zfs_quota.h>
#include "zfs_comutil.h"
#include "zfs_crrd.h"
#ifndef MNTK_VMSETSIZE_BUG
#define MNTK_VMSETSIZE_BUG 0
@@ -1352,7 +1353,12 @@ out:
dmu_objset_disown(zfsvfs->z_os, B_TRUE, zfsvfs);
zfsvfs_free(zfsvfs);
} else {
spa_t *spa = zfsvfs->z_os->os_spa;
atomic_inc_32(&zfs_active_fs_count);
vfsp->mnt_time = dbrrd_latest_time(&spa->spa_txg_log_time);
vfsp->mnt_time = MAX(vfsp->mnt_time, spa->spa_load_txg_ts);
}
return (error);