scst_local module added.

Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@526 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2008-10-16 19:23:22 +00:00
parent 775ddf6f18
commit 3fb2634b6e
9 changed files with 1248 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ QLA_ISP_DIR=qla_isp
LSI_DIR=mpt
USR_DIR=usr/fileio
SRP_DIR=srpt
SCST_LOCAL_DIR=scst_local
ISCSI_DIR=iscsi-scst
#ISCSI_DISTDIR=../../../iscsi_scst_inst
@@ -77,6 +78,10 @@ help:
@echo " srpt_install : srp target: install"
@echo " srpt_uninstall : srp target: uninstall"
@echo ""
@echo " scst_local : make scst_local target"
@echo " scst_local_install : scst_local target: install"
@echo " scst_local_uninstall : scst_local target: uninstall"
@echo ""
@echo " usr : make user space fileio_tgt target"
@echo " usr_clean : usr target: clean "
@echo " usr_extraclean : usr target: clean + clean dependencies"
@@ -99,6 +104,7 @@ all:
# @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi
install:
cd $(SCST_DIR) && $(MAKE) $@
@@ -108,6 +114,7 @@ install:
# @if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) DISTDIR=$(ISCSI_DISTDIR) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi
uninstall:
cd $(SCST_DIR) && $(MAKE) $@
@@ -117,6 +124,7 @@ uninstall:
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi
clean:
cd $(SCST_DIR) && $(MAKE) $@
@@ -127,6 +135,7 @@ clean:
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi
extraclean:
cd $(SCST_DIR) && $(MAKE) $@
@@ -137,6 +146,7 @@ extraclean:
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@if [ -d $(SCST_LOCAL_DIR) ]; then cd $(SCST_LOCAL_DIR) && $(MAKE) $@; fi
scst:
cd $(SCST_DIR) && $(MAKE) all
@@ -239,12 +249,27 @@ srpt_install:
srpt_uninstall:
cd $(SRP_DIR) && $(MAKE) uninstall
srpt_clean:
srpt_clean:
cd $(SRP_DIR) && $(MAKE) clean
srpt_extraclean:
cd $(SRP_DIR) && $(MAKE) extraclean
scst_local:
cd $(SCST_LOCAL_DIR) && $(MAKE) all
scst_local_install:
cd $(SCST_LOCAL_DIR) && $(MAKE) install
scst_local_uninstall:
cd $(SCST_LOCAL_DIR) && $(MAKE) uninstall
scst_local_clean:
cd $(SCST_LOCAL_DIR) && $(MAKE) clean
scst_local_extraclean:
cd $(SCST_LOCAL_DIR) && $(MAKE) extraclean
usr:
cd $(USR_DIR) && $(MAKE)
@@ -301,4 +326,5 @@ release2debug:
scstadm scstadm_install scstadm_uninstall scstadm_clean scstadm_extraclean \
srpt srpt_install srpt_uninstall srpt_clean srpt_extraclean \
usr usr_install usr_uninstall usr_clean usr_extraclean \
scst_local scst_local_install scst_local_uninstall scst_local_clean scst_local_extraclean \
debug2perf, debug2release, perf2debug, release2debug

View File

@@ -24,10 +24,11 @@
########################
function usage {
echo "Usage: $0 [-q] [-s] [-m] <kernel version>, where: "
echo "Usage: $0 [-q] [-s] [-m] [-l] <kernel version>, where: "
echo " -q - add qla2x00t driver"
echo " -s - exclude srpt driver"
echo " -m - add mpt target driver"
echo " -l - add scst_local target driver"
}
# Convert an existing patch.
@@ -83,17 +84,19 @@ EOF
qla2x00t="false"
srpt="true"
mpt_scst="false"
scst_local="false"
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt ]; then
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt -o ! -e scst_local ]; then
echo "Please run this script from inside the SCST subversion source tree."
exit 1
fi
set -- $(/usr/bin/getopt hmqs "$@")
set -- $(/usr/bin/getopt hlmqs "$@")
while [ "$1" != "${1#-}" ]
do
case "$1" in
'-h') usage; exit 1;;
'-l') scst_local="true"; shift;;
'-m') mpt_scst="true"; shift;;
'-q') qla2x00t="true"; shift;;
'-s') srpt="false"; shift;;
@@ -264,3 +267,15 @@ if [ "$mpt_scst" = "true" ]; then
done
fi
# Directory drivers/scst/scst-local
if [ "$scst_local" = "true" ]; then
add_file "scst_local/in-tree/Kconfig" "drivers/scst/scst_local/Kconfig"
add_file "scst_local/in-tree/Makefile" "drivers/scst/scst_local/Makefile"
add_file "scst_local/scst_local.c" "drivers/scst/scst_local/scst_local.c"
fi

View File

@@ -251,5 +251,6 @@ config SCST_MEASURE_LATENCY
source "drivers/scst/iscsi-scst/Kconfig"
source "drivers/scst/qla2xxx-target/Kconfig"
source "drivers/scst/srpt/Kconfig"
source "drivers/scst/scst_local/Kconfig"
endmenu

View File

@@ -7,5 +7,6 @@ scst-y += scst_proc.o
scst-y += scst_mem.o
scst-y += scst_debug.o
obj-$(CONFIG_SCST) += scst.o dev_handlers/ iscsi-scst/ qla2xxx-target/ srpt/
obj-$(CONFIG_SCST) += scst.o dev_handlers/ iscsi-scst/ qla2xxx-target/ srpt/ \
scst_local/

68
scst_local/Makefile Normal file
View File

@@ -0,0 +1,68 @@
#
# A Makefile for the scst-local ...
#
#SCST_INC_DIR := /usr/local/include/scst
#SCST_DIR := $(SCST_INC_DIR)
SCST_INC_DIR := $(SUBDIRS)/../scst/include/
SCST_DIR := $(shell pwd)/../scst/src
EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(SCST_DIR) -Wextra -Wno-unused-parameter
EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS
#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING
EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG
ifeq ($(KVER),)
ifeq ($(KDIR),)
KDIR := /lib/modules/$(shell uname -r)/build
endif
else
KDIR := /lib/modules/$(KVER)/build
endif
ifneq ($(KERNELRELEASE),)
obj-m := scst_local.o
else
all: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m
tgt: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m
install: all scst_local.ko
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \
modules_install
-depmod -a
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Modules.symvers: $(SCST_DIR)/Modules.symvers
cp $(SCST_DIR)/Modules.symvers .
else
.PHONY: Modules.symvers
endif
# It's renamed in 2.6.18
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Module.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Module.symvers: $(SCST_DIR)/Module.symvers
cp $(SCST_DIR)/Module.symvers .
else
.PHONY: Module.symvers
endif
uninstall:
rm -f $(INSTALL_DIR)/scst_local.kp
-/sbin/depmod -a $(KVER)
endif
clean:
@$(MAKE) -C $(KDIR) M=$(PWD) clean
@$(RM) tags Modules.symvers module.symvers Module.markers modules.order
extraclean: clean
.PHONY: all tgt install uninstall clean extraclean

89
scst_local/README Normal file
View File

@@ -0,0 +1,89 @@
SCST Debug ...
Richard Sharpe, 24-Sep-2008
This is the SCST Local driver. Its function is to allow you to access devices
that are exported via SCST directly on the same Linux system that they are
exported from.
No assumptions are made in the code about the device types on the target, so
any device handlers that you load in SCST should be visible, including tapes
and so forth.
To build, simply issue 'make' in the scst-local directory.
Try 'modinfo scst_local.ko' for a listing of module parameters so far.
Here is how I have used it so far:
1. Load up scst:
modprobe scst
modprobe scst_vdisk
2. Create a virtual disk (or your own device handler):
dd if=/dev/zero of=/some/path/vdisk1.img bs=16384 count=1000000
# dd if=/dev/zero of=/some/path/vdisk2.img bs=16384 count=1000000
echo "open vm_disk1 /some/path/vdisk1.img" > /proc/scsi_tgt/vdisk/vdisk
# echo "open vm_disk2 /some/path/vdisk2.img" > /proc/scsi_tgt/vdisk/vdisk
echo "add vm_disk1 0" > /proc/scsi_tgt/groups/Default/devices
# echo "add vm_disk2 1" > /proc/scsi_tgt/groups/Default/devices
3. Load the scst_local driver:
insmod scst_local.ko
# insmod scst_local.ko max_luns=8 options=1 # That options prints debug info
4. Check what you have
cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: ST9320320AS Rev: 0303
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: TSSTcorp Model: CD/DVDW TS-L632D Rev: TO04
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi7 Channel: 00 Id: 00 Lun: 00
Vendor: SCST_FIO Model: vm_disk1 Rev: 101
Type: Direct-Access ANSI SCSI revision: 04
5. Have fun.
Some of this was coded while in Santa Clara, some in Bangalore, and some in
Hyderabad. Noe doubt some will be coded on the way back to Santa Clara.
The code still has bugs, so if you encounter any, email me the fixes at:
realrichardsharpe@gmail.com
I am thinking of renaming this to something more interesting.
6. Change log
V0.1 24-Sep-2008 (Hyderabad) Initial coding, pretty chatty and messy,
but worked.
V0.2 25-Sep-2008 (Hong Kong) Cleaned up the code a lot, reduced the log
chatter, fixed a bug where multiple LUNs did not
work. Also, added logging control. Tested with
five virtual disks. They all came up as /dev/sdb
through /dev/sdf and I could dd to them. Also
fixed a bug preventing multiple adapters.
V0.3 26-Sep-2008 (Santa Clara) Added back a copyright plus cleaned up some
unused functions and structures.
V0.4 5-Oct-2008 (Santa Clara) Changed name to scst_local as suggested, cleaned
up some unused variables (made them used) and
change allocation to a kmem_cache pool.
V0.5 5-Oct-2008 (Santa Clara) Added mgmt commands to handle dev reset and
aborts. Not sure if aborts works. Also corrected
the version info and renamed readme to README.
V0.6 7-Oct-2008 (Santa Clara) Removed some redundant code and made some
changes suggested by Vladislav.
V0.7 11-Oct-2008 (Santa Clara) Moved into the scst tree. Cleaned up some
unused functions, used TRACE macros etc.

View File

@@ -0,0 +1,10 @@
config SCST_LOCAL
tristate "SCST Local driver"
depends on SCST
---help---
This module provides a LLD SCSI driver that connects to
the SCST target mode subsystem in a loop-back manner.
It allows you to test target-mode device-handlers locally.
You will need the SCST subsystem as well.
If unsure whether you really want or need this, say N.

View File

@@ -0,0 +1,10 @@
SCST_INC_DIR := include/scst
SCST_DIR := drivers/scst
EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(SCST_DIR)
#EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS
#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING
#EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG
obj-$(CONFIG_SCST_LOCAL) += scst_local.o

1023
scst_local/scst_local.c Normal file

File diff suppressed because it is too large Load Diff