diff options
author | Richard Yao <ryao@gentoo.org> | 2013-06-09 05:31:33 -0400 |
---|---|---|
committer | Richard Yao <ryao@cs.stonybrook.edu> | 2013-06-09 09:47:39 -0400 |
commit | c812c35100771bb527f6b03853fa6d8ef66a48fe (patch) | |
tree | 9679c1007fd8354d5e39664d95dba0862b0c79d8 | |
parent | Add call_func_timeout helper function (diff) | |
download | genkernel-c812c35100771bb527f6b03853fa6d8ef66a48fe.tar.gz genkernel-c812c35100771bb527f6b03853fa6d8ef66a48fe.tar.bz2 genkernel-c812c35100771bb527f6b03853fa6d8ef66a48fe.zip |
Import pool after ZFS module finishes loading
There is a race between ZFS module initialization and our attempt to
import pools. We address this by doing a busy wait for the /dev/zfs
device to appear. We wait a maximum of 5 seconds for the device to
appear.
We also slightly alter output messages to be more readable.
Signed-off-by: Richard Yao <ryao@gentoo.org>
-rw-r--r-- | defaults/initrd.scripts | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index bfdde75..35e5957 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -636,6 +636,12 @@ chooseKeymap() { fi } +# This helper function is to be called using call_func_timeout. +# It enables us to wait a reasonable amount of time until /dev/zfs appears. +waitForZFS() { + while [ ! -c /dev/zfs ]; do echo >/dev/null; done; +} + startVolumes() { #good_msg 'Checking if volumes need to be started...' @@ -714,7 +720,12 @@ startVolumes() { if [ "${USE_ZFS}" = '1' ] then - if [ -z "${ZFS_POOL}" ] + + # Avoid race involving asynchronous module loading + if call_func_timeout waitForZFS 5 + then + bad_msg "Cannot import ZFS pool because /dev/zfs is missing" + elif [ -z "${ZFS_POOL}" ] then good_msg "Importing ZFS pools" @@ -745,9 +756,9 @@ startVolumes() { if [ "$?" = '0' ] then - good_msg "Importing ${ZFS_POOL} succeeded" + good_msg "Import of ${ZFS_POOL} succeeded" else - bad_msg "Importing ${ZFS_POOL} failed" + bad_msg "Import of ${ZFS_POOL} failed" fi fi fi |