Ensure all block devices are available
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 30 Jun 2011 21:45:33 +0000 (14:45 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 30 Jun 2011 21:45:33 +0000 (14:45 -0700)
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.

etc/init.d/zfs.fedora
etc/init.d/zfs.gentoo
etc/init.d/zfs.lsb
etc/init.d/zfs.lunar
etc/init.d/zfs.redhat

index 69df621..bfed452 100644 (file)
@@ -126,6 +126,9 @@ start()
                 action $"SELinux ZFS policy required: " /bin/false || return 6
         fi
 
+       # Delay until all required block devices are present.
+       udevadm settle
+
        # load kernel module infrastructure
        if ! grep -q zfs /proc/modules ; then
                action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5
index c9c5d85..a33d9dc 100644 (file)
@@ -41,6 +41,10 @@ checksystem() {
 start() {
        ebegin "Starting ZFS"
        checksystem || return 1
+
+       # Delay until all required block devices are present.
+       udevadm settle
+
        if [ ! -c /dev/zfs ]; then
                modprobe $ZFS_MODULE
                rv=$?
index a84c1df..6c0a743 100644 (file)
@@ -50,6 +50,9 @@ start()
                return 4
        fi
 
+       # Delay until all required block devices are present.
+       udevadm settle
+
        # Load the zfs module stack
        /sbin/modprobe zfs
 
index c7aa1ed..4512151 100644 (file)
@@ -13,6 +13,9 @@
 case $1 in
   start)  echo "$1ing ZFS filesystems"
 
+    # Delay until all required block devices are present.
+    udevadm settle
+
     if ! grep "zfs" /proc/modules > /dev/null; then
       echo "ZFS kernel module not loaded yet; loading...";
       if ! modprobe zfs; then
index 99ff80e..3f34f2f 100644 (file)
@@ -76,6 +76,9 @@ start()
                 action $"SELinux ZFS policy required: " /bin/false || return 6
         fi
 
+       # Delay until all required block devices are present.
+       udevadm settle
+
        # load kernel module infrastructure
        if ! grep -q zfs /proc/modules ; then
                action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5