Tcm loop

The Linux SCSI Target Wiki

(Difference between revisions)
Jump to: navigation, search
m
m
Line 1: Line 1:
-
'''tcm_loop''' is a fabric module that provides full local [SCSI device emulation ([[SPC-3]] and [[SPC-4]]) for raw block storage objects, from both kernel and user space.
+
'''tcm_loop''' is a fabric module that provides full local SCSI device emulation ([[SPC-3]] and [[SPC-4]]) for raw block storage objects, from both kernel and user space. This allows, e.g., unmodified guests running in VMs high-performance access to underlying storage object.
== Overview ==
== Overview ==

Revision as of 03:06, 27 November 2010

tcm_loop is a fabric module that provides full local SCSI device emulation (SPC-3 and SPC-4) for raw block storage objects, from both kernel and user space. This allows, e.g., unmodified guests running in VMs high-performance access to underlying storage object.

Contents

Overview

Target/FILEIO with a tcm_loop SAS port on KVM x86_64 host running v2.6.34 with the new LSI Megasas 8708EM2 PPC HBA emulation into a Windows 7 x64 KVM Guest.
Target/FILEIO with a tcm_loop SCSI port on KVM x86_64 host running v2.6.36-rc3+ with QEMU lsi53c895a HBA emulation into an OS/2 Warp v4 guest. A HPFS partition has been formatted and mounted as DRIVE D:
tcm_loop fabric module running on LIO v3.2 on a Linux Host providing shared virtual SAS Target emulation into a VM hypervisor to multiple VM guests of RHEL 5.4 x86_64 and NetBSD 5.x 32-bit.
tcm_loop fabric module running on LIO v3.2 on Linux Host v2.6.32-rc5 providing persistent reservations to RHEL 5.4 x86_64 KVM Guest using scsi generic passthrough with Vmware Workstation 6.5.

tcm_loop (tcm_loop.ko) is a LIO Target v3.2 full virtual SCSI device emulation for all block storage objects (such as Target/IBLOCK, Target/FILEIO, etc.), locally, from kernel and/or user space. It allows SPC-3 and SPC-4 SCSI emulation to be accessed via a SCSI LLD driver, and provides CDB-level SAS emulation.

The initial release of tcm_loop has been made available with the following announcement.

Specification compliance

The type of SCSI fabric features that are available with tcm_loop (Target mode emulated SAS ports) includes the complete set of SPC-3 logic in the Target engine including advanced features such as PRs, ALUA, etc.

Low-level CLI

The LIO 3.0 CLI manual describes a simple userspace shell (lio-utils) for LIO v3.0 configuration:

It also describes how to setup a number of different subsystem storage object backstores for LIO LUN endpoints.

RTSadmin

RisingTide Systems makes available upon request and for free RTSadmin, a comprehensive, powerful, yet easy shell, API and library for managing complex LIO installations.

Example

Here is an example of creating two local virtual SCSI devices from a single Target/IBLOCK object on two virtual SAS Target port addresses, which are prefixed here with "naa."

The simple userspace shell (lio-utils) for LIO v3.0 configuration was used in this example (RTSadmin is a better management tool).

Setup

Create first I_T Nexus

Create the first I_T Nexus that creates a new Linux/SCSI struct Scsi_Host:

   target:/usr/src/lio-utils.git# tcm_loop --createnexus 1
   Successfully created virtual SCSI I_T Nexus between TCM and Linux/SCSI HBA
     SAS Target Address: naa.600140554cf3a18e
     SAS Initiator Address naa.60014053226f0388

Create LUN

Create the LUN on the SAS Target port and rescan the Linux/SCSI LLD by SCSI HCTL bus address:

  target:/usr/src/lio-utils.git# tcm_loop --addlun naa.600140554cf3a18e 1 0 iblock_0/lvm_test0
  Successfully created SAS Target Port to local virtual SCSI Logical Unit

Create second I_T Nexus

Create the second I_T Nexus that creates another virtual Linux/SCSI HBA:

  target:/usr/src/lio-utils.git# tcm_loop --createnexus 1
  Successfully created virtual SCSI I_T Nexus between TCM and Linux/SCSI HBA
    SAS Target Address: naa.600140566ce31347
    SAS Initiator Address naa.6001405fd3afa2ef
  target:/usr/src/lio-utils.git# tcm_loop --addlun naa.600140566ce31347 1 0 iblock_0/lvm_test0
  Successfully created SAS Target Port to local virtual SCSI Logical Unit

Results

Healthy results should look similar to the following examples, which are provided as a reference.

ConfigFS object tree

The resulting Target/configFS object tree in /sys/kernel/config/target/loopback/:

  /sys/kernel/config/target/loopback/
  |-- naa.600140554cf3a18e
  |   `-- tpgt_1
  |       |-- lun
  |       |   `-- lun_0
  |       |       `-- virtual_scsi_port -> ../../../../../../target/core/iblock_0/lvm_test0
  |       `-- nexus
  |           `-- naa.60014053226f0388
  |-- naa.600140566ce31347
  |   `-- tpgt_1
  |       |-- lun
  |       |   `-- lun_0
  |       |       `-- virtual_scsi_port -> ../../../../../../target/core/iblock_0/lvm_test0
  |       `-- nexus
  |           `-- naa.6001405fd3afa2ef
  `-- version

SCSI devices

The list of resulting SCSI devices with:

  lsscsi -v output 

is:

  [9:0:1:0]    disk    LIO-ORG  IBLOCK           3.1   /dev/sdg 
    dir: /sys/bus/scsi/devices/9:0:1:0  [/sys/devices/tcm_loop_0/tcm_loop_adapter_0/host9/target9:0:1/9:0:1:0]
  [10:0:1:0]   disk    LIO-ORG  IBLOCK           3.1   /dev/sdh 
    dir: /sys/bus/scsi/devices/10:0:1:0  [/sys/devices/tcm_loop_0/tcm_loop_adapter_1/host10/target10:0:1/10:0:1:0]

Block devices

The list of resulting block devices with:

  sg_inq -i /dev/sdg 

is:

  VPD INQUIRY: Device Identification page
  Designation descriptor number 1, descriptor length: 20
    id_type: NAA,  code_set: Binary
    associated with the addressed logical unit
      NAA 6, IEEE Company_id: 0x1405
      Vendor Specific Identifier: 0xa97e4ce21
      Vendor Specific Identifier Extension: 0xc0711de829b000c2
      [0x6001405a97e4ce21c0711de829b000c2]
  Designation descriptor number 2, descriptor length: 52
    id_type: T10 vendor identification,  code_set: ASCII
    associated with the addressed logical unit
      vendor id: LIO-ORG
      vendor specific: IBLOCK:a97e4ce21c0711de829b000c2943d57b
  Designation descriptor number 3, descriptor length: 8
    transport: Serial Attached SCSI (SAS)
    id_type: Relative target port,  code_set: Binary
    associated with the target port
      Relative target port: 0x8
  Designation descriptor number 4, descriptor length: 8
    transport: Serial Attached SCSI (SAS)
    id_type: Target port group,  code_set: Binary
    associated with the target port
      Target port group: 0x0
  Designation descriptor number 5, descriptor length: 8
    id_type: Logical unit group,  code_set: Binary
    associated with the addressed logical unit
      Logical unit group: 0x0
  Designation descriptor number 6, descriptor length: 36
    transport: Serial Attached SCSI (SAS)
    id_type: SCSI name string,  code_set: UTF-8
    associated with the target port
      SCSI name string:
      naa.600140554cf3a18e,t,0x0001

Modules

The resulting loadable kernel modules (LKMs) with:

  lsmod output

are as follows:

   Module                  Size  Used by
   tcm_loop               11606  9 
   iscsi_target_mod      205640  44 
   target_core_mod       226770  75 tcm_loop,iscsi_target_mod
   scsi_tgt                8806  1 target_core_mod
   configfs               21168  4 tcm_loop,iscsi_target_mod,target_core_mod
   dm_mirror              10356  0 
   dm_region_hash          7562  1 dm_mirror
   dm_log                  6769  2 dm_mirror,dm_region_hash
   dm_snapshot            18562  0 
   pcnet32                25510  0 
   mii                     3430  1 pcnet32

Kernel ringbuffer

The resulting messages in the kernel ringbuffer, dumped with:

  dmesg

should look similar to:

   Target_Core_ConfigFS: REGISTER -> group: e1193d80 name: loopback
   Initialized TCM Loop Core Bus
   <<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>>>>>>>>>>>>>>>
   Initialized struct target_fabric_configfs: df226208 for loopback
   <<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>>>>>>
   TCM_LOOP[0] - Set fabric -> tcm_loop_fabric_configfs
   Target_Core_ConfigFS: REGISTER -> Located fabric: loopback
   Target_Core_ConfigFS: REGISTER -> e17bcddc
   Target_Core_ConfigFS: REGISTER -> Allocated Fabric: loopback
   Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric for loopback
   scsi9 : TCM_Loopback
   TCM_Loop_ConfigFS: Allocated emulated Target SAS Address: naa.600140554cf3a18e at Linux/SCSI Host ID: 9
   TARGET_CORE[loopback]: Allocated Normal se_portal_group_t for endpoint: naa.600140554cf3a18e, Portal Tag: 1
   TCM_Loop_ConfigFS: Allocated Emulated SAS Target Port naa.600140554cf3a18e,t,0x0001
   loopback_TPG[1] - Added DYNAMIC ACL with TCQ Depth: 1 for loopback Initiator Node: naa.60014053226f0388
   TARGET_CORE[loopback]: Registered fabric_sess_ptr: d43376e8
   TCM_Loop_ConfigFS: Established I_T Nexus to emulated SAS Initiator Port: naa.60014053226f0388
   iblock/loopback: Adding to default ALUA Target Port Group: alua/default_tg_pt_gp
   loopback_TPG[1]_LUN[0] - Activated loopback Logical Unit from CORE HBA: 3
   TARGET_CORE[loopback]->TPG[1]_LUN[0] - Adding READ-WRITE access for LUN in Demo Mode
   TCM_Loop_ConfigFS: Port Link Successful
   scsi 9:0:1:0: Direct-Access     LIO-ORG  IBLOCK           3.1  PQ: 0 ANSI: 5
   sd 9:0:1:0: Attached scsi generic sg7 type 0
   sd 9:0:1:0: [sdg] READ CAPACITY(16) failed
   sd 9:0:1:0: [sdg] Result: hostbyte=0x05 driverbyte=0x00
   sd 9:0:1:0: [sdg] Sense not available.
   sd 9:0:1:0: [sdg] 3072000 512-byte logical blocks: (1.57 GB/1.46 GiB)
   sd 9:0:1:0: [sdg] Write Protect is off
   sd 9:0:1:0: [sdg] Mode Sense: 2f 00 00 00
   sd 9:0:1:0: [sdg] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
   sd 9:0:1:0: [sdg] READ CAPACITY(16) failed
   sd 9:0:1:0: [sdg] Result: hostbyte=0x05 driverbyte=0x00
   sd 9:0:1:0: [sdg] Sense not available.
    sdg: unknown partition table
   sd 9:0:1:0: [sdg] READ CAPACITY(16) failed
   sd 9:0:1:0: [sdg] Result: hostbyte=0x05 driverbyte=0x00
   sd 9:0:1:0: [sdg] Sense not available.
   sd 9:0:1:0: [sdg] Attached SCSI disk
   scsi10 : TCM_Loopback
   TCM_Loop_ConfigFS: Allocated emulated Target SAS Address: naa.600140566ce31347 at Linux/SCSI Host ID: 10
   TARGET_CORE[loopback]: Allocated Normal se_portal_group_t for endpoint: naa.600140566ce31347, Portal Tag: 1
   TCM_Loop_ConfigFS: Allocated Emulated SAS Target Port naa.600140566ce31347,t,0x0001
   loopback_TPG[1] - Added DYNAMIC ACL with TCQ Depth: 1 for loopback Initiator Node: naa.6001405fd3afa2ef
   TARGET_CORE[loopback]: Registered fabric_sess_ptr: d4337a28
   TCM_Loop_ConfigFS: Established I_T Nexus to emulated SAS Initiator Port: naa.6001405fd3afa2ef
   iblock/loopback: Adding to default ALUA Target Port Group: alua/default_tg_pt_gp
   loopback_TPG[1]_LUN[0] - Activated loopback Logical Unit from CORE HBA: 3
   TARGET_CORE[loopback]->TPG[1]_LUN[0] - Adding READ-WRITE access for LUN in Demo Mode
   TCM_Loop_ConfigFS: Port Link Successful
   scsi 10:0:1:0: Direct-Access     LIO-ORG  IBLOCK           3.1  PQ: 0 ANSI: 5
   sd 10:0:1:0: Attached scsi generic sg8 type 0
   sd 10:0:1:0: [sdh] READ CAPACITY(16) failed
   sd 10:0:1:0: [sdh] Result: hostbyte=0x05 driverbyte=0x00
   sd 10:0:1:0: [sdh] Sense not available.
   sd 10:0:1:0: [sdh] 3072000 512-byte logical blocks: (1.57 GB/1.46 GiB)
   sd 10:0:1:0: [sdh] Write Protect is off
   sd 10:0:1:0: [sdh] Mode Sense: 2f 00 00 00
   sd 10:0:1:0: [sdh] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
   sd 10:0:1:0: [sdh] READ CAPACITY(16) failed
   sd 10:0:1:0: [sdh] Result: hostbyte=0x05 driverbyte=0x00
   sd 10:0:1:0: [sdh] Sense not available.
    sdh: unknown partition table
   sd 10:0:1:0: [sdh] READ CAPACITY(16) failed
   sd 10:0:1:0: [sdh] Result: hostbyte=0x05 driverbyte=0x00
   sd 10:0:1:0: [sdh] Sense not available.
   sd 10:0:1:0: [sdh] Attached SCSI disk

See also

External links

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
Google AdSense