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 487DA1381F3 for ; Sun, 9 Jun 2013 13:33:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 11DC1E0848; Sun, 9 Jun 2013 13:33:48 +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 55955E0848 for ; Sun, 9 Jun 2013 13:33:47 +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 6858133E366 for ; Sun, 9 Jun 2013 13:33:46 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 08AF5E5461 for ; Sun, 9 Jun 2013 13:33:45 +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: <1370784296.90f1bb4fb7b30b777c7d44816bebd967141d5d57.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: 90f1bb4fb7b30b777c7d44816bebd967141d5d57 X-VCS-Branch: ryao Date: Sun, 9 Jun 2013 13:33:45 +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: cc876b29-1d0d-4952-ae9b-00e2b7e078e8 X-Archives-Hash: a1ded277586e3e2c82d3e21cb31e2a15 commit: 90f1bb4fb7b30b777c7d44816bebd967141d5d57 Author: Richard Yao gentoo org> AuthorDate: Sun Jun 9 09:31:33 2013 +0000 Commit: Richard Yao gentoo org> CommitDate: Sun Jun 9 13:24:56 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=90f1bb4f 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