Skip to contentSkip to conversation

: Add struct Scsi_Host target infrastructure WIP

PATCH New Nicholas A. Bellinger 1 participant 1 message Apr 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Add struct Scsi_Host target infrastructure WIP

Greetings all,

This patch adds the first pieces of a v3.x subsystem plugin that interacts with Linux/SCSI to create a virtual target mode struct Scsi_Host, and using userspace backstores from the existing STGT codebase.

So far, creating and removing STGT virtual target HBAs in through ConfigFS is working and status appearing under /sys/bus/stgt_bus and /sys/class/scsi_host/host#/

Most of the code required for actual STGT struct scsi_cmnd is in place (but not-tested yet), and the next main step is hooking up stgt_create_virtdevice() in drivers/target/target_core_stgt.c to assoicate the userspace backstore attached to the Target_Core_Mod/STGT virtual SCSI target mode HBA.

The long term goal to allow all kernel level fabric modules to take advantage of the upstream STGT code in drivers/scsi/scsi_tgt_[if,lib].c.

Here is what the running code looks like:

*) tree /sys/kernel/config/target/core/

/sys/kernel/config/target/core/

|-- alua
|   |-- lu_gps
|   |   `-- default_lu_gp
|   |       |-- alua_access_state
|   |       |-- lu_gp_id
|   |       `-- members
|   `-- tg_pt_gps
|       `-- default_tg_pt_gp
|           |-- alua_access_state
|           |-- members
|           `-- tg_pt_gp_id
|-- stgt_0
|   `-- hba_info
|-- stgt_1
|   `-- hba_info
|-- stgt_2
|   `-- hba_info
`-- stgt_3
    `-- hba_info

*) tree /sys/bus/stgt_bus/

/sys/bus/stgt_bus/

|-- devices
|   |-- stgt_adapter0 -> ../../../devices/stgt_primary_0/stgt_adapter0
|   |-- stgt_adapter1 -> ../../../devices/stgt_primary_0/stgt_adapter1
|   |-- stgt_adapter2 -> ../../../devices/stgt_primary_0/stgt_adapter2
|   `-- stgt_adapter3 -> ../../../devices/stgt_primary_0/stgt_adapter3
|-- drivers
|   `-- stgt_tcm
|       |-- bind
|       |-- stgt_adapter0 -> ../../../../devices/stgt_primary_0/stgt_adapter0
|       |-- stgt_adapter1 -> ../../../../devices/stgt_primary_0/stgt_adapter1
|       |-- stgt_adapter2 -> ../../../../devices/stgt_primary_0/stgt_adapter2
|       |-- stgt_adapter3 -> ../../../../devices/stgt_primary_0/stgt_adapter3
|       |-- uevent
|       `-- unbind
|-- drivers_autoprobe
|-- drivers_probe

`-- uevent

*) Output in /sys/class/scsi_host/host$LINUX_HOST_ID for each stgt_tcm HBA target mode driver

target# cat /sys/class/scsi_host/host30/active_mode Target
target# cat /sys/class/scsi_host/host30/supported_mode Target
target# cat /sys/class/scsi_host/host30/proc_name stgt_tcm

11 directories, 6 files

*) lsmod

lsmod
Module Size Used by
target_core_mod 194128 8
scsi_transport_iscsi 26808 0

scsi_tgt               11008  1 target_core_mod
configfs               21680  2 target_core_mod
pcnet32                29412  0 
mii                     4212  1 pcnet32

*) kernel ring buffer

TARGET_CORE[0]: Loading Generic Kernel Storage Engine: v3.0.0 on Linux/i686 on 2.6.29 TARGET_CORE[0]: Initialized ConfigFS Fabric Infrastructure: v1.0.0 on Linux/i686 on 2.6.29 SE_PC[0] - Registered Plugin Class: TRANSPORT
PLUGIN_TRANSPORT[1] - pscsi registered
PLUGIN_TRANSPORT[2] - stgt registered
CORE_STGT[0]: Bus Initalization complete
PLUGIN_TRANSPORT[4] - iblock registered
PLUGIN_TRANSPORT[5] - rd_dr registered
PLUGIN_TRANSPORT[6] - rd_mcp registered
PLUGIN_TRANSPORT[7] - fileio registered
SE_PC[1] - Registered Plugin Class: OBJ
PLUGIN_OBJ[1] - dev registered
Target_Core_ConfigFS: Located se_plugin: dfbc0850 plugin_name: stgt hba_type: 2 plugin_dep_id: 0 scsi27 : stgt_tcm
CORE_HBA[0] - Linux-iSCSI.org STGT HBA Driver v1.0 on Generic Target Core Stack v3.0 CORE_HBA[0] - stgt_tcm
CORE_HBA[0] - Attached STGT HBA to Generic Target Core with TCQ Depth: 1 MaxSectors: 1024 CORE_HBA[0] - Attached HBA to Generic Target Core
Target_Core_ConfigFS: Located se_plugin: dfbc0850 plugin_name: stgt hba_type: 2 plugin_dep_id: 1 scsi28 : stgt_tcm
CORE_HBA[1] - Linux-iSCSI.org STGT HBA Driver v1.0 on Generic Target Core Stack v3.0 CORE_HBA[1] - stgt_tcm
CORE_HBA[1] - Attached STGT HBA to Generic Target Core with TCQ Depth: 1 MaxSectors: 1024 CORE_HBA[1] - Attached HBA to Generic Target Core
Target_Core_ConfigFS: Located se_plugin: dfbc0850 plugin_name: stgt hba_type: 2 plugin_dep_id: 2 scsi29 : stgt_tcm
CORE_HBA[2] - Linux-iSCSI.org STGT HBA Driver v1.0 on Generic Target Core Stack v3.0 CORE_HBA[2] - stgt_tcm
CORE_HBA[2] - Attached STGT HBA to Generic Target Core with TCQ Depth: 1 MaxSectors: 1024 CORE_HBA[2] - Attached HBA to Generic Target Core
Target_Core_ConfigFS: Located se_plugin: dfbc0850 plugin_name: stgt hba_type: 2 plugin_dep_id: 3 scsi30 : stgt_tcm
CORE_HBA[3] - Linux-iSCSI.org STGT HBA Driver v1.0 on Generic Target Core Stack v3.0 CORE_HBA[3] - stgt_tcm
CORE_HBA[3] - Attached STGT HBA to Generic Target Core with TCQ Depth: 1 MaxSectors: 1024 CORE_HBA[3] - Attached HBA to Generic Target Core

These patches are made against lio-core-2.6.git/master and tested on v2.6.29 x86 32-bit HVM. The lio-core-2.6.git tree can be found at:

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=summary

---
 drivers/target/MCONFIG_TARGET                 |    1 +
 drivers/target/Makefile                       |    4 +
 drivers/target/target_core_stgt.c             |  916 +++++++++++++++++++++++++
 drivers/target/target_core_transport.c        |    7 +
 include/target/target_core_base.h             |    2 +-
 include/target/target_core_stgt.h             |  200 ++++++
 include/target/target_core_transport_plugin.h |    7 +
 7 files changed, 1136 insertions(+), 1 deletions(-)
 create mode 100644 drivers/target/target_core_stgt.c
 create mode 100644 include/target/target_core_stgt.h
drivers/target/MCONFIG_TARGET +1 -0
index 77378be..8023deb 100644
@@ -9,6 +9,7 @@ PYX_ISCSI_VENDOR ?="Linux-iSCSI.org"
 # Transport Plugins and Devices.
 #
 LINUX_PARALLEL_SCSI ?= 1
+LINUX_STGT ?= 1
 LINUX_SCSI_MEDIA_ROM ?= 1
 LINUX_PARALLEL_ATA ?= 0
 LINUX_IBLOCK ?= 1
drivers/target/Makefile +4 -0
index 63c1e3b..47fef07 100644
@@ -51,6 +51,10 @@ ifeq ($(LINUX_PARALLEL_SCSI), 1)
 target_core_mod-objs			+=	target_core_pscsi.o
 EXTRA_CFLAGS				+=	-DPARALLEL_SCSI
 endif
+ifeq ($(LINUX_STGT), 1)
+target_core_mod-objs			+=	target_core_stgt.o
+EXTRA_CFLAGS				+=	-DSTGT_PLUGIN
+endif
 ifeq ($(LINUX_RAMDISK), 1)
 target_core_mod-objs			+=	target_core_rd.o
 EXTRA_CFLAGS				+=	-DPYX_RAMDISK
drivers/target/target_core_stgt.c new file +916 -0

916 lines not on this page · raw message

drivers/target/target_core_transport.c +7 -0
index 4faaf12..ec130a6 100644
@@ -516,6 +516,13 @@ void transport_load_plugins(void)
 			pscsi_template.name, PLUGIN_TYPE_TRANSPORT,
 			pscsi_template.get_plugin_info, NULL, NULL, &ret);
 #endif
+#ifdef STGT_PLUGIN
+	plugin_register((void *)&stgt_template, stgt_template.type,
+			stgt_template.name, PLUGIN_TYPE_TRANSPORT,
+			stgt_template.get_plugin_info,
+			stgt_template.plugin_init,
+			stgt_template.plugin_free, &ret);
+#endif
 #ifdef PYX_IBLOCK
 	plugin_register((void *)&iblock_template, iblock_template.type,
 			iblock_template.name, PLUGIN_TYPE_TRANSPORT,
include/target/target_core_base.h +1 -1
index 0151915..182270c 100644
@@ -150,7 +150,7 @@
 
 /* se_device_t->type */
 #define PSCSI					1
-#define SSCSI					2
+#define STGT					2
 #define PATA					3
 #define IBLOCK					4
 #define RAMDISK_DR				5
include/target/target_core_stgt.h new file +200 -0

200 lines not on this page · raw message

include/target/target_core_transport_plugin.h +7 -0
index 118ee3a..7e46360 100644
@@ -35,6 +35,13 @@
 extern se_subsystem_api_t pscsi_template;
 #endif /* PARALLEL_SCSI */
 
+#ifdef STGT_PLUGIN
+#define STGT_INCLUDE_STRUCTS
+#include <target/target_core_stgt.h>
+#undef STGT_INCLUDE_STRUCTS
+extern se_subsystem_api_t stgt_template;
+#endif /* STGT_PLUGIN */
+
 #ifdef PYX_IBLOCK
 #define IBLOCK_INCLUDE_STRUCTS
 #include <target/target_core_iblock.h>
Signature · 1 line
1.5.4.1