[stgt] Need some help setting up a tape changer

Albert Pauw albert.pauw at gmail.com
Fri Feb 27 21:00:05 CET 2009


After getting a virtual tape drive working I tried setting up a tape 
changer with three drives.

Here is the script I use for it, part of the tgt-core-test script 
supplied in the git tree:

#!/bin/bash

###############################################################################
# Set up SBC HDD device
###############################################################################
TID=1

# Create Target ID 1..
tgtadm --lld iscsi --mode target --op new --tid $TID \
        -T iqn.2008-09.com.example:server.tape
sleep

###############################################################################
# Set up SMC Medium Changer
###############################################################################
LUN=1
if [ ! -f $HOME/smc ]; then
    dd if=/dev/zero of=$HOME/smc bs=1k count=1
fi

tgtadm --lld iscsi --mode logicalunit --op new --tid $TID --lun $LUN \
            -b $HOME/smc --device-type=changer

#### Set up mode pages ####
# From smc3-06.pdf
# Page 0x02: Disconnect/Reconnect SPC-3
# Page 0x0a: Control SPC-3
# Page 0x18: Protocol Specific LUN SPC-3
# Page 0x19: Protocol Specific Port SPC-3
# Page 0x1a: Power Condition SPC-3
# Page 0x1c: Informational Exceptions Control SPC-3
# Page 0x1d: Element Address Assignment SMC-3 7.3.4
# Page 0x1e: Transport Geometry Parameters SMC-3 7.3.5
# Page 0x1f: Device Capabilities SMC-3 7.3.2
# Page 0x1f/Subpage 0x41: Extended Device Capabilities SMC-3 7.3.3

# Dummy 'page 0'
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=0:0:0
# Disconnect/Reconnect
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=2:0:14:0x80:0x80:0:0xa:0:0:0:0:0:0:0:0:0:0
# Power Condition
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=0x1a:0:18:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
# Informational Exceptions Control Mode Page
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=0x1c:0:10:8:0:0:0:0:0:0:0:0:0
# Element Address Assignment - Setup afterwards.
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=0x1d:0:0x12:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
# Transport Geometry Parameters
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params mode_page=0x1e:0:2:0:0
# Device Capabilities
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params 
mode_page=0x1f:0:0x12:0x0f:7:0x0f:0x0f:0x0f:0x0f:0:0:0:0:0x0f:0x0f:0x0f:0x0f:0:0:0:0

tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params 
vendor_id=STK,product_id=L700,product_rev=0010,scsi_sn=XYZZY_0,removable=1


## Add Data Transfer devices (3 drives)
# Define slot address for devices.
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=4,start_address=1,quantity=3
# Now define which device at each address.
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=4,address=1,tid=1,lun=2
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=4,address=2,tid=1,lun=3
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=4,address=3,tid=1,lun=4

# Medium Transport Elements (robot arm / picker)
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=1,start_address=16,quantity=1

## Storage Elements - 8 starting at addr 1024
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=2,start_address=1024,quantity=8
# Add 'media' to slots
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=2,address=1024,barcode=00000001,sides=1
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=2,address=1025,barcode=00000002,sides=1

# Import/Export Elements - 5 starting at addr 32
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params element_type=3,start_address=32,quantity=5

# define path to virtual media
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params media_home=/root/tapes

# Dump the list of configured slots to syslog...
tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun $LUN \
    --params dump=1


# Allow ALL initiators to connect to this target
tgtadm --lld iscsi --mode target --op bind --tid $TID -I ALL


# Show all our good work.
tgtadm --lld iscsi --mode target --op show


What happens is that after logging in I get the controller on LUN 0 and 
the changer on LUN 1:

Target 1: iqn.2008-09.com.example:server.tape
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
        LUN: 1
            Type: changer
            SCSI ID: deadbeaf1:1
            SCSI SN: XYZZY_0
            Size: 0 MB
            Online: Yes
            Removable media: Yes
            Backing store: /root/smc
    Account information:
    ACL information:
        ALL


And an inventory using mtx -f /dev/sg3 status gives:

  Storage Changer /dev/sg3:3 Drives, 13 Slots ( 5 Import/Export )
Data Transfer Element 0:Empty
Data Transfer Element 1:Empty
Data Transfer Element 2:Empty
      Storage Element 1:Full :VolumeTag=00000001                      
      Storage Element 2:Full :VolumeTag=00000002                      
      Storage Element 3:Empty:VolumeTag=                               
      Storage Element 4:Empty:VolumeTag=                              
      Storage Element 5:Empty:VolumeTag=                              
      Storage Element 6:Empty:VolumeTag=                              
      Storage Element 7:Empty:VolumeTag=                              
      Storage Element 8:Empty:VolumeTag=                              
      Storage Element 9 
IMPORT/EXPORT:Empty:VolumeTag=                               
      Storage Element 10 
IMPORT/EXPORT:Empty:VolumeTag=                              
      Storage Element 11 
IMPORT/EXPORT:Empty:VolumeTag=                              
      Storage Element 12 
IMPORT/EXPORT:Empty:VolumeTag=                              
      Storage Element 13 
IMPORT/EXPORT:Empty:VolumeTag=                        

I can move tapes between the storage elements, not to a data transfer 
element.
Also the data transfer elements don't appear after iscsi login as tape 
drives,
only the empty controller and the changer:

scsi 4:0:0:0: RAID              IET      Controller       0001 PQ: 0 ANSI: 5
scsi 4:0:0:0: Attached scsi generic sg2 type 12
scsi 4:0:0:1: Medium Changer    STK      L700             0010 PQ: 0 ANSI: 5
scsi 4:0:0:1: Attached scsi generic sg3 type 8
scsi5 : iSCSI Initiator over TCP/IP
scsi 5:0:0:0: RAID              IET      Controller       0001 PQ: 0 ANSI: 5
scsi 5:0:0:0: Attached scsi generic sg2 type 12
scsi 5:0:0:1: Medium Changer    STK      L700             0010 PQ: 0 ANSI: 5
scsi 5:0:0:1: Attached scsi generic sg3 type 8

Am I doing something wrong here, or do I want to much for the moment (ie 
things are not implemented yet).

Thanks,

Albert


--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list