From c685db2cac4390db6a43f1723390b5ceba886e6d Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 28 Jun 2010 15:13:20 +0200 Subject: [PATCH 1/3] stopping iscsi daemon returns 'failed' for root on iSCSI When running with root on iSCSI the init script returns 'failed' on stop. Problem here is that we're not logging out of the session for the root fs, but rather skipping it when trying to umount all fs. However, later on we're checking if we have been able to close all sessions and return an error if not. Which of course is wrong for root-on-iscsi setups. So we should be better counting the number of sessions we _should have_ stopped, and only try to logout from those. References: bnc#608224 Signed-off-by: Hannes Reinecke --- etc/initd/initd.suse | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse index ca73366..2067fd3 100644 --- a/etc/initd/initd.suse +++ b/etc/initd/initd.suse @@ -289,8 +289,9 @@ iscsi_check_target() # iscsi_stop_sessions() { - local t m s + local t m s i + i=0 for session in /sys/class/iscsi_session/session* ; do [ -e "$session" ] || continue; [ -e $session/device ] || continue @@ -300,10 +301,12 @@ iscsi_stop_sessions() if [ -z "$m" ] ; then echo "stopping session $s" iscsiadm -m session -r ${s} -u + i=$(( $i + 1 )) else iscsi_check_interface $s fi done + echo $i } iscsi_list_all_nodes() @@ -338,18 +341,22 @@ case "$1" in fi ;; stop) - iscsi_stop_sessions + n=$(iscsi_stop_sessions) echo -n "Stopping iSCSI initiator service: " - m=$(iscsiadm -m session 2> /dev/null) - if [ -z "$m" ] ; then - killproc -KILL $DAEMON - RETVAL=$? - if grep -q bnx2i /proc/modules ; then - killproc -KILL $BRCM_ISCSIUIO + if [ "$n" -gt 0 ] ; then + m=$(iscsiadm -m session 2> /dev/null) + if [ -z "$m" ] ; then + killproc -KILL $DAEMON + RETVAL=$? + if grep -q bnx2i /proc/modules ; then + killproc -KILL $BRCM_ISCSIUIO + fi + RETVAL=$? + else + RETVAL=1 fi - RETVAL=$? else - RETVAL=1 + RETVAL=0 fi rc_failed $RETVAL rc_status -v -- 1.6.6.1