From d50f88e3c61b4e4c0f48d79b74dfae0f0a75f892 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Tue, 13 Jul 2010 18:15:30 +0300 Subject: [PATCH] up: Revamp the up script - Define a function to load a single back-store. - Use above to load multiple back-stores. - Do not load multiple LUNs in one target, load multiple targets (same IP) with single LUN each. This will take advantage of new pthread per target. (Above should be done in two patches, but who's looking?) Signed-off-by: Boaz Harrosh --- up | 61 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/up b/up index 23ea42f..15d4534 100755 --- a/up +++ b/up @@ -1,47 +1,44 @@ #!/bin/sh -# must have LUN0 -BACKSTORE0=/usr0/var/osd-tgt/tgt-0/ -# Optional additional LUNes here -BACKSTORE1=/usr0/var/osd-tgt/tgt-1/ -BACKSTORE2=/usr0/var/osd-tgt/tgt-2/ -BACKSTORE3=/usr0/var/osd-tgt/tgt-3/ - +# Path to executables, assuming source tree TGTADM=./tgt/usr/tgtadm OTGTD=./tgt/usr/otgtd + +# must have target1 +BACKSTORE1=/usr0/var/osd-tgt/tgt-0/ +# Optional additional back-stores here +BACKSTORE2=/usr0/var/osd-tgt/tgt-1/ +# BACKSTORE3=/usr0/var/osd-tgt/tgt-2/ +# BACKSTORE4=/usr0/var/osd-tgt/tgt-3/ + +# $1<=BACKSTORE $2<=tid +load_target() +{ +$TGTADM --lld iscsi --mode target --op new --tid $2 --targetname ${1//\//\.}$(hostname) +$TGTADM --lld iscsi --mode target \ + --op bind --tid $2 --initiator-address ALL + +$TGTADM --lld iscsi --mode logicalunit \ + --op new --tid $2 --lun 0 --bstype=osdemu --device-type osd \ + --backing-store $1 +} + +# First run the otgtd daemon in forgraound # -f - forgraound # -d - debug level # DEBUG="-d 9" DEBUG="" - $OTGTD $DEBUG -f & sleep 2 -$TGTADM --lld iscsi --mode target --op new --tid 1 --targetname $(hostname) -$TGTADM --lld iscsi --mode target \ - --op bind --tid 1 --initiator-address ALL -$TGTADM --lld iscsi --mode logicalunit \ - --op new --tid 1 --lun 0 --bstype=osdemu --device-type osd \ - --backing-store $BACKSTORE0 - -if [ -n $BACKSTORE1 ]; then - $TGTADM --lld iscsi --mode logicalunit \ - --op new --tid 1 --lun 1 --bstype=osdemu --device-type osd \ - --backing-store $BACKSTORE1 -fi - -if [ -n $BACKSTORE2 ]; then - $TGTADM --lld iscsi --mode logicalunit \ - --op new --tid 1 --lun 2 --bstype=osdemu --device-type osd \ - --backing-store $BACKSTORE2 -fi - -if [ -n $BACKSTORE3 ]; then - $TGTADM --lld iscsi --mode logicalunit \ - --op new --tid 1 --lun 3 --bstype=osdemu --device-type osd \ - --backing-store $BACKSTORE3 -fi +# 2nd Load some targets + +load_target $BACKSTORE1 1 +load_target $BACKSTORE2 2 +# load_target $BACKSTORE3 3 +# load_target $BACKSTORE4 4 +# Last print what we got, then stay in forgraound (ctrl-C to exit) $TGTADM --lld iscsi --mode target --op show wait