iSCSI/configFS
From Linux-iSCSI
|
iSCSI fabric module | |
| Original author(s) | Nicholas Bellinger |
| Developer(s) | RisingTide Systems LLC |
| Initial release | March 15, 2007 |
| Stable release | 3.5.0 / September 19, 2010 |
| Preview release | 4.1.0-rc1 / February 21, 2011 |
| Development status | Production |
| Written in | C |
| Operating system | Linux |
| Type | Fabric module |
| License | GNU General Public License |
| Website | risingtidesystems.com |
- See Target for a complete overview over all fabric modules.
iSCSI/configFS describes the configFS kernel interface for the iSCSI fabric module. ConfigFS is a RAM-based virtual file system provided by the 2.6 Linux kernel, originally based on sysfs code and developed as a hybrid control mechanism for OCFS2.
Contents |
Introduction
To setup an iSCSI Target, targetcli (from RisingTide Systems) should be used. targetcli is a comprehensive, powerful, easy storage management tool that can efficiently handle complex LIO Target installations.
This page describes the resulting low-level user-space configuration of the iSCSI configFS object tree. ConfigFS uses symbolic links for inter- and intra-modules configuration, and the iSCSI fabric module is mapped into configFS at /sys/kernel/config/target/iscsi/. A $FABRIC shell variable is defined to point to the iSCSI root:
export FABRIC=/sys/kernel/config/target/iscsi/
iSCSI
Under /sys/kernel/config/target/$FABRIC, configFS-enabled fabric modules use intra-module symbolic links via link(2)/unlink(2) for creating/removing SCSI Target Ports and TPG endpoints.
The endpoint in the iSCSI fabric module can be exported and associated with the Target and its various backstore storage objects by creating inetr-module symbolic links from $FABRIC/$IQN/tpgt_1/lun/lun_$ID into Target/configFS.
For production systems, iSCSI Initiator node ACLs are created under $FABRIC/$IQN/tpgt_1/acl to grant iSCSI Initiators access to a given TPG. 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 TPGs.
The following examples show the configuration of the iSCSI fabric module by directly poking its configFS interface. For production systems, of course, the targetcli (from RisingTide Systems) provides a management tool that is much more convenient und usable.
Setup
The setup procedure and script currently looks like this. The configFS setup calls are broken out into four different sections:
- Storage objects: calls into Target/configFS to setup storage objects
- iSCSI: calls into $FABRIC to load
iscsi_target_modand setup an iSCSI target - ACL: calls into $FABRIC/$IQN/$TPGT/acls/ to allow iSCSI Initiators to log into iSCSI target endpoint
- TPG: calls into $FABRIC/$IQN/$TPGT/attrib and enable $IQN/$TPGT for accepting new iSCSI traffic
Generic
#!/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/ # END CONFIGFS CODE FOR GENERIC TARGET ENGINE
Setting up IBLOCK
# BEGIN IBLOCK SUBSYSTEM PLUGIN EXPORT # 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 IBLOCK SUBSYSTEM PLUGIN EXPORT
Setting up the iSCSI target
# 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)
Setting up access for Initiators (ACLs)
# 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
Enabling the TPG
# 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
Object tree
Here is the tree configFS output of a running iSCSI target from /sys/kernel/config/target:
`-- 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
See also
- Management: targetcli
- ConfigFS: configFS
- Target, Target/configFS