[Glibc-bsd-commits] r3152 - trunk/zfsutils/debian

Aurelien Jarno aurel32 at alioth.debian.org
Sat Aug 7 11:39:03 UTC 2010


Author: aurel32
Date: 2010-08-07 11:39:01 +0000 (Sat, 07 Aug 2010)
New Revision: 3152

Modified:
   trunk/zfsutils/debian/changelog
   trunk/zfsutils/debian/zfsutils.zfs.init
Log:
  * Update init script to also start/stop zvol and mount swap on zvol.
    Closes: bug#591909.



Modified: trunk/zfsutils/debian/changelog
===================================================================
--- trunk/zfsutils/debian/changelog	2010-08-07 11:17:25 UTC (rev 3151)
+++ trunk/zfsutils/debian/changelog	2010-08-07 11:39:01 UTC (rev 3152)
@@ -2,6 +2,8 @@
 
   * Create /etc/zfs so that zfs can store its configuration. Closes: 
     bug#591921.
+  * Update init script to also start/stop zvol and mount swap on zvol.
+    Closes: bug#591909.
 
  -- Aurelien Jarno <aurel32 at debian.org>  Fri, 06 Aug 2010 22:47:15 +0200
 

Modified: trunk/zfsutils/debian/zfsutils.zfs.init
===================================================================
--- trunk/zfsutils/debian/zfsutils.zfs.init	2010-08-07 11:17:25 UTC (rev 3151)
+++ trunk/zfsutils/debian/zfsutils.zfs.init	2010-08-07 11:39:01 UTC (rev 3152)
@@ -1,11 +1,11 @@
 #! /bin/sh
 ### BEGIN INIT INFO
-# Provides:          zfs
+# Provides:          zvol zfs
 # Required-Start:
 # Required-Stop: 
 # Default-Start:     S
 # Default-Stop:      0 6
-# Short-Description: Mount/umount zfs filesystems.
+# Short-Description: Start/stop ZFS subsystem.
 # Description:
 ### END INIT INFO
 
@@ -15,31 +15,90 @@
 . /lib/init/vars.sh
 
 do_start() {
-	if [ "$VERBOSE" = no ]
-	then
-		log_action_begin_msg "Mounting zfs filesystems"
-		zfs mount -a
-		log_action_end_msg $?
-	else
-		log_daemon_msg "Will now mount zfs filesystems"
-		zfs mount -a
-		log_end_msg $?
+	log_begin_msg "Starting ZFS subsystem..."
+
+	# zvol
+	log_progress_msg "zvol"
+	zfs volinit
+	RET=$?
+	if [ $RET != 0 ] ; then
+		log_end_msg $RET
+		exit $RET
 	fi
+
+	# Enable swap on ZVOLs with property org.freebsd:swap=on.
+	log_progress_msg "swap"
+	zfs list -H -o org.freebsd:swap,name -t volume | \
+	while read state name; do
+		case "${state}" in
+		[oO][nN])
+			swapon /dev/zvol/${name}
+			RET=$?
+			if [ $RET != 0 ] ; then
+				log_end_msg $RET
+				exit $RET
+			fi
+		esac
+	done
+
+	# filesystems
+	log_progress_msg "filesystems"
+	zfs mount -a
+	RET=$?
+	if [ $RET != 0 ] ; then
+		log_end_msg $RET
+		exit $RET
+	fi
+
+	# end
+	log_end_msg 0
 }
 
 do_stop() {
-	if [ "$VERBOSE" = no ]
-	then
-		log_action_begin_msg "Mounting zfs filesystems"
-		zfs umount -a
-		zfs unshare -a
-		log_action_end_msg $?
-	else
-		log_daemon_msg "Will now mount zfs filesystems"
-		zfs umount -a
-		zfs unshare -a
-		log_end_msg $?
+	log_begin_msg "Stopping ZFS subsystem..."
+
+	# Disable swap on ZVOLs with property org.freebsd:swap=on.
+	log_progress_msg "zvol"
+	zfs list -H -o org.freebsd:swap,name -t volume | \
+	while read state name; do
+		case "${state}" in
+		[oO][nN])
+			swapoff /dev/zvol/${name}
+			RET=$?
+			if [ $RET != 0 ] ; then
+				log_end_msg $RET
+				exit $RET
+			fi
+			;;
+		esac
+	done
+
+	# zvol
+	log_progress_msg "zvol"
+	zfs volfini
+	RET=$?
+	if [ $RET != 0 ] ; then
+		log_end_msg $RET
+		exit $RET
 	fi
+
+	# filesystems
+	log_progress_msg "filesystems"
+	zfs unshare -a
+	RET=$?
+	if [ $RET != 0 ] ; then
+		log_end_msg $RET
+		exit $RET
+	fi
+	zfs umount -a
+	RET=$?
+	if [ $RET != 0 ] ; then
+		log_end_msg $RET
+		exit $RET
+	fi
+
+	# end
+	log_end_msg 0
 }
 
 




More information about the Glibc-bsd-commits mailing list