rpms/zfs-fuse/devel zfs-fuse.spec,1.3,1.4 zfs-fuse.init,1.2,1.3

Uwe Kubosch donv at fedoraproject.org
Wed Dec 24 23:45:47 UTC 2008


Author: donv

Update of /cvs/pkgs/rpms/zfs-fuse/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv31827/devel

Modified Files:
	zfs-fuse.spec zfs-fuse.init 
Log Message:
* Sun Dec 28 2008 Uwe Kubosh <uwe at kubosch.no> - 0.5.0-5.20081221
- Updated etc/init.d/zfs-fuse init script after feedback from
  dragonfear at gmail.com at
  http://groups.google.com/group/zfs-fuse/browse_thread/thread/da94aa803bceef52
- Adds better wait at startup before mounting filesystems.
- Add OOM kill protection.
- Adds syncing of disks at shutdown.
- Adds pool status when asking for service status.



Index: zfs-fuse.spec
===================================================================
RCS file: /cvs/pkgs/rpms/zfs-fuse/devel/zfs-fuse.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- zfs-fuse.spec	22 Dec 2008 21:45:14 -0000	1.3
+++ zfs-fuse.spec	24 Dec 2008 23:45:16 -0000	1.4
@@ -83,6 +83,15 @@
 %{_sysconfdir}/sysconfig/%{name}
 
 %changelog
+* Sun Dec 28 2008 Uwe Kubosh <uwe at kubosch.no> - 0.5.0-5.20081221
+- Updated etc/init.d/zfs-fuse init script after feedback from
+  dragonfear at gmail.com at
+  http://groups.google.com/group/zfs-fuse/browse_thread/thread/da94aa803bceef52
+- Adds better wait at startup before mounting filesystems.
+- Add OOM kill protection.
+- Adds syncing of disks at shutdown.
+- Adds pool status when asking for service status.
+
 * Sun Dec 21 2008 Uwe Kubosh <uwe at kubosch.no> - 0.5.0-4.20081221
 - Updated to upstream trunk of 2008-12-21
 - Added config file in /etc/sysconfig/zfs


Index: zfs-fuse.init
===================================================================
RCS file: /cvs/pkgs/rpms/zfs-fuse/devel/zfs-fuse.init,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- zfs-fuse.init	22 Dec 2008 21:45:14 -0000	1.2
+++ zfs-fuse.init	24 Dec 2008 23:45:16 -0000	1.3
@@ -20,93 +20,173 @@
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-exec="/usr/bin/zfs-fuse"
 prog="zfs-fuse"
+exec="/usr/bin/$prog"
 config=/etc/sysconfig/$prog
 
 [ -e $config ] && . $config
 
-lockfile=/var/lock/subsys/$prog
+PIDFILE=/var/run/$prog.pid
+
+unset LANG
 
 start() {
-    [ -x $exec ] || exit 5
+    [ -x $exec ] || (echo "$prog binary not present or executable" && exit 5)
+    PID=`pidofproc $prog`
+    start_status=$?
+    case "$start_status" in
+    0)
+        echo "ZFS-FUSE is already running with pid $pid"
+        exit 3
+        ;;
+    1)
+        echo "Cleaning up stale $prog PID file in $PIDFILE"
+        rm -f "$PIDFILE"
+        ;;
+    3)
+        # not running
+        ;;
+    *)
+    	echo "Huh?"
+    	exit 99
+    esac
+
     echo -n $"Starting $prog: "
-    daemon $exec
-    retval=$?
+    daemon $exec -p "$PIDFILE"
+    exec_retval=$?
     echo
-    if [ $retval -eq 0 ] ; then
-    	touch $lockfile
-    	if [ $ZFS_AUTOMOUNT -eq 1 ] ; then
-			echo -n $"Mounting zfs partitions: "
-    		sleep 1
-			zfs mount -a
-			zfs_mount_retval=$?
-			if [ $zfs_mount_retval = 0 ]; then
-				echo_success
-			else
-				echo_warning
-			fi
-			echo
-    	fi
+    [ $exec_retval -ne 0 ] && return $exec_retval
+	
+    for a in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
+        PID=`pidofproc $prog`
+        [ "$PID" != "" ] && break
+        echo -n "."
+        sleep 1
+    done
+
+    if [ "$PID" = "" ] ; then
+        echo "ZFS-FUSE did not start or create $PIDFILE"
+        exit 3
+    fi 
+
+    echo -n "Immunizing $prog against OOM kills"
+    echo -17 > "/proc/$PID/oom_adj"
+    ES_TO_REPORT=$?
+    if [ "$ES_TO_REPORT" -ne 0 ] ; then
+		echo_warning
+        echo "code $ES_TO_REPORT"
+        exit 3
     fi
-    return $retval
+    echo_success
+    echo
+
+	if [ $ZFS_AUTOMOUNT -eq 1 ] ; then
+		echo -n $"Mounting zfs partitions: "
+    	sleep 1
+        rm -f /var/lib/random-seed
+		zfs mount -a
+		zfs_mount_retval=$?
+		if [ $zfs_mount_retval = 0 ]; then
+			echo_success
+		else
+			echo_warning
+			echo zfs mount failed with code $zfs_mount_retval
+		fi
+		echo
+    fi
+    
+    
+#    if [ -x /nonexistent -a -x /usr/bin/renice ] ; then # DISABLED
+#        log_action_begin_msg "Increasing ZFS-FUSE priority"
+#        /usr/bin/renice -15 -g $PID > /dev/null
+#        ES_TO_REPORT=$?
+#        if [ 0 = "$ES_TO_REPORT" ] ; then
+#            log_action_end_msg 0
+#        else
+#            log_action_end_msg 1 "code $ES_TO_REPORT"
+#            exit 3
+#        fi
+#        true
+#    fi 
+        
+    
+    return $exec_retval
 }
 
 stop() {
+    status_quiet || return 0
+    [ -x $exec ] || (echo "$prog binary not present or executable" && exit 5)
+    PID=`pidofproc $prog`
+    if [ "$PID" != "" ] ; then
+        echo -n "Syncing disks"
+        sync
+        echo_success
+        echo
+
+        echo -n "Unmounting ZFS filesystems"
+        zfs unmount -a
+        ES_TO_REPORT=$?
+        if [ 0 = "$ES_TO_REPORT" ] ; then
+            echo_success
+        else
+            echo_warning
+            exit 3
+        fi
+        echo
+    fi
+
     echo -n $"Stopping $prog: "
     killproc $prog
-    retval=$?
-    echo
-    [ $retval -eq 0 ] && rm -f $lockfile
-    return $retval
-}
-
-restart() {
-    stop
-    start 
-}
+    kill_retval=$?
+	echo
+	
+	if [ "$PID" != "" ] ; then
+    	echo -n "Syncing disks again"
+    	sync
+    	echo_success
+    	echo
+    fi
 
-reload() {
-    restart
+    return $kill_retval
 }
 
-force_reload() {
-    restart
+restart() {
+	stop
+	start
 }
 
-rh_status() {
+pool_status() {
     # run checks to determine if the service is running or use generic status
-    status $prog
+    status $prog && /usr/bin/zpool status
 }
 
-rh_status_q() {
-    rh_status >/dev/null 2>&1
+status_quiet() {
+    pool_status >/dev/null 2>&1
 }
 
 case "$1" in
     start)
-        rh_status_q && exit 0
+        status_quiet && exit 0
         $1
         ;;
     stop)
-        rh_status_q || exit 0
         $1
         ;;
     restart)
-        $1
+    	restart 
         ;;
     reload)
-        rh_status_q || exit 7
-        $1
+        status_quiet || exit 7
+	    restart
         ;;
     force-reload)
-        force_reload
+	    restart
         ;;
     status)
-        rh_status
+        pool_status
         ;;
     condrestart|try-restart)
-        rh_status_q || exit 0
+        status_quiet || exit 0
         restart
         ;;
     *)




More information about the fedora-extras-commits mailing list