Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Jul 13, 2010
1 parent 3ea2ff6 commit d50f88e
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions 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

0 comments on commit d50f88e

Please sign in to comment.