From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2FA551381F3 for ; Sun, 9 Jun 2013 13:17:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 027A0E0853; Sun, 9 Jun 2013 13:17:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 08C49E07FA for ; Sun, 9 Jun 2013 13:17:23 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 17E3133E356 for ; Sun, 9 Jun 2013 13:17:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B714DE5461 for ; Sun, 9 Jun 2013 13:17:21 +0000 (UTC) From: "Richard Yao" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Richard Yao" Message-ID: <1370783794.ce6de04860a629e9deb033bc4773c8bfccf2ed02.ryao@gentoo> Subject: [gentoo-commits] proj/genkernel:ryao commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts X-VCS-Directories: defaults/ X-VCS-Committer: ryao X-VCS-Committer-Name: Richard Yao X-VCS-Revision: ce6de04860a629e9deb033bc4773c8bfccf2ed02 X-VCS-Branch: ryao Date: Sun, 9 Jun 2013 13:17:21 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 36b78a06-2cb0-4ab7-aa82-9e738449d51a X-Archives-Hash: 3a0b426e179b78d112c77692d3bd7791 commit: ce6de04860a629e9deb033bc4773c8bfccf2ed02 Author: Richard Yao gentoo org> AuthorDate: Sun Jun 9 09:31:33 2013 +0000 Commit: Richard Yao gentoo org> CommitDate: Sun Jun 9 13:16:34 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=ce6de048 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 gentoo.org> --- defaults/initrd.scripts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index c8e7abb..f598402 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