ISCSI

The Linux SCSI Target Wiki

Revision as of 00:18, 12 September 2009 by Admin (Talk | contribs)
Jump to: navigation, search

ConfigFS is a virtual filesystem originally based on Sysfs code and developed as a hyrbid control mechanism for OCFS2. One of the princaple differences between SysFS and ConfigFS is that the former represents kernel data structures who's existence depends upon a kernel operation, where with the latter the generation of these data structures in kernel space is driven by userspace through configfs.

In LIO-Target v3.x, configfs has become the preferred choice of inter module control, as well as *BETWEEN* target_core_mod and iscsi_target_mod modules (see below) using configfs symbolic links.

As of 10162008, the majority of LIO-Target v2.9 functionality is up and running under v3.x using configfs. Also, it is important to note that v3.0, there are two seperate kernel modules. For information about the ConfigFS enabled generic target engine (target_core_mod) v3.x, please see Target_Core_Mod/ConfigFS.

To see how to checkout the LIO-Target v3.0 source for use with ConfigFS, please see LIO-Target#Building_Generic_Target_Engine_and_LIO-Target_v3.x.0_from_kernel.org_git

To see the LIO v3.x CLI operations using lio_node.py and lio_dump.py from lio-utils, have a look at Lio-utils#v3.2_LIO_CLI_operations

drivers/lio-core/target_core_mod.ko

The Generic Target Mode Engine (target_core_mod) that lives under /sys/kernel/config/target/core/

Under this configfs directory, we define the following shell variable for our code:

export TARGET=/sys/kernel/config/target/core/

It is then under $TARGET one can create the following $TARGET/$HBA_$HBA_ID/$STORAGE_OBJECT for use a Target Mode Fabric, like iSCSI:

drivers/lio-core/iscsi_target_mod.ko

The Linux-iSCSI.org Target (LIO-Target) (iscsi_target_mod) under /sys/kernel/config/target/iscsi/

Under this configfs directory, we define the following shell variable for our code:

export FABRIC=/sys/kernel/config/target/iscsi/

It is then under $FABRIC, (which also could be called $ISCSI) we create iSCSI TargetName and iSCSI Target Portal Group endpoints. From there $STORAGE_OBJECTS from the generic target engine under $TARGET are symlinked into $FABRIC/$IQN/tpgt_1/lun/lun_$ID.

For production systems, iSCSI Initiator Node ACLs are created under $FABRIC/$IQN/tpgt_1/acl to allow iSCSI Initiators access to a given target portal group. Also, iSCSI Initiator LUN ACL symlinks are created from $FABRIC/$IQN/tpgt_1/lun/ into $FABRIC/$IQN/tpgt_1/acl/$INITIATOR_NAME/lun_$ID for allowing virtually any type of LUN mapping to occur between iSCSI Initiators and iSCSI Target Portal Groups.

Making it all go..

Here is what the startup script currently looks like.. Just as above, the calls into $CONFIGFS are broken out into different sections:

       #!/bin/sh
       # BEGIN CONFIGFS CODE FOR GENERIC TARGET ENGINE
       modprobe target_core_mod
       # Set up our shell variables
       export CONFIGFS=/sys/kernel/config/
       export TARGET=/sys/kernel/config/target/core/
       export FABRIC=/sys/kernel/config/target/iscsi/
       # Create a IBLOCK device called 'lvm_test0' on iblock_0 HBA
       mkdir -p $TARGET/iblock_0/lvm_test0
       # Locate the IBLOCK struct block_device and enable for target_core_mod usage
       echo iblock_major=254,iblock_minor=2 > $TARGET/iblock_0/lvm_test0/control
       echo 1 > $TARGET/iblock_0/lvm_test0/enable
       # Create a SCSI device called 'sdd' on pscsi_0 HBA
       mkdir -p $TARGET/pscsi_0/sdd
       # Locate the SCSI struct scsi_device and entire for target_core_mod usage
       echo scsi_channel_id=0,scsi_target_id=3,scsi_lun_id=0 > $TARGET/pscsi_0/sdd/control
       echo 1 > $TARGET/pscsi_0/sdd/enable
       # END CONFIGFS CODE FOR GENERIC TARGET ENGINE        
       # BEGIN CONFIGFS CODE FOR LINUX ISCSI TARGET (LIO-TARGET) 
       DEF_IQN="iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0"
       # Define the first iSCSI Network Portal
       PORTAL="172.16.201.137:3260"
       # The first mkdir(2) to $FABRIC will load iscsi_target_mod
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/np/$PORTAL"
       # Enable iSCSI/SCTP traffic on this $PORTAL for $DEF_IQN/tpgt_1
       echo 1 > "$FABRIC/$DEF_IQN/tpgt_1/np/$PORTAL/sctp"
       # Create iSCSI LUN=0 on $DEF_IQN/tpgt_1
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_0"
       # Map $TARGET/$HBA/$STORAGE_OBJECT into LIO-Target for $DEF_IQN/tpgt_1 LUN=0 with symbolic port name 'lio-west-port'
       ln -s $TARGET/iblock_0/lvm_test0 "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_0/lio_west_port"
       # Create iSCSI LUN=1 on $DEF_IQN/tpgt_1
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_1"
       # Map $TARGET/$HBA/$STORAGE_OBJECT into LIO-Target for $DEF_IQN/tpgt_1 LUN=1 with symbolic port name 'lio-east-port'
       ln -s $TARGET/pscsi_0/sdd "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_1/lio_east_port"
       # END CONFIGFS CODE FOR LINUX ISCSI TARGET (LIO-TARGET)
       # BEGIN CONFIFS CODE FOR ISCSI INITIATOR NODE ACLS for LIO-TARGET
       # Now, add a iSCSI Initiator node ACL for a Debian node.  The first mkdir(2) here will
       # allow this iSCSI Initiator node access to $DEF_IQN/tpgt_1 and map the iSCSI Initiator LUN=0 ACL
       # to $DEF_IQN/tpgt_1/lun/lun_0
       INITIATOR_DEBIAN="iqn.1993-08.org.debian:01:2dadf92d0ef"
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_DEBIAN/lun_0"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_0" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_DEBIAN/lun_0/."
       # Map iSCSI Initiator LUN=1 ACL to $DEF_IQN/tpgt_1/lun/lun_1
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_DEBIAN/lun_1"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_1" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_DEBIAN/lun_1/."
       # Add another iSCSI Initiator node ACL and lun_0 and lun_1 ACLs, this time for a OpenSuSE node
       INITIATOR_SUSE="iqn.1996-04.de.suse:01:1661f9ee7b5"
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_SUSE/lun_0"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_0" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_SUSE/lun_0/."
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_SUSE/lun_1"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_1" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_SUSE/lun_1/."
       # Allow the OpenMoko Freerunner the same iSCSI Initiator Node and LUN ACLs to this $DEF_IQN/tpgt_1
       INITIATOR_OM="iqn.2003-01.org.linux-iscsi.om-gta02.armv4tl:sn.8f882218a9d0"
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_OM/lun_0"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_0" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_OM/lun_0/."
       mkdir -p "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_OM/lun_1"
       ln -s "$FABRIC/$DEF_IQN/tpgt_1/lun/lun_1" "$FABRIC/$DEF_IQN/tpgt_1/acls/$INITIATOR_OM/lun_1/."
       # END CONFIFS CODE FOR ISCSI INITIATOR NODE ACLS FOR LIO-TARGET
       # Set last bits in $DEF_IQN/tpgt_1 before throwing enable flag to allow iSCSI Initiator to Login
       # Disable Authentication
       echo 0 > $FABRIC/$DEF_IQN/tpgt_1/attrib/authentication
       # Enable the TPG Endpoint so initiators can login
       echo 1 > $FABRIC/$DEF_IQN/tpgt_1/enable

/sys/kernel/config/ `-- target

   # From the Generic Target Engine Core (target_core_mod):
   |-- core
   |   |-- iblock_0
   |   |   |-- hba_info
   |   |   `-- lvm_test0
   |   |       |-- control
   |   |       |-- enable
   |   |       `-- info
   |   `-- pscsi_0
   |       |-- hba_info
   |       `-- sdd
   |           |-- control
   |           |-- enable
   |           `-- info
   # From LIO-Target: 
   |-- iscsi
       # First iSCSI Node TargetName
   |   |-- iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0
           # First iSCSI Target Portal Group
   |   |   `-- tpgt_1
               # iSCSI Initiator Node ACLs to his TargetName/TargetPortalGroupTag
   |   |       |-- acls
                   # The first iSCSI Initiator Node ACL
   |   |       |   |-- iqn.1993-08.org.debian:01:2dadf92d0ef
                       # Attributes specific to this Initiator Node
   |   |       |   |   |-- attrib
   |   |       |   |   |   |-- dataout_timeout
   |   |       |   |   |   |-- dataout_timeout_retries
   |   |       |   |   |   |-- default_erl
   |   |       |   |   |   |-- nopin_response_timeout
   |   |       |   |   |   |-- nopin_timeout
   |   |       |   |   |   |-- random_datain_pdu_offsets
   |   |       |   |   |   |-- random_datain_seq_offsets
   |   |       |   |   |   `-- random_r2t_offsets
                       # iSCSI Initiator Node's Session CmdSN Depth
   |   |       |   |   |-- cmdsn_depth
   |   |       |   |   |-- info
                       # iSCSI Initiator LUN=0 and LUN=1 ACLs symlinked to $TPGT/lun/lun_0 and $TPGT/lun/lun_1 
   |   |       |   |   |-- lun_0
   |   |       |   |   |   `-- lun_0 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_0
   |   |       |   |   `-- lun_1
   |   |       |   |       `-- lun_1 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_1
                   # Another iSCSI Initiator Node ACL
   |   |       |   |-- iqn.1996-04.de.suse:01:1661f9ee7b5
   |   |       |   |   |-- attrib
   |   |       |   |   |   |-- dataout_timeout
   |   |       |   |   |   |-- dataout_timeout_retries
   |   |       |   |   |   |-- default_erl
   |   |       |   |   |   |-- nopin_response_timeout
   |   |       |   |   |   |-- nopin_timeout
   |   |       |   |   |   |-- random_datain_pdu_offsets
   |   |       |   |   |   |-- random_datain_seq_offsets
   |   |       |   |   |   `-- random_r2t_offsets
   |   |       |   |   |-- cmdsn_depth
   |   |       |   |   |-- info
   |   |       |   |   |-- lun_0
   |   |       |   |   |   `-- lun_0 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_0
   |   |       |   |   `-- lun_1
   |   |       |   |       `-- lun_1 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_1
                   # Yet Another iSCSI Initiator Node ACL
   |   |       |   `-- iqn.2003-01.org.linux-iscsi.om-gta02.armv4tl:sn.8f882218a9d0
   |   |       |       |-- attrib
   |   |       |       |   |-- dataout_timeout
   |   |       |       |   |-- dataout_timeout_retries
   |   |       |       |   |-- default_erl
   |   |       |       |   |-- nopin_response_timeout
   |   |       |       |   |-- nopin_timeout
   |   |       |       |   |-- random_datain_pdu_offsets
   |   |       |       |   |-- random_datain_seq_offsets
   |   |       |       |   `-- random_r2t_offsets
   |   |       |       |-- cmdsn_depth
   |   |       |       |-- info
   |   |       |       |-- lun_0
   |   |       |       |   `-- lun_0 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_0
   |   |       |       `-- lun_1
   |   |       |           `-- lun_1 -> ../../../../../../../target/iscsi/iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0/tpgt_1/lun/lun_1
               # Attributes specific to this iSCSI Target Portal Group
   |   |       |-- attrib
   |   |       |   |-- authentication
   |   |       |   |-- cache_dynamic_acls
   |   |       |   |-- default_cmdsn_depth
   |   |       |   |-- demo_mode_lun_access
   |   |       |   |-- generate_node_acls
   |   |       |   |-- login_timeout
   |   |       |   `-- netif_timeout
   |   |       |-- control
               # Enable/Disable this iSCSI Target Portal Group
   |   |       |-- enable
               # iSCSI Target Port/LUNs for this Target Portal Group                
   |   |       |-- lun
                   # LUN=0 symlinks IBLOCK device from /sys/kernel/config/target/core/iblock_0/lvm_test0
   |   |       |   |-- lun_0
   |   |       |   |   |-- control
   |   |       |   |   |-- info
   |   |       |   |   `-- lio_west_port -> ../../../../../../target/core/iblock_0/lvm_test0
                   # LUN=1 symlinks PSCSI device from /sys/kernel/config/target/core/pscsi_0/sdd
   |   |       |   `-- lun_1
   |   |       |       |-- control
   |   |       |       |-- info
   |   |       |       `-- lio_east_port -> ../../../../../../target/core/pscsi_0/sdd
               # iSCSI/TCP Network Portals mapped to this iSCSI Target Portal Group
   |   |       `-- np
   |   |           `-- 192.168.0.111:3260
   |   |               |-- info
                       # Enable/Disable iSCSI over Stream Control Transmission Protocol (SCTP).  (disabled by default)
   |   |               `-- sctp
   |   `-- lio_version
   `-- version
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
Google AdSense