Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev
[PATCH 1 of 3] iSCSITarget: improve loop over existing connections on stop
 

Index | Next | Previous | View Flat


florian.haas at linbit

Jun 23, 2009, 6:01 AM


Views: 278
Permalink
[PATCH 1 of 3] iSCSITarget: improve loop over existing connections on stop

# HG changeset patch
# User Florian Haas <florian.haas[at]linbit.com>
# Date 1245761391 -7200
# Node ID 720e09be75f065024570525f413231b1fd88bcb4
# Parent 2c2f6d93c1eee5addb8652900151a4ceb540d341
iSCSITarget: improve loop over existing connections on stop

Cosmetic change: replace the ugly "while read" loop with some
set/shift magic.

diff -r 2c2f6d93c1ee -r 720e09be75f0 resources/OCF/iSCSITarget
--- a/resources/OCF/iSCSITarget Mon Jun 22 12:44:13 2009 +0200
+++ b/resources/OCF/iSCSITarget Tue Jun 23 14:49:51 2009 +0200
@@ -193,19 +193,19 @@
# Close existing connections. There is no other way to
# do this in IET than to parse the contents of
# /proc/net/iet/session.
- local line
- sed -ne '/^tid:'${OCF_RESKEY_tid}' /,/^tid/ {
+ set -- $(sed -ne '/^tid:'${OCF_RESKEY_tid}' /,/^tid/ {
/^[[:space:]]*sid:\([0-9]\+\)/ {
s/^[[:space:]]*sid:\([0-9]*\).*/--sid=\1/; h;
};
/^[[:space:]]*cid:\([0-9]\+\)/ {
- s/^[[:space:]]*cid:\([0-9]*\).*/--cid=\1/; G; s/\n/ /;p;
+ s/^[[:space:]]*cid:\([0-9]*\).*/--cid=\1/; G; p;
};
- }' < /proc/net/iet/session \
- | while read line; do
- # $line looks like "--sid=X --cid=Y"
- do_cmd ietadm --op delete \
- --tid ${OCF_RESKEY_tid} $line
+ }' < /proc/net/iet/session)
+ while [[ -n $2 ]]; do
+ # $2 $1 looks like "--sid=X --cid=Y"
+ do_cmd ietadm --op delete \
+ --tid=${OCF_RESKEY_tid} $2 $1
+ shift 2
done
do_cmd ietadm --op delete \
--tid=${OCF_RESKEY_tid} && return $OCF_SUCCESS
@@ -214,24 +214,24 @@
# Close existing connections. There is no other way to
# do this in tgt than to parse the output of "tgtadm --op
# show".
- local line
- tgtadm --lld iscsi --op show --mode target \
+ set -- $(tgtadm --lld iscsi --op show --mode target \
| sed -ne '/^Target '${OCF_RESKEY_tid}':/,/^Target/ {
/^[[:space:]]*I_T nexus: \([0-9]\+\)/ {
s/^.*: \([0-9]*\).*/--sid=\1/; h;
};
/^[[:space:]]*Connection: \([0-9]\+\)/ {
- s/^.*: \([0-9]*\).*/--cid=\1/; G; s/\n/ /;p;
+ s/^.*: \([0-9]*\).*/--cid=\1/; G; p;
};
/^[[:space:]]*LUN information:/ q;
- }' \
- | while read line; do
- # $line looks like "--sid=X --cid=Y"
- do_cmd tgtadm --lld iscsi --op delete --mode connection \
- --tid ${OCF_RESKEY_tid} $line
+ }')
+ while [[ -n $2 ]]; do
+ # $2 $1 looks like "--sid=X --cid=Y"
+ do_cmd tgtadm --lld iscsi --op delete --mode connection \
+ --tid=${OCF_RESKEY_tid} $2 $1
+ shift 2
done
do_cmd tgtadm --lld iscsi --op delete --mode target \
- --tid ${OCF_RESKEY_tid} && return $OCF_SUCCESS
+ --tid=${OCF_RESKEY_tid} && return $OCF_SUCCESS
;;
esac
else
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev[at]lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Subject User Time
[PATCH 1 of 3] iSCSITarget: improve loop over existing connections on stop florian.haas at linbit Jun 23, 2009, 6:01 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.