public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2012-11-05 18:30 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2012-11-05 18:30 UTC (permalink / raw
  To: gentoo-commits

commit:     3fa1bf680d90f5841d8830634ed13bbfd76271b7
Author:     Marek Sapota <marek <AT> sapota <DOT> org>
AuthorDate: Fri Nov  2 17:04:18 2012 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Fri Nov  2 17:06:02 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=3fa1bf68

Bug #378105: UUID/LABEL support for LUKS keydevs

LUKS keydevs now support mount by UUID/LABEL.

X-Gentoo-Bug: 378105
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=378105
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 defaults/initrd.scripts |   83 ++++++++++++++++++++++++++---------------------
 1 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 53e1f97..7cb41b3 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -282,6 +282,36 @@ findnfsmount() {
 	fi
 }
 
+find_real_device() {
+	local DEVICE="${1}"
+	case "${DEVICE}" in
+		UUID\=*|LABEL\=*)
+			local REAL_DEVICE=""
+			local retval=1
+
+			if [ "${retval}" -ne 0 ]; then
+				REAL_DEVICE=`findfs "${DEVICE}" 2>/dev/null`
+				retval=$?
+			fi
+
+			if [ "$retval" -ne 0 ]; then
+				REAL_DEVICE=`busybox findfs "${DEVICE}" 2>/dev/null`
+				retval=$?
+			fi
+
+			if [ "${retval}" -ne 0 ]; then
+				REAL_DEVICE=`blkid -o device -l -t "${DEVICE}"`
+				retval=$?
+			fi
+
+			if [ "${retval}" -eq 0 ] && [ -n "${REAL_DEVICE}" ]; then
+				DEVICE="${REAL_DEVICE}"
+			fi
+		;;
+	esac
+	echo -n "${DEVICE}"
+}
+
 check_loop() {
 	if [ "${LOOP}" = '' -o ! -e "${CDROOT_PATH}/${LOOP}" ]
 	then
@@ -811,32 +841,7 @@ openLUKS() {
 			prompt_user "LUKS_KEYDEV" "${LUKS_NAME} key device"
 			KEYDEV_ERROR=0
 		else
-			case "${LUKS_DEVICE}" in
-				UUID\=*|LABEL\=*)
-					local REAL_LUKS=""
-					local retval=1
-
-					if [ "${retval}" -ne 0 ]; then
-						REAL_LUKS=`findfs "${LUKS_DEVICE}" 2>/dev/null`
-						retval=$?
-					fi
-
-					if [ "$retval" -ne 0 ]; then
-						REAL_LUKS=`busybox findfs "${LUKS_DEVICE}" 2>/dev/null`
-						retval=$?
-					fi
-
-					if [ "${retval}" -ne 0 ]; then
-						REAL_LUKS=`blkid -o device -l -t "${LUKS_DEVICE}"`
-						retval=$?
-					fi
-
-					if [ "${retval}" -eq 0 ] && [ -n "${REAL_LUKS}" ]; then
-						good_msg "Detected device ${REAL_LUKS}"
-						LUKS_DEVICE="${REAL_LUKS}"
-					fi
-				;;
-			esac
+			LUKS_DEVICE=$(find_real_device "${LUKS_DEVICE}")
 
 			setup_md_device ${LUKS_DEVICE}
 			cryptsetup isLuks ${LUKS_DEVICE}
@@ -855,10 +860,12 @@ openLUKS() {
 
 				if [ -n "${LUKS_KEY}" ] 
 				then
+					local REAL_LUKS_KEYDEV="${LUKS_KEYDEV}"
 					if [ ! -e "${mntkey}${LUKS_KEY}" ] 
 					then
-						if [ -b "${LUKS_KEYDEV}" ]
-						then good_msg "Using key device ${LUKS_KEYDEV}." ${CRYPT_SILENT}
+						REAL_LUKS_KEYDEV=$(find_real_device "${LUKS_KEYDEV}")
+						if [ -b "${REAL_LUKS_KEYDEV}" ]
+						then good_msg "Using key device ${REAL_LUKS_KEYDEV}." ${CRYPT_SILENT}
 						else
 							good_msg "Please insert removable device ${LUKS_KEYDEV} for ${LUKS_NAME}" ${CRYPT_SILENT}
 							# abort after 10 secs
@@ -867,18 +874,20 @@ openLUKS() {
 							do 
 								count=$((count-1))
 								sleep 1
-								if [ -b "${LUKS_KEYDEV}" ]
+								REAL_LUKS_KEYDEV=$(find_real_device "${LUKS_KEYDEV}")
+								if [ -b "${REAL_LUKS_KEYDEV}" ]
 								then
-									good_msg "Removable device ${LUKS_KEYDEV} detected." ${CRYPT_SILENT}
+									good_msg "Removable device ${REAL_LUKS_KEYDEV} detected." ${CRYPT_SILENT}
 									break
 								fi
 							done
-							if [ ! -b "${LUKS_KEYDEV}" ]
+							if [ ! -b "${REAL_LUKS_KEYDEV}" ]
 							then
 								eval CRYPT_${TYPE}_KEY=${LUKS_KEY}
 								bootstrapKey ${TYPE}
 								eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
-								if [ ! -b "${LUKS_KEYDEV}" ]; then
+								REAL_LUKS_KEYDEV=$(find_real_device "${LUKS_KEYDEV}")
+								if [ ! -b "${REAL_LUKS_KEYDEV}" ]; then
 									KEYDEV_ERROR=1
 									bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
 									continue
@@ -890,27 +899,27 @@ openLUKS() {
 						# At this point a device was recognized, now let's see if the key is there
 						[ ! -d "$mntkey" ] && mkdir -p ${mntkey} 2>/dev/null >/dev/null
 
-						mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null
+						mount -n -o ro ${REAL_LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null
 						if [ "$?" != '0' ]
 						then
 							KEYDEV_ERROR=1
-							bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT}
+							bad_msg "Mounting of device ${REAL_LUKS_KEYDEV} failed." ${CRYPT_SILENT}
 							continue
 						else
-							good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT}
+							good_msg "Removable device ${REAL_LUKS_KEYDEV} mounted." ${CRYPT_SILENT}
 							sleep 2
 							# keyfile exists?
 							if [ ! -e "${mntkey}${LUKS_KEY}" ]; then
 								umount -n ${mntkey} 2>/dev/null >/dev/null
 								KEY_ERROR=1
 								KEYDEV_ERROR=1
-								bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
+								bad_msg "Key {LUKS_KEY} on device ${REAL_LUKS_KEYDEV} not found." ${CRYPT_SILENT}
 								continue
 							fi
 						fi
 					fi
 					# At this point a candidate key exists (either mounted before or not)
-					good_msg "${LUKS_KEY} on device ${LUKS_KEYDEV} found" ${CRYPT_SILENT}
+					good_msg "${LUKS_KEY} on device ${REAL_LUKS_KEYDEV} found" ${CRYPT_SILENT}
 					if [ "$(echo ${LUKS_KEY} | grep -o '.gpg$')" = ".gpg" ] && [ -e /sbin/gpg ] ; then
 						[ -e /dev/tty ] && mv /dev/tty /dev/tty.org
 						mknod /dev/tty c 5 1


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
  2012-11-11 17:04 [gentoo-commits] proj/genkernel:master " Richard Yao
@ 2012-11-11 17:32 ` Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2012-11-11 17:32 UTC (permalink / raw
  To: gentoo-commits

commit:     30c7284c92cacf47250541172dddb10abd70a7a0
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Nov 11 09:13:03 2012 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Nov 11 17:01:28 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=30c7284c

Unquote ${ZPOOL_FORCE} variable usage.

The default value of ${ZPOOL_USAGE} is unset, quoting it would result into
a "" argument passed to zpool. The workaround to this is to use "dozfs=force"
boot argument.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 7cb41b3..2e8e744 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -707,7 +707,7 @@ startVolumes() {
 		then
 			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a "${ZPOOL_FORCE}"
+			/sbin/zpool import -N -a ${ZPOOL_FORCE}
 
 			if [ "$?" = '0' ]
 			then
@@ -725,12 +725,12 @@ startVolumes() {
 				then
 					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
 					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N "${ZPOOL_FORCE}" "${ZFS_POOL}"
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 				fi
 			else
 				good_msg "Importing ZFS pool ${ZFS_POOL}"
 
-				/sbin/zpool import -N "${ZPOOL_FORCE}" "${ZFS_POOL}"
+				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
 				if [ "$?" = '0' ]
 				then


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2012-11-22 22:20 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2012-11-22 22:20 UTC (permalink / raw
  To: gentoo-commits

commit:     52c9537c4809aebae0f60a1be7c9b3011108ebcb
Author:     Toralf Förster <toralf.foerster <AT> gmx <DOT> de>
AuthorDate: Thu Nov 22 22:13:17 2012 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Nov 22 22:15:24 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=52c9537c

Fix non-functional init_opts parameter, bug #422471

If INIT_OPTS='' is not specified before the argument loop, scoping rules
will prevent it from being seen by the switch_root invocation.

Signed-off-by: Toralf Förster <toralf.foerster <AT> gmx.de>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 1bc09a7..c14e9f6 100755
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -38,6 +38,7 @@ CMDLINE=$(cat /proc/cmdline)
 FAKE_ROOT=''
 FAKE_INIT=''
 REAL_ROOTFLAGS=''
+INIT_OPTS=''
 ROOTFSTYPE='auto'
 CRYPT_SILENT=0
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-01-01 16:53 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-01-01 16:53 UTC (permalink / raw
  To: gentoo-commits

commit:     02f271d59f5d729e73de88204b0dc41d12ac6813
Author:     Richard Yao <ryao <AT> cs <DOT> stonybrook <DOT> edu>
AuthorDate: Tue Jan  1 16:47:45 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Tue Jan  1 16:49:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=02f271d5

Add sysctl to busybox

sysctl is necessary to modify chroot restrictions when performing
recovery operations on Gentoo Hardened systems.

Reported-by: Matthew Thode <prometheanfire <AT> gentoo.org>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 2b9a4c4..f086b14 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -907,7 +907,7 @@ CONFIG_PS=y
 # CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
 # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
 # CONFIG_RENICE is not set
-# CONFIG_BB_SYSCTL is not set
+CONFIG_BB_SYSCTL=y
 # CONFIG_TOP is not set
 # CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
 # CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
  2012-11-22 22:20 [gentoo-commits] proj/genkernel:master " Richard Yao
@ 2013-01-01 16:53 ` Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-01-01 16:53 UTC (permalink / raw
  To: gentoo-commits

commit:     543181ebefddbd83850d667aa422991fbe8c3735
Author:     Toralf Förster <toralf.foerster <AT> gmx <DOT> de>
AuthorDate: Thu Nov 22 22:13:17 2012 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Nov 22 22:17:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=543181eb

Fix non-functional init_opts parameter, bug #422471

If INIT_OPTS='' is not specified before the argument loop, scoping rules
will prevent it from being seen by the switch_root invocation.

Signed-off-by: Toralf Förster <toralf.foerster <AT> gmx.de>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 4166396..f1e20ce 100755
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -38,6 +38,7 @@ CMDLINE=$(cat /proc/cmdline)
 FAKE_ROOT=''
 FAKE_INIT=''
 REAL_ROOTFLAGS=''
+INIT_OPTS=''
 ROOTFSTYPE='auto'
 CRYPT_SILENT=0
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     682d0b0d0aaf30e4236809bcf87fc674e6e88c8c
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Tue Apr 23 15:54:10 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 07:20:40 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=682d0b0d

Drop "sleep 3" from sdelay if CDROOT=1. One can use scandelay=secs if needed.

While this makes out of the box booting a bit harder on some ancient CD/DVD
drives, it really speeds up the common use case by not sleeping for 3 seconds.

---
 defaults/initrd.scripts | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index e614064..abd8fad 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -991,19 +991,13 @@ startLUKS() {
 
 sdelay() {
 	# Sleep a specific number of seconds if SDELAY is set
-	if [ "${SDELAY}" ]
+	if [ -n "${SDELAY}" ]
 	then
 		good_msg "Waiting ${SDELAY} seconds..."
 		sleep ${SDELAY}
 	elif [ "${CDROOT}" = '1' ]
 	then
-		# many CD/DVD drives require extra sleep, especially when
-		# connected via USB. Many people reported that 1 second sleep
-		# is not enough on their notebooks, that's why sleep 3, when booting
-		# off a livecd is a better default.
-		sleep 3
-	else
-		good_msg 'Hint: Use parameter scandelay[=seconds] if you need waiting here'
+		good_msg 'Hint: Use scandelay[=seconds] if your live medium is slowand boot fails'
 	fi
 }
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     a408d4a5135fed4507333925713736368a2bf279
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Tue Apr 23 15:41:22 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 07:20:32 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=a408d4a5

Drop useless parens in conditionals

---
 defaults/initrd.scripts | 2 +-
 defaults/linuxrc        | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 7ec5c94..e614064 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -420,7 +420,7 @@ prompt_user(){
 
 	eval local oldvalue='$'${1}
 
-	[ \( $# != 2 \) -a \( $# != 3 \) ] && \
+	[ $# != 2 -a $# != 3 ] && \
 		bad_msg "Bad invocation of function prompt_user, please file a bug \
 		report with this message" && exit 1
 	[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 0fe05ef..805515b 100755
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -270,13 +270,13 @@ do
 	esac
 done
 
-if [ \( "${CDROOT}" = '0' \) ]
+if [ "${CDROOT}" = '0' ]
 then
-	if [ -z "${REAL_ROOT}" -a \( "${FAKE_ROOT}" != "/dev/ram0" \) ]
+	if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ]
 	then
 		REAL_ROOT="${FAKE_ROOT}"
 	fi
-	if [ -z "${REAL_INIT}" -a \( "${FAKE_INIT}" != "/linuxrc" \) ]
+	if [ -z "${REAL_INIT}" -a "${FAKE_INIT}" != "/linuxrc" ]
 	then
 		REAL_INIT="${FAKE_INIT}"
 	fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     499f2d98b60588987b8e0a9e3a59a182c83d5785
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Tue Apr 23 16:31:51 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 07:21:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=499f2d98

Improve speed of bootstrapCD by not calling devicelist unless needed

---
 defaults/initrd.scripts | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index a216b84..ff724b5 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -157,12 +157,15 @@ devicelist(){
 }
 
 bootstrapCD() {
-	local DEVICES=`devicelist`
-	# The device was specified on the command line, so there's no need to scan
-	# a bunch of extra devices
+	local DEVICES=
+
+	# The device was specified on the command line, so there's no need
+	# to scan a bunch of extra devices
 	[ -n "${CDROOT_DEV}" ] && DEVICES="${CDROOT_DEV}"
+	[ -z "${CDROOT_DEV}" ] && DEVICES=$(devicelist)
 
-	findmediamount "cdrom" "${SUBDIR}/${CDROOT_MARKER}" "REAL_ROOT" "${CDROOT_PATH}" ${DEVICES}
+	findmediamount "cdrom" "${SUBDIR}/${CDROOT_MARKER}" \
+		"REAL_ROOT" "${CDROOT_PATH}" ${DEVICES}
 }
 
 bootstrapKey() {


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     421b210c67a59b5a92ce5a92c6d49254cf1ec07a
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Tue Apr 23 15:26:24 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 07:20:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=421b210c

Drop KV_2_6_OR_GREATER

Linux 2.2 and 2.4 are no longer supported. RIP old kernels.

---
 defaults/initrd.defaults |  5 -----
 defaults/linuxrc         | 18 ++++++------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 8ff5510..e70beab 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -50,11 +50,6 @@ KMINOR=`echo $KV | cut -f2 -d.`
 KVER="${KMAJOR}.${KMINOR}"
 MISCOPTS='debug detect'
 
-if [ "${KMAJOR}" -ge 3 ] || [ "${KMAJOR}" -eq 2 -a "${KMINOR}" -eq '6' ]
-then
-	KV_2_6_OR_GREATER="yes"
-fi
-
 QUIET='1'
 ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul'
 ROOT_TREES='etc root home var'

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 703652d..0fe05ef 100755
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -324,16 +324,13 @@ mount_devfs
 mount_sysfs
 
 # Initialize mdev
-if [ "${KV_2_6_OR_GREATER}" ]
-then
-	good_msg 'Activating mdev'
+good_msg 'Activating mdev'
 
-	# Serialize hotplug events
-	touch /dev/mdev.seq
+# Serialize hotplug events
+touch /dev/mdev.seq
 
-	# Setup hotplugging for firmware loading
-	echo /sbin/mdev > /proc/sys/kernel/hotplug
-fi
+# Setup hotplugging for firmware loading
+echo /sbin/mdev > /proc/sys/kernel/hotplug
 
 # Load modules listed in MY_HWOPTS if /lib/modules exists for the running kernel
 if [ -z "${DO_modules}" ]
@@ -357,10 +354,7 @@ else
 fi
 
 # Ensure that device nodes are properly configured
-if [ "${KV_2_6_OR_GREATER}" ]
-then
-	mdev -s || bad_msg "mdev -s failed"
-fi
+mdev -s || bad_msg "mdev -s failed"
 
 # Apply scan delay if specified
 sdelay


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     108f1daf60acfb48e94cf025252ce9d8cb71191a
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Thu Apr 25 15:55:56 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Mon Apr 29 09:54:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=108f1daf

linuxrc: run the debug shell multiple times, add a hook before switch_root

---
 defaults/initrd.scripts | 1 +
 defaults/linuxrc        | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c1969d1..9b0e899 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1055,6 +1055,7 @@ rundebugshell() {
 	if [ -n "$DEBUG" ]
 	then
 		good_msg 'Starting debug shell as requested by "debug" option.'
+		good_msg "Stopping by: ${1}"
 		do_rundebugshell
 	fi
 }

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 1d26aaf..4bbe5e2 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -424,7 +424,7 @@ mkdir -p "${NEW_ROOT}"
 CHROOT="${NEW_ROOT}"
 
 # Run debug shell if requested
-rundebugshell
+rundebugshell "before setting up the root filesystem"
 
 if [ "${CDROOT}" = '1' ]
 then
@@ -937,6 +937,9 @@ then
 	bad_msg "ERROR: your real /dev is missing tty1, required for splash"
 fi
 
+# Run debug shell if requested
+rundebugshell "before entering switch_root"
+
 exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
 
 # If we get here, something bad has happened


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:35 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:35 UTC (permalink / raw
  To: gentoo-commits

commit:     89658dbe29fb2b37f31c0dc8ca6f16e5e37dbbc2
Author:     Richard Yao <ryao <AT> cs <DOT> stonybrook <DOT> edu>
AuthorDate: Tue Jan  1 16:47:45 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Mon Jun  3 23:34:01 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=89658dbe

Add sysctl to busybox

sysctl is necessary to modify chroot restrictions when performing
recovery operations on Gentoo Hardened systems.

Reported-by: Matthew Thode <prometheanfire <AT> gentoo.org>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 2b9a4c4..f086b14 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -907,7 +907,7 @@ CONFIG_PS=y
 # CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
 # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
 # CONFIG_RENICE is not set
-# CONFIG_BB_SYSCTL is not set
+CONFIG_BB_SYSCTL=y
 # CONFIG_TOP is not set
 # CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
 # CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-03 23:49 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-03 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     d35ead2b610d11430c432ad67e68be2c90be8080
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  1 16:47:45 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Mon Jun  3 23:48:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=d35ead2b

Add sysctl to busybox

sysctl is necessary to modify chroot restrictions when performing
recovery operations on Gentoo Hardened systems.

Reported-by: Matthew Thode <prometheanfire <AT> gentoo.org>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 2b9a4c4..f086b14 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -907,7 +907,7 @@ CONFIG_PS=y
 # CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
 # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
 # CONFIG_RENICE is not set
-# CONFIG_BB_SYSCTL is not set
+CONFIG_BB_SYSCTL=y
 # CONFIG_TOP is not set
 # CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
 # CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-06  3:36 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-06  3:36 UTC (permalink / raw
  To: gentoo-commits

commit:     1c19d8a9c6baee1e418275d3106726472992718b
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  1 16:47:45 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Mon Jun  3 23:49:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=1c19d8a9

Add sysctl to busybox

sysctl is necessary to modify chroot restrictions when performing
recovery operations on Gentoo Hardened systems.

Reported-by: Matthew Thode <prometheanfire <AT> gentoo.org>
Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 2b9a4c4..f086b14 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -907,7 +907,7 @@ CONFIG_PS=y
 # CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
 # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
 # CONFIG_RENICE is not set
-# CONFIG_BB_SYSCTL is not set
+CONFIG_BB_SYSCTL=y
 # CONFIG_TOP is not set
 # CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
 # CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  6:43 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  6:43 UTC (permalink / raw
  To: gentoo-commits

commit:     f60f1859fd778c5476bf152f0091957fb397927d
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 06:17:12 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 06:24:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=f60f1859

linuxrc: call depmod as workaround for bug #472312

busybox modprobe does not properly handle dependencies without
modules.dep.bb, so commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 broke
module loading (bug #472312). Calling `busybox depmod -b` is required to
generate modules.dep.bb at build time, but `busybox depmod -b` is
broken, so we call it in the initramfs. Testing by Fabio Erculiani has
shown that the time penalty for this is approximately 0.05 ms, so this
is an acceptable workaround from a performance standpoint.

This is a squashed version of commits from Sabayon's genkernel-next
repository on github, with a new commit message by Richard Yao:

https://github.com/Sabayon/genkernel-next/commit/ece907ea64c3655854cd4044ed33c5d22d8ca463
https://github.com/Sabayon/genkernel-next/commit/f3570c39577573b3dcd8c77720a292fa6b89a022

The workaround implemented was suggested by Ben Kohler.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 11 +++++++++++
 defaults/linuxrc        |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..ef58b5b 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,17 @@
 
 . /etc/initrd.defaults
 
+# We should ship the initramfs with modules.dep.bb
+# But current busybox depmod has broken -b support
+# so we can't do that at build time, unless we want
+# to chroot into the initramfs root, which is much more
+# fragile. See bug #472312
+busybox_depmod_workaround() {
+       local depmod_args
+       [ -n "${QUIET}" ] && depmod_args="-q"
+       depmod ${depmod_args}
+}
+
 modules_load() {
 	for module in $*
 	do

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..ad6af4b 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -320,6 +320,13 @@ mount_devfs
 # Mount sysfs
 mount_sysfs
 
+# We should ship the initramfs with modules.dep.bb
+# But current busybox depmod has broken -b support
+# so we can't do that at build time, unless we want
+# to chroot into the initramfs root, which is much more
+# fragile. See bug #472312
+busybox_depmod_workaround
+
 # Initialize mdev
 good_msg 'Activating mdev'
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  7:45 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  7:45 UTC (permalink / raw
  To: gentoo-commits

commit:     bf5df4d56c9e29e593af4c5df0770a19ff36b80d
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sat Jun  8 14:46:52 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 07:44:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=bf5df4d5

busybox: switch away from MODPROBE_SMALL, see bug #472312#c27

---
 defaults/busy-config | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..82c879c 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
-# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
+CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
+CONFIG_MODPROBE=y
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils
@@ -508,9 +508,9 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  8:32 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  8:32 UTC (permalink / raw
  To: gentoo-commits

commit:     60b5b0327161b0b7b539d3a3bd0001493bce5fb1
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sat Jun  8 14:46:52 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 08:30:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=60b5b032

busybox: switch away from MODPROBE_SMALL, see bug #472312#c27

---
 defaults/busy-config | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..82c879c 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
-# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
+CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
+CONFIG_MODPROBE=y
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils
@@ -508,9 +508,9 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:44 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:44 UTC (permalink / raw
  To: gentoo-commits

commit:     8f4cf00ddc89eb1c710509a9fd23321cef356730
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 09:43:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=8f4cf00d

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 | 77 ++++++++++++++++++++++++-------------------------
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..2f7286b 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,22 +2,6 @@
 
 . /etc/initrd.defaults
 
-call_func_timeout()
-{
-	local func=$1 timeout=$2 pid watcher
-	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
-
-	( ${func} ) & pid=$!
-	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
-	if wait ${pid} 2>/dev/null; then
-	    kill -HUP $watcher 2> /dev/null
-	    wait $watcher
-	    return 1
-	fi
-
-	return 0
-}
-
 modules_load() {
 	for module in $*
 	do
@@ -636,6 +620,12 @@ chooseKeymap() {
 	fi
 }
 
+# This is helper function meant 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,40 +704,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout wait_for_ZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
+
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:44 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:44 UTC (permalink / raw
  To: gentoo-commits

commit:     add80bbae16dff97c52be8d8da92fe3ccdf4bdd9
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 09:43:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=add80bba

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..c8e7abb 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:46 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:46 UTC (permalink / raw
  To: gentoo-commits

commit:     bf7cf9542e40ca2731a1fb0a037d23f279c4a3bd
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 09:45:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=bf7cf954

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 | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..5ef0d39 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -636,6 +636,12 @@ chooseKeymap() {
 	fi
 }
 
+# This is helper function meant 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,40 +720,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout wait_for_ZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
+
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:49 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:49 UTC (permalink / raw
  To: gentoo-commits

commit:     64ba11e1a413394a65d39843fcc54926e7e3044d
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 09:48:47 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=64ba11e1

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..c8e7abb 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:49 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:49 UTC (permalink / raw
  To: gentoo-commits

commit:     951638ab5e354e5d8352858c5e23b391e1ff5079
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 09:48:48 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=951638ab

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 | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..5ef0d39 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -636,6 +636,12 @@ chooseKeymap() {
 	fi
 }
 
+# This is helper function meant 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,40 +720,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout wait_for_ZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
+
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:53 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:53 UTC (permalink / raw
  To: gentoo-commits

commit:     96fc5959f5f911a019079fe4cf6e808448d6a0d4
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 09:52:52 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=96fc5959

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 | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..bc647d8 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,40 +720,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout wait_for_ZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
+
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:58 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     61ba0959fdb6dee4259a7db04982d836ccaaa3b8
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sat Jun  8 14:46:52 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 09:57:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=61ba0959

busybox: switch away from MODPROBE_SMALL, see bug #472312#c27

---
 defaults/busy-config | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..82c879c 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
-# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
+CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
+CONFIG_MODPROBE=y
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils
@@ -508,9 +508,9 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:58 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     171324ea0c713f4c6c7f60587e01fe6718d11874
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 09:57:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=171324ea

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..c8e7abb 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09  9:58 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     643b61faf11add722bcaef2e0bd9c22e9b440c5f
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 09:57:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=643b61fa

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 | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..bc647d8 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,40 +720,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout wait_for_ZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
+
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 10:02 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 10:02 UTC (permalink / raw
  To: gentoo-commits

commit:     6a1fe6ba0d836242d2ab2b600f34cc0a98c883d2
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 10:01:35 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=6a1fe6ba

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 | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c8e7abb..0b76011 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,40 +720,47 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-		if [ -z "${ZFS_POOL}" ]
-		then
-			good_msg "Importing ZFS pools"
 
-			/sbin/zpool import -N -a ${ZPOOL_FORCE}
-
-			if [ "$?" = '0' ]
-			then
-				good_msg "Importing ZFS pools succeeded"
-			else
-				bad_msg "Imported ZFS pools failed"
-			fi
+		# Avoid race involving asynchronous module loading
+		if call_func_timeout waitForZFS 5
+		then
+			bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
 		else
-
-			if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
+			if [ -z "${ZFS_POOL}" ]
 			then
-				good_msg "ZFS pool ${ZFS_POOL} already imported."
+				good_msg "Importing ZFS pools"
 
-				if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+				/sbin/zpool import -N -a ${ZPOOL_FORCE}
+
+				if [ "$?" = '0' ]
 				then
-					good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
-					/sbin/zpool export -f "${ZFS_POOL}"
-					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					good_msg "Importing ZFS pools succeeded"
+				else
+					bad_msg "Imported ZFS pools failed"
 				fi
 			else
-				good_msg "Importing ZFS pool ${ZFS_POOL}"
-
-				/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
 
-				if [ "$?" = '0' ]
+				if [ "$(zpool list -H -o name ${ZFS_POOL} 2>&1)" = "$ZFS_POOL" ]
 				then
-					good_msg "Importing ${ZFS_POOL} succeeded"
+					good_msg "ZFS pool ${ZFS_POOL} already imported."
+
+					if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
+					then
+						good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
+						/sbin/zpool export -f "${ZFS_POOL}"
+						/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+					fi
 				else
-					bad_msg "Importing ${ZFS_POOL} failed"
+					good_msg "Importing ZFS pool ${ZFS_POOL}"
+
+					/sbin/zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
+
+					if [ "$?" = '0' ]
+					then
+						good_msg "Import of ${ZFS_POOL} succeeded"
+					else
+						bad_msg "Import of ${ZFS_POOL} failed"
+					fi
 				fi
 			fi
 		fi


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 10:05 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 10:05 UTC (permalink / raw
  To: gentoo-commits

commit:     71d35173727dc968d7baa2107accb99ebbc5b188
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 10:05:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=71d35173

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 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


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 10:28 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 10:28 UTC (permalink / raw
  To: gentoo-commits

commit:     90c4d77b8dc8d6de601ca41cd6ffa7bfd2cd5a2e
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 10:27:29 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 10:27:29 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=90c4d77b

Do not set CONFIG_FEATURE_CHECK_TAINTED_MODULE

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 82c879c..bf24321 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -508,7 +508,7 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
 CONFIG_FEATURE_MODUTILS_ALIAS=y
 CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 11:43 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 11:43 UTC (permalink / raw
  To: gentoo-commits

commit:     7bf3e57adcab2900860090efbdb83ac2b9787d8b
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 11:42:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=7bf3e57a

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will call invoke modprobe if /dev/zvol is
missing, which concealed this problem. However, this caused problems
because some invocations would fail and under certain circumstances,
init would be killed, causing a kernel panic. We prevent this by
explicitly calling modprobe on each of the dependencies before
attempting to import the pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 6 ++++++
 defaults/linuxrc        | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..4d1cc90 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -721,6 +721,12 @@ startVolumes() {
 	if [ "${USE_ZFS}" = '1' ]
 	then
 
+		# Load modules
+		for i in zlib_deflate spl zavl znvpair zcommon zunicode zfs
+		do
+			modprobe ${i}
+		done
+
 		# Avoid race involving asynchronous module loading
 		if call_func_timeout waitForZFS 5
 		then

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..f54f7d5 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,12 +298,9 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
+	if [ ! -x /sbin/zfs -o ! -x /sbin/zpool ]
 	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
 		USE_ZFS=0
-
 		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
 		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
 		bad_msg 'Aborting use of zfs!'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 11:47 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 11:47 UTC (permalink / raw
  To: gentoo-commits

commit:     c46d88810aefa5e982cdfe01237f64a7e6a63b5a
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 11:47:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=c46d8881

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will call invoke modprobe if /dev/zvol is
missing, which concealed this problem. However, this caused problems
because some invocations would fail and under certain circumstances,
init would be killed, causing a kernel panic. We prevent this by
explicitly calling modprobe on each of the dependencies before
attempting to import the pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 6 ++++++
 defaults/linuxrc        | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..4d1cc90 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -721,6 +721,12 @@ startVolumes() {
 	if [ "${USE_ZFS}" = '1' ]
 	then
 
+		# Load modules
+		for i in zlib_deflate spl zavl znvpair zcommon zunicode zfs
+		do
+			modprobe ${i}
+		done
+
 		# Avoid race involving asynchronous module loading
 		if call_func_timeout waitForZFS 5
 		then

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..f54f7d5 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,12 +298,9 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
+	if [ ! -x /sbin/zfs -o ! -x /sbin/zpool ]
 	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
 		USE_ZFS=0
-
 		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
 		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
 		bad_msg 'Aborting use of zfs!'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 11:51 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 11:51 UTC (permalink / raw
  To: gentoo-commits

commit:     1ffe68f499e1b95e951413731bd6fd0f55dede61
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 11:51:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=1ffe68f4

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will call invoke modprobe if /dev/zvol is
missing, which concealed this problem. However, this caused problems
because some invocations would fail and under certain circumstances,
init would be killed, causing a kernel panic. We prevent this by
explicitly calling modprobe on each of the dependencies before
attempting to import the pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..60294e6 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -300,7 +300,7 @@ if [ "USE_ZFS" = "1" ]
 then
 	if [ -x /sbin/zfs -a -x /sbin/zpool ]
 	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
+		MY_HWOPTS="${MY_HWOPTS} zlib_deflate spl zavl znvpair zcommon zunicode zfs"
 	else
 		USE_ZFS=0
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 11:56 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 11:56 UTC (permalink / raw
  To: gentoo-commits

commit:     404e452dffbbf89c99fa658c90390d6eb59546af
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 11:55:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=404e452d

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. We prevent this by explicitly calling
modprobe on each of the dependencies before attempting to import the
pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..60294e6 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -300,7 +300,7 @@ if [ "USE_ZFS" = "1" ]
 then
 	if [ -x /sbin/zfs -a -x /sbin/zpool ]
 	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
+		MY_HWOPTS="${MY_HWOPTS} zlib_deflate spl zavl znvpair zcommon zunicode zfs"
 	else
 		USE_ZFS=0
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 12:11 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 12:11 UTC (permalink / raw
  To: gentoo-commits

commit:     36ae7f3a00476c6c1e4173d41d3ccf41a3574937
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 12:11:07 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=36ae7f3a

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. We prevent this by explicitly calling
modprobe on each of the dependencies before attempting to import the
pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts |  2 ++
 defaults/linuxrc        | 19 +++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..298feec 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -720,6 +720,8 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
+		# Workaround busybox modprobe's inability to load modules with multiple levels of dependencies
+		modprobe -a zlib_deflate spl zavl znvpair zcommon zunicode zfs
 
 		# Avoid race involving asynchronous module loading
 		if call_func_timeout waitForZFS 5

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,15 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
-
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 12:29 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 12:29 UTC (permalink / raw
  To: gentoo-commits

commit:     022336959eeb1b15b10c2d351432ee3dd68aacb7
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 12:28:19 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=02233695

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. We prevent this by explicitly calling
modprobe on each of the dependencies before attempting to import the
pool.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts |  6 +++---
 defaults/linuxrc        | 19 +++++++++----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..340cc54 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {
@@ -720,7 +721,6 @@ startVolumes() {
 	
 	if [ "${USE_ZFS}" = '1' ]
 	then
-
 		# Avoid race involving asynchronous module loading
 		if call_func_timeout waitForZFS 5
 		then

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,15 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
-
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:15 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:15 UTC (permalink / raw
  To: gentoo-commits

commit:     cd14f68ef3d13622bd5924da375f58e9307533f4
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:13:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=cd14f68e

Refactor ZFS module load hook

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..3784456 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,17 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:15 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:15 UTC (permalink / raw
  To: gentoo-commits

commit:     28da47e3363631dfd1c97164a0efe767f2eb5371
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:14:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=28da47e3

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This was discovered by commit
71d35173727dc968d7baa2107accb99ebbc5b188 because it changed things so
that the zpool and zfs commands were not run until the ZFS module was
loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..73c0f0c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:17 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     ce6de04860a629e9deb033bc4773c8bfccf2ed02
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: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 <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 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


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:17 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     ea52c0e7e74a601d46b26caf3a2bf6a1095726ae
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:16:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=ea52c0e7

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..c8e7abb 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:17 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     f61e7933733687d7d3a424c0d7389787b353973a
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:16:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=f61e7933

Refactor ZFS module load hook

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..3784456 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,17 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:17 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     a0d40003ea3098553f963a17f311671ef3b131e4
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:16:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=a0d40003

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This was discovered by commit
71d35173727dc968d7baa2107accb99ebbc5b188 because it changed things so
that the zpool and zfs commands were not run until the ZFS module was
loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..73c0f0c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:21 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:21 UTC (permalink / raw
  To: gentoo-commits

commit:     1c0131bc6d5acb9a0f7b6d6a7d6c80c0ce2f4cf7
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:19:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=1c0131bc

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
71d35173727dc968d7baa2107accb99ebbc5b188 because it ensured that the
zpool and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..73c0f0c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     31faf0535cb6bbe8b3c4240614b6c162694c2570
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:24:55 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=31faf053

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..c8e7abb 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     90f1bb4fb7b30b777c7d44816bebd967141d5d57
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: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 <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 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


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     ce8210ead879b98cc5314a922874a068aa106b47
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:24:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=ce8210ea

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
71d35173727dc968d7baa2107accb99ebbc5b188 because it ensured that the
zpool and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..73c0f0c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     15ee411366089342e7a9d56f4d2d16af2df40749
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:24:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=15ee4113

Refactor ZFS module load hook

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..3784456 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,17 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     c3c2e464e21a7298284c4688a2fd3776c813bedb
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:28:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=c3c2e464

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression because
busybox's modprobe does fails to properly load certain modules. This can
be addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few
other features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:33 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:33 UTC (permalink / raw
  To: gentoo-commits

commit:     9beda0297d361945a8e51325b9742a83f9fb5753
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:32:25 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=9beda029

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:36 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:36 UTC (permalink / raw
  To: gentoo-commits

commit:     2f648312a5d2328721fd94324cf2ba95280efffb
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:34:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=2f648312

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression where
busybox's modprobe fails to properly load certain modules. This can be
addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few other
features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:36 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:36 UTC (permalink / raw
  To: gentoo-commits

commit:     f9ba19f4d1327abf2b424bb5317b5c18c4726686
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:35:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=f9ba19f4

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:37 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:37 UTC (permalink / raw
  To: gentoo-commits

commit:     2ccc6fc53812d83e458a2e69afdf63cf0c9c449a
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:36:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=2ccc6fc5

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
71d35173727dc968d7baa2107accb99ebbc5b188, which ensured that the zpool
and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f598402..73c0f0c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:37 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:37 UTC (permalink / raw
  To: gentoo-commits

commit:     26a6269afc71bc11f0a708337210c48e0576c779
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:37:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=26a6269a

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression where
busybox's modprobe fails to properly load certain modules. This can be
addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few other
features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:37 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f554af43673f3ccf680e76e4862365360c5b1c3c
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:37:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=f554af43

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     4f38da94eb1dc5f3758a583741eaa5fb1ed3d511
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=4f38da94

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression where
busybox's modprobe fails to properly load certain modules. This can be
addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few other
features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     a33f93c174b67cb766c2b4af39b02ecb6584a76e
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=a33f93c1

Refactor ZFS module load hook

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..3784456 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,17 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     11d3bde66e76d378cab256fb38f5fac4d8d00738
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=11d3bde6

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..bfdde75 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher 2>/dev/null
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     15471fa1d64ff16f666cea789dab106eb49dd8ed
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=15471fa1

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     440c2c143295d158fbb3614886c0c6f7185bfd6d
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=440c2c14

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
71d35173727dc968d7baa2107accb99ebbc5b188, which ensured that the zpool
and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 35e5957..cb0fcb8 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:40 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:40 UTC (permalink / raw
  To: gentoo-commits

commit:     c157dbbd68b2277fdaa0c4179ecf5495db861eb9
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:39:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=c157dbbd

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


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
  2013-06-09 13:48 [gentoo-commits] proj/genkernel:master " Richard Yao
@ 2013-06-09 13:57 ` Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     c2da0c02efadf7d3b70f71ed2acb53ad4e735a75
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 11:36:43 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=c2da0c02

Refactor ZFS module load hook

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/linuxrc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 9ea305b..3784456 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -298,16 +298,17 @@ esac
 # Verify that it is safe to use ZFS
 if [ "USE_ZFS" = "1" ]
 then
-	if [ -x /sbin/zfs -a -x /sbin/zpool ]
-	then
-		MY_HWOPTS="${MY_HWOPTS} zfs"
-	else
-		USE_ZFS=0
+	for i in /sbin/zfs /sbin/zpool
+	do
+		if [ ! -x ${i} ]
+		then
+			USE_ZFS=0
+			bad_msg 'Aborting use of zfs because ${i} not found!'
+			break
+		fi
+	done
 
-		[ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!'
-		[ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!'
-		bad_msg 'Aborting use of zfs!'
-	fi
+	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     85bf0efd762b167c5b47e2fd064bcd536bf98ad7
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:55:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=85bf0efd

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
c812c35100771bb527f6b03853fa6d8ef66a48fe, which ensured that the zpool
and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 35e5957..cb0fcb8 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

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


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     a21728ae287e988a1848435ab27f7ab503def784
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:40:07 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=a21728ae

Add call_func_timeout helper function

call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:

http://stackoverflow.com/a/11056286

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9b0e899..bfdde75 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,6 +2,22 @@
 
 . /etc/initrd.defaults
 
+call_func_timeout()
+{
+	local func=$1 timeout=$2 pid watcher
+	[ $# -ne 2 ] && gen_die "call_func_timeout() called with $# arguments"
+
+	( ${func} ) & pid=$!
+	( sleep ${timeout} && kill -HUP ${pid} ) 2>/dev/null & watcher=$!
+	if wait ${pid} 2>/dev/null; then
+	    kill -HUP $watcher 2> /dev/null
+	    wait $watcher 2>/dev/null
+	    return 1
+	fi
+
+	return 0
+}
+
 modules_load() {
 	for module in $*
 	do


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     6db2bc0f217d2f7b02a49184c489e9f1b469c009
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:55:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=6db2bc0f

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     38a8e4a8d31dbec3af7e623640d536274c7c5f50
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:55:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=38a8e4a8

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression where
busybox's modprobe fails to properly load certain modules. This can be
addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few other
features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
  2013-06-09 13:57 [gentoo-commits] proj/genkernel:master " Richard Yao
@ 2013-06-09 13:57 ` Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     987bb3098e81c43e8aaf2a02830508acb801ac0c
Author:     Ben Kohler <bkohler <AT> gmail <DOT> com>
AuthorDate: Sun Jun  9 13:28:23 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:56:25 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=987bb309

Make busybox's module loading more fully featured, bug #472312

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, this caused a regression where
busybox's modprobe fails to properly load certain modules. This can be
addressed by abandoning CONFIG_MODPROBE_SMALL=y. We also set a few other
features to make module loading more fully featured.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index f086b14..513ff0b 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -487,16 +487,16 @@ CONFIG_CHPASSWD=y
 # Linux Module Utilities
 #
 CONFIG_MODINFO=y
-CONFIG_MODPROBE_SMALL=y
-CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
-CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
-# CONFIG_INSMOD is not set
-# CONFIG_RMMOD is not set
-# CONFIG_LSMOD is not set
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+CONFIG_INSMOD=y
+CONFIG_RMMOD=y
+CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
-# CONFIG_MODPROBE is not set
+CONFIG_MODPROBE=y
 # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
-# CONFIG_DEPMOD is not set
+CONFIG_DEPMOD=y
 
 #
 # Options common to multiple modutils


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-06-09 13:57 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     62bd9ecc16d0875257c22c7b8f68b73452e9cb80
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Sun Jun  9 13:32:25 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:56:25 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=62bd9ecc

Add more module loading features

These additional features were suggested by Fabio in bug #472312.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/busy-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/defaults/busy-config b/defaults/busy-config
index 513ff0b..da260a8 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -495,7 +495,7 @@ CONFIG_RMMOD=y
 CONFIG_LSMOD=y
 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
 CONFIG_MODPROBE=y
-# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
 CONFIG_DEPMOD=y
 
 #
@@ -508,9 +508,9 @@ CONFIG_DEPMOD=y
 # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
 # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
-# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
-# CONFIG_FEATURE_MODUTILS_ALIAS is not set
-# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
 CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
 CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
 


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
  2013-06-09 13:57 [gentoo-commits] proj/genkernel:master " Richard Yao
@ 2013-06-09 13:57 ` Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-06-09 13:57 UTC (permalink / raw
  To: gentoo-commits

commit:     2fa0a9beaa069a61f907f0b06c9bd6abeddb1ca7
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 13:13:58 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 13:56:14 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=2fa0a9be

Workaround busybox modprobe's inability to load ZFS modules

Commit 3a054014e880e5b1ff28e3d87767c45a073da6b5 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.

The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
c812c35100771bb527f6b03853fa6d8ef66a48fe, which ensured that the zpool
and zfs commands were not run until the ZFS module was loaded.

busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.

We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.

Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 5 +++--
 defaults/linuxrc        | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 35e5957..cb0fcb8 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -637,9 +637,10 @@ chooseKeymap() {
 }
 
 # 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.
+# This works around the inability of busybox modprobe to handle complex module dependencies.
+# This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
-	while [ ! -c /dev/zfs ]; do echo >/dev/null; done;
+	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
 }
 
 startVolumes() {

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 3784456..d6d0eaa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -307,8 +307,6 @@ then
 			break
 		fi
 	done
-
-	[ "USE_ZFS" = "1" ] && MY_HWOPTS="${MY_HWOPTS} zfs"
 fi
 
 splash 'init'


^ permalink raw reply related	[flat|nested] 68+ messages in thread

* [gentoo-commits] proj/genkernel:ryao commit in: defaults/
@ 2013-10-02 12:43 Richard Yao
  0 siblings, 0 replies; 68+ messages in thread
From: Richard Yao @ 2013-10-02 12:43 UTC (permalink / raw
  To: gentoo-commits

commit:     7f988ea77debe3f5d0627568584af60a4625f251
Author:     Richard Yao <ryao <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 21 15:18:54 2013 +0000
Commit:     Richard Yao <ryao <AT> gentoo <DOT> org>
CommitDate: Wed Aug 21 15:18:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=7f988ea7

Add exit 1 to waitForZFS

Proper use of call_func_timeout() requires that we return an exit status
of 1 upon success.

Signed-off-by: Richard Yao <ryao <AT> gentoo.org>

---
 defaults/initrd.scripts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index cb0fcb8..4b7c5ba 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -641,6 +641,7 @@ chooseKeymap() {
 # This also enables us to wait a reasonable amount of time until /dev/zfs appears.
 waitForZFS() {
 	while [ ! -c /dev/zfs ]; do modprobe zfs 2> /dev/null; done;
+	exit 1
 }
 
 startVolumes() {


^ permalink raw reply related	[flat|nested] 68+ messages in thread

end of thread, other threads:[~2013-10-02 12:43 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09 11:47 [gentoo-commits] proj/genkernel:ryao commit in: defaults/ Richard Yao
  -- strict thread matches above, loose matches on Subject: below --
2013-10-02 12:43 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 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: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 [gentoo-commits] proj/genkernel:master " Richard Yao
2013-01-01 16:53 ` [gentoo-commits] proj/genkernel:ryao " Richard Yao
2012-11-22 22:20 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox