Ensure all block devices are available

These days most disk drivers will probe for devices asynchronously.
This means it's possible that when you zfs init script runs all the
required block devices may not yet have been discovered.  The result
is the pool may fail to cleanly import at boot time.  This is
particularly common when you have a large number of devices.

The fix is for the init script to block until udev settles and we
are no longer detecting new devices.  Once the system has settled
the zfs modules can be loaded and the pool with be automatically
imported.
This commit is contained in:
Brian Behlendorf 2011-06-30 14:45:33 -07:00
parent 218b8eafbd
commit 2a005961a4
5 changed files with 16 additions and 0 deletions

View File

@ -126,6 +126,9 @@ start()
action $"SELinux ZFS policy required: " /bin/false || return 6 action $"SELinux ZFS policy required: " /bin/false || return 6
fi fi
# Delay until all required block devices are present.
udevadm settle
# load kernel module infrastructure # load kernel module infrastructure
if ! grep -q zfs /proc/modules ; then if ! grep -q zfs /proc/modules ; then
action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5 action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5

View File

@ -41,6 +41,10 @@ checksystem() {
start() { start() {
ebegin "Starting ZFS" ebegin "Starting ZFS"
checksystem || return 1 checksystem || return 1
# Delay until all required block devices are present.
udevadm settle
if [ ! -c /dev/zfs ]; then if [ ! -c /dev/zfs ]; then
modprobe $ZFS_MODULE modprobe $ZFS_MODULE
rv=$? rv=$?

View File

@ -50,6 +50,9 @@ start()
return 4 return 4
fi fi
# Delay until all required block devices are present.
udevadm settle
# Load the zfs module stack # Load the zfs module stack
/sbin/modprobe zfs /sbin/modprobe zfs

View File

@ -13,6 +13,9 @@
case $1 in case $1 in
start) echo "$1ing ZFS filesystems" start) echo "$1ing ZFS filesystems"
# Delay until all required block devices are present.
udevadm settle
if ! grep "zfs" /proc/modules > /dev/null; then if ! grep "zfs" /proc/modules > /dev/null; then
echo "ZFS kernel module not loaded yet; loading..."; echo "ZFS kernel module not loaded yet; loading...";
if ! modprobe zfs; then if ! modprobe zfs; then

View File

@ -76,6 +76,9 @@ start()
action $"SELinux ZFS policy required: " /bin/false || return 6 action $"SELinux ZFS policy required: " /bin/false || return 6
fi fi
# Delay until all required block devices are present.
udevadm settle
# load kernel module infrastructure # load kernel module infrastructure
if ! grep -q zfs /proc/modules ; then if ! grep -q zfs /proc/modules ; then
action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5 action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5