public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Richard Yao" <ryao@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:ryao commit in: defaults/
Date: Sun,  9 Jun 2013 13:57:10 +0000 (UTC)	[thread overview]
Message-ID: <1370785659.c812c35100771bb527f6b03853fa6d8ef66a48fe.ryao@gentoo> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: "Richard Yao" <ryao@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
Date: Sun,  9 Jun 2013 13:48:27 +0000 (UTC)	[thread overview]
Message-ID: <1370785659.c812c35100771bb527f6b03853fa6d8ef66a48fe.ryao@gentoo> (raw)
Message-ID: <20130609134827.IQq_1bGd5FMRqzoJh2BRzFGNMxsLqjZAoUblalvWdoQ@z> (raw)

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


             reply	other threads:[~2013-06-09 13:57 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09 13:57 Richard Yao [this message]
2013-06-09 13:48 ` [gentoo-commits] proj/genkernel:master commit in: defaults/ Richard Yao
  -- strict thread matches above, loose matches on Subject: below --
2013-10-02 12:43 [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-09 13:57 Richard Yao
2013-06-09 13:57 Richard Yao
2013-06-09 13:57 Richard Yao
2013-06-09 13:57 Richard Yao
2013-06-09 13:57 Richard Yao
2013-06-09 13:57 [gentoo-commits] proj/genkernel:master " Richard Yao
2013-06-09 13:57 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-09 13:57 [gentoo-commits] proj/genkernel:master " Richard Yao
2013-06-09 13:57 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-09 13:48 [gentoo-commits] proj/genkernel:master " Richard Yao
2013-06-09 13:57 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:40 Richard Yao
2013-06-09 13:37 Richard Yao
2013-06-09 13:37 Richard Yao
2013-06-09 13:37 Richard Yao
2013-06-09 13:36 Richard Yao
2013-06-09 13:36 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:33 Richard Yao
2013-06-09 13:21 Richard Yao
2013-06-09 13:17 Richard Yao
2013-06-09 13:17 Richard Yao
2013-06-09 13:17 Richard Yao
2013-06-09 13:17 Richard Yao
2013-06-09 13:15 Richard Yao
2013-06-09 13:15 Richard Yao
2013-06-09 12:29 Richard Yao
2013-06-09 12:11 Richard Yao
2013-06-09 11:56 Richard Yao
2013-06-09 11:51 Richard Yao
2013-06-09 11:47 Richard Yao
2013-06-09 11:43 Richard Yao
2013-06-09 10:28 Richard Yao
2013-06-09 10:05 Richard Yao
2013-06-09 10:02 Richard Yao
2013-06-09  9:58 Richard Yao
2013-06-09  9:58 Richard Yao
2013-06-09  9:58 Richard Yao
2013-06-09  9:53 Richard Yao
2013-06-09  9:49 Richard Yao
2013-06-09  9:49 Richard Yao
2013-06-09  9:46 Richard Yao
2013-06-09  9:44 Richard Yao
2013-06-09  9:44 Richard Yao
2013-06-09  8:32 Richard Yao
2013-06-09  7:45 Richard Yao
2013-06-09  6:43 Richard Yao
2013-06-06  3:36 Richard Yao
2013-06-03 23:49 Richard Yao
2013-06-03 23:35 Richard Yao
2013-06-03 23:35 Richard Yao
2013-06-03 23:35 Richard Yao
2013-06-03 23:35 Richard Yao
2013-06-03 23:35 Richard Yao
2013-06-03 23:35 Richard Yao
2013-01-01 16:53 Richard Yao
2012-11-22 22:20 Richard Yao
2012-11-22 22:20 [gentoo-commits] proj/genkernel:master " Richard Yao
2013-01-01 16:53 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2012-11-11 17:04 [gentoo-commits] proj/genkernel:master " Richard Yao
2012-11-11 17:32 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2012-11-05 18:30 Richard Yao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370785659.c812c35100771bb527f6b03853fa6d8ef66a48fe.ryao@gentoo \
    --to=ryao@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox