From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-598162-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 5AB5E1381F3
	for <garchives@archives.gentoo.org>; Sun,  9 Jun 2013 13:57:19 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 25A1DE08C0;
	Sun,  9 Jun 2013 13:57:14 +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 792A1E0888
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:57:13 +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 8720633E1F2
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:57:12 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id 37244E5465
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:57:10 +0000 (UTC)
From: "Richard Yao" <ryao@gentoo.org>
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" <ryao@gentoo.org>
Message-ID: <1370785659.c812c35100771bb527f6b03853fa6d8ef66a48fe.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: c812c35100771bb527f6b03853fa6d8ef66a48fe
X-VCS-Branch: ryao
Date: Sun,  9 Jun 2013 13:57:10 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 1a173b58-4ddf-49d2-9667-c7508d39a646
X-Archives-Hash: a6ec5fff665d2cb682b5f6b9ebdaf82f

commit:     c812c35100771bb527f6b03853fa6d8ef66a48fe
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:31:33 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:47:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=c812c351

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 <AT> gentoo.org>

---
 defaults/initrd.scripts | 17 ++++++++++++++---
 1 file 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


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-598150-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 824FE1381F3
	for <garchives@archives.gentoo.org>; Sun,  9 Jun 2013 13:48:31 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id CD97FE0848;
	Sun,  9 Jun 2013 13:48:30 +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 18F77E0848
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:48:29 +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 2202233E286
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:48:29 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id C3B71E5461
	for <gentoo-commits@lists.gentoo.org>; Sun,  9 Jun 2013 13:48:27 +0000 (UTC)
From: "Richard Yao" <ryao@gentoo.org>
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" <ryao@gentoo.org>
Message-ID: <1370785659.c812c35100771bb527f6b03853fa6d8ef66a48fe.ryao@gentoo>
Subject: [gentoo-commits] proj/genkernel:master 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: c812c35100771bb527f6b03853fa6d8ef66a48fe
X-VCS-Branch: master
Date: Sun,  9 Jun 2013 13:48:27 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 29377d31-e0cf-48cf-b2a0-d7f140f1ecc3
X-Archives-Hash: ae56a62284e8b97393b4bbde85404eca
Message-ID: <20130609134827.IQq_1bGd5FMRqzoJh2BRzFGNMxsLqjZAoUblalvWdoQ@z>

commit:     c812c35100771bb527f6b03853fa6d8ef66a48fe
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:31:33 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:47:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=c812c351

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 <AT> gentoo.org>

---
 defaults/initrd.scripts | 17 ++++++++++++++---
 1 file 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