summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorMike Christie <mnc@max.(none)>2009-07-29 02:53:07 -0500
committerMike Christie <mnc@max.(none)>2009-07-29 02:53:07 -0500
commita62d1b60856dc3118ab1d07990d43695b336fd69 (patch)
tree186a3cab57a0c4a53c475ceb407561eed657666a /etc
parentfea9e286cb9da1f643662266ccd00b31fe65aeba (diff)
downloadopen-iscsi-a62d1b60856dc3118ab1d07990d43695b336fd69.tar.gz
[PATCH] Don't kill iscsid if logout from all nodes fail
Patch and email from Erez: If 'iscsiadm -m node --logoutall=all' fails when stopping the open-iscsi service, we shouldn't kill iscsid. This solves the following race: 1. A logout from a node is initiated by the user. 2. Before the logout completes, the user runs /etc/init.d/iscsi stop. The 'stop' method logs out from all nodes. When it tries to logout from the node that is already logging out (step #1), it fails because it is already logging out. Then, the 'stop' method kills iscsid. 3. The logout command form step #1 returns and notifies the (dead) daemon. Now, running 'iscsiadm -m session' shows a session (which, actually, doesn't exist anymore) and the iscsi service is down. Signed-off-by: Erez Zilber <erezzi.list@gmail.com>
Diffstat (limited to 'etc')
-rw-r--r--etc/initd/initd.debian16
-rw-r--r--etc/initd/initd.redhat13
-rw-r--r--etc/initd/initd.suse5
3 files changed, 33 insertions, 1 deletions
diff --git a/etc/initd/initd.debian b/etc/initd/initd.debian
index c0dfd1e..59bf59b 100644
--- a/etc/initd/initd.debian
+++ b/etc/initd/initd.debian
@@ -46,11 +46,17 @@ stoptargets() {
log_daemon_msg "Disconnecting iSCSI targets"
sync
$ADM -m node --logoutall=all
- log_end_msg 0
+ RETVAL=$?
+ log_end_msg $RETVAL
}
stop() {
stoptargets
+ if [ $RETVAL -ne 0 ]; then
+ log_failure_msg "Could not stop all targets, try again later"
+ return $RETVAL
+ fi
+
log_daemon_msg "Stopping iSCSI initiator service"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
rm -f $PIDFILE
@@ -68,11 +74,19 @@ stop() {
restart() {
stop
+ if [ $RETVAL -ne 0 ]; then
+ log_failure_msg "Stopping iSCSI initiator service failed, not starting"
+ return $RETVAL
+ fi
start
}
restarttargets() {
stoptargets
+ if [ $RETVAL -ne 0 ]; then
+ log_failure_msg "Could not stop all targets, try again later"
+ return $RETVAL
+ fi
starttargets
}
diff --git a/etc/initd/initd.redhat b/etc/initd/initd.redhat
index d68f135..c767cfb 100644
--- a/etc/initd/initd.redhat
+++ b/etc/initd/initd.redhat
@@ -39,6 +39,11 @@ stop()
echo -n $"Stopping iSCSI initiator service: "
sync
iscsiadm -m node --logoutall=all
+ RETVAL=$?
+ if [ $RETVAL -ne 0 ]; then
+ echo "Could not logout from all nodes, try again later"
+ return $RETVAL
+ fi
killproc iscsid
rm -f /var/run/iscsid.pid
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-iscsi
@@ -63,6 +68,10 @@ stop()
restart()
{
stop
+ if [ $RETVAL -ne 0 ]; then
+ echo "Stopping iSCSI initiator service failed, not starting"
+ return $RETVAL
+ fi
start
}
@@ -76,6 +85,10 @@ case "$1" in
;;
restart)
stop
+ if [ $RETVAL -ne 0 ]; then
+ echo "Stopping iSCSI initiator service failed, not starting"
+ exit $RETVAL
+ fi
start
;;
status)
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 23bbac0..bdb4dc7 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -192,6 +192,11 @@ case "$1" in
;;
restart)
$0 stop
+ RETVAL=$?
+ if [ "$RETVAL" != "0" ]; then
+ echo "Stopping iSCSI initiator service failed, not starting"
+ exit $RETVAL
+ fi
sleep 1
$0 start
;;