mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 00:12:45 +00:00
Currently there is a problem with fscking UFS file systems created on
top of ZVOLs. The problem is that rc.d/fsck runs before rc.d/zfs. The latter makes ZVOLs to appear in /dev/. In such case rc.d/fsck cannot find devfs entry and aborts. We cannot simply move rc.d/zfs before rc.d/fsck, because we first want kern.hostid to be configured (by rc.d/hostid). If we won't wait (hostid will be 0) we can reuse disks which are in use by different systems (eg. in SAN/NAS environment). We also cannot move rc.d/hostid before rc.d/fsck, because rc.d/hostid on first system start stores generated kern.hostuuid in /etc/hostid file, so it needs root file system to be mounted read-write. The fix is to split rc.d/hostid so that rc.d/hostid (which will now run before rc.d/fsck) only generates hostid and sets up sysctls, but doesn't touch root file system and rc.d/hostid_save (which is run after rc.d/root) and only creates /etc/hostid file. With that in place, we can move ZVOL initialization to dedicated rc.d/zvol script which runs before rc.d/fsck. PR: conf/120194 Reported by: James Snow <snow@teardrop.org> Reviewed by: brooks Approved by: re (kib) MFC after: 2 weeks
This commit is contained in:
parent
0df811a678
commit
d5d7e76d2b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=195938
@ -13,7 +13,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKING SERVERS \
|
|||||||
fsck ftp-proxy ftpd \
|
fsck ftp-proxy ftpd \
|
||||||
gbde geli geli2 gssd \
|
gbde geli geli2 gssd \
|
||||||
hcsecd \
|
hcsecd \
|
||||||
hostapd hostid hostname \
|
hostapd hostid hostid_save hostname \
|
||||||
inetd initrandom \
|
inetd initrandom \
|
||||||
ip6addrctl ip6fw ipfilter ipfs ipfw ipmon \
|
ip6addrctl ip6fw ipfilter ipfs ipfw ipmon \
|
||||||
ipnat ipsec ipxrouted \
|
ipnat ipsec ipxrouted \
|
||||||
@ -40,7 +40,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKING SERVERS \
|
|||||||
watchdogd wpa_supplicant \
|
watchdogd wpa_supplicant \
|
||||||
ypbind yppasswdd ypserv \
|
ypbind yppasswdd ypserv \
|
||||||
ypset ypupdated ypxfrd \
|
ypset ypupdated ypxfrd \
|
||||||
zfs
|
zfs zvol
|
||||||
|
|
||||||
.if ${MK_OPENSSH} != "no"
|
.if ${MK_OPENSSH} != "no"
|
||||||
FILES+= sshd
|
FILES+= sshd
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# PROVIDE: hostid
|
# PROVIDE: hostid
|
||||||
# REQUIRE: root
|
# BEFORE: fsck
|
||||||
# BEFORE: mountcritlocal
|
|
||||||
# KEYWORD: nojail
|
# KEYWORD: nojail
|
||||||
|
|
||||||
. /etc/rc.subr
|
. /etc/rc.subr
|
||||||
@ -68,7 +67,7 @@ hostid_hardware()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
hostid_reset()
|
hostid_generate()
|
||||||
{
|
{
|
||||||
# First look for UUID in hardware.
|
# First look for UUID in hardware.
|
||||||
uuid=`hostid_hardware`
|
uuid=`hostid_hardware`
|
||||||
@ -76,12 +75,17 @@ hostid_reset()
|
|||||||
# If not found, fall back to software-generated UUID.
|
# If not found, fall back to software-generated UUID.
|
||||||
uuid=`uuidgen`
|
uuid=`uuidgen`
|
||||||
fi
|
fi
|
||||||
|
hostid_set $uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
hostid_reset()
|
||||||
|
{
|
||||||
|
hostid_generate
|
||||||
# Store newly generated UUID in ${hostid_file}.
|
# Store newly generated UUID in ${hostid_file}.
|
||||||
echo $uuid > ${hostid_file}
|
echo $uuid > ${hostid_file}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
warn "could not store hostuuid in ${hostid_file}."
|
warn "could not store hostuuid in ${hostid_file}."
|
||||||
fi
|
fi
|
||||||
hostid_set $uuid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hostid_start()
|
hostid_start()
|
||||||
@ -91,7 +95,7 @@ hostid_start()
|
|||||||
hostid_set `cat ${hostid_file}`
|
hostid_set `cat ${hostid_file}`
|
||||||
else
|
else
|
||||||
# No hostid file, generate UUID.
|
# No hostid file, generate UUID.
|
||||||
hostid_reset
|
hostid_generate
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
etc/rc.d/hostid_save
Executable file
29
etc/rc.d/hostid_save
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
# PROVIDE: hostid_save
|
||||||
|
# REQUIRE: root
|
||||||
|
# BEFORE: mountcritlocal
|
||||||
|
# KEYWORD: nojail
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="hostid_save"
|
||||||
|
start_cmd="hostid_save"
|
||||||
|
stop_cmd=":"
|
||||||
|
rcvar="hostid_enable"
|
||||||
|
|
||||||
|
hostid_save()
|
||||||
|
{
|
||||||
|
if [ ! -r ${hostid_file} ]; then
|
||||||
|
$SYSCTL_N kern.hostuuid > ${hostid_file}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
warn "could not store hostuuid in ${hostid_file}."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
20
etc/rc.d/zfs
20
etc/rc.d/zfs
@ -23,21 +23,11 @@ zfs_start_jail()
|
|||||||
|
|
||||||
zfs_start_main()
|
zfs_start_main()
|
||||||
{
|
{
|
||||||
zfs volinit
|
|
||||||
zfs mount -a
|
zfs mount -a
|
||||||
zfs share -a
|
zfs share -a
|
||||||
if [ ! -r /etc/zfs/exports ]; then
|
if [ ! -r /etc/zfs/exports ]; then
|
||||||
touch /etc/zfs/exports
|
touch /etc/zfs/exports
|
||||||
fi
|
fi
|
||||||
# Enable swap on ZVOLs with property org.freebsd:swap=on.
|
|
||||||
zfs list -H -o org.freebsd:swap,name -t volume | \
|
|
||||||
while read state name; do
|
|
||||||
case "${state}" in
|
|
||||||
[oO][nN])
|
|
||||||
swapon /dev/zvol/${name}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zfs_start()
|
zfs_start()
|
||||||
@ -58,18 +48,8 @@ zfs_stop_jail()
|
|||||||
|
|
||||||
zfs_stop_main()
|
zfs_stop_main()
|
||||||
{
|
{
|
||||||
# Disable swap on ZVOLs with property org.freebsd:swap=on.
|
|
||||||
zfs list -H -o org.freebsd:swap,name -t volume | \
|
|
||||||
while read state name; do
|
|
||||||
case "${state}" in
|
|
||||||
[oO][nN])
|
|
||||||
swapoff /dev/zvol/${name}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
zfs unshare -a
|
zfs unshare -a
|
||||||
zfs unmount -a
|
zfs unmount -a
|
||||||
zfs volfini
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zfs_stop()
|
zfs_stop()
|
||||||
|
48
etc/rc.d/zvol
Executable file
48
etc/rc.d/zvol
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
# PROVIDE: zvol
|
||||||
|
# REQUIRE: hostid
|
||||||
|
# BEFORE: fsck
|
||||||
|
# KEYWORD: nojail
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="zvol"
|
||||||
|
rcvar="zfs_enable"
|
||||||
|
start_cmd="zvol_start"
|
||||||
|
stop_cmd="zvol_stop"
|
||||||
|
required_modules="zfs"
|
||||||
|
|
||||||
|
zvol_start()
|
||||||
|
{
|
||||||
|
zfs volinit
|
||||||
|
# Enable swap on ZVOLs with property org.freebsd:swap=on.
|
||||||
|
zfs list -H -o org.freebsd:swap,name -t volume | \
|
||||||
|
while read state name; do
|
||||||
|
case "${state}" in
|
||||||
|
[oO][nN])
|
||||||
|
swapon /dev/zvol/${name}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
zvol_stop()
|
||||||
|
{
|
||||||
|
# Disable swap on ZVOLs with property org.freebsd:swap=on.
|
||||||
|
zfs list -H -o org.freebsd:swap,name -t volume | \
|
||||||
|
while read state name; do
|
||||||
|
case "${state}" in
|
||||||
|
[oO][nN])
|
||||||
|
swapoff /dev/zvol/${name}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
zfs volfini
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
Loading…
Reference in New Issue
Block a user