From: <vl...@us...> - 2008-05-15 15:00:48
|
Revision: 373 http://scst.svn.sourceforge.net/scst/?rev=373&view=rev Author: vlnb Date: 2008-05-15 08:00:21 -0700 (Thu, 15 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: By this time I have reworked the update of scripts/generate-kernel-patch'>scripts/generate-kernel-patch. These are the changes that were already present in version 1 of this patch and that have been kept in this patch: - The SCST code has been moved from drivers/scsi/scsi_tgt to drivers/scst. - Moved SCST header files from include/scsi_tgt to include/scst. - Added iscsi-scst in drivers/scst/iscsi-scst. For the time being the generate-kernel-patch does no longer try to add the qla2x00t driver in drivers/scst/qla2x00-target -- I have not yet been able to figure out how to get qla2x00t/qla2x00-target compiled without the initiator code. Just as in version 1 of this patch, the following files in the Subversion repository have been renamed to reflect the above changes: - Renamed scst/kernel/in-tree/Makefile.scsi.Linux-2.6.24.patch'>scst/kernel/in-tree/Makefile.scsi.Linux-2.6.24.patch to scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch'>scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch. - Renamed Kconfig'>scst/kernel/in-tree/Kconfig.scsi.Linux-2.6.24.patch to scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch'>scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch. - Renamed scst/kernel/in-tree/Makefile.scsi_tgt'>scst/kernel/in-tree/Makefile.scsi_tgt to scst/kernel/in-tree/Makefile.scst'>scst/kernel/in-tree/Makefile.scst. - Renamed scst/kernel/in-tree/Kconfig.scsi_tgt'>scst/kernel/in-tree/Kconfig.scsi_tgt to scst/kernel/in-tree/Kconfig.scst'>scst/kernel/in-tree/Kconfig.scst. Because of the above changes the include path specified in the following Makefiles had to be changed: - scst/kernel/in-tree/Makefile.dev_handlers'>scst/kernel/in-tree/Makefile.dev_handlers - srpt/src/Makefile.in_kernel'>srpt/src/Makefile.in_kernel Other changes: - I have added menu/endmenu entries in file scst/kernel/in-tree/Kconfig.scst such that the SCST entries become visible when running make xconfig or make menuconfig. - Elaborated the SCST help texts a little bit (in file scst/kernel/in-tree/Kconfig.scst). New in version 2 of this patch: - Moved remaining patches in the generate-kernel-patch script to separate files. - Added support for the 2.6.25 kernel. This patch has been tested as follows: mkdir -p tmp cd tmp rm -rf linux-2.6.25.3 /lib/modules/2.6.25.3-scst tar xjf ~vanasscb/software/downloads/linux-2.6.25.3.tar.bz2 cd linux-2.6.25.3 cp ../.config-2.6.25 . (cd ~vanasscb/software/scst && ~vanasscb/software/scst/scripts/generate-kernel-patch \ 2.6.25) | patch -p1 make oldconfig diff ../.config . make xconfig make menuconfig make -j5 bzImage modules make modules_install install cp -r /lib/firmware/$(uname -r) /lib/firmware/2.6.25.3-scst update-initramfs -k 2.6.25.3-scst -c reboot modprobe iscsi-scst modprobe ib_srpt lsmod | grep -E 'scst|ib_srpt' dmesg Signed-off-by: bar...@gm... Modified Paths: -------------- trunk/scripts/generate-kernel-patch trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch trunk/scst/kernel/in-tree/Kconfig.scst trunk/scst/kernel/in-tree/Makefile.dev_handlers trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch trunk/scst/kernel/in-tree/Makefile.scst trunk/srpt/src/Makefile.in_kernel Added Paths: ----------- trunk/iscsi-scst/kernel/Kconfig trunk/iscsi-scst/kernel/Makefile.in-kernel trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.25.patch trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch trunk/srpt/src/Kconfig.infiniband.Linux-2.6.25.patch trunk/srpt/src/Makefile.infiniband.Linux-2.6.25.patch Added: trunk/iscsi-scst/kernel/Kconfig =================================================================== --- trunk/iscsi-scst/kernel/Kconfig (rev 0) +++ trunk/iscsi-scst/kernel/Kconfig 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,5 @@ +config SCST_ISCSI + tristate "SCST iSCSI Support" + depends on SCSI + ---help--- + iSCSI target support. The iSCSI protocol has been defined in RFC 3720. Added: trunk/iscsi-scst/kernel/Makefile.in-kernel =================================================================== --- trunk/iscsi-scst/kernel/Makefile.in-kernel (rev 0) +++ trunk/iscsi-scst/kernel/Makefile.in-kernel 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,5 @@ +EXTRA_CFLAGS += -Iinclude/scst + +obj-m := iscsi-scst.o +iscsi-scst-objs := iscsi.o nthread.o config.o digest.o \ + conn.o session.o target.o event.o param.o Modified: trunk/scripts/generate-kernel-patch =================================================================== --- trunk/scripts/generate-kernel-patch 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scripts/generate-kernel-patch 2008-05-15 15:00:21 UTC (rev 373) @@ -28,31 +28,42 @@ # $2: path in kernel tree of file to be patched. function add_patch { if [ ! -e "$1" ]; then - echo "Error: could not find $1." + echo "Error: could not find $1." >&2 exit 1 fi sed -e "s:^--- [^ ]*:--- orig/$2:" -e "s:^+++ [^ ]*:+++ $2:" < "$1" } -# Generate a patch for a file to be added to the kernel source tree. +# Generate a patch for a file to be added to the kernel source tree, and strip +# trailing whitespace from C source files while converting the file to patch +# format. # $1: path of file to be added. # $2: path in kernel tree where file should be added. function add_file { local a b if [ ! -e "$1" ]; then - echo "Error: could not find $1." + echo "Error: could not find $1." >&2 exit 1 fi + # Skip any files generated by the kernel build process (*.mod.c). + if [ "${1%.mod.c}" != "$1" ]; then + return 0; + fi + cat <<EOF diff -uprN orig/$2 $2 --- orig/$2 +++ $2 @@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@ EOF - sed "s/^/+/" <"$1" + if [ "${2%.[ch]}" != "$2" ]; then + sed -e 's/^/+/' -e 's/[ ]*$//g' < "$1" + else + sed -e 's/^/+/' < "$1" + fi } @@ -70,6 +81,7 @@ exit 1 fi + #################### # Patch Generation # #################### @@ -86,11 +98,11 @@ echo "Error: kernel version ${kernel_version} is not supported by SCST." echo "(could not find file $p)." exit 1 - fi + fi >&2 done -# Kernel patches for other directories than drivers/scsi/scsi_tgt/. +# General kernel patches. for p in "${kpatch[@]}" do @@ -99,53 +111,102 @@ echo '' done -add_patch "scst/kernel/in-tree/Kconfig.scsi.Linux-${kernel_version}.patch" \ - "linux-${kernel_version}/drivers/scsi/Kconfig" -add_patch "scst/kernel/in-tree/Makefile.scsi.Linux-${kernel_version}.patch" \ - "linux-${kernel_version}/drivers/scsi/Makefile" +# Directory include/scst/ - -# Directory include/scsi_tgt/ - for f in scst/include/*h do - add_file "${f}" "linux-${kernel_version}/include/scsi_tgt/${f#scst/include/}" + add_file "${f}" "linux-${kernel_version}/include/scst/${f#scst/include/}" done +for f in iscsi-scst/include/*h +do +add_file "${f}" "linux-${kernel_version}/include/scst/${f#iscsi-scst/include/}" +done -# Directory drivers/scsi/scsi_tgt/ -add_file "scst/kernel/in-tree/Kconfig.scsi_tgt" \ - "drivers/scsi/scsi_tgt/Kconfig" -add_file "scst/kernel/in-tree/Makefile.scsi_tgt" \ - "drivers/scsi/scsi_tgt/Makefile" +# Directory drivers/ +add_patch "scst/kernel/in-tree/Kconfig.drivers.Linux-${kernel_version}.patch" \ + "linux-${kernel_version}/drivers/Kconfig" -for f in scst/src/*[ch] +add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kernel_version}.patch"\ + "linux-${kernel_version}/drivers/Makefile" + + +# Directory drivers/scst/ + +add_file "scst/kernel/in-tree/Kconfig.scst" \ + "linux-${kernel_version}/drivers/scst/Kconfig" +add_file "scst/kernel/in-tree/Makefile.scst" \ + "linux-${kernel_version}/drivers/scst/Makefile" + + +for f in scst/src/*.[ch] do - add_file ${f} linux-${kernel_version}/drivers/scsi/scsi_tgt/${f#scst/src/} + add_file ${f} linux-${kernel_version}/drivers/scst/${f#scst/src/} echo '' echo '' done -# Directory drivers/scsi/scsi_tgt/dev_handlers/ +# Directory drivers/scst/dev_handlers/ add_file "scst/kernel/in-tree/Makefile.dev_handlers" \ - "linux-${kernel_version}/drivers/scsi/scsi_tgt/dev_handlers/Makefile" + "linux-${kernel_version}/drivers/scst/dev_handlers/Makefile" for f in scst/src/dev_handlers/*.[ch] do - add_file ${f} linux-${kernel_version}/drivers/scsi/scsi_tgt/dev_handlers/${f#scst/src/dev_handlers/} + add_file ${f} linux-${kernel_version}/drivers/scst/dev_handlers/${f#scst/src/dev_handlers/} echo '' echo '' done +# Directory drivers/scst/iscsi-scst/ + +add_file "iscsi-scst/kernel/Makefile.in-kernel" \ + "linux-${kernel_version}/drivers/scst/iscsi-scst/Makefile" + +add_file "iscsi-scst/kernel/Kconfig" \ + "linux-${kernel_version}/drivers/scst/iscsi-scst/Kconfig" + +for f in iscsi-scst/kernel/*.[ch] +do + add_file "${f}" \ + "linux-${kernel_version}/drivers/scst/iscsi-scst/${f#iscsi-scst/kernel/}" + echo '' + echo '' +done + + +# Directory drivers/scst/qla2x00-target/ + +if false; then + +add_file "qla2x00t/qla2x00-target/Makefile.in-kernel" \ + "linux-${kernel_version}/drivers/scst/qla2x00-target/Makefile" + +add_file "qla2x00t/qla2x00-target/Kconfig" \ + "linux-${kernel_version}/drivers/scst/qla2x00-target/Kconfig" + +add_file "qla2x00t/qla2x_tgt_def.h" \ + "linux-${kernel_version}/drivers/scst/qla2x00-target/qla2x_tgt_def.h" + +for f in qla2x00t/qla2x00-target/*.[ch] +do + add_file "${f}" \ + "linux-${kernel_version}/drivers/scst/qla2x00-target/${f#qla2x00t/qla2x00-target/}" + echo '' + echo '' +done + +fi + + # Directory drivers/infiniband/ulp/srpt/ -add_patch "srpt/src/Kconfig.infiniband.Linux-${kernel_version}.patch" \ +add_patch "srpt/src/Kconfig.infiniband.Linux-${kernel_version}.patch" \ "linux-${kernel_version}/drivers/infiniband/Kconfig" add_patch "srpt/src/Makefile.infiniband.Linux-${kernel_version}.patch" \ @@ -155,7 +216,7 @@ add_file "srpt/src/Makefile.in_kernel" "drivers/infiniband/ulp/srpt/Makefile" -for f in srpt/src/*[ch] +for f in srpt/src/*.[ch] do add_file ${f} linux-${kernel_version}/drivers/infiniband/ulp/srpt/${f#srpt/src/} echo '' Modified: trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch =================================================================== --- trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -1,11 +1,12 @@ ---- orig/linux-2.6.24/drivers/scsi/Kconfig 2008-01-24 23:58:37.000000000 +0100 -+++ linux-2.6.24/drivers/scsi/Kconfig 2008-05-09 13:25:39.000000000 +0200 -@@ -1351,6 +1351,8 @@ config SCSI_QLOGICPTI - source "drivers/scsi/qla2xxx/Kconfig" - source "drivers/scsi/qla4xxx/Kconfig" - -+source "drivers/scsi/scsi_tgt/Kconfig" +diff -uprN ../orig/linux-2.6.24/drivers/Kconfig linux-2.6.24/drivers/Kconfig +--- ../orig/linux-2.6.24/drivers/Kconfig 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/Kconfig 2008-05-13 13:05:55.000000000 +0200 +@@ -24,6 +24,8 @@ + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" + - config SCSI_LPFC - tristate "Emulex LightPulse Fibre Channel Support" - depends on PCI && SCSI + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" Added: trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.25.patch =================================================================== --- trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.25.patch (rev 0) +++ trunk/scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.25.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,12 @@ +diff -uprN ../orig/linux-2.6.24/drivers/Kconfig linux-2.6.24/drivers/Kconfig +--- ../orig/linux-2.6.24/drivers/Kconfig 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/Kconfig 2008-05-13 13:05:55.000000000 +0200 +@@ -24,6 +24,8 @@ + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" ++ + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" Modified: trunk/scst/kernel/in-tree/Kconfig.scst =================================================================== --- trunk/scst/kernel/in-tree/Kconfig.scst 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scst/kernel/in-tree/Kconfig.scst 2008-05-15 15:00:21 UTC (rev 373) @@ -1,3 +1,5 @@ +menu "SCSI target middle level support" + config SCSI_TARGET tristate "SCSI target middle level support" default SCSI @@ -70,17 +72,25 @@ ---help--- SCSI TARGET handler for virtual user space device. +source "drivers/scst/iscsi-scst/Kconfig" + config SCSI_TARGET_EXTRACHECKS - bool "Extrachecks support" + bool "Extra consistency checks" ---help--- - SCSI TARGET extrachecks. + Enable additional consistency checks in the SCSI middle level target + code. This may be helpful for SCST developers. config SCSI_TARGET_TRACING bool "Tracing support" ---help--- - SCSI TARGET tracing. + Enable SCSI middle level tracing support. Tracing can be controlled + dynamically via /proc/scsi_tgt/trace_level. The traced information + is sent to the kernel log and may be very helpful when analyzing + the cause of a communication problem between initiator and target. config SCSI_TARGET_DEBUG bool "Debug support" ---help--- SCSI TARGET debugging. + +endmenu Modified: trunk/scst/kernel/in-tree/Makefile.dev_handlers =================================================================== --- trunk/scst/kernel/in-tree/Makefile.dev_handlers 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scst/kernel/in-tree/Makefile.dev_handlers 2008-05-15 15:00:21 UTC (rev 373) @@ -1,4 +1,4 @@ -EXTRA_CFLAGS += -Iinclude/scsi_tgt -Wextra -Wno-unused-parameter +EXTRA_CFLAGS += -Iinclude/scst -Wextra -Wno-unused-parameter obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ scst_vdisk.o scst_raid.o scst_processor.o scst_user.o Modified: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -1,11 +1,11 @@ -diff -uprN orig/linux-2.6.24/drivers/scsi/Makefile linux-2.6.24/drivers/scsi/Makefile ---- orig/linux-2.6.24/drivers/scsi/Makefile 2008-01-24 23:58:37.000000000 +0100 -+++ linux-2.6.24/drivers/scsi/Makefile 2008-05-09 13:05:36.000000000 +0200 -@@ -88,6 +88,7 @@ obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas - obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o - obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/ - obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/ -+obj-$(CONFIG_SCSI_TARGET) += scsi_tgt/ - obj-$(CONFIG_SCSI_LPFC) += lpfc/ - obj-$(CONFIG_SCSI_PAS16) += pas16.o - obj-$(CONFIG_SCSI_SEAGATE) += seagate.o +diff -uprN ../orig/linux-2.6.24/drivers/Makefile linux-2.6.24/drivers/Makefile +--- ../orig/linux-2.6.24/drivers/Makefile 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/Makefile 2008-05-13 13:06:34.000000000 +0200 +@@ -35,6 +35,7 @@ + obj-y += macintosh/ + obj-$(CONFIG_IDE) += ide/ + obj-$(CONFIG_SCSI) += scsi/ ++obj-$(CONFIG_SCSI_TARGET) += scst/ + obj-$(CONFIG_ATA) += ata/ + obj-$(CONFIG_FUSION) += message/ + obj-$(CONFIG_FIREWIRE) += firewire/ Added: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch (rev 0) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,11 @@ +diff -uprN ../orig/linux-2.6.24/drivers/Makefile linux-2.6.24/drivers/Makefile +--- ../orig/linux-2.6.24/drivers/Makefile 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/Makefile 2008-05-13 13:06:34.000000000 +0200 +@@ -36,6 +36,7 @@ + obj-y += macintosh/ + obj-$(CONFIG_IDE) += ide/ + obj-$(CONFIG_SCSI) += scsi/ ++obj-$(CONFIG_SCSI_TARGET) += scst/ + obj-$(CONFIG_ATA) += ata/ + obj-$(CONFIG_FUSION) += message/ + obj-$(CONFIG_FIREWIRE) += firewire/ Modified: trunk/scst/kernel/in-tree/Makefile.scst =================================================================== --- trunk/scst/kernel/in-tree/Makefile.scst 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/scst/kernel/in-tree/Makefile.scst 2008-05-15 15:00:21 UTC (rev 373) @@ -1,4 +1,4 @@ -EXTRA_CFLAGS += -Iinclude/scsi_tgt -Wextra -Wno-unused-parameter +EXTRA_CFLAGS += -Iinclude/scst -Wextra -Wno-unused-parameter scst-y += scst_main.o scst-y += scst_targ.o Added: trunk/srpt/src/Kconfig.infiniband.Linux-2.6.25.patch =================================================================== --- trunk/srpt/src/Kconfig.infiniband.Linux-2.6.25.patch (rev 0) +++ trunk/srpt/src/Kconfig.infiniband.Linux-2.6.25.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,12 @@ +diff -uprN orig/linux-2.6.24/drivers/infiniband/Kconfig linux-2.6.24/drivers/infiniband/Kconfig +--- orig/linux-2.6.24/drivers/infiniband/Kconfig 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/infiniband/Kconfig 2008-05-09 13:55:27.000000000 +0200 +@@ -51,6 +51,8 @@ + + source "drivers/infiniband/ulp/srp/Kconfig" + ++source "drivers/infiniband/ulp/srpt/Kconfig" ++ + source "drivers/infiniband/ulp/iser/Kconfig" + + endif # INFINIBAND Modified: trunk/srpt/src/Makefile.in_kernel =================================================================== --- trunk/srpt/src/Makefile.in_kernel 2008-05-15 09:35:20 UTC (rev 372) +++ trunk/srpt/src/Makefile.in_kernel 2008-05-15 15:00:21 UTC (rev 373) @@ -1,4 +1,4 @@ EXTRA_CFLAGS += -Idrivers/infiniband/include -EXTRA_CFLAGS += -Iinclude/scsi_tgt +EXTRA_CFLAGS += -Iinclude/scst obj-$(CONFIG_INFINIBAND_SRPT) += ib_srpt.o Added: trunk/srpt/src/Makefile.infiniband.Linux-2.6.25.patch =================================================================== --- trunk/srpt/src/Makefile.infiniband.Linux-2.6.25.patch (rev 0) +++ trunk/srpt/src/Makefile.infiniband.Linux-2.6.25.patch 2008-05-15 15:00:21 UTC (rev 373) @@ -0,0 +1,9 @@ +diff -uprN orig/linux-2.6.24/drivers/infiniband/Makefile linux-2.6.24/drivers/infiniband/Makefile +--- orig/linux-2.6.24/drivers/infiniband/Makefile 2008-01-24 23:58:37.000000000 +0100 ++++ linux-2.6.24/drivers/infiniband/Makefile 2008-05-09 13:57:00.000000000 +0200 +@@ -8,4 +8,5 @@ + obj-$(CONFIG_INFINIBAND_NES) += hw/nes/ + obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/ + obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/ ++obj-$(CONFIG_INFINIBAND_SRPT) += ulp/srpt/ + obj-$(CONFIG_INFINIBAND_ISER) += ulp/iser/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-16 10:29:41
|
Revision: 375 http://scst.svn.sourceforge.net/scst/?rev=375&view=rev Author: vlnb Date: 2008-05-16 03:29:34 -0700 (Fri, 16 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: I don't know when this was broken, but with the current SVN version, after having generated and applied a kernel patch for SCST, iscsi-scst doesn't build anymore. The patch below fixes this and also includes a cleanup patch for the generate-kernel-patch'>generate-kernel-patch script. The generated kernel patch has been tested with the 2.6.24 and 2.6.25.4 kernels (extracted kernel sources + applied patch + built kernel + installed kernel + reboot + load SCST modules). Signed-off-by: <bar...@gm...> Modified Paths: -------------- trunk/scripts/generate-kernel-patch trunk/scst/kernel/in-tree/Makefile.scst Modified: trunk/scripts/generate-kernel-patch =================================================================== --- trunk/scripts/generate-kernel-patch 2008-05-15 17:27:50 UTC (rev 374) +++ trunk/scripts/generate-kernel-patch 2008-05-16 10:29:34 UTC (rev 375) @@ -32,7 +32,9 @@ exit 1 fi - sed -e "s:^--- [^ ]*:--- orig/$2:" -e "s:^+++ [^ ]*:+++ $2:" < "$1" + sed -e "s:^--- [^ ]*:--- orig/linux-${kernel_version}/$2:" \ + -e "s:^+++ [^ ]*:+++ linux-${kernel_version}/$2:" \ + < "$1" } # Generate a patch for a file to be added to the kernel source tree, and strip @@ -48,21 +50,20 @@ exit 1 fi - # Skip any files generated by the kernel build process (*.mod.c). - if [ "${1%.mod.c}" != "$1" ]; then - return 0; - fi - - cat <<EOF -diff -uprN orig/$2 $2 ---- orig/$2 -+++ $2 + # Only include files that were not generated by the build process + # -- skip *.mod.c. + if [ "$1" = "${1%.mod.c}" -a "$1" ]; then + cat <<EOF +diff -uprN orig/linux-${kernel_version}/$2 linux-${kernel_version}/$2 +--- orig/linux-${kernel_version}/$2 ++++ linux-${kernel_version}/$2 @@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@ EOF - if [ "${2%.[ch]}" != "$2" ]; then - sed -e 's/^/+/' -e 's/[ ]*$//g' < "$1" - else - sed -e 's/^/+/' < "$1" + if [ "${2%.[ch]}" != "$2" ]; then + sed -e 's/^/+/' -e 's/[ ]*$//g' < "$1" + else + sed -e 's/^/+/' < "$1" + fi fi } @@ -104,79 +105,71 @@ # General kernel patches. -for p in "${kpatch[@]}" -do - cat "$p" - echo '' - echo '' -done +cat "${kpatch[@]}" # Directory include/scst/ +# Make sure the file iscsi-scst/iscsi_scst_itf_ver.h is up to date. +make -C iscsi-scst include/iscsi_scst_itf_ver.h + for f in scst/include/*h do - add_file "${f}" "linux-${kernel_version}/include/scst/${f#scst/include/}" + add_file "${f}" "include/scst/${f#scst/include/}" done for f in iscsi-scst/include/*h do -add_file "${f}" "linux-${kernel_version}/include/scst/${f#iscsi-scst/include/}" + add_file "${f}" "include/scst/${f#iscsi-scst/include/}" done # Directory drivers/ add_patch "scst/kernel/in-tree/Kconfig.drivers.Linux-${kernel_version}.patch" \ - "linux-${kernel_version}/drivers/Kconfig" + "drivers/Kconfig" add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kernel_version}.patch"\ - "linux-${kernel_version}/drivers/Makefile" + "drivers/Makefile" # Directory drivers/scst/ -add_file "scst/kernel/in-tree/Kconfig.scst" \ - "linux-${kernel_version}/drivers/scst/Kconfig" -add_file "scst/kernel/in-tree/Makefile.scst" \ - "linux-${kernel_version}/drivers/scst/Makefile" +add_file "scst/kernel/in-tree/Kconfig.scst" "drivers/scst/Kconfig" +add_file "scst/kernel/in-tree/Makefile.scst" "drivers/scst/Makefile" +add_file "scst/README" "Documentation/scst/README.scst" + for f in scst/src/*.[ch] do - add_file ${f} linux-${kernel_version}/drivers/scst/${f#scst/src/} - echo '' - echo '' + add_file "${f}" "drivers/scst/${f#scst/src/}" done # Directory drivers/scst/dev_handlers/ add_file "scst/kernel/in-tree/Makefile.dev_handlers" \ - "linux-${kernel_version}/drivers/scst/dev_handlers/Makefile" + "drivers/scst/dev_handlers/Makefile" for f in scst/src/dev_handlers/*.[ch] do - add_file ${f} linux-${kernel_version}/drivers/scst/dev_handlers/${f#scst/src/dev_handlers/} - echo '' - echo '' + add_file "${f}" "drivers/scst/dev_handlers/${f#scst/src/dev_handlers/}" done # Directory drivers/scst/iscsi-scst/ add_file "iscsi-scst/kernel/Makefile.in-kernel" \ - "linux-${kernel_version}/drivers/scst/iscsi-scst/Makefile" + "drivers/scst/iscsi-scst/Makefile" -add_file "iscsi-scst/kernel/Kconfig" \ - "linux-${kernel_version}/drivers/scst/iscsi-scst/Kconfig" +add_file "iscsi-scst/kernel/Kconfig" "drivers/scst/iscsi-scst/Kconfig" +add_file "iscsi-scst/README" "Documentation/scst/README.iscsi" + for f in iscsi-scst/kernel/*.[ch] do - add_file "${f}" \ - "linux-${kernel_version}/drivers/scst/iscsi-scst/${f#iscsi-scst/kernel/}" - echo '' - echo '' + add_file "${f}" "drivers/scst/iscsi-scst/${f#iscsi-scst/kernel/}" done @@ -185,20 +178,20 @@ if false; then add_file "qla2x00t/qla2x00-target/Makefile.in-kernel" \ - "linux-${kernel_version}/drivers/scst/qla2x00-target/Makefile" + "drivers/scst/qla2x00-target/Makefile" add_file "qla2x00t/qla2x00-target/Kconfig" \ - "linux-${kernel_version}/drivers/scst/qla2x00-target/Kconfig" + "drivers/scst/qla2x00-target/Kconfig" add_file "qla2x00t/qla2x_tgt_def.h" \ - "linux-${kernel_version}/drivers/scst/qla2x00-target/qla2x_tgt_def.h" + "drivers/scst/qla2x00-target/qla2x_tgt_def.h" +add_file "qla2x00t/qla2x00-target/README" \ + "Documentation/scst/README.qla2x00t" + for f in qla2x00t/qla2x00-target/*.[ch] do - add_file "${f}" \ - "linux-${kernel_version}/drivers/scst/qla2x00-target/${f#qla2x00t/qla2x00-target/}" - echo '' - echo '' + add_file "${f}" "drivers/scst/qla2x00-target/${f#qla2x00t/qla2x00-target/}" done fi @@ -207,18 +200,18 @@ # Directory drivers/infiniband/ulp/srpt/ add_patch "srpt/src/Kconfig.infiniband.Linux-${kernel_version}.patch" \ - "linux-${kernel_version}/drivers/infiniband/Kconfig" + "drivers/infiniband/Kconfig" add_patch "srpt/src/Makefile.infiniband.Linux-${kernel_version}.patch" \ - "linux-${kernel_version}/drivers/infiniband/Makefile" + "drivers/infiniband/Makefile" -add_file "srpt/src/Kconfig" "drivers/infiniband/ulp/srpt/Kconfig" +add_file "srpt/src/Kconfig" "drivers/infiniband/ulp/srpt/Kconfig" -add_file "srpt/src/Makefile.in_kernel" "drivers/infiniband/ulp/srpt/Makefile" +add_file "srpt/src/Makefile.in_kernel" "drivers/infiniband/ulp/srpt/Makefile" +add_file "srpt/README" "Documentation/scst/README.srpt" + for f in srpt/src/*.[ch] do - add_file ${f} linux-${kernel_version}/drivers/infiniband/ulp/srpt/${f#srpt/src/} - echo '' - echo '' + add_file "${f}" "drivers/infiniband/ulp/srpt/${f#srpt/src/}" done Modified: trunk/scst/kernel/in-tree/Makefile.scst =================================================================== --- trunk/scst/kernel/in-tree/Makefile.scst 2008-05-15 17:27:50 UTC (rev 374) +++ trunk/scst/kernel/in-tree/Makefile.scst 2008-05-16 10:29:34 UTC (rev 375) @@ -7,5 +7,5 @@ scst-y += scst_mem.o scst-y += scst_debug.o -obj-$(CONFIG_SCSI_TARGET) += scst.o dev_handlers/ +obj-$(CONFIG_SCSI_TARGET) += scst.o dev_handlers/ iscsi-scst/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-19 10:21:51
|
Revision: 377 http://scst.svn.sourceforge.net/scst/?rev=377&view=rev Author: vlnb Date: 2008-05-19 03:21:41 -0700 (Mon, 19 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>, except few chuncks from qla2x00t/ obviously not related to the target mode addon: One of the Linux kernel patch submission requirements is that source files do not contain trailing whitespace. The patch below removes trailing whitespace from .c and .h source files. Note: it might be more convenient to run the script I used to generate this patch than to review and apply the patch below. This is how I generated and verified the patch below: cat <<EOF >./strip-trailing-whitespace #!/bin/bash trap "rm -f $t" EXIT t=/tmp/temporary-file.$$ for f in "$@" do sed 's/[ ]*$//' <"$f" >"$t" && mv "$t" "$f" done EOF chmod a+x ./strip-trailing-whitespace find -name '*.[ch]' | xargs ./strip-trailing-whitespace svn diff -x -w Signed-off-by: <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/include/iscsi_scst.h trunk/iscsi-scst/include/iscsi_scst_ver.h trunk/iscsi-scst/kernel/config.c trunk/iscsi-scst/kernel/conn.c trunk/iscsi-scst/kernel/digest.c trunk/iscsi-scst/kernel/digest.h trunk/iscsi-scst/kernel/event.c trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/iscsi.h trunk/iscsi-scst/kernel/iscsi_dbg.h trunk/iscsi-scst/kernel/iscsi_hdr.h trunk/iscsi-scst/kernel/nthread.c trunk/iscsi-scst/kernel/param.c trunk/iscsi-scst/kernel/session.c trunk/iscsi-scst/kernel/target.c trunk/iscsi-scst/usr/chap.c trunk/iscsi-scst/usr/config.h trunk/iscsi-scst/usr/conn.c trunk/iscsi-scst/usr/ctldev.c trunk/iscsi-scst/usr/event.c trunk/iscsi-scst/usr/iscsi_adm.c trunk/iscsi-scst/usr/iscsi_adm.h trunk/iscsi-scst/usr/iscsi_hdr.h trunk/iscsi-scst/usr/iscsi_scstd.c trunk/iscsi-scst/usr/iscsid.c trunk/iscsi-scst/usr/iscsid.h trunk/iscsi-scst/usr/log.c trunk/iscsi-scst/usr/message.c trunk/iscsi-scst/usr/misc.h trunk/iscsi-scst/usr/param.c trunk/iscsi-scst/usr/param.h trunk/iscsi-scst/usr/plain.c trunk/iscsi-scst/usr/session.c trunk/iscsi-scst/usr/target.c trunk/iscsi-scst/usr/types.h trunk/mpt/mpt_scst.c trunk/mpt/mpt_scst.h trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/qla2x00t/qla2x00-target/qla2x00t.h trunk/qla2x00t/qla2x_tgt.h trunk/qla2x00t/qla2x_tgt_def.h trunk/qla2x00t/qla_attr.c trunk/qla2x00t/qla_dbg.c trunk/qla2x00t/qla_init.c trunk/qla2x00t/qla_isr.c trunk/qla2x00t/qla_os.c trunk/qla_isp/common/isp.c trunk/qla_isp/common/isp_library.c trunk/qla_isp/common/isp_library.h trunk/qla_isp/common/isp_stds.h trunk/qla_isp/common/isp_target.c trunk/qla_isp/common/isp_target.h trunk/qla_isp/common/isp_tpublic.h trunk/qla_isp/common/ispmbox.h trunk/qla_isp/common/ispreg.h trunk/qla_isp/common/ispvar.h trunk/qla_isp/firmware/asm_1000.h trunk/qla_isp/firmware/asm_1040.h trunk/qla_isp/firmware/asm_1080.h trunk/qla_isp/firmware/asm_12160.h trunk/qla_isp/firmware/asm_2100.h trunk/qla_isp/firmware/asm_2200.h trunk/qla_isp/firmware/asm_2300.h trunk/qla_isp/firmware/asm_2322.h trunk/qla_isp/firmware/asm_2400.h trunk/qla_isp/linux/exioct.h trunk/qla_isp/linux/exioctln.h trunk/qla_isp/linux/isp_cb_ops.c trunk/qla_isp/linux/isp_ioctl.h trunk/qla_isp/linux/isp_linux.c trunk/qla_isp/linux/isp_linux.h trunk/qla_isp/linux/isp_pci.c trunk/qla_isp/linux/scsi_target.c trunk/qla_isp/linux/scsi_target.h trunk/qla_isp/linux/scsi_target_ctl.c trunk/scst/include/scst.h trunk/scst/include/scst_const.h trunk/scst/include/scst_debug.h trunk/scst/include/scst_user.h trunk/scst/src/dev_handlers/scst_cdrom.c trunk/scst/src/dev_handlers/scst_changer.c trunk/scst/src/dev_handlers/scst_dev_handler.h trunk/scst/src/dev_handlers/scst_disk.c trunk/scst/src/dev_handlers/scst_modisk.c trunk/scst/src/dev_handlers/scst_processor.c trunk/scst/src/dev_handlers/scst_raid.c trunk/scst/src/dev_handlers/scst_tape.c trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_cdbprobe.h trunk/scst/src/scst_debug.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_mem.h trunk/scst/src/scst_module.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c trunk/srpt/src/ib_srpt.c trunk/usr/fileio/common.c trunk/usr/fileio/common.h trunk/usr/fileio/debug.c trunk/usr/fileio/debug.h trunk/usr/fileio/fileio.c Modified: trunk/iscsi-scst/include/iscsi_scst.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/include/iscsi_scst.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/include/iscsi_scst_ver.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/config.c =================================================================== --- trunk/iscsi-scst/kernel/config.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/config.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2004 - 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -505,7 +505,7 @@ if (trace_flag & TRACE_D_IOV) { int i; printk("%p, %zd\n", msg->msg_iov, msg->msg_iovlen); - for (i = 0; i < min_t(size_t, msg->msg_iovlen, + for (i = 0; i < min_t(size_t, msg->msg_iovlen, ISCSI_CONN_IOV_MAX); i++) { printk("%d: %p,%zd\n", i, msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len); Modified: trunk/iscsi-scst/kernel/conn.c =================================================================== --- trunk/iscsi-scst/kernel/conn.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/conn.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/digest.c =================================================================== --- trunk/iscsi-scst/kernel/digest.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/digest.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2004 - 2006 Xiranet Communications GmbH <arn...@xi...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -117,7 +117,7 @@ offset += sg[0].offset; idx = offset >> PAGE_SHIFT; offset &= ~PAGE_MASK; - + count = get_pgcnt(size, offset); TRACE_DBG("req %p, idx %d, count %d, sg_cnt %d, size %d, " @@ -209,7 +209,7 @@ offset = 0; } - /* + /* * cmnd is used here regardless of its sg comes from parent or was * allocated for this cmnd only, see cmnd_send_pdu() */ Modified: trunk/iscsi-scst/kernel/digest.h =================================================================== --- trunk/iscsi-scst/kernel/digest.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/digest.h 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2004 Xiranet Communications GmbH <arn...@xi...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/event.c =================================================================== --- trunk/iscsi-scst/kernel/event.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/event.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -148,7 +148,7 @@ #ifdef NET_PAGE_CALLBACKS_DEFINED atomic_set(&cmnd->net_ref_cnt, 0); -#endif +#endif spin_lock_init(&cmnd->rsp_cmd_lock); INIT_LIST_HEAD(&cmnd->rsp_cmd_list); INIT_LIST_HEAD(&cmnd->rx_ddigest_cmd_list); @@ -382,7 +382,7 @@ /* * Corresponding conn may also gets destroyed atfer this function, except only - * if it's called from the read thread! + * if it's called from the read thread! */ void req_cmnd_release(struct iscsi_cmnd *req) { @@ -437,7 +437,7 @@ /* * Corresponding conn may also gets destroyed atfer this function, except only - * if it's called from the read thread! + * if it's called from the read thread! */ void rsp_cmnd_release(struct iscsi_cmnd *cmnd) { @@ -458,7 +458,7 @@ /** * create a new command used as response. * - * iscsi_cmnd_create_rsp_cmnd - + * iscsi_cmnd_create_rsp_cmnd - * @cmnd: ptr to request command * * @return ptr to response command or NULL @@ -494,7 +494,7 @@ static void iscsi_cmnds_init_write(struct list_head *send, int flags) { - struct iscsi_cmnd *rsp = list_entry(send->next, struct iscsi_cmnd, + struct iscsi_cmnd *rsp = list_entry(send->next, struct iscsi_cmnd, write_list_entry); struct iscsi_conn *conn = rsp->conn; struct list_head *pos, *next; @@ -572,7 +572,7 @@ u8 *p = (u8*)page_address(sg_page(&cmnd->sg[idx])) + (last_off & ~PAGE_MASK); int i = 4 - (size & 3); - while(i--) + while(i--) *p++ = 0; } } @@ -679,7 +679,7 @@ if (rsp->bufflen - rsp->pdu.datasize) { int i = rsp->pdu.datasize; u8 *p = (u8 *)sense + i; - + while (i < rsp->bufflen) { *p ++ = 0; i++; @@ -747,7 +747,7 @@ static inline int iscsi_get_allowed_cmds(struct iscsi_session *sess) { - int res = max(-1, (int)sess->max_queued_cmnds - + int res = max(-1, (int)sess->max_queued_cmnds - atomic_read(&sess->active_cmds)-1); TRACE_DBG("allowed cmds %d (sess %p, active_cmds %d)", res, sess, atomic_read(&sess->active_cmds)); @@ -1165,7 +1165,7 @@ SCST_LOAD_SENSE(iscsi_sense_crc_error)); res = SCST_PREPROCESS_STATUS_ERROR_SENSE_SET; /* - * The rest of rx_ddigest_cmd_list will be freed + * The rest of rx_ddigest_cmd_list will be freed * in req_cmnd_release() */ goto out; @@ -1562,7 +1562,7 @@ /* * Here, if cmnd is data_waiting, we should iscsi_fail_waiting_cmnd() * it. But, since this function can be called from any thread, not only - * from the read one, we at the moment can't do that, because of + * from the read one, we at the moment can't do that, because of * absence of appropriate locking protection. But this isn't a stuff * for 0.9.6. So, currently a misbehaving initiator, not sending * data in R2T state for a sharing between targets device, for which @@ -2479,7 +2479,7 @@ return; } -/* +/* * No locks. * * IMPORTANT! Connection conn must be protected by additional conn_get() @@ -2611,7 +2611,7 @@ } if (req->bufflen != 0) { - /* + /* * Check above makes sure that is_send_status is set, * so status is valid here, but in future that could change. * ToDo @@ -2967,7 +2967,7 @@ out_callb: #ifdef NET_PAGE_CALLBACKS_DEFINED net_set_get_put_page_callbacks(NULL, NULL); -#endif +#endif goto out; } Modified: trunk/iscsi-scst/kernel/iscsi.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/iscsi.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -124,7 +124,7 @@ #define ISCSI_CONN_IOV_MAX (PAGE_SIZE/sizeof(struct iovec)) #define ISCSI_CONN_RD_STATE_IDLE 0 -#define ISCSI_CONN_RD_STATE_IN_LIST 1 +#define ISCSI_CONN_RD_STATE_IN_LIST 1 #define ISCSI_CONN_RD_STATE_PROCESSING 2 #define ISCSI_CONN_WR_STATE_IDLE 0 @@ -137,7 +137,7 @@ /* Both protected by session->sn_lock */ u32 stat_sn; - u32 exp_stat_sn; + u32 exp_stat_sn; spinlock_t cmd_list_lock; /* BH lock */ @@ -235,7 +235,7 @@ #define ISCSI_REJECT_CMD 2 #define ISCSI_REJECT_DATA 3 -/* +/* * Most of the fields don't need any protection, since accessed from only a * single thread, except where noted. */ @@ -287,7 +287,7 @@ unsigned long write_timeout; /* - * Unprotected, since could be accessed from only a single + * Unprotected, since could be accessed from only a single * thread at time */ struct list_head rx_ddigest_cmd_list; @@ -538,7 +538,7 @@ atomic_read(&conn->conn_ref_cnt)-1); sBUG_ON(atomic_read(&conn->conn_ref_cnt) == 0); - /* + /* * It always ordered to protect from undesired side effects like * accessing just destroyed object because of this *_dec() reordering. */ Modified: trunk/iscsi-scst/kernel/iscsi_dbg.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/iscsi_hdr.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi_hdr.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/iscsi_hdr.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/nthread.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2004 - 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -398,7 +398,7 @@ } sBUG_ON(cmnd->parent_req != NULL); - + spin_lock_bh(&cmnd->rsp_cmd_lock); list_for_each_entry(rsp, &cmnd->rsp_cmd_list, rsp_cmd_list_entry) { TRACE_CONN_CLOSE_DBG(" rsp %p, ref_cnt %d, net_ref_cnt %d, " @@ -1012,7 +1012,7 @@ break; goto out_iov; } - sBUG_ON(iop > conn->write_iov + + sBUG_ON(iop > conn->write_iov + sizeof(conn->write_iov)/sizeof(conn->write_iov[0])); iop->iov_base += rest; iop->iov_len -= rest; @@ -1082,7 +1082,7 @@ retry2: res = sendpage(sock, sg_page(&sg[idx]), offset, size, flags); TRACE_WRITE("Final %s %#Lx:%u: %d(%lu,%u,%u, cmd %p, page %p)", - (sendpage != sock_no_sendpage) ? "sendpage" : + (sendpage != sock_no_sendpage) ? "sendpage" : "sock_no_sendpage", conn->session->sid, conn->cid, res, sg_page(&sg[idx])->index, offset, size, @@ -1110,7 +1110,7 @@ res = sendpage(sock, sg_page(&sg[idx]), offset, sendsize, flags | MSG_MORE); TRACE_WRITE("%s %#Lx:%u: %d(%lu,%u,%u, cmd %p, page %p)", - (sendpage != sock_no_sendpage) ? "sendpage" : + (sendpage != sock_no_sendpage) ? "sendpage" : "sock_no_sendpage", (unsigned long long)conn->session->sid, conn->cid, res, sg_page(&sg[idx])->index, offset, sendsize, @@ -1257,7 +1257,7 @@ return res; } -/* +/* * No locks, conn is wr processing. * * IMPORTANT! Connection conn must be protected by additional conn_get() @@ -1288,7 +1288,7 @@ init_tx_hdigest(cmnd); conn->write_state = TX_BHS_DATA; case TX_BHS_DATA: - res = iscsi_do_send(conn, ddigest && cmnd->pdu.datasize ? + res = iscsi_do_send(conn, ddigest && cmnd->pdu.datasize ? TX_INIT_DDIGEST : TX_END); if (res <= 0 || conn->write_state != TX_INIT_DDIGEST) break; Modified: trunk/iscsi-scst/kernel/param.c =================================================================== --- trunk/iscsi-scst/kernel/param.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/param.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/session.c =================================================================== --- trunk/iscsi-scst/kernel/session.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/session.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/kernel/target.c =================================================================== --- trunk/iscsi-scst/kernel/target.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/kernel/target.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/chap.c =================================================================== --- trunk/iscsi-scst/usr/chap.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/chap.c 2008-05-19 10:21:41 UTC (rev 377) @@ -15,7 +15,7 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/config.h =================================================================== --- trunk/iscsi-scst/usr/config.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/config.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/conn.c =================================================================== --- trunk/iscsi-scst/usr/conn.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/conn.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/ctldev.c =================================================================== --- trunk/iscsi-scst/usr/ctldev.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/ctldev.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2004 - 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -208,7 +208,7 @@ goto out; } else log_error("Unknown %s string: %s\n", PROC_SESSION, p); - + done = 1; } @@ -414,7 +414,7 @@ do { res = ioctl(ctrl_fd, DEL_SESSION, &info); } while (res < 0 && errno == EINTR); - + return res; } Modified: trunk/iscsi-scst/usr/event.c =================================================================== --- trunk/iscsi-scst/usr/event.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/event.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/iscsi_adm.c =================================================================== --- trunk/iscsi-scst/usr/iscsi_adm.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsi_adm.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2004 - 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -159,7 +159,7 @@ do { ret = readv(fd, iov, 2); } while (ret < 0 && errno == EINTR); - + if (ret != sizeof(rsp) + sizeof(*req)) { err = (ret < 0) ? -errno : -EIO; fprintf(stderr, "%s %d %d %d\n", __FUNCTION__, __LINE__, ret, Modified: trunk/iscsi-scst/usr/iscsi_adm.h =================================================================== --- trunk/iscsi-scst/usr/iscsi_adm.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsi_adm.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/iscsi_hdr.h =================================================================== --- trunk/iscsi-scst/usr/iscsi_hdr.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsi_hdr.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/iscsi_scstd.c =================================================================== --- trunk/iscsi-scst/usr/iscsi_scstd.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsi_scstd.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -123,14 +123,14 @@ if (setsockopt(sock, SOL_TCP, TCP_KEEPCNT, &opt, sizeof(opt))) log_warning("unable to set TCP_KEEPCNT on server socket (%s)!", strerror(errno)); - + if (setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout))) log_warning("unable to set TCP_KEEPIDLE on server socket (%s)!", strerror(errno)); - + opt = 3; if (setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &opt, sizeof(opt))) log_warning("unable to set KEEPINTVL on server socket (%s)!", strerror(errno)); - + opt = 1; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt))) log_warning("unable to set SO_KEEPALIVE on server socket (%s)!", strerror(errno)); @@ -166,7 +166,7 @@ } sock_set_keepalive(sock, 50); - + opt = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) log_warning("Unable to set SO_REUSEADDR on server socket (%s)!", @@ -422,7 +422,7 @@ void wait_4_iscsi_event(int timeout) { int res; - + do { res = poll(&poll_array[POLL_NL], 1, timeout); } while (res < 0 && errno == EINTR); @@ -497,12 +497,12 @@ for (i = 0; i < INCOMING_MAX; i++) { struct connection *conn = incoming[i]; struct pollfd *pollfd = &poll_array[POLL_INCOMING + i]; - + if (!conn || !pollfd->revents) continue; pollfd->revents = 0; - + event_conn(conn, pollfd); if (conn->state == STATE_CLOSE) { Modified: trunk/iscsi-scst/usr/iscsid.c =================================================================== --- trunk/iscsi-scst/usr/iscsid.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsid.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -394,7 +394,7 @@ rsp->status_detail = ISCSI_STATUS_SVC_UNAVAILABLE; conn->state = STATE_EXIT; } - conn->session_param[key_max_recv_data_length].exec_val = + conn->session_param[key_max_recv_data_length].exec_val = conn->session_param[key_max_recv_data_length].local_val; } conn->exp_cmd_sn = be32_to_cpu(req->cmd_sn); Modified: trunk/iscsi-scst/usr/iscsid.h =================================================================== --- trunk/iscsi-scst/usr/iscsid.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/iscsid.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/log.c =================================================================== --- trunk/iscsi-scst/usr/log.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/log.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/message.c =================================================================== --- trunk/iscsi-scst/usr/message.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/message.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2004 - 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/misc.h =================================================================== --- trunk/iscsi-scst/usr/misc.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/misc.h 2008-05-19 10:21:41 UTC (rev 377) @@ -1,12 +1,12 @@ /* * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/param.c =================================================================== --- trunk/iscsi-scst/usr/param.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/param.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/param.h =================================================================== --- trunk/iscsi-scst/usr/param.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/param.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,11 +2,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/plain.c =================================================================== --- trunk/iscsi-scst/usr/plain.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/plain.c 2008-05-19 10:21:41 UTC (rev 377) @@ -4,11 +4,11 @@ * Copyright (C) 2005 FUJITA Tomonori <to...@ac...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/session.c =================================================================== --- trunk/iscsi-scst/usr/session.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/session.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/target.c =================================================================== --- trunk/iscsi-scst/usr/target.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/target.c 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/iscsi-scst/usr/types.h =================================================================== --- trunk/iscsi-scst/usr/types.h 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/iscsi-scst/usr/types.h 2008-05-19 10:21:41 UTC (rev 377) @@ -2,12 +2,12 @@ * Copyright (C) 2002-2003 Ardis Technolgies <ro...@ar...> * Copyright (C) 2007 Vladislav Bolkhovitin * Copyright (C) 2007 CMS Distribution Limited - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, version 2 * of the License. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2008-05-16 17:47:31 UTC (rev 376) +++ trunk/mpt/mpt_scst.c 2008-05-19 10:21:41 UTC (rev 377) @@ -7,7 +7,7 @@ * and Leonid Stoljar * * MPT SCSI target mode driver for SCST. - * + * * Originally By: Stephen Shirron * Port to SCST By: Hu Gang <hu...@so...> * @@ -15,7 +15,7 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -90,7 +90,7 @@ static void stmapp_tgt_command(MPT_STM_PRIV *priv, u32 reply_word); static void stm_cmd_buf_post(MPT_STM_PRIV *priv, int index); -static void stm_tgt_reply_high_pri(MPT_ADAPTER *ioc, +static void stm_tgt_reply_high_pri(MPT_ADAPTER *ioc, TargetCmdBufferPostErrorReply_t *rep); static void stm_target_reply_error(MPT_ADAPTER *ioc, TargetErrorReply_t *rep); static void stmapp_target_error(MPT_STM_PRIV *priv, u32 reply_word, int index, @@ -122,7 +122,7 @@ static void stm_wait(MPT_STM_PRIV *priv, int milliseconds, int sleep); static int stm_wait_for(MPT_STM_PRIV *priv, volatile int *flag, int seconds, int sleep); -static void stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, +static void stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, u32 offset, LinkServiceBufferPostReply_t *rep, int index); static void stm_set_scsi_port_page1(MPT_STM_PRIV *priv, int sleep); @@ -144,7 +144,7 @@ MPT_STM_PRIV *priv = tgt->priv; TRACE_ENTRY(); - TRACE_DBG("priv %p, tgt %p", priv, tgt); + TRACE_DBG("priv %p, tgt %p", priv, tgt); sBUG_ON(tgt == NULL); sBUG_ON(ioc == NULL); @@ -210,7 +210,7 @@ } static int -mpt_proc_target_write(struct file *file, const char __user *buf, +mpt_proc_target_write(struct file *file, const char __user *buf, size_t length, loff_t *off) { @@ -249,10 +249,10 @@ int id = simple_strtoul(s, NULL, 0); if (id < MPT_MAX_SCSI_DEVICES) { if (IsScsi(tgt->priv)) { - TRACE_DBG("Changing target id to %d\n", + TRACE_DBG("Changing target id to %d\n", id); tgt->priv->port_id = id; - stm_set_scsi_port_page1(tgt->priv, + stm_set_scsi_port_page1(tgt->priv, NO_SLEEP); } } @@ -273,7 +273,7 @@ static int mpt_target_release(struct scst_tgt *scst_tgt); static int stmapp_pending_sense(struct mpt_cmd *mpt_cmd); static int mpt_xmit_response(struct scst_cmd *scst_cmd); -static void mpt_inquiry_no_tagged_commands(MPT_STM_PRIV *priv, +static void mpt_inquiry_no_tagged_commands(MPT_STM_PRIV *priv, struct scst_cmd *scst_cmd); static int mpt_rdy_to_xfer(struct scst_cmd *scst_cmd); static void mpt_on_free_cmd(struct scst_cmd *scst_cmd); @@ -301,13 +301,13 @@ .task_mgmt_fn_done = mpt_task_mgmt_fn_done, }; -static inline void +static inline void mpt_msg_frame_free(MPT_STM_PRIV *priv, int index) { MPT_ADAPTER *ioc = priv->ioc; if (priv->current_mf[index] != NULL) { TRACE_DBG("%s: free mf index %d, %p", ioc->name, - MF_TO_INDEX(priv->current_mf[index]), + MF_TO_INDEX(priv->current_mf[index]), priv->current_mf[index]); mpt_free_msg_frame(_HANDLE_IOC_ID, priv->current_mf[index]); priv->current_mf[index] = NULL; @@ -321,7 +321,7 @@ MPT_FRAME_HDR *mf; if (index != -1) { - TRACE_DBG("%s: current_mf %p, index %d", + TRACE_DBG("%s: current_mf %p, index %d", ioc->name, priv->current_mf[index], index); WARN_ON(priv->current_mf[index] != NULL); } @@ -331,12 +331,12 @@ if (mf == NULL) { sBUG_ON(1); } - + if (index != -1) { priv->current_mf[index] = mf; } - TRACE_DBG("%s: alloc mf index %d, %p, %d", ioc->name, + TRACE_DBG("%s: alloc mf index %d, %p, %d", ioc->name, MF_TO_INDEX(mf), mf, index); return mf; @@ -353,7 +353,7 @@ struct proc_dir_entry *p; struct proc_dir_entry *root; char name[4]; - + TRACE_ENTRY(); ret = mpt_stm_adapter_install(ioc); if (ret != 0) { @@ -379,12 +379,12 @@ tgt->priv->scsi_id_config = 0; atomic_set(&tgt->sess_count, 0); init_waitqueue_head(&tgt->waitQ); - + tgt->scst_tgt = scst_register(&tgt_template, NULL); if (tgt->scst_tgt == NULL) { PRINT_ERROR(MYNAM ": scst_register() " "failed for host %p", pdev); - + ret = -ENODEV; goto out; } @@ -406,11 +406,11 @@ scst_tgt_set_tgt_priv(tgt->scst_tgt, tgt); mpt_stm_priv[ioc->id]->tgt = tgt; _mpt_ada_nums ++; - + out: - + TRACE_EXIT_RES(ret); - + return ret; } @@ -438,7 +438,7 @@ * the system. Each found adapter should be registered by calling * scst_register(). The function should return a value >= 0 to signify * the number of detected target adapters. A negative value should be - * returned whenever there is an error. + * returned whenever there is an error. */ static int mpt_target_detect(struct scst_tgt_template *templ) { @@ -456,17 +456,17 @@ ret = -ENODEV; goto out; } - + ret = _mpt_ada_nums; - + out: TRACE_EXIT_RES(ret); - + return ret; } static struct scst_cmd * -_stm_target_command(MPT_STM_PRIV *priv, int reply_word, +_stm_target_command(MPT_STM_PRIV *priv, int reply_word, struct mpt_cmd *mpt_cmd) { u8 *cdb; @@ -478,9 +478,9 @@ #ifdef DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif - /* - * Get the CBD, LUN, tag, Task Mgmt flags, and data length from the - * receive packet + /* + * Get the CBD, LUN, tag, Task Mgmt flags, and data length from the + * receive packet */ TRACE_ENTRY(); @@ -546,7 +546,7 @@ TRACE_DBG("%s: cmd %p, re_word %x, alias %x, lun %x, tag %x," "%s, init_idx %d, %p, %d", - ioc->name, cmd, reply_word, alias, lun, tag, alias_lun, + ioc->name, cmd, reply_word, alias, lun, tag, alias_lun, init_index, priv->scst_cmd[index], dl); mpt_cmd->CMD = cmd; @@ -581,7 +581,7 @@ stmapp_set_status(cmd->priv, cmd->CMD, STS_BUSY); } -static void +static void mpt_alloc_session_done(struct scst_session *scst_sess, void *data, int result) { struct mpt_sess *sess = (struct mpt_sess *) data; @@ -592,7 +592,7 @@ TRACE_ENTRY(); if (result == 0) { scst_sess_set_tgt_priv(scst_sess, sess); - + while (!list_empty(&sess->delayed_cmds)) { cmd = list_entry(sess->delayed_cmds.next, typeof(*cmd), delayed_cmds_entry); @@ -600,7 +600,7 @@ if (rc == 0) rc = mpt_send_cmd_to_scst(cmd, SCST_CONTEXT_THREAD); if (rc != 0) { - PRINT_INFO(MYNAM ": Unable to get the command, sending BUSY state %p", + PRINT_INFO(MYNAM ": Unable to get the command, sending BUSY state %p", cmd); mpt_send_busy(cmd); kfree(cmd); @@ -619,27 +619,27 @@ kfree(cmd); } tgt->sess[sess->init_index] = NULL; - + TRACE_MEM("kfree for sess %p", sess); kfree(sess); - + if (atomic_dec_and_test(&tgt->sess_count)) wake_up_all(&tgt->waitQ); } - + __clear_bit(MPT_SESS_INITING, &sess->sess_flags); TRACE_EXIT(); return; } -static int +static int mpt_send_cmd_to_scst(struct mpt_cmd *cmd, int context) { int res = 0; - + TRACE_ENTRY(); - + cmd->scst_cmd = _stm_target_command(cmd->priv, cmd->reply_word, cmd); if (cmd->scst_cmd == NULL) { res = -EFAULT; @@ -650,9 +650,9 @@ #endif scst_cmd_init_done(cmd->scst_cmd, context); - out: + out: TRACE_EXIT_RES(res); - + return res; } @@ -685,7 +685,7 @@ } static void -stm_data_done(MPT_ADAPTER *ioc, u32 reply_word, +stm_data_done(MPT_ADAPTER *ioc, u32 reply_word, struct scst_cmd *scst_cmd, struct mpt_cmd *cmd, int index) { MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; @@ -704,7 +704,7 @@ TRACE_EXIT(); } -void +void stm_tgt_reply(MPT_ADAPTER *ioc, u32 reply_word) { MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; @@ -713,7 +713,7 @@ struct scst_cmd *scst_cmd; struct mpt_cmd *cmd; volatile int *io_state; - + TRACE_ENTRY(); index = GET_IO_INDEX(reply_word); @@ -724,23 +724,23 @@ TRACE_DBG("index %d, state %x, scst cmd %p, current_mf %p", index, *io_state, scst_cmd, priv->current_mf[index]); /* - * if scst_cmd is NULL it show the command buffer not using by + * if scst_cmd is NULL it show the command buffer not using by * SCST, let parse the CDB */ if (scst_cmd == NULL) { WARN_ON((*io_state & ~IO_STATE_HIGH_PRIORITY) != IO_STATE_POSTED); *io_state &= ~IO_STATE_POSTED; - + mpt_msg_frame_free(priv, index); stmapp_tgt_command(priv, reply_word); goto out; } - + cmd = (struct mpt_cmd *)scst_cmd_get_tgt_priv(scst_cmd); - TRACE_DBG("scst cmd %p, index %d, cmd %p, cmd state %s", + TRACE_DBG("scst cmd %p, index %d, cmd %p, cmd state %s", scst_cmd, index, cmd, mpt_state_string[cmd->state]); - + if (cmd->state == MPT_STATE_NEED_DATA) { int context = SCST_CONTEXT_TASKLET; int rx_status = SCST_RX_STATUS_SUCCESS; @@ -801,18 +801,18 @@ switch (atomic_read(&priv->pending_sense[init_index])) { /* attempt to send status and sense succeeded */ case MPT_STATUS_SENSE_ATTEMPT: - atomic_set(&priv->pending_sense[init_index], + atomic_set(&priv->pending_sense[init_index], MPT_STATUS_SENSE_IDLE); /* ToDo: check and set scst_set_delivery_status(), if necessary */ scst_tgt_cmd_done(scst_cmd); break; - /* we tried to send status and sense - * simltaneously and failed. Prepare to handle - * the next command without SCST if it is + /* we tried to send status and sense + * simltaneously and failed. Prepare to handle + * the next command without SCST if it is * REQUEST_SENSE */ case MPT_STATUS_SENSE_NOT_SENT: - atomic_set(&priv->pending_sense[init_index], + atomic_set(&priv->pending_sense[init_index], MPT_STATUS_SENSE_HANDLE_RQ); /* ToDo: check and set scst_set_delivery_status(), if necessary */ scst_tgt_cmd_done(scst_cmd); @@ -821,17 +821,17 @@ /* we've handled REQUEST_SENSE ourselves and * we're done with the command. Clean up */ case MPT_STATUS_SENSE_HANDLE_RQ: - TRACE_DBG("%s: clearing pending sense", + TRACE_DBG("%s: clearing pending sense", ioc->name); - atomic_set(&priv->pending_sense[init_index], + atomic_set(&priv->pending_sense[init_index], MPT_STATUS_SENSE_IDLE); mpt_on_free_cmd(scst_cmd); /* scst_cmd alloced in stmapp_pending_sense */ - kfree(scst_cmd); + kfree(scst_cmd); break; default: - /* nothing much to do here, we aren't + /* nothing much to do here, we aren't * handling cached sense/status */ /* ToDo: check and set scst_set_delivery_status(), if necessary */ scst_tgt_cmd_done(scst_cmd); @@ -863,7 +863,7 @@ /* * just insert into list - * bug how can i handle it + * bug how can i handle it */ if (*io_state == 0 && cmd->state == MPT_STATE_NEW) { WARN_ON(1); @@ -881,11 +881,11 @@ #endif WARN_ON(1); out: - + TRACE_EXIT(); } -static int +static int mpt_is_task_mgm(MPT_STM_PRIV *priv, u32 reply_word, int *lun) { int task_mgmt = 0, index; @@ -927,22 +927,22 @@ int init_index, res = 0, task_mgmt, lun; TRACE_ENTRY(); - + tgt = priv->tgt; task_mgmt = mpt_is_task_mgm(priv, reply_word, &lun); if (task_mgmt) { mpt_handle_task_mgmt(priv, reply_word, task_mgmt, lun); } - + init_index = GET_INITIATOR_INDEX(reply_word); - + if (test_bit(MPT_TGT_SHUTDOWN, &tgt->tgt_flags)) { TRACE_DBG("New command while the device %p is shutting down", tgt); res = -EFAULT; goto out; } - + cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC); TRACE_MEM("kmalloc(GFP_ATOMIC) for cmd (%d): %p", sizeof(*cmd), cmd); if (cmd == NULL) { @@ -950,7 +950,7 @@ res = -ENOMEM; goto out; } - + memset(cmd, 0, sizeof(*cmd)); cmd->priv = priv; cmd->reply_word = reply_word; @@ -966,29 +966,29 @@ goto out_free_cmd; } /* WWPN */ - + atomic_inc(&tgt->sess_count); smp_mb__after_atomic_inc(); - + memset(sess, 0, sizeof(*sess)); sess->tgt = tgt; sess->init_index = init_index; INIT_LIST_HEAD(&sess->delayed_cmds); - + sess->scst_sess = scst_register_session(tgt->scst_tgt, 1, "", sess, mpt_alloc_session_done); if (sess->scst_sess == NULL) { - PRINT_ERROR(MYNAM ": scst_register_session failed %p", + PRINT_ERROR(MYNAM ": scst_register_session failed %p", tgt); res = -EFAULT; goto out_free_sess; } - + __set_bit(MPT_SESS_INITING, &sess->sess_flags); - + tgt->sess[init_index] = sess; scst_sess_set_tgt_priv(sess->scst_sess, sess); - + cmd->sess = sess; list_add_tail(&cmd->delayed_cmds_entry, &sess->delayed_cmds); goto out; @@ -1009,7 +1009,7 @@ goto out_free_cmd; } } - + out: TRACE_EXIT(); return; @@ -1029,7 +1029,7 @@ /* * mpt_target_release - * + * * this function is * intended to free up the resources allocated to the device. The function * should return 0 to indicate successful release or a negative value if @@ -1058,7 +1058,7 @@ struct mpt_cmd *cmd; }; -static inline void +static inline void mpt_dump_sge(MPT_SGE *sge, struct scatterlist *sg) { if (sge) { @@ -1066,13 +1066,13 @@ struct page *page = NULL; address = bus_to_virt(sge->address); page = virt_to_page(address); - TRACE_DBG("address %p, length %x, count %d, page %p", + TRACE_DBG("address %p, length %x, count %d, page %p", address, sge->length, page_count(page), page); TRACE_BUFFER("sge data", address, min(sge->length, (u32)0x10)); } if (sg) { TRACE_DBG("sg %p, page %p, %p, offset %d, dma address %x, len %d", - sg, sg->page, page_address(sg->page), + sg, sg->page, page_address(sg->page), sg->offset, sg->dma_address, sg->length); TRACE_BUFFER("sg data", page_address(sg->page), (u32)0x10); } @@ -1096,8 +1096,8 @@ prm->sg = (struct scatterlist *)prm->buffer; prm->seg_cnt = pci_map_sg(priv->ioc->pcidev, prm->sg, prm->use_sg, scst_to_tgt_dma_dir(prm->data_direction)); - - pci_dma_sync_sg_for_cpu(priv->ioc->pcidev, prm->sg, prm->use_sg, + + pci_dma_sync_sg_for_cpu(priv->ioc->pcidev, prm->sg, prm->use_sg, scst_to_tgt_dma_dir(prm->data_direction)); for (i = 0; i < prm->use_sg; i++) { sgl->sge[i].length = sg_dma_len(&prm->sg[i]); @@ -1110,11 +1110,11 @@ mpt_dump_sge(&sgl->sge[i], &prm->sg[i]); bufflen -= sgl->sge[i].length; } - pci_dma_sync_sg_for_device(priv->ioc->pcidev, prm->sg, prm->use_sg, + pci_dma_sync_sg_for_device(priv->ioc->pcidev, prm->sg, prm->use_sg, scst_to_tgt_dma_dir(prm->data_direction)); - + sgl->num_sges = prm->seg_cnt; - + TRACE_EXIT(); } @@ -1122,7 +1122,7 @@ mpt_set_sense_info(MPT_STM_PRIV *priv, CMD *cmd, int len, u8 *sense_buf) { u8 *info = NULL; - + TRACE_ENTRY(); if (IsScsi(priv)) { @@ -1180,11 +1180,11 @@ TRACE_ENTRY(); req = (TargetAssistRequest_t *)mpt_msg_frame_alloc(ioc,index); memset(req, 0, sizeof(*req)); - + if (priv->exiting) { flags &= ~TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER; } - + if (priv->io_state[index] & IO_STATE_HIGH_PRIORITY) { flags |= TARGET_ASSIST_FLAGS_HIGH_PRIORITY; if (flags & TARGET_ASSIST_FLAGS_AUTO_STATUS) { @@ -1192,7 +1192,7 @@ priv->io_state[index] |= IO_STATE_AUTO_REPOST; } } - + if (priv->fcp2_capable/* && priv->initiators != NULL*/) { init_index = GET_INITIATOR_INDEX(reply_word); /*init = priv->initiators[init_index]; @@ -1202,7 +1202,7 @@ } TRACE_DBG("flags %x, tag %x, lun %x, offset %x, length %x", flags, tag, lun, offset, length); - + req->StatusCode = 0; req->TargetAssistFlags = (u8)flags; req->Function = MPI_FUNCTION_TARGET_ASSIST; @@ -1229,7 +1229,7 @@ (u8)(MPI_SGE_FLAGS_CHAIN_ELEMENT | MPI_SGE_FLAGS_MPT_STM_ADDRESSING); dma_addr = priv->hw_dma + - ((u8 *)priv->hw->cmd_buf[index].chain_sge - + ((u8 *)priv->hw->cmd_buf[index].chain_sge - (u8 *)priv->hw); stm_set_dma_addr(sge_chain->Address, dma_addr); /* set the "last element" flag in the mf */ @@ -1347,7 +1347,7 @@ } #endif res = 0; - + priv->io_state[index] |= IO_STATE_DATA_SENT; if (flags & TARGET_ASSIST_FLAGS_AUTO_STATUS) priv->io_state[index] |= IO_STATE_STATUS_SENT; @@ -1361,28 +1361,28 @@ } TRACE_EXIT_RES(res); - - return res; + + return res; } -/* +/* * calling mpt_send_target_data * */ -static void +static void mpt_send_target_data(struct mpt_prm *prm, int flags) { MPT_STM_PRIV *priv; u32 reply_word; int index, lun, tag, length, offset; MPT_SGL *sgl; - + TRACE_ENTRY(); priv = prm->tgt->priv; sgl = &priv->sgl; - + mpt_sge_to_sgl(prm, priv, sgl); - + reply_word = prm->cmd->CMD->reply_word; index = GET_IO_INDEX(reply_word); @@ -1392,15 +1392,15 @@ if (prm->data_direction == SCST_DATA_READ) { flags |= TARGET_ASSIST_FLAGS_DATA_DIRECTION; } - + length = prm->bufflen; offset = 0; -#if 0 +#if 0 TRACE_DBG("priv %p, reply_word %x, index %x, flags %x, lun %x, " "tag %x, sgl %p, length %x, offset %x", - priv, reply_word, index, flags, lun, tag, + priv, reply_word, index, flags, lun, tag, sgl,... [truncated message content] |
From: <vl...@us...> - 2008-05-21 11:56:19
|
Revision: 381 http://scst.svn.sourceforge.net/scst/?rev=381&view=rev Author: vlnb Date: 2008-05-21 04:56:09 -0700 (Wed, 21 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: The patch below implements the following changes: - Fixes the remaining warnings reported by checkpatch.pl with regard to the use of whitespace in C code. - Adds double qoutes around some #warning messages, such that checkpatch.pl does no longer try to interprete the text behind the #warning preprocessor directive. - Adds an extra conversion to the generate-kernel-patch script that removes the single space from before goto-labels while generating the kernel patch. This patch has been tested as follows: - Verified that svn diff -x -w only shows changes in the #warning preprocessor directives. - Verified the output of svn diff by reading it. - Verified that checkpatch.pl does no longer complain on the use of whitespace (searched through the checkpatch.pl output for the text ' space'). - Verified that the patch generated by the generate-kernel-patch script still applies cleanly to the 2.6.24 kernel, and that the patched kernel still compiles cleanly. Please let me know if I have to resubmit parts of this patch to other SCST authors. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/include/iscsi_scst.h trunk/iscsi-scst/kernel/conn.c trunk/iscsi-scst/kernel/event.c trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/nthread.c trunk/iscsi-scst/kernel/session.c trunk/iscsi-scst/kernel/target.c trunk/mpt/mpt_scst.c trunk/mpt/mpt_scst.h trunk/qla2x00t/ql2400.c trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/qla2x00t/qla_attr.c trunk/qla2x00t/qla_dbg.h trunk/qla2x00t/qla_def.h trunk/qla2x00t/qla_gbl.h trunk/qla2x00t/qla_init.c trunk/qla2x00t/qla_inline.h trunk/qla2x00t/qla_isr.c trunk/qla2x00t/qla_os.c trunk/qla_isp/common/isp.c trunk/qla_isp/common/isp_target.c trunk/qla_isp/linux/isp_cb_ops.c trunk/qla_isp/linux/isp_linux.c trunk/qla_isp/linux/isp_linux.h trunk/qla_isp/linux/isp_pci.c trunk/qla_isp/linux/isp_scst.c trunk/qla_isp/linux/scsi_target.c trunk/scripts/generate-kernel-patch trunk/scst/include/scst.h trunk/scst/include/scst_debug.h trunk/scst/src/dev_handlers/scst_changer.c trunk/scst/src/dev_handlers/scst_dev_handler.h trunk/scst/src/dev_handlers/scst_processor.c trunk/scst/src/dev_handlers/scst_raid.c trunk/scst/src/dev_handlers/scst_tape.c trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_cdbprobe.h trunk/scst/src/scst_debug.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_mem.h trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c trunk/srpt/src/ib_srpt.c Modified: trunk/iscsi-scst/include/iscsi_scst.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/include/iscsi_scst.h 2008-05-21 11:56:09 UTC (rev 381) @@ -141,7 +141,7 @@ static inline int iscsi_is_key_declarative(int key) { - switch(key) + switch (key) { case key_max_xmit_data_length: return 1; Modified: trunk/iscsi-scst/kernel/conn.c =================================================================== --- trunk/iscsi-scst/kernel/conn.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/conn.c 2008-05-21 11:56:09 UTC (rev 381) @@ -30,7 +30,7 @@ return; } - switch(conn->rd_state) { + switch (conn->rd_state) { case ISCSI_CONN_RD_STATE_PROCESSING: snprintf(p, size, "%s", "read_processing "); printed = 1; @@ -41,7 +41,7 @@ break; } - switch(conn->wr_state) { + switch (conn->wr_state) { case ISCSI_CONN_WR_STATE_PROCESSING: snprintf(p, size, "%s", "write_processing "); printed = 1; @@ -452,7 +452,7 @@ if (unlikely(current != conn->rd_task)) { printk(KERN_EMERG "conn %p rd_task != current %p (pid %d)\n", conn, current, current->pid); - while(in_softirq()) + while (in_softirq()) local_bh_enable(); printk(KERN_EMERG "rd_state %x\n", conn->rd_state); printk(KERN_EMERG "rd_task %p\n", conn->rd_task); @@ -466,7 +466,7 @@ if (unlikely(current != conn->wr_task)) { printk(KERN_EMERG "conn %p wr_task != current %p (pid %d)\n", conn, current, current->pid); - while(in_softirq()) + while (in_softirq()) local_bh_enable(); printk(KERN_EMERG "wr_state %x\n", conn->wr_state); printk(KERN_EMERG "wr_task %p\n", conn->wr_task); Modified: trunk/iscsi-scst/kernel/event.c =================================================================== --- trunk/iscsi-scst/kernel/event.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/event.c 2008-05-21 11:56:09 UTC (rev 381) @@ -39,7 +39,7 @@ return 0; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)) static int event_recv_skb(struct sk_buff *skb) #else static void event_recv_skb(struct sk_buff *skb) @@ -64,14 +64,14 @@ } out: -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)) return 0; #else return; #endif } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)) static void event_recv(struct sock *sk, int length) { struct sk_buff *skb; @@ -118,17 +118,17 @@ int __init event_init(void) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)) nl = netlink_kernel_create(NETLINK_ISCSI_SCST, 1, event_recv, THIS_MODULE); #else - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - nl = netlink_kernel_create(NETLINK_ISCSI_SCST, 1, event_recv, NULL, - THIS_MODULE); - #else +# if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)) + nl = netlink_kernel_create(NETLINK_ISCSI_SCST, 1, event_recv, NULL, + THIS_MODULE); +# else nl = netlink_kernel_create(&init_net, NETLINK_ISCSI_SCST, 1, - event_recv_skb, NULL, THIS_MODULE); - #endif + event_recv_skb, NULL, THIS_MODULE); +# endif #endif if (!nl) { PRINT_ERROR("%s", "netlink_kernel_create() failed"); Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-05-21 11:56:09 UTC (rev 381) @@ -130,7 +130,7 @@ struct iscsi_cmnd *cmnd; /* ToDo: __GFP_NOFAIL?? */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) cmnd = kmem_cache_alloc(iscsi_cmnd_cache, GFP_KERNEL|__GFP_NOFAIL); memset(cmnd, 0, sizeof(*cmnd)); #else @@ -236,7 +236,7 @@ /* Order between above and below code is important! */ if (cmnd->scst_cmd) { - switch(cmnd->scst_state) { + switch (cmnd->scst_state) { case ISCSI_CMD_STATE_PROCESSED: TRACE_DBG("cmd %p PROCESSED", cmnd); scst_tgt_cmd_done(cmnd->scst_cmd); @@ -254,7 +254,7 @@ } default: PRINT_CRIT_ERROR("Unexpected cmnd scst state %d", - cmnd->scst_state); + cmnd->scst_state); sBUG(); break; } @@ -572,7 +572,7 @@ u8 *p = (u8*)page_address(sg_page(&cmnd->sg[idx])) + (last_off & ~PAGE_MASK); int i = 4 - (size & 3); - while(i--) + while (i--) *p++ = 0; } } @@ -593,7 +593,7 @@ offset = 0; sn = 0; - while(1) { + while (1) { rsp = iscsi_cmnd_create_rsp_cmnd(req); TRACE_DBG("rsp %p", rsp); rsp->sg = req->sg; @@ -681,7 +681,7 @@ u8 *p = (u8 *)sense + i; while (i < rsp->bufflen) { - *p ++ = 0; + *p++ = 0; i++; } } @@ -1126,7 +1126,7 @@ if (++req->outstanding_r2t >= session->sess_param.max_outstanding_r2t) break; - } while(req->r2t_length != 0); + } while (req->r2t_length != 0); iscsi_cmnds_init_write(&send, ISCSI_INIT_WRITE_WAKE); @@ -1322,7 +1322,7 @@ dir = SCST_DATA_NONE; scst_cmd_set_expected(scst_cmd, dir, be32_to_cpu(req_hdr->data_length)); - switch(req_hdr->flags & ISCSI_CMD_ATTR_MASK) { + switch (req_hdr->flags & ISCSI_CMD_ATTR_MASK) { case ISCSI_CMD_SIMPLE: scst_cmd->queue_type = SCST_CMD_QUEUE_SIMPLE; break; @@ -1621,8 +1621,8 @@ if (req_hdr->lun != hdr->lun) { PRINT_ERROR("ABORT TASK: LUN mismatch: req LUN " - "%Lx, cmd LUN %Lx, rtt %u", req_hdr->lun, - hdr->lun, req_hdr->rtt); + "%Lx, cmd LUN %Lx, rtt %u", req_hdr->lun, + hdr->lun, req_hdr->rtt); err = ISCSI_RESPONSE_FUNCTION_REJECTED; goto out_put; } @@ -2494,7 +2494,7 @@ TRACE_ENTRY(); spin_lock_bh(&iscsi_wr_lock); - switch(conn->wr_state) { + switch (conn->wr_state) { case ISCSI_CONN_WR_STATE_IN_LIST: list_del(&conn->wr_list_entry); /* go through */ @@ -2514,7 +2514,7 @@ if (local) { int rc = 1; - while(test_write_ready(conn)) { + while (test_write_ready(conn)) { rc = iscsi_send(conn); if ((rc <= 0) || single_only) { break; @@ -2581,7 +2581,7 @@ create_status_rsp(req, status, sense, sense_len); - switch(old_state) { + switch (old_state) { case ISCSI_CMD_STATE_RX_CMD: case ISCSI_CMD_STATE_AFTER_PREPROC: break; @@ -2681,7 +2681,7 @@ /* This should be checked for immediate TM commands as well */ - switch(function) { + switch (function) { default: if (before(sess->exp_cmd_sn, req_hdr->cmd_sn)) res = 1; @@ -2781,7 +2781,7 @@ static inline int iscsi_get_mgmt_response(int status) { - switch(status) { + switch (status) { case SCST_MGMT_STATUS_SUCCESS: return ISCSI_RESPONSE_FUNCTION_COMPLETE; Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/nthread.c 2008-05-21 11:56:09 UTC (rev 381) @@ -95,7 +95,7 @@ if (cmnd_get_check(cmnd)) continue; - for(i = 0; i < cmnd->sg_cnt; i++) { + for (i = 0; i < cmnd->sg_cnt; i++) { struct page *page = sg_page(&cmnd->sg[i]); TRACE_CONN_CLOSE_DBG("page %p, net_priv %p, " "_count %d", page, page->net_priv, @@ -106,7 +106,7 @@ spin_unlock_bh(&conn->cmd_list_lock); restart = 1; } - while(page->net_priv != NULL) + while (page->net_priv != NULL) iscsi_put_page_callback(page); } } @@ -128,7 +128,7 @@ if (cmnd_get_check(rsp)) continue; - for(i = 0; i < rsp->sg_cnt; i++) { + for (i = 0; i < rsp->sg_cnt; i++) { struct page *page = sg_page(&rsp->sg[i]); TRACE_CONN_CLOSE_DBG(" page %p, net_priv %p, " "_count %d", page, page->net_priv, @@ -140,7 +140,7 @@ spin_unlock_bh(&conn->cmd_list_lock); restart = 1; } - while(page->net_priv != NULL) + while (page->net_priv != NULL) iscsi_put_page_callback(page); } } @@ -229,7 +229,7 @@ conn_abort(conn); /* ToDo: not the best way to wait */ - while(atomic_read(&conn->conn_ref_cnt) != 0) { + while (atomic_read(&conn->conn_ref_cnt) != 0) { struct iscsi_cmnd *cmnd; mutex_lock(&target->target_mutex); @@ -252,19 +252,19 @@ if (!list_empty(&session->pending_list)) { struct list_head *pending_list = &session->pending_list; - int req_freed; - - TRACE_CONN_CLOSE_DBG("Disposing pending commands on " - "connection %p (conn_ref_cnt=%d)", conn, - atomic_read(&conn->conn_ref_cnt)); - + int req_freed; + + TRACE_CONN_CLOSE_DBG("Disposing pending commands on " + "connection %p (conn_ref_cnt=%d)", conn, + atomic_read(&conn->conn_ref_cnt)); + /* * Such complicated approach currently isn't necessary, * but it will be necessary for MC/S, if we won't want * to reestablish the whole session on a connection * failure. */ - + spin_lock(&session->sn_lock); do { req_freed = 0; @@ -293,7 +293,7 @@ break; } } - } while(req_freed); + } while (req_freed); spin_unlock(&session->sn_lock); if (time_after(jiffies, start_waiting + CONN_PENDING_TIMEOUT)) { @@ -329,7 +329,7 @@ break; } } - } while(req_freed); + } while (req_freed); spin_unlock(&session->sn_lock); } } @@ -389,7 +389,7 @@ atomic_read(&cmnd->net_ref_cnt), cmnd->sg); if (cmnd->sg != NULL) { int i; - for(i = 0; i < cmnd->sg_cnt; i++) { + for (i = 0; i < cmnd->sg_cnt; i++) { struct page *page = sg_page(&cmnd->sg[i]); TRACE_CONN_CLOSE_DBG("page %p, net_priv %p, _count %d", page, page->net_priv, @@ -406,7 +406,7 @@ atomic_read(&rsp->net_ref_cnt), rsp->sg); if ((rsp->sg != cmnd->sg) && (rsp->sg != NULL)) { int i; - for(i = 0; i < rsp->sg_cnt; i++) { + for (i = 0; i < rsp->sg_cnt; i++) { TRACE_CONN_CLOSE_DBG(" page %p, net_priv %p, " "_count %d", sg_page(&rsp->sg[i]), sg_page(&rsp->sg[i])->net_priv, @@ -429,7 +429,7 @@ conn->sock->sk->sk_write_space = conn->old_write_space; write_unlock_bh(&conn->sock->sk->sk_callback_lock); - while(1) { + while (1) { bool t; spin_lock_bh(&iscsi_wr_lock); @@ -577,8 +577,8 @@ if (res >= first_len) { int done = 1 + ((res - first_len) >> PAGE_SHIFT); conn->read_msg.msg_iov += done; - conn->read_msg.msg_iovlen -= done; - } + conn->read_msg.msg_iovlen -= done; + } } else conn->read_state = state; } @@ -756,7 +756,7 @@ *closed = 1; break; } - } while(res > 0); + } while (res > 0); TRACE_EXIT_RES(res); return res; @@ -772,7 +772,7 @@ /* We delete/add to tail connections to maintain fairness between them */ - while(!list_empty(&iscsi_rd_list)) { + while (!list_empty(&iscsi_rd_list)) { int rc, closed = 0; struct iscsi_conn *conn = list_entry(iscsi_rd_list.next, typeof(*conn), rd_list_entry); @@ -824,7 +824,7 @@ current->flags |= PF_NOFREEZE; spin_lock_bh(&iscsi_rd_lock); - while(!kthread_should_stop()) { + while (!kthread_should_stop()) { wait_queue_t wait; init_waitqueue_entry(&wait, current); @@ -889,7 +889,7 @@ if (atomic_dec_and_test(&cmd->net_ref_cnt)) { int i, sg_cnt = cmd->sg_cnt; - for(i = 0; i < sg_cnt; i++) { + for (i = 0; i < sg_cnt; i++) { struct page *page = sg_page(&cmd->sg[i]); TRACE_NET_PAGE("Clearing page %p", page); if (page->net_priv == cmd) @@ -1356,7 +1356,7 @@ /* We delete/add to tail connections to maintain fairness between them */ - while(!list_empty(&iscsi_wr_list)) { + while (!list_empty(&iscsi_wr_list)) { int rc; struct iscsi_conn *conn = list_entry(iscsi_wr_list.next, typeof(*conn), wr_list_entry); @@ -1419,7 +1419,7 @@ current->flags |= PF_NOFREEZE; spin_lock_bh(&iscsi_wr_lock); - while(!kthread_should_stop()) { + while (!kthread_should_stop()) { wait_queue_t wait; init_waitqueue_entry(&wait, current); Modified: trunk/iscsi-scst/kernel/session.c =================================================================== --- trunk/iscsi-scst/kernel/session.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/session.c 2008-05-21 11:56:09 UTC (rev 381) @@ -57,7 +57,7 @@ name = kmalloc(strlen(info->user_name) + strlen(info->initiator_name) + 1, GFP_KERNEL); - if (name == NULL){ + if (name == NULL) { err = -ENOMEM; goto err; } Modified: trunk/iscsi-scst/kernel/target.c =================================================================== --- trunk/iscsi-scst/kernel/target.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/iscsi-scst/kernel/target.c 2008-05-21 11:56:09 UTC (rev 381) @@ -155,7 +155,7 @@ do { if (!++next_target_id) ++next_target_id; - } while(target_lookup_by_id(next_target_id)); + } while (target_lookup_by_id(next_target_id)); tid = next_target_id; } @@ -219,7 +219,7 @@ TRACE_MGMT_DBG("%s", "Deleting all targets"); /* Complete brain damage, ToDo */ - while(1) { + while (1) { mutex_lock(&target_mgmt_mutex); if (list_empty(&target_list)) Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/mpt/mpt_scst.c 2008-05-21 11:56:09 UTC (rev 381) @@ -32,7 +32,7 @@ #include <linux/seq_file.h> #include <scsi/scsi_host.h> -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) #include <linux/pci.h> #endif @@ -155,7 +155,7 @@ ioc->prod_name, tgt->target_enable ? "True" : "False"); -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 15)) if (ioc->bus_type == SCSI) { #else if (ioc->bus_type == SPI) { Modified: trunk/mpt/mpt_scst.h =================================================================== --- trunk/mpt/mpt_scst.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/mpt/mpt_scst.h 2008-05-21 11:56:09 UTC (rev 381) @@ -2,7 +2,7 @@ #define __MPT_SCST_H #if defined(MODULE) && !defined(__GENKSYMS__) -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) #include <linux/config.h> #else #include <linux/autoconf.h> Modified: trunk/qla2x00t/ql2400.c =================================================================== --- trunk/qla2x00t/ql2400.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/ql2400.c 2008-05-21 11:56:09 UTC (rev 381) @@ -78,7 +78,7 @@ .subdevice = PCI_ANY_ID, .driver_data = (unsigned long)&qla_board_tbl[1], }, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) { .vendor = PCI_VENDOR_ID_QLOGIC, .device = PCI_DEVICE_ID_QLOGIC_ISP5422, Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2008-05-21 11:56:09 UTC (rev 381) @@ -1240,7 +1240,7 @@ scst_cmd_set_expected(cmd->scst_cmd, dir, le32_to_cpu(cmd->atio.data_length)); - switch(cmd->atio.task_codes) { + switch (cmd->atio.task_codes) { case ATIO_SIMPLE_QUEUE: cmd->scst_cmd->queue_type = SCST_CMD_QUEUE_SIMPLE; break; @@ -1388,7 +1388,7 @@ goto out; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) cmd = kmem_cache_alloc(q2t_cmd_cachep, GFP_ATOMIC); #else cmd = kmem_cache_zalloc(q2t_cmd_cachep, GFP_ATOMIC); @@ -1398,7 +1398,7 @@ res = -ENOMEM; goto out; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) memset(cmd, 0, sizeof(*cmd)); #endif Modified: trunk/qla2x00t/qla_attr.c =================================================================== --- trunk/qla2x00t/qla_attr.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_attr.c 2008-05-21 11:56:09 UTC (rev 381) @@ -321,7 +321,7 @@ qla2x00_update_portdb); #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -346,7 +346,7 @@ return (count); } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -431,7 +431,7 @@ .write = qla2x00_sysfs_write_fw_dump, }; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -457,7 +457,7 @@ return ha->nvram_size; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -517,7 +517,7 @@ .write = qla2x00_sysfs_write_nvram, }; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_read_optrom(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -542,7 +542,7 @@ return count; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_write_optrom(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -578,7 +578,7 @@ .write = qla2x00_sysfs_write_optrom, }; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -664,7 +664,7 @@ .write = qla2x00_sysfs_write_optrom_ctl, }; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_read_vpd(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -692,7 +692,7 @@ return ha->vpd_size; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) static ssize_t qla2x00_sysfs_write_vpd(struct kobject *kobj, char *buf, loff_t off, size_t count) @@ -1239,7 +1239,7 @@ .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, .show_rport_dev_loss_tmo = 1, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15) .issue_fc_host_lip = qla2x00_issue_lip, .get_fc_host_stats = qla2x00_get_fc_host_stats, #endif Modified: trunk/qla2x00t/qla_dbg.h =================================================================== --- trunk/qla2x00t/qla_dbg.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_dbg.h 2008-05-21 11:56:09 UTC (rev 381) @@ -126,26 +126,26 @@ #endif #if defined(QL_DEBUG_LEVEL_11) -#define DEBUG11(x) do{x;} while(0); +#define DEBUG11(x) do{x;} while (0); #if !defined(DEBUG2_11) -#define DEBUG2_11(x) do{x;} while(0); +#define DEBUG2_11(x) do{x;} while (0); #endif #if !defined(DEBUG2_3_11) -#define DEBUG2_3_11(x) do{x;} while(0); +#define DEBUG2_3_11(x) do{x;} while (0); #endif #if !defined(DEBUG3_11) -#define DEBUG3_11(x) do{x;} while(0); +#define DEBUG3_11(x) do{x;} while (0); #endif #else -#define DEBUG11(x) do{} while(0); +#define DEBUG11(x) do{} while (0); #if !defined(QL_DEBUG_LEVEL_2) - #define DEBUG2_11(x) do{} while(0); + #define DEBUG2_11(x) do{} while (0); #if !defined(QL_DEBUG_LEVEL_3) - #define DEBUG2_3_11(x) do{} while(0); + #define DEBUG2_3_11(x) do{} while (0); #endif #endif #if !defined(QL_DEBUG_LEVEL_3) - #define DEBUG3_11(x) do{} while(0); + #define DEBUG3_11(x) do{} while (0); #endif #endif @@ -158,12 +158,12 @@ #if defined(QL_DEBUG_LEVEL_13) #define DEBUG13(x) do {x;} while (0) #if !defined(DEBUG2_13) -#define DEBUG2_13(x) do {x;} while(0) +#define DEBUG2_13(x) do {x;} while (0) #endif #else #define DEBUG13(x) do {} while (0) #if !defined(QL_DEBUG_LEVEL_2) -#define DEBUG2_13(x) do {} while(0) +#define DEBUG2_13(x) do {} while (0) #endif #endif Modified: trunk/qla2x00t/qla_def.h =================================================================== --- trunk/qla2x00t/qla_def.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_def.h 2008-05-21 11:56:09 UTC (rev 381) @@ -2124,7 +2124,7 @@ char * (*pci_info_str) (struct scsi_qla_host *, char *); char * (*fw_version_str) (struct scsi_qla_host *, char *); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) irqreturn_t (*intr_handler) (int, void *, struct pt_regs *); #else irq_handler_t intr_handler; Modified: trunk/qla2x00t/qla_gbl.h =================================================================== --- trunk/qla2x00t/qla_gbl.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_gbl.h 2008-05-21 11:56:09 UTC (rev 381) @@ -213,7 +213,7 @@ /* * Global Function Prototypes in qla_isr.c source file. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) extern irqreturn_t qla2100_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla2300_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla24xx_intr_handler(int, void *, struct pt_regs *); @@ -320,7 +320,7 @@ extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *); extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid) { cmd->resid = resid; Modified: trunk/qla2x00t/qla_init.c =================================================================== --- trunk/qla2x00t/qla_init.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_init.c 2008-05-21 11:56:09 UTC (rev 381) @@ -1725,13 +1725,13 @@ } static void -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) qla2x00_rport_add(void *data) #else qla2x00_rport_add(struct work_struct *work) #endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) fc_port_t *fcport = data; #else fc_port_t *fcport = container_of(work, struct fc_port, rport_add_work); @@ -1741,13 +1741,13 @@ } static void -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) qla2x00_rport_del(void *data) #else qla2x00_rport_del(struct work_struct *work) #endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) fc_port_t *fcport = data; #else fc_port_t *fcport = container_of(work, struct fc_port, rport_del_work); @@ -1790,7 +1790,7 @@ fcport->flags = FCF_RLC_SUPPORT; fcport->supported_classes = FC_COS_UNSPECIFIED; spin_lock_init(&fcport->rport_lock); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) INIT_WORK(&fcport->rport_add_work, qla2x00_rport_add, fcport); INIT_WORK(&fcport->rport_del_work, qla2x00_rport_del, fcport); #else @@ -2137,7 +2137,7 @@ unsigned long flags; if (fcport->drport) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) qla2x00_rport_del(fcport); #else qla2x00_rport_del(&fcport->rport_del_work); @@ -3056,7 +3056,7 @@ /* Go with deferred removal of rport references. */ list_for_each_entry(fcport, &ha->fcports, list) if (fcport->drport) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) qla2x00_rport_del(fcport); #else qla2x00_rport_del(&fcport->rport_del_work); Modified: trunk/qla2x00t/qla_inline.h =================================================================== --- trunk/qla2x00t/qla_inline.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_inline.h 2008-05-21 11:56:09 UTC (rev 381) @@ -104,7 +104,7 @@ static inline void qla2x00_poll(scsi_qla_host_t *ha) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) ha->isp_ops.intr_handler(0, ha, NULL); #else ha->isp_ops.intr_handler(0, ha); Modified: trunk/qla2x00t/qla_isr.c =================================================================== --- trunk/qla2x00t/qla_isr.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_isr.c 2008-05-21 11:56:09 UTC (rev 381) @@ -32,7 +32,7 @@ * * Returns handled flag. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) irqreturn_t qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) #else @@ -117,7 +117,7 @@ * * Returns handled flag. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) irqreturn_t qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs) #else @@ -1581,7 +1581,7 @@ * * Returns handled flag. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) irqreturn_t qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs) #else Modified: trunk/qla2x00t/qla_os.c =================================================================== --- trunk/qla2x00t/qla_os.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla2x00t/qla_os.c 2008-05-21 11:56:09 UTC (rev 381) @@ -1198,7 +1198,7 @@ ha->device_type |= DT_ISP2432; ha->device_type |= DT_ZIO_SUPPORTED; break; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) case PCI_DEVICE_ID_QLOGIC_ISP5422: ha->device_type |= DT_ISP5422; break; @@ -2181,7 +2181,7 @@ int rval; rval = QLA_SUCCESS; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); #else ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab, @@ -2402,7 +2402,7 @@ ha->isp_ops.beacon_blink(ha); ha->dpc_active = 0; - } /* End of while(1) */ + } /* End of while (1) */ DEBUG(printk("scsi(%ld): DPC handler exiting\n", ha->host_no)); @@ -2719,7 +2719,7 @@ PCI_ANY_ID, PCI_ANY_ID, }, { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432, PCI_ANY_ID, PCI_ANY_ID, }, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422, PCI_ANY_ID, PCI_ANY_ID, }, { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432, @@ -2776,7 +2776,7 @@ /* Allocate cache for SRBs. */ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, SLAB_HWCACHE_ALIGN, NULL -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) , NULL); #else ); Modified: trunk/qla_isp/common/isp.c =================================================================== --- trunk/qla_isp/common/isp.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/common/isp.c 2008-05-21 11:56:09 UTC (rev 381) @@ -381,7 +381,7 @@ sdp = SDPARAM(isp, 1); l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT); l &= ISP1080_MODE_MASK; - switch(l) { + switch (l) { case ISP1080_LVD_MODE: sdp->isp_lvdmode = 1; isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD"); @@ -1648,7 +1648,7 @@ /* * Prefer or force Point-To-Point instead Loop? */ - switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { + switch (isp->isp_confopts & ISP_CFG_PORT_PREF) { case ISP_CFG_NPORT: icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP; break; @@ -1921,7 +1921,7 @@ icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS; icbp->icb_fwoptions2 = fcp->isp_xfwoptions; - switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { + switch (isp->isp_confopts & ISP_CFG_PORT_PREF) { #if 0 case ISP_CFG_NPORT: /* @@ -2901,7 +2901,7 @@ static const char * ispfc_fw_statename(int state) { - switch(state) { + switch (state) { case FW_CONFIG_WAIT: return "Config Wait"; case FW_WAIT_AL_PA: return "Waiting for AL_PA"; case FW_WAIT_LOGIN: return "Wait Login"; Modified: trunk/qla_isp/common/isp_target.c =================================================================== --- trunk/qla_isp/common/isp_target.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/common/isp_target.c 2008-05-21 11:56:09 UTC (rev 381) @@ -200,7 +200,7 @@ ISP_TDQE(isp, "isp_target_notify", (int) *optrp, vptr); - switch(type) { + switch (type) { case RQSTYPE_ATIO: if (IS_24XX(isp)) { int len; @@ -1182,7 +1182,7 @@ * about this so it's ignored. */ - switch(aep->at_status & ~QLTM_SVALID) { + switch (aep->at_status & ~QLTM_SVALID) { case AT_PATH_INVALID: /* * ATIO rejected by the firmware due to disabled lun. @@ -1275,7 +1275,7 @@ * about this so it's ignored. */ - switch(aep->at_status & ~QLTM_SVALID) { + switch (aep->at_status & ~QLTM_SVALID) { case AT_PATH_INVALID: /* * ATIO rejected by the firmware due to disabled lun. @@ -1351,7 +1351,7 @@ xs = NULL; } - switch(ct->ct_status & ~QLTM_SVALID) { + switch (ct->ct_status & ~QLTM_SVALID) { case CT_OK: /* * There are generally 3 possibilities as to why we'd get @@ -1512,7 +1512,7 @@ xs = NULL; } - switch(ct->ct_status & ~QLTM_SVALID) { + switch (ct->ct_status & ~QLTM_SVALID) { case CT_BUS_ERROR: isp_prt(isp, ISP_LOGERR, "PCI DMA Bus Error"); /* FALL Through */ @@ -1674,7 +1674,7 @@ xs = NULL; } - switch(ct->ct_nphdl) { + switch (ct->ct_nphdl) { case CT7_BUS_ERROR: isp_prt(isp, ISP_LOGERR, "PCI DMA Bus Error"); /* FALL Through */ Modified: trunk/qla_isp/linux/isp_cb_ops.c =================================================================== --- trunk/qla_isp/linux/isp_cb_ops.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/isp_cb_ops.c 2008-05-21 11:56:09 UTC (rev 381) @@ -843,7 +843,7 @@ unsigned int i; ext.Instance = 0; - for(i = 0; i < MAX_ISP; i++) { + for (i = 0; i < MAX_ISP; i++) { if (isplist[i] && IS_FC(isplist[i])) { ext.Instance++; } Modified: trunk/qla_isp/linux/isp_linux.c =================================================================== --- trunk/qla_isp/linux/isp_linux.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/isp_linux.c 2008-05-21 11:56:09 UTC (rev 381) @@ -3973,7 +3973,7 @@ ISP_IUNLK_SOFTC(isp); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) #define PTARG , struct pt_regs *pt #else #define PTARG Modified: trunk/qla_isp/linux/isp_linux.h =================================================================== --- trunk/qla_isp/linux/isp_linux.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/isp_linux.h 2008-05-21 11:56:09 UTC (rev 381) @@ -80,7 +80,7 @@ #define KERNEL_VERSION(v,p,s) (((v)<<16)+(p<<8)+s) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,7,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 7, 0) #error "Only Linux 2.5/2.6 kernels are supported with this driver" #endif @@ -122,7 +122,7 @@ #include <scsi/scsi_device.h> #include <linux/cdev.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13) #include <linux/devfs_fs_kernel.h> #define ISP_CLASS struct class_simple #define CREATE_ISP_CLASS class_simple_create @@ -197,7 +197,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) #define sg_page(_sg) ((_sg)->page) #define sg_assign_page(_sg, _pg) ((_sg)->page = (_pg)) #endif @@ -395,8 +395,8 @@ #define ISP_IUNLK_SOFTC ISP_UNLK_SOFTC #define ISP_IGET_LK_SOFTC(isp) spin_lock_irq(&isp->isp_osinfo.slock) #define ISP_DROP_LK_SOFTC(isp) spin_unlock_irq(&isp->isp_osinfo.slock) -#define ISP_LOCK_SCSI_DONE(isp) do { } while(0) -#define ISP_UNLK_SCSI_DONE(isp) do { } while(0) +#define ISP_LOCK_SCSI_DONE(isp) do { } while (0) +#define ISP_UNLK_SCSI_DONE(isp) do { } while (0) #define ISP_LOCKU_SOFTC ISP_ILOCK_SOFTC #define ISP_UNLKU_SOFTC ISP_IUNLK_SOFTC #define ISP_TLOCK_INIT(isp) spin_lock_init(&isp->isp_osinfo.tlock) @@ -628,7 +628,7 @@ */ void isplinux_timer(unsigned long); void isplinux_mbtimer(unsigned long); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) irqreturn_t isplinux_intr(int, void *, struct pt_regs *); #else irqreturn_t isplinux_intr(int, void *); Modified: trunk/qla_isp/linux/isp_pci.c =================================================================== --- trunk/qla_isp/linux/isp_pci.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/isp_pci.c 2008-05-21 11:56:09 UTC (rev 381) @@ -87,7 +87,7 @@ static int isp_pci_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t); static void isp_pci_dmateardown(ispsoftc_t *, XS_T *, uint32_t); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6) #define DMA_64BIT_MASK 0xffffffffffffffffULL #define DMA_32BIT_MASK 0x00000000ffffffffULL #endif @@ -99,7 +99,7 @@ #define SAME_4G(addr, cnt) (FOURG_SEG(addr) == FOURG_SEG(addr + cnt - 1)) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) #define ISP_IRQ_FLAGS SA_INTERRUPT | SA_SHIRQ #else #define ISP_IRQ_FLAGS IRQF_SHARED @@ -365,11 +365,11 @@ msix_enabled : 2, msi_enabled : 1; }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) #define pci_enable_msi(x) -ENXIO #define pci_enable_msix(x) -ENXIO -#define pci_disable_msi(x) do { ; } while(0) -#define pci_disable_msix(x) do { ; } while(0) +#define pci_disable_msi(x) do { ; } while (0) +#define pci_disable_msix(x) do { ; } while (0) #endif /* @@ -506,7 +506,7 @@ } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 7) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) /** * pci_intx - enables/disables PCI INTx for device dev * @pdev: the PCI device to operate on @@ -619,7 +619,7 @@ return (1); } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 7) if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432) { struct msix_entry isp_msix[3]; int reg; @@ -669,7 +669,7 @@ pci_write_config_word(pdev, reg + PCI_EXP_DEVCTL, pectl); } } else -#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) +#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0) if (pci_enable_msi(pdev) == 0) { isp_pci->msi_enabled = 1; } @@ -3479,7 +3479,7 @@ static struct pci_driver isplinux_pci_driver = { .name = ISP_NAME, -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9) .driver = { .owner = THIS_MODULE, }, Modified: trunk/qla_isp/linux/isp_scst.c =================================================================== --- trunk/qla_isp/linux/isp_scst.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/isp_scst.c 2008-05-21 11:56:09 UTC (rev 381) @@ -1245,7 +1245,7 @@ * Many procfs things is taken from scst/src/scst_proc.c */ -#if !defined(CONFIG_PPC) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) +#if !defined(CONFIG_PPC) && (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)) static int strncasecmp(const char *s1, const char *s2, size_t n) { Modified: trunk/qla_isp/linux/scsi_target.c =================================================================== --- trunk/qla_isp/linux/scsi_target.c 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/qla_isp/linux/scsi_target.c 2008-05-21 11:56:09 UTC (rev 381) @@ -79,7 +79,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) #define sg_page(_sg) ((_sg)->page) #define sg_assign_page(_sg, _pg) ((_sg)->page = (_pg)) #endif @@ -482,7 +482,7 @@ { int rv = 0; - switch(cmd) { + switch (cmd) { case SC_ENABLE_LUN: case SC_DISABLE_LUN: { Modified: trunk/scripts/generate-kernel-patch =================================================================== --- trunk/scripts/generate-kernel-patch 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/scripts/generate-kernel-patch 2008-05-21 11:56:09 UTC (rev 381) @@ -60,7 +60,7 @@ @@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@ EOF if [ "${2%.[ch]}" != "$2" ]; then - sed -e 's/^/+/' -e 's/[ ]*$//g' < "$1" + sed -e 's/^ \([^ ]*:\)$/\1/' -e 's/^/+/' < "$1" else sed -e 's/^/+/' < "$1" fi Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/scst/include/scst.h 2008-05-21 11:56:09 UTC (rev 381) @@ -40,7 +40,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) typedef _Bool bool; #define true 1 #define false 0 @@ -48,7 +48,7 @@ /* Version numbers, the same as for the kernel */ #define SCST_VERSION_CODE 0x00090601 -#define SCST_VERSION(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) +#define SCST_VERSION(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) #define SCST_VERSION_STRING "0.9.6-rc1" #define SCST_INTERFACE_VERSION SCST_VERSION_STRING "$Revision$" SCST_CONST_VERSION @@ -1146,7 +1146,7 @@ unsigned long start_time; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) struct scsi_request *scsi_req; /* SCSI request */ #endif @@ -2335,7 +2335,7 @@ return mcmd->fn; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) static inline struct page *sg_page(struct scatterlist *sg) { @@ -2365,7 +2365,7 @@ sg->length = len; } -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) */ +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */ static inline void sg_clear(struct scatterlist *sg) { @@ -2549,7 +2549,7 @@ int scst_single_seq_open(struct inode *inode, struct file *file); struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry * root, - const char *name, struct scst_proc_data *pdata); + const char *name, struct scst_proc_data *pdata); #define SCST_DEF_RW_SEQ_OP(x) \ .seq_op = { \ Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-05-21 00:11:38 UTC (rev 380) +++ trunk/scst/include/scst_debug.h 2008-05-21 11:56:09 UTC (rev 381) @@ -146,40 +146,40 @@ extern void debug_print_buffer(const char *log_level, const void *data, int len); -#define TRACE(trace, format, args...) \ -do { \ - if (___unlikely(trace_flag & (trace))) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ -} while(0) +#define TRACE(trace, format, args...) \ +do { \ + if (___unlikely(trace_flag & (trace))) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ + __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ +} while (0) #define PRINT_BUFFER(message, buff, len) \ do { \ - PRINT(NO_FLAG, "%s:", message); \ - debug_print_buffer(INFO_FLAG, buff, len); \ -} while(0) + PRINT(NO_FLAG, "%s:", message); \ + debug_print_buffer(INFO_FLAG, buff, len); \ +} while (0) -#define PRINT_BUFF_FLAG(flag, message, buff, len) \ -do { \ - if (___unlikely(trace_flag & (flag))) \ - { \ - char *__tflag = INFO_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(INFO_FLAG, buff, len); \ - } \ -} while(0) +#define PRINT_BUFF_FLAG(flag, message, buff, len) \ +do { \ + if (___unlikely(trace_flag & (flag))) \ + { \ + char *__tflag = INFO_FLAG; \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ + __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(INFO_FLAG, buff, len); \ + } \ +} while (0) #else /* DEBUG || TRACING */ @@ -191,19 +191,19 @@ #ifdef DEBUG -#define __TRACE(trace, format, args...) \ -do { \ - if (trace_flag & (trace)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ -} while(0) +#define __TRACE(trace, format, args...) \ +do { \ + if (trace_flag & (trace)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ + __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ +} while (0) #define TRACE_MEM(args...) __TRACE(TRACE_MEMORY, args) #define TRACE_SG(args...) __TRACE(TRACE_SG_OP, args) @@ -212,137 +212,137 @@ #define TRACE_MGMT_DBG(args...) __TRACE(TRACE_MGMT_DEBUG, args) #define TRACE_MGMT_DBG_SPECIAL(args...) __TRACE(TRACE_MGMT_DEBUG|TRACE_SPECIAL, args) -#define TRACE_BUFFER(message, buff, len) \ -do { \ - if (trace_flag & TRACE_BUFF) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(LOG_FLAG, buff, len); \ - } \ -} while(0) +#define TRACE_BUFFER(message, buff, len) \ +do { \ + if (trace_flag & TRACE_BUFF) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ + __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(LOG_FLAG, buff, len); \ + } \ +} while (0) -#define TRACE_BUFF_FLAG(flag, message, buff, len) \ -do { \ - if (trace_flag & (flag)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(LOG_FLAG, buff, len); \ - } \ -} while(0) +#define TRACE_BUFF_FLAG(flag, message, buff, len) \ +do { \ + if (trace_flag & (flag)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ + __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(LOG_FLAG, buff, len); \ + } \ +} while (0) -#define PRINT_LOG_FLAG(log_flag, format, args...) \ -do { \ - char *__tflag = log_flag; \ - if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ -} while(0) +#define PRINT_LOG_FLAG(log_flag, format, args...) \ +do { \ + char *__tflag = log_flag; \ + if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ + __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ +} while (0) -#define PRINT_ERROR(format, args...) \ -do { \ - if (strcmp(ERROR_FLAG, LOG_FLAG)) \ - { \ - PRINT_LOG_FLAG(LOG_FLAG, "***ERROR*** " format, args); \ - } \ - PRINT_LOG_FLAG(ERROR_FLAG, "***ERROR*** " format, args); \ -} while(0) +#define PRINT_ERROR(format, args...) \ +do { \ + if (strcmp(ERROR_FLAG, LOG_FLAG)) \ + { \ + PRINT_LOG_FLAG(LOG_FLAG, "***ERROR*** " format, args); \ + } \ + PRINT_LOG_FLAG(ERROR_FLAG, "***ERROR*** " format, args); \ +} while (0) -#define PRINT_CRIT_ERROR(format, args...) \ -do { \ -/* if (strcmp(CRIT_FLAG, LOG_FLAG)) \ - { \ - PRINT_LOG_FLAG(LOG_FLAG, "***CRITICAL ERROR*** " format, args); \ - }*/ \ - PRINT_LOG_FLAG(CRIT_FLAG, "***CRITICAL ERROR*** " format, args); \ -} while(0) +#define PRINT_CRIT_ERROR(format, args...) \ +do { \ + /* if (strcmp(CRIT_FLAG, LOG_FLAG)) \ + { \ + PRINT_LOG_FLAG(LOG_FLAG, "***CRITICAL ERROR*** " format, args); \ + }*/ \ + PRINT_LOG_FLAG(CRIT_FLAG, "***CRITICAL ERROR*** " format, args); \ +} while (0) -#define PRINT_INFO(format, args...) \ -do { \ - if (strcmp(INFO_FLAG, LOG_FLAG)) \ - { \ - PRINT_LOG_FLAG(LOG_FLAG, format, args); \ - } \ - PRINT_LOG_FLAG(INFO_FLAG, format, args); \ -} while(0) +#define PRINT_INFO(format, args...) \ +do { \ + if (strcmp(INFO_FLAG, LOG_FLAG)) \ + { \ + PRINT_LOG_FLAG(LOG_FLAG, format, args); \ + } \ + PRINT_LOG_FLAG(INFO_FLAG, format, args); \ +} while (0) -#define TRACE_ENTRY() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ - } \ - } \ -} while(0) +#define TRACE_ENTRY() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ + } \ + } \ +} while (0) -#define TRACE_EXIT() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ - } \ - } \ -} while(0) +#define TRACE_EXIT() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ + } \ + } \ +} while (0) -#define TRACE_EXIT_RES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ - } \ - } \ -} while(0) +#define TRACE_EXIT_RES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ + } \ + } \ +} while (0) -#define TRACE_EXIT_HRES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ - } \ - } \ -} while(0) +#define TRACE_EXIT_HRES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ + } \ + } \ +} while (0) #else /* DEBUG */ @@ -361,48 +361,48 @@ #ifdef LOG_PREFIX -#define PRINT_INFO(format, args...) \ -do { \ - PRINT(INFO_FLAG, "%s: " format, LOG_PREFIX, args); \ -} while(0) +#define PRINT_INFO(format, args...) \ +do { \ + PRINT(INFO_FLAG, "%s: " format, LOG_PREFIX, args); \ +} while (0) #define PRINT_ERROR(format, args...) \ do { \ - PRINT(ERROR_FLAG, "%s: ***ERROR*** " \ - format, LOG_PREFIX, args); \ -} while(0) + PRINT(ERROR_FLAG, "%s: ***ERROR*** " \ + format, LOG_PREFIX, args); \ +} while (0) #define PRINT_CRIT_ERROR(format, args...) \ do { \ - PRINT(CRIT_FLAG, "%s: ***CRITICAL ERROR*** " \ - format, LOG_PREFIX, args); \ -} while(0) + PRINT(CRIT_FLAG, "%s: ***CRITICAL ERROR*** " \ + format, LOG_PREFIX, args); \ +} while (0) #else #define PRINT_INFO(format, args...) \ do { \ - PRINT(INFO_FLAG, format, args); \ -} while(0) + PRINT(INFO_FLAG, format, args); \ +} while (0) #define PRINT_ERROR(format, args...) \ do { \ - PRINT(ERROR_FLAG, "***ERROR*** " \ - format, args); \ -} while(0) + PRINT(ERROR_FLAG, "***ERROR*** " \ + format, args); \ +} while (0) -#define PRINT_CRIT_ERROR(format, args...) \ -do { \ - PRINT(CRIT_FLAG, "***CRITICAL ERROR*** " \ - format, args); \ -} while(0) +#define PRINT_CRIT_ERROR(format, args...) \ +do { \ + PRINT(CRIT_FLAG, "***CRITICAL ERROR*** " \ + format, args); \ +} while (0) #endif /* LOG_PREFIX */ #endif /* DEBUG */ #if defined(DEBUG) && defined(CONFIG_DEBUG_SLAB) -#define SCST_SLAB_FLAGS ( SLAB_RED_ZONE | SLAB_POISON ) +#define SCST_SLAB_FLAGS (SLAB_RED_ZONE | SLAB_POISON) #else #define SCST_SLAB_FLAGS 0L #endif Modified: trunk/scst/src/dev_handlers/scst_changer.c =... [truncated message content] |
From: <vl...@us...> - 2008-05-21 15:40:41
|
Revision: 382 http://scst.svn.sourceforge.net/scst/?rev=382&view=rev Author: vlnb Date: 2008-05-21 08:40:33 -0700 (Wed, 21 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: The patch below fixes another category of checkpatch warnings, namely: ERROR: "foo * bar" should be "foo *bar" This patch has been verified by checking that the output of svn diff -x -w is empty. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/scst/include/scst.h trunk/scst/src/scst_proc.c trunk/srpt/src/ib_srpt.c Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-05-21 11:56:09 UTC (rev 381) +++ trunk/scst/include/scst.h 2008-05-21 15:40:33 UTC (rev 382) @@ -2548,7 +2548,7 @@ int scst_single_seq_open(struct inode *inode, struct file *file); -struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry * root, +struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry *root, const char *name, struct scst_proc_data *pdata); #define SCST_DEF_RW_SEQ_OP(x) \ Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2008-05-21 11:56:09 UTC (rev 381) +++ trunk/scst/src/scst_proc.c 2008-05-21 15:40:33 UTC (rev 382) @@ -2123,7 +2123,7 @@ .show = scst_dev_handler_info_show, }; -struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry * root, +struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry *root, const char *name, struct scst_proc_data *pdata) { struct proc_dir_entry *p = NULL; Modified: trunk/srpt/src/ib_srpt.c =================================================================== --- trunk/srpt/src/ib_srpt.c 2008-05-21 11:56:09 UTC (rev 381) +++ trunk/srpt/src/ib_srpt.c 2008-05-21 15:40:33 UTC (rev 382) @@ -145,7 +145,7 @@ } } -static void srpt_set_ioc(u8 * c_list, u32 slot, u8 value) +static void srpt_set_ioc(u8 *c_list, u32 slot, u8 value) { u16 id; u8 tmp; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-23 15:22:14
|
Revision: 393 http://scst.svn.sourceforge.net/scst/?rev=393&view=rev Author: vlnb Date: 2008-05-23 08:22:12 -0700 (Fri, 23 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: The patch below fixes the following checkpatch warning: __func__ should be used instead of gcc specific __FUNCTION__ This patch has been tested as follows: - Checked that make iscsi scst still works. - Checked that after loading the scst module the kernel messages generated because of the shell command "echo all >/proc/scsi_tg/trace_level" still make sense. An example: [ 646.408035] [5845]: scst: scst_proc_log_entry_write:346:Changed trace level for "scsi_tgt": old 0x80005f0e, new 0xffffffff - Checked that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.4 kernel, that the patched kernel still compiles, installs and boots and that the scst, iscsi-scst and ib_srpt modules still load (I performed rm -rf /lib/modules/2.6.25.4* before starting kernel compilation). Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/kernel/digest.c trunk/iscsi-scst/usr/iscsi_adm.c trunk/iscsi-scst/usr/iscsid.c trunk/iscsi-scst/usr/isns.c trunk/iscsi-scst/usr/target.c trunk/scst/include/scst_debug.h trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c Modified: trunk/iscsi-scst/kernel/digest.c =================================================================== --- trunk/iscsi-scst/kernel/digest.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/iscsi-scst/kernel/digest.c 2008-05-23 15:22:12 UTC (rev 393) @@ -195,7 +195,7 @@ u32 offset; TRACE_DBG("%s:%d req %p, own_sg %d, sg %p, sgcnt %d cmnd %p, " - "own_sg %d, sg %p, sgcnt %d", __FUNCTION__, __LINE__, + "own_sg %d, sg %p, sgcnt %d", __func__, __LINE__, cmnd->parent_req, cmnd->parent_req->own_sg, cmnd->parent_req->sg, cmnd->parent_req->sg_cnt, cmnd, cmnd->own_sg, cmnd->sg, cmnd->sg_cnt); Modified: trunk/iscsi-scst/usr/iscsi_adm.c =================================================================== --- trunk/iscsi-scst/usr/iscsi_adm.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/iscsi-scst/usr/iscsi_adm.c 2008-05-23 15:22:12 UTC (rev 393) @@ -137,7 +137,7 @@ if (ret != sizeof(*req)) { err = (ret < 0) ? -errno : -EIO; - fprintf(stderr, "%s %d %d %d\n", __FUNCTION__, __LINE__, ret, + fprintf(stderr, "%s %d %d %d\n", __func__, __LINE__, ret, err); } else err = 0; @@ -162,7 +162,7 @@ if (ret != sizeof(rsp) + sizeof(*req)) { err = (ret < 0) ? -errno : -EIO; - fprintf(stderr, "%s %d %d %d\n", __FUNCTION__, __LINE__, ret, + fprintf(stderr, "%s %d %d %d\n", __func__, __LINE__, ret, err); } else err = rsp.err; Modified: trunk/iscsi-scst/usr/iscsid.c =================================================================== --- trunk/iscsi-scst/usr/iscsid.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/iscsi-scst/usr/iscsid.c 2008-05-23 15:22:12 UTC (rev 393) @@ -642,7 +642,7 @@ if (ss.ss_family == AF_INET6 && suppress_ip6) { if (strstr(p, "::ffff:") != p) { log_error("%s, %s:%d.", __FILE__, - __FUNCTION__, __LINE__); + __func__, __LINE__); suppress_ip6 = 0; } else addr += 7; Modified: trunk/iscsi-scst/usr/isns.c =================================================================== --- trunk/iscsi-scst/usr/isns.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/iscsi-scst/usr/isns.c 2008-05-23 15:22:12 UTC (rev 393) @@ -141,7 +141,7 @@ return -1; } - log_error("%s %d: new connection %d", __FUNCTION__, __LINE__, fd); + log_error("%s %d: new connection %d", __func__, __LINE__, fd); if (!strlen(eid)) { err = isns_get_ip(fd); @@ -210,7 +210,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); return 0; } @@ -269,7 +269,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); return 0; } @@ -323,7 +323,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); return 0; } @@ -361,7 +361,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); return 0; } @@ -423,7 +423,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); if (scn_listen_port) isns_scn_register(); @@ -493,7 +493,7 @@ err = write(isns_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); return 0; } @@ -587,7 +587,7 @@ get_hdr_param(hdr, function, length, flags, transaction, \ sequence) \ log_error("%s %d: unknown function %x %u %x %u %u", \ - __FUNCTION__, __LINE__, \ + __func__, __LINE__, \ function, length, flags, transaction, sequence); \ } @@ -644,28 +644,28 @@ } log_error("%s %d: transaction not found %u", - __FUNCTION__, __LINE__, transaction); + __func__, __LINE__, transaction); return; found: if (status) { log_error("%s %d: error response %u", - __FUNCTION__, __LINE__, status); + __func__, __LINE__, status); goto free_qry_mgmt; } if (!strlen(mgmt->name)) { log_debug(1, "%s %d: skip %u", - __FUNCTION__, __LINE__, transaction); + __func__, __LINE__, transaction); goto free_qry_mgmt; } target = target_lookup_by_name(mgmt->name); if (!target) { log_error("%s %d: invalid tid %s", - __FUNCTION__, __LINE__, mgmt->name); + __func__, __LINE__, mgmt->name); goto free_qry_mgmt; } @@ -684,7 +684,7 @@ break; case ISNS_ATTR_ISCSI_NODE_TYPE: if (ntohl(*(tlv->value)) == ISNS_NODE_INITIATOR && name) { - log_error("%s %d: %s", __FUNCTION__, __LINE__, + log_error("%s %d: %s", __func__, __LINE__, (char *) name); ini = malloc(sizeof(*ini)); if (!ini) @@ -723,7 +723,7 @@ if (err) { if (err == -EAGAIN) return err; - log_debug(1, "%s %d: close connection %d", __FUNCTION__, __LINE__, + log_debug(1, "%s %d: close connection %d", __func__, __LINE__, isns_fd); close(isns_fd); isns_fd = 0; @@ -746,7 +746,7 @@ case ISNS_FUNC_SCN: name = print_scn_pdu(hdr); if (name) { - log_error("%s %d: %s", __FUNCTION__, __LINE__, name); + log_error("%s %d: %s", __func__, __LINE__, name); isns_attr_query(name); } break; @@ -766,7 +766,7 @@ slen = sizeof(from); fd = accept(scn_listen_fd, (struct sockaddr *) &from, &slen); if (fd < 0) { - log_error("%s %d: accept error %s", __FUNCTION__, __LINE__, + log_error("%s %d: accept error %s", __func__, __LINE__, strerror(errno)); return -errno; } @@ -774,7 +774,7 @@ err = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)); if (err) - log_error("%s %d: %s\n", __FUNCTION__, __LINE__, + log_error("%s %d: %s\n", __func__, __LINE__, strerror(errno)); /* not critical, so ignore. */ @@ -804,7 +804,7 @@ err = write(scn_fd, buf, length + sizeof(struct isns_hdr)); if (err < 0) - log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s", __func__, __LINE__, strerror(errno)); } int isns_scn_handle(int is_accept) @@ -815,7 +815,7 @@ uint16_t function, length, flags, transaction, sequence; char *name = NULL; - log_error("%s %d: %d", __FUNCTION__, __LINE__, is_accept); + log_error("%s %d: %d", __func__, __LINE__, is_accept); if (is_accept) return scn_accept_connection(); @@ -824,7 +824,7 @@ if (err) { if (err == -EAGAIN) return err; - log_debug(1, "%s %d: close connection %d", __FUNCTION__, __LINE__, + log_debug(1, "%s %d: close connection %d", __func__, __LINE__, scn_fd); close(scn_fd); scn_fd = 0; @@ -858,7 +858,7 @@ fd = socket(ss.ss_family, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { - log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s\n", __func__, __LINE__, strerror(errno)); return -errno; } @@ -866,21 +866,21 @@ if (ss.ss_family == AF_INET6) { err = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)); if (err) - log_error("%s %d: %s\n", __FUNCTION__, __LINE__, + log_error("%s %d: %s\n", __func__, __LINE__, strerror(errno)); goto out; } err = listen(fd, 5); if (err) { - log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s\n", __func__, __LINE__, strerror(errno)); goto out; } slen = sizeof(lss); err = getsockname(fd, (struct sockaddr *) &lss, &slen); if (err) { - log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); + log_error("%s %d: %s\n", __func__, __LINE__, strerror(errno)); goto out; } Modified: trunk/iscsi-scst/usr/target.c =================================================================== --- trunk/iscsi-scst/usr/target.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/iscsi-scst/usr/target.c 2008-05-23 15:22:12 UTC (rev 393) @@ -96,7 +96,7 @@ remque(&target->tlist); if (!list_empty(&target->sessions_list)) { - log_error("%s still have sessions %d\n", __FUNCTION__, tid); + log_error("%s still have sessions %d\n", __func__, tid); exit(-1); } Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/scst/include/scst_debug.h 2008-05-23 15:22:12 UTC (rev 393) @@ -151,7 +151,7 @@ if (___unlikely(trace_flag & (trace))) { \ char *__tflag = LOG_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) { \ + __func__, __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s" format, __tflag, args); \ @@ -168,7 +168,7 @@ do { \ if (___unlikely(trace_flag & (flag))) { \ char *__tflag = INFO_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ + if (debug_print_prefix(trace_flag, __tflag, NULL, __func__,\ __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ @@ -191,7 +191,7 @@ do { \ if (trace_flag & (trace)) { \ char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ + if (debug_print_prefix(trace_flag, __tflag, NULL, __func__,\ __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ @@ -210,7 +210,7 @@ do { \ if (trace_flag & TRACE_BUFF) { \ char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __func__, \ __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ @@ -223,7 +223,7 @@ do { \ if (trace_flag & (flag)) { \ char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ + if (debug_print_prefix(trace_flag, __tflag, NULL, __func__, \ __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ @@ -236,7 +236,7 @@ do { \ char *__tflag = log_flag; \ if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) { \ + __func__, __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s" format, __tflag, args); \ @@ -272,10 +272,10 @@ if (trace_flag & TRACE_ENTRYEXIT) { \ if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ - __FUNCTION__); \ + __func__); \ } \ else { \ - PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ + PRINT(LOG_FLAG, "ENTRY %s", __func__); \ } \ } \ } while (0) @@ -285,10 +285,10 @@ if (trace_flag & TRACE_ENTRYEXIT) { \ if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ - __FUNCTION__); \ + __func__); \ } \ else { \ - PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ + PRINT(LOG_FLAG, "EXIT %s", __func__); \ } \ } \ } while (0) @@ -298,10 +298,10 @@ if (trace_flag & TRACE_ENTRYEXIT) { \ if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ - __FUNCTION__, (long)(res)); \ + __func__, (long)(res)); \ } \ else { \ - PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ + PRINT(LOG_FLAG, "EXIT %s: %ld", __func__, (long)(res)); \ } \ } \ } while (0) @@ -311,10 +311,10 @@ if (trace_flag & TRACE_ENTRYEXIT) { \ if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ - __FUNCTION__, (long)(res)); \ + __func__, (long)(res)); \ } \ else { \ - PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ + PRINT(LOG_FLAG, "EXIT %s: %lx", __func__, (long)(res)); \ } \ } \ } while (0) Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/scst/src/scst_lib.c 2008-05-23 15:22:12 UTC (rev 393) @@ -262,7 +262,7 @@ if (!list_empty(&dev->dev_tgt_dev_list) || !list_empty(&dev->dev_acg_dev_list)) { PRINT_CRIT_ERROR("%s: dev_tgt_dev_list or dev_acg_dev_list " - "is not empty!", __FUNCTION__); + "is not empty!", __func__); sBUG(); } #endif @@ -354,7 +354,7 @@ TRACE_ENTRY(); if (!list_empty(&acg->acg_sess_list)) { - PRINT_ERROR("%s: acg_sess_list is not empty!", __FUNCTION__); + PRINT_ERROR("%s: acg_sess_list is not empty!", __func__); res = -EBUSY; goto out; } @@ -1341,7 +1341,7 @@ #if defined(EXTRACHECKS) && (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) if (cmd->scsi_req) { - PRINT_ERROR("%s: %s", __FUNCTION__, "Cmd with unfreed " + PRINT_ERROR("%s: %s", __func__, "Cmd with unfreed " "scsi_req!"); scst_release_request(cmd); } @@ -2193,7 +2193,7 @@ buffer_size = scst_get_buf_first(cmd, &buffer); if (unlikely(buffer_size <= 0)) { PRINT_ERROR("%s: Unable to get the buffer " - "(%d)", __FUNCTION__, buffer_size); + "(%d)", __func__, buffer_size); goto out; } @@ -2245,7 +2245,7 @@ buffer_size = scst_get_buf_first(cmd, &buffer); if (unlikely(buffer_size <= 0)) { PRINT_ERROR("%s: Unable to get the buffer (%d)", - __FUNCTION__, buffer_size); + __func__, buffer_size); goto out; } break; Modified: trunk/scst/src/scst_main.c =================================================================== --- trunk/scst/src/scst_main.c 2008-05-23 15:19:52 UTC (rev 392) +++ trunk/scst/src/scst_main.c 2008-05-23 15:22:12 UTC (rev 393) @@ -644,13 +644,13 @@ if (dev_handler == NULL) { PRINT_ERROR("%s: valid device handler must be supplied", - __FUNCTION__); + __func__); res = -EINVAL; goto out; } if (dev_name == NULL) { - PRINT_ERROR("%s: device name must be non-NULL", __FUNCTION__); + PRINT_ERROR("%s: device name must be non-NULL", __func__); res = -EINVAL; goto out; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-26 11:13:55
|
Revision: 397 http://scst.svn.sourceforge.net/scst/?rev=397&view=rev Author: vlnb Date: 2008-05-26 04:13:04 -0700 (Mon, 26 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: While all warnings on mismatches between printf-style format strings and argument lists were fixed on i386 and x86_64, gcc prints a large number of warnings about mismatches when compiling SCST on ppc64. The patch below fixes these by casting integer arguments to the type (long long unsigned int) where appropriate. This patch has been tested as follows: - Verified the patch by reading it. - Checked that make -s clean && make -s iscsi scst && make -s -C srpt did not trigger any compiler warnings about format strings on i386, x86_64 and ppc. - Checked that no previously fixed checkpatch warnings were reintroduced in the patch generated by generate-kernel-patch. - Checked that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.4 kernel, and that the patched kernel tree still compiles, installs and boots fine. Additionally, this patch splits a kernel version preprocessor test from one into two lines, such that the generate-kernel-patch script can process the version check properly. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/kernel/conn.c trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/nthread.c trunk/iscsi-scst/kernel/session.c trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c Modified: trunk/iscsi-scst/kernel/conn.c =================================================================== --- trunk/iscsi-scst/kernel/conn.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/iscsi-scst/kernel/conn.c 2008-05-26 11:13:04 UTC (rev 397) @@ -254,7 +254,7 @@ PRINT_ERROR("Timeout sending data to initiator " "%s (SID %Lx), closing connection", conn->session->initiator_name, - conn->session->sid); + (long long unsigned int)conn->session->sid); mark_conn_closed(conn); } } else { @@ -281,13 +281,13 @@ mm_segment_t oldfs; struct iscsi_session *session = conn->session; - TRACE_DBG("%llu", session->sid); + TRACE_DBG("%llu", (long long unsigned int)session->sid); conn->sock = SOCKET_I(conn->file->f_dentry->d_inode); if (conn->sock->ops->sendpage == NULL) { PRINT_ERROR("Socket for sid %llu doesn't support sendpage()", - session->sid); + (long long unsigned int)session->sid); res = -EINVAL; goto out; } @@ -324,7 +324,9 @@ int conn_free(struct iscsi_conn *conn) { TRACE_MGMT_DBG("Freeing conn %p (sess=%p, %#Lx %u)", conn, - conn->session, conn->session->sid, conn->cid); + conn->session, + (long long unsigned int)conn->session->sid, + conn->cid); del_timer_sync(&conn->rsp_timer); @@ -359,7 +361,7 @@ } TRACE_MGMT_DBG("Creating connection %p for sid %#Lx, cid %u", conn, - session->sid, info->cid); + (long long unsigned int)session->sid, info->cid); /* Changing it, change ISCSI_CONN_IOV_MAX as well !! */ conn->read_iov = (struct iovec *)get_zeroed_page(GFP_KERNEL); Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-05-26 11:13:04 UTC (rev 397) @@ -1621,8 +1621,10 @@ if (req_hdr->lun != hdr->lun) { PRINT_ERROR("ABORT TASK: LUN mismatch: req LUN " - "%Lx, cmd LUN %Lx, rtt %u", req_hdr->lun, - hdr->lun, req_hdr->rtt); + "%Lx, cmd LUN %Lx, rtt %u", + (long long unsigned int)req_hdr->lun, + (long long unsigned int)hdr->lun, + req_hdr->rtt); err = ISCSI_RESPONSE_FUNCTION_REJECTED; goto out_put; } Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/iscsi-scst/kernel/nthread.c 2008-05-26 11:13:04 UTC (rev 397) @@ -989,7 +989,8 @@ res = vfs_writev(file, (struct iovec __user *)iop, count, &off); set_fs(oldfs); - TRACE_WRITE("%#Lx:%u: %d(%ld)", conn->session->sid, + TRACE_WRITE("%#Lx:%u: %d(%ld)", + (long long unsigned int)conn->session->sid, conn->cid, res, (long)iop->iov_len); if (unlikely(res <= 0)) { @@ -1089,7 +1090,8 @@ TRACE_WRITE("Final %s %#Lx:%u: %d(%lu,%u,%u, cmd %p, page %p)", (sendpage != sock_no_sendpage) ? "sendpage" : "sock_no_sendpage", - conn->session->sid, conn->cid, + (long long unsigned int)conn->session->sid, + conn->cid, res, sg_page(&sg[idx])->index, offset, size, write_cmnd, sg_page(&sg[idx])); if (unlikely(res <= 0)) { @@ -1168,7 +1170,8 @@ #endif { PRINT_ERROR("error %d at sid:cid %#Lx:%u, cmnd %p", res, - conn->session->sid, conn->cid, conn->write_cmnd); + (long long unsigned int)conn->session->sid, + conn->cid, conn->write_cmnd); } if (ref_cmd->scst_cmd != NULL) scst_set_delivery_status(ref_cmd->scst_cmd, Modified: trunk/iscsi-scst/kernel/session.c =================================================================== --- trunk/iscsi-scst/kernel/session.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/iscsi-scst/kernel/session.c 2008-05-26 11:13:04 UTC (rev 397) @@ -129,7 +129,8 @@ { int i; - TRACE_MGMT_DBG("Freeing session %p:%#Lx", session, session->sid); + TRACE_MGMT_DBG("Freeing session %p:%#Lx", + session, (long long unsigned int)session->sid); sBUG_ON(!list_empty(&session->conn_list)); if (unlikely(atomic_read(&session->active_cmds) != 0)) { @@ -162,7 +163,8 @@ return -ENOENT; if (!list_empty(&session->conn_list)) { - PRINT_ERROR("%llu still have connections", session->sid); + PRINT_ERROR("%llu still have connections", + (long long unsigned int)session->sid); return -EBUSY; } @@ -176,7 +178,8 @@ list_for_each_entry(session, &target->session_list, session_list_entry) { seq_printf(seq, "\tsid:%llu initiator:%s shutting down %d\n", - session->sid, session->initiator_name, + (long long unsigned int)session->sid, + session->initiator_name, session->shutting_down); conn_info_show(seq, session); } Modified: trunk/scst/src/dev_handlers/scst_user.c =================================================================== --- trunk/scst/src/dev_handlers/scst_user.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/dev_handlers/scst_user.c 2008-05-26 11:13:04 UTC (rev 397) @@ -1689,7 +1689,7 @@ if (res < 0) goto out_up; - TRACE_DBG("ureply %Ld", ureply); + TRACE_DBG("ureply %Ld", (long long unsigned int)ureply); cmd = kzalloc(max(sizeof(*cmd), sizeof(*reply)), GFP_KERNEL); if (cmd == NULL) { Modified: trunk/scst/src/dev_handlers/scst_vdisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_vdisk.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/dev_handlers/scst_vdisk.c 2008-05-26 11:13:04 UTC (rev 397) @@ -469,7 +469,7 @@ filp_close(fd, NULL); } virt_dev->file_size = err; - TRACE_DBG("size of file: %Ld", (uint64_t)err); + TRACE_DBG("size of file: %Ld", (long long unsigned int)err); } else virt_dev->file_size = 0; @@ -487,7 +487,8 @@ (dev->handler->type == TYPE_DISK) ? "disk" : "cdrom", virt_dev->name, virt_dev->file_name, virt_dev->file_size >> 20, virt_dev->block_size, - virt_dev->nblocks, virt_dev->nblocks/64/32, + (long long unsigned int)virt_dev->nblocks, + (long long unsigned int)virt_dev->nblocks/64/32, virt_dev->nblocks < 64*32 ? " !WARNING! cyln less than 1" : ""); } else { PRINT_INFO("Attached empty SCSI target virtual cdrom %s", @@ -771,12 +772,16 @@ loff = (loff_t)lba_start << virt_dev->block_shift; TRACE_DBG("cmd %p, lba_start %Ld, loff %Ld, data_len %Ld", cmd, - lba_start, (uint64_t)loff, (uint64_t)data_len); + (long long unsigned int)lba_start, + (long long unsigned int)loff, + (long long unsigned int)data_len); if (unlikely(loff < 0) || unlikely(data_len < 0) || unlikely((loff + data_len) > virt_dev->file_size)) { PRINT_INFO("Access beyond the end of the device " - "(%lld of %lld, len %Ld)", (uint64_t)loff, - (uint64_t)virt_dev->file_size, (uint64_t)data_len); + "(%lld of %lld, len %Ld)", + (long long unsigned int)loff, + (long long unsigned int)virt_dev->file_size, + (long long unsigned int)data_len); scst_set_cmd_error(cmd, SCST_LOAD_SENSE( scst_sense_block_out_range_error)); goto out_compl; @@ -789,8 +794,8 @@ fua = (cdb[1] & 0x8); if (fua) { TRACE(TRACE_ORDER, "FUA: loff=%Ld, " - "data_len=%Ld", (uint64_t)loff, - (uint64_t)data_len); + "data_len=%Ld", (long long unsigned int)loff, + (long long unsigned int)data_len); } break; } @@ -821,8 +826,8 @@ if (vdisk_need_pre_sync(cmd->queue_type, last_queue_type)) { TRACE(TRACE_ORDER, "ORDERED " "WRITE(%d): loff=%Ld, data_len=%Ld", - cmd->queue_type, (uint64_t)loff, - (uint64_t)data_len); + cmd->queue_type, (long long unsigned int)loff, + (long long unsigned int)data_len); do_fsync = 1; if (vdisk_fsync(thr, 0, 0, cmd) != 0) goto out_compl; @@ -856,8 +861,8 @@ if (vdisk_need_pre_sync(cmd->queue_type, last_queue_type)) { TRACE(TRACE_ORDER, "ORDERED " "WRITE_VERIFY(%d): loff=%Ld, data_len=%Ld", - cmd->queue_type, (uint64_t)loff, - (uint64_t)data_len); + cmd->queue_type, (long long unsigned int)loff, + (long long unsigned int)data_len); do_fsync = 1; if (vdisk_fsync(thr, 0, 0, cmd) != 0) goto out_compl; @@ -880,8 +885,8 @@ { int immed = cdb[1] & 0x2; TRACE(TRACE_ORDER, "SYNCHRONIZE_CACHE: " - "loff=%Ld, data_len=%Ld, immed=%d", (uint64_t)loff, - (uint64_t)data_len, immed); + "loff=%Ld, data_len=%Ld, immed=%d", (long long unsigned int)loff, + (long long unsigned int)data_len, immed); if (immed) { scst_cmd_get(cmd); cmd->completed = 1; @@ -2029,8 +2034,9 @@ else err = default_llseek(fd, loff, 0/*SEEK_SET*/); if (err != loff) { - PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, - (uint64_t)loff); + PRINT_ERROR("lseek trouble %Ld != %Ld", + (long long unsigned int)err, + (long long unsigned int)loff); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_set_fs; } @@ -2043,8 +2049,9 @@ } if ((err < 0) || (err < full_len)) { - PRINT_ERROR("readv() returned %Ld from %zd", (uint64_t)err, - full_len); + PRINT_ERROR("readv() returned %Ld from %zd", + (long long unsigned int)err, + full_len); if (err == -EAGAIN) scst_set_busy(cmd); else { @@ -2119,8 +2126,9 @@ else err = default_llseek(fd, loff, 0 /*SEEK_SET */); if (err != loff) { - PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, - (uint64_t)loff); + PRINT_ERROR("lseek trouble %Ld != %Ld", + (long long unsigned int)err, + (long long unsigned int)loff); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_set_fs; @@ -2137,7 +2145,8 @@ if (err < 0) { PRINT_ERROR("write() returned %Ld from %zd", - (uint64_t)err, full_len); + (long long unsigned int)err, + full_len); if (err == -EAGAIN) scst_set_busy(cmd); else { @@ -2410,8 +2419,9 @@ else err = default_llseek(fd, loff, 0/*SEEK_SET*/); if (err != loff) { - PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, - (uint64_t)loff); + PRINT_ERROR("lseek trouble %Ld != %Ld", + (long long unsigned int)err, + (long long unsigned int)loff); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_set_fs; } @@ -2444,7 +2454,7 @@ err = len_mem; if ((err < 0) || (err < len_mem)) { PRINT_ERROR("verify() returned %Ld from %zd", - (uint64_t)err, len_mem); + (long long unsigned int)err, len_mem); if (err == -EAGAIN) scst_set_busy(cmd); else { @@ -3129,7 +3139,8 @@ "(file=\"%s\", fs=%LdMB, bs=%d, nblocks=%Ld, cyln=%Ld%s)", virt_dev->name, virt_dev->file_name, virt_dev->file_size >> 20, virt_dev->block_size, - virt_dev->nblocks, virt_dev->nblocks/64/32, + (long long unsigned int)virt_dev->nblocks, + (long long unsigned int)virt_dev->nblocks/64/32, virt_dev->nblocks < 64*32 ? " !WARNING! cyln less " "than 1" : ""); } else { Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/scst_lib.c 2008-05-26 11:13:04 UTC (rev 397) @@ -195,7 +195,9 @@ #ifdef DEBUG TRACE(TRACE_SG_OP|TRACE_MEMORY, "cmd %p (tag %llu), " "resp_data_len %d, i %d, cmd->sg[i].length %d, " - "left %d", cmd, cmd->tag, resp_data_len, i, + "left %d", + cmd, (long long unsigned int)cmd->tag, + resp_data_len, i, cmd->sg[i].length, left); #endif cmd->orig_sg_cnt = cmd->sg_cnt; @@ -453,10 +455,12 @@ TRACE_MGMT_DBG("host=%d, channel=%d, id=%d, lun=%d, " "SCST lun=%Ld", dev->scsi_dev->host->host_no, dev->scsi_dev->channel, dev->scsi_dev->id, - dev->scsi_dev->lun, (uint64_t)tgt_dev->lun); + dev->scsi_dev->lun, + (long long unsigned int)tgt_dev->lun); } else { TRACE_MGMT_DBG("Virtual device %s on SCST lun=%Ld", - dev->virt_name, (uint64_t)tgt_dev->lun); + dev->virt_name, + (long long unsigned int)tgt_dev->lun); } spin_lock_init(&tgt_dev->tgt_dev_lock); @@ -723,12 +727,14 @@ if (dev->virt_name != NULL) { PRINT_INFO("Added device %s to group %s (LUN %Ld, " "rd_only %d)", dev->virt_name, acg->acg_name, - lun, read_only); + (long long unsigned int)lun, + read_only); } else { PRINT_INFO("Added device %d:%d:%d:%d to group %s (LUN " "%Ld, rd_only %d)", dev->scsi_dev->host->host_no, dev->scsi_dev->channel, dev->scsi_dev->id, - dev->scsi_dev->lun, acg->acg_name, lun, + dev->scsi_dev->lun, acg->acg_name, + (long long unsigned int)lun, read_only); } } @@ -1329,7 +1335,8 @@ TRACE_ENTRY(); - TRACE_DBG("Freeing cmd %p (tag %Lu)", cmd, cmd->tag); + TRACE_DBG("Freeing cmd %p (tag %Lu)", + cmd, (long long unsigned int)cmd->tag); if (unlikely(test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags))) { TRACE_MGMT_DBG("Freeing aborted cmd %p (scst_cmd_count %d)", @@ -1339,13 +1346,15 @@ sBUG_ON(cmd->inc_blocking || cmd->needs_unblocking || cmd->dec_on_dev_needed); -#if defined(EXTRACHECKS) && (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) +#if defined(EXTRACHECKS) if (cmd->scsi_req) { PRINT_ERROR("%s: %s", __func__, "Cmd with unfreed " "scsi_req!"); scst_release_request(cmd); } #endif +#endif scst_check_restore_sg_buff(cmd); @@ -1386,7 +1395,8 @@ if (unlikely(!cmd->sent_to_midlev)) { PRINT_ERROR("Finishing not executed cmd %p (opcode " "%d, target %s, lun %Ld, sn %ld, expected_sn %ld)", - cmd, cmd->cdb[0], cmd->tgtt->name, (uint64_t)cmd->lun, + cmd, cmd->cdb[0], cmd->tgtt->name, + (long long unsigned int)cmd->lun, cmd->sn, cmd->tgt_dev->expected_sn); scst_unblock_deferred(cmd->tgt_dev, cmd); } @@ -1394,7 +1404,9 @@ if (unlikely(cmd->out_of_sn)) { TRACE_SN("Out of SN cmd %p (tag %llu, sn %ld), " - "destroy=%d", cmd, cmd->tag, cmd->sn, destroy); + "destroy=%d", cmd, + (long long unsigned int)cmd->tag, + cmd->sn, destroy); destroy = test_and_set_bit(SCST_CMD_CAN_BE_DESTROYED, &cmd->cmd_flags); } @@ -2431,7 +2443,8 @@ list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { TRACE(TRACE_MGMT, "Clearing RESERVE'ation for tgt_dev " - "lun %Ld", tgt_dev->lun); + "lun %Ld", + (long long unsigned int)tgt_dev->lun); clear_bit(SCST_TGT_DEV_RESERVED, &tgt_dev->tgt_dev_flags); } @@ -2660,7 +2673,7 @@ list_for_each_entry_safe(UA_entry, t, &tgt_dev->UA_list, UA_list_entry) { TRACE_MGMT_DBG("Clearing UA for tgt_dev lun %Ld", - tgt_dev->lun); + (long long unsigned int)tgt_dev->lun); list_del(&UA_entry->UA_list_entry); kfree(UA_entry); } @@ -2720,7 +2733,9 @@ * !! already destroyed !! */ TRACE_SN("cmd %p (tag %llu) with skipped sn %ld found", - cmd, cmd->tag, cmd->sn); + cmd, + (long long unsigned int)cmd->tag, + cmd->sn); tgt_dev->def_cmd_count--; list_del(&cmd->sn_cmd_list_entry); spin_unlock_irq(&tgt_dev->sn_lock); @@ -2833,7 +2848,8 @@ sBUG_ON(cmd->needs_unblocking); cmd->needs_unblocking = 1; - TRACE_MGMT_DBG("Needs unblocking cmd %p (tag %llu)", cmd, cmd->tag); + TRACE_MGMT_DBG("Needs unblocking cmd %p (tag %llu)", + cmd, (long long unsigned int)cmd->tag); scst_block_dev(cmd->dev, outstanding); } @@ -2899,7 +2915,7 @@ scst_dec_on_dev_cmd(cmd); TRACE_MGMT_DBG("Delaying cmd %p due to blocking or " "serializing (tag %llu, dev %p)", cmd, - cmd->tag, dev); + (long long unsigned int)cmd->tag, dev); list_add_tail(&cmd->blocked_cmd_list_entry, &dev->blocked_cmd_list); res = 1; @@ -2917,7 +2933,7 @@ if (dev->block_count == 0) { TRACE_MGMT_DBG("cmd %p (tag %llu), blocking further " "cmds due to serializing (dev %p)", cmd, - cmd->tag, dev); + (long long unsigned int)cmd->tag, dev); __scst_block_dev(dev); cmd->inc_blocking = 1; } else { @@ -3095,12 +3111,13 @@ if (cmd->dev->tas) { TRACE_MGMT_DBG("Flag ABORTED OTHER set for cmd %p " "(tag %llu), returning TASK ABORTED ", cmd, - cmd->tag); + (long long unsigned int)cmd->tag); scst_set_cmd_error_status(cmd, SAM_STAT_TASK_ABORTED); } else { TRACE_MGMT_DBG("Flag ABORTED OTHER set for cmd %p " "(tag %llu), aborting without delivery or " - "notification", cmd, cmd->tag); + "notification", + cmd, (long long unsigned int)cmd->tag); /* * There is no need to check/requeue possible UA, * because, if it exists, it will be delivered Modified: trunk/scst/src/scst_priv.h =================================================================== --- trunk/scst/src/scst_priv.h 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/scst_priv.h 2008-05-26 11:13:04 UTC (rev 397) @@ -456,7 +456,7 @@ int cmd_blocking = cmd->inc_blocking; if (cmd_blocking) { TRACE_MGMT_DBG("cmd %p (tag %llu): unblocking dev %p", cmd, - cmd->tag, cmd->dev); + (long long unsigned int)cmd->tag, cmd->dev); cmd->inc_blocking = 0; } cmd->dec_on_dev_needed = 0; Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/scst_proc.c 2008-05-26 11:13:04 UTC (rev 397) @@ -1912,7 +1912,8 @@ acg_dev->rd_only_flag ? "RO" : ""); } else { seq_printf(seq, "%-60s%4Ld%12s\n", - acg_dev->dev->virt_name, acg_dev->lun, + acg_dev->dev->virt_name, + (long long unsigned int)acg_dev->lun, acg_dev->rd_only_flag ? "RO" : ""); } } Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-05-26 11:00:19 UTC (rev 396) +++ trunk/scst/src/scst_targ.c 2008-05-26 11:13:04 UTC (rev 397) @@ -194,8 +194,10 @@ #endif TRACE_DBG("Preferred context: %d (cmd %p)", pref_context, cmd); - TRACE(TRACE_SCSI, "tag=%llu, lun=%Ld, CDB len=%d", cmd->tag, - (uint64_t)cmd->lun, cmd->cdb_len); + TRACE(TRACE_SCSI, "tag=%llu, lun=%Ld, CDB len=%d", + (long long unsigned int)cmd->tag, + (long long unsigned int)cmd->lun, + cmd->cdb_len); PRINT_BUFF_FLAG(TRACE_SCSI|TRACE_RCV_BOT, "Recieving CDB", cmd->cdb, cmd->cdb_len); @@ -718,7 +720,9 @@ TRACE_ENTRY(); TRACE_DBG("Preferred context: %d", pref_context); - TRACE_DBG("tag=%llu, status=%#x", scst_cmd_get_tag(cmd), status); + TRACE_DBG("tag=%llu, status=%#x", + (long long unsigned int)scst_cmd_get_tag(cmd), + status); #ifdef EXTRACHECKS if (in_irq() && ((pref_context == SCST_CONTEXT_DIRECT) || @@ -957,7 +961,9 @@ TRACE_ENTRY(); TRACE_DBG("Preferred context: %d", pref_context); - TRACE(TRACE_SCSI, "tag=%llu status=%#x", scst_cmd_get_tag(cmd), status); + TRACE(TRACE_SCSI, "tag=%llu status=%#x", + (long long unsigned int)scst_cmd_get_tag(cmd), + status); #ifdef EXTRACHECKS if (in_irq() && ((pref_context == SCST_CONTEXT_DIRECT) || @@ -1402,7 +1408,7 @@ if ((cmd->cdb[0] == RESERVE_10) && (cmd->cdb[2] & SCST_RES_3RDPTY)) { PRINT_ERROR("RESERVE_10: 3rdPty RESERVE not implemented " - "(lun=%Ld)", (uint64_t)cmd->lun); + "(lun=%Ld)", (long long unsigned int)cmd->lun); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb)); goto out_done; @@ -1726,7 +1732,7 @@ if (unlikely(dev->scsi_dev == NULL)) { PRINT_ERROR("Command for virtual device must be " "processed by device handler (lun %Ld)!", - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); goto out_error; } @@ -1935,7 +1941,8 @@ if (unlikely(test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags))) { /* Necessary to allow aborting out of sn cmds */ TRACE_MGMT_DBG("Aborting out of sn cmd %p (tag %llu)", - cmd, cmd->tag); + cmd, + (long long unsigned)cmd->tag); tgt_dev->def_cmd_count--; cmd->state = SCST_CMD_STATE_PRE_DEV_DONE; res = SCST_CMD_STATE_RES_CONT_SAME; @@ -2059,7 +2066,8 @@ "Double UA detected"); /* Do retry */ TRACE(TRACE_MGMT_MINOR, "Retrying cmd %p " - "(tag %llu)", cmd, cmd->tag); + "(tag %llu)", cmd, + (long long unsigned)cmd->tag); cmd->status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; @@ -2214,7 +2222,8 @@ if (buffer[SCST_INQ_BYTE3] & SCST_INQ_NORMACA_BIT) { PRINT_INFO("NormACA set for device: " "lun=%Ld, type 0x%02x", - (uint64_t)cmd->lun, buffer[0]); + (long long unsigned int)cmd->lun, + buffer[0]); } #endif buffer[SCST_INQ_BYTE3] &= ~SCST_INQ_NORMACA_BIT; @@ -2232,7 +2241,7 @@ (cmd->cdb[0] == MODE_SELECT_10) || (cmd->cdb[0] == LOG_SELECT))) { TRACE(TRACE_SCSI, "MODE/LOG SELECT succeeded (LUN %Ld)", - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); cmd->state = SCST_CMD_STATE_MODE_SELECT_CHECKS; *pres = SCST_CMD_STATE_RES_CONT_SAME; res = 1; @@ -2246,7 +2255,9 @@ struct scst_device *dev = cmd->dev; TRACE(TRACE_SCSI, "Real RESERVE failed lun=%Ld, " - "status=%x", (uint64_t)cmd->lun, cmd->status); + "status=%x", + (long long unsigned int)cmd->lun, + cmd->status); PRINT_BUFF_FLAG(TRACE_SCSI, "Sense", cmd->sense, SCST_SENSE_BUFFERSIZE); @@ -2268,8 +2279,9 @@ SCST_SENSE_VALID(cmd->sense) && scst_is_ua_sense(cmd->sense) && (cmd->sense[12] == 0x2a) && (cmd->sense[13] == 0x01)) { - TRACE(TRACE_SCSI, "MODE PARAMETERS CHANGED UA (lun %Ld)", - (uint64_t)cmd->lun); + TRACE(TRACE_SCSI, + "MODE PARAMETERS CHANGED UA (lun %Ld)", + (long long unsigned int)cmd->lun); cmd->state = SCST_CMD_STATE_MODE_SELECT_CHECKS; *pres = SCST_CMD_STATE_RES_CONT_SAME; res = 1; @@ -2320,7 +2332,7 @@ TRACE(TRACE_SCSI, "MODE/LOG SELECT succeeded, " "setting the SELECT UA (lun=%Ld)", - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); spin_lock_bh(&dev->dev_lock); spin_lock(&scst_temp_UA_lock); @@ -2357,7 +2369,7 @@ TRACE(TRACE_SCSI, "Possible parameters changed UA %x " "(lun %Ld): getting new parameters", cmd->sense[12], - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); scst_obtain_device_parameters(cmd->dev); } else @@ -2508,7 +2520,7 @@ if (unlikely(test_bit(SCST_CMD_NO_RESP, &cmd->cmd_flags))) { TRACE_MGMT_DBG("Flag NO_RESP set for cmd %p (tag %llu), skipping", - cmd, cmd->tag); + cmd, (long long unsigned int)cmd->tag); cmd->state = SCST_CMD_STATE_FINISHED; res = SCST_CMD_STATE_RES_CONT_SAME; goto out; @@ -2827,7 +2839,7 @@ struct list_head *sess_tgt_dev_list_head = &cmd->sess->sess_tgt_dev_list_hash[HASH_VAL(cmd->lun)]; TRACE_DBG("Finding tgt_dev for cmd %p (lun %Ld)", cmd, - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); res = -1; list_for_each_entry(tgt_dev, sess_tgt_dev_list_head, sess_tgt_dev_list_entry) { @@ -2837,7 +2849,8 @@ if (unlikely(tgt_dev->dev->handler == &scst_null_devtype)) { PRINT_INFO("Dev handler for device " "%Ld is NULL, the device will not be " - "visible remotely", (uint64_t)cmd->lun); + "visible remotely", + (long long unsigned int)cmd->lun); break; } @@ -2851,7 +2864,7 @@ } if (res != 0) { TRACE(TRACE_MINOR, "tgt_dev for lun %Ld not found, command to " - "unexisting LU?", (uint64_t)cmd->lun); + "unexisting LU?", (long long unsigned int)cmd->lun); __scst_put(); } } else { @@ -2962,7 +2975,7 @@ } } else { TRACE_MGMT_DBG("Aborting not inited cmd %p (tag %llu)", - cmd, cmd->tag); + cmd, (long long unsigned int)cmd->tag); cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP; } @@ -3106,7 +3119,7 @@ res = SCST_CMD_STATE_RES_CONT_NEXT; TRACE_MGMT_DBG("Skipping cmd %p (tag %llu), " "because of TM DBG delay", cmd, - cmd->tag); + (long long unsigned int)cmd->tag); break; } res = scst_send_to_midlev(&cmd); @@ -3325,7 +3338,7 @@ TRACE_ENTRY(); TRACE_DBG("Finding tgt_dev for mgmt cmd %p (lun %Ld)", mcmd, - (uint64_t)mcmd->lun); + (long long unsigned int)mcmd->lun); __scst_get(1); @@ -3365,7 +3378,8 @@ TRACE_ENTRY(); - TRACE_MGMT_DBG("cmd %p done (tag %llu)", cmd, cmd->tag); + TRACE_MGMT_DBG("cmd %p done (tag %llu)", + cmd, (long long unsigned int)cmd->tag); spin_lock_irqsave(&scst_mcmd_lock, flags); @@ -3413,7 +3427,8 @@ TRACE_ENTRY(); - TRACE_MGMT_DBG("cmd %p finished (tag %llu)", cmd, cmd->tag); + TRACE_MGMT_DBG("cmd %p finished (tag %llu)", + cmd, (long long unsigned int)cmd->tag); spin_lock_irqsave(&scst_mcmd_lock, flags); @@ -3504,7 +3519,8 @@ TRACE_ENTRY(); TRACE(((mcmd != NULL) && (mcmd->fn == SCST_ABORT_TASK)) ? TRACE_MGMT_MINOR : TRACE_MGMT, - "Aborting cmd %p (tag %llu, op %x)", cmd, cmd->tag, cmd->cdb[0]); + "Aborting cmd %p (tag %llu, op %x)", + cmd, (long long unsigned int)cmd->tag, cmd->cdb[0]); /* To protect from concurrent aborts */ spin_lock_irqsave(&other_ini_lock, flags); @@ -3573,14 +3589,14 @@ */ TRACE_MGMT_DBG("cmd %p (tag %llu) being executed/xmitted " "(state %d, proc time %ld sec.), deferring ABORT...", - cmd, cmd->tag, cmd->state, + cmd, (long long unsigned int)cmd->tag, cmd->state, (long)(jiffies - cmd->start_time)/HZ); mcmd->cmd_finish_wait_count++; if (!cmd->done) { TRACE_MGMT_DBG("cmd %p (tag %llu) not done yet", - cmd, cmd->tag); + cmd, (long long unsigned int)cmd->tag); mcmd->cmd_done_wait_count++; } } @@ -3732,7 +3748,7 @@ struct scst_device *dev = tgt_dev->dev; TRACE(TRACE_MGMT, "Aborting task set (lun=%Ld, mcmd=%p)", - tgt_dev->lun, mcmd); + (long long unsigned int)tgt_dev->lun, mcmd); mcmd->needs_unblocking = 1; @@ -3762,7 +3778,7 @@ TRACE_ENTRY(); TRACE_DBG("Finding match for dev %p and cmd %p (lun %Ld)", dev, cmd, - (uint64_t)cmd->lun); + (long long unsigned int)cmd->lun); sess_tgt_dev_list_head = &cmd->sess->sess_tgt_dev_list_hash[HASH_VAL(cmd->lun)]; @@ -3791,7 +3807,7 @@ TRACE_ENTRY(); TRACE(TRACE_MGMT, "Clearing task set (lun=%Ld, mcmd=%p)", - (uint64_t)mcmd->lun, mcmd); + (long long unsigned int)mcmd->lun, mcmd); mcmd->needs_unblocking = 1; @@ -3873,7 +3889,8 @@ cmd = __scst_find_cmd_by_tag(sess, mcmd->tag); if (cmd == NULL) { TRACE(TRACE_MGMT_MINOR, "ABORT TASK failed: command " - "for tag %llu not found", mcmd->tag); + "for tag %llu not found", + (long long unsigned int)mcmd->tag); mcmd->status = SCST_MGMT_STATUS_TASK_NOT_EXIST; mcmd->state = SCST_MGMT_CMD_STATE_DONE; spin_unlock_irq(&sess->sess_list_lock); @@ -3882,20 +3899,23 @@ __scst_cmd_get(cmd); spin_unlock_irq(&sess->sess_list_lock); TRACE_MGMT_DBG("Cmd %p for tag %llu (sn %ld, set %d, " - "queue_type %x) found, aborting it", cmd, mcmd->tag, + "queue_type %x) found, aborting it", + cmd, (long long unsigned int)mcmd->tag, cmd->sn, cmd->sn_set, cmd->queue_type); mcmd->cmd_to_abort = cmd; if (mcmd->lun_set && (mcmd->lun != cmd->lun)) { PRINT_ERROR("ABORT TASK: LUN mismatch: mcmd LUN %Lx, " - "cmd LUN %Lx, cmd tag %Lu", mcmd->lun, cmd->lun, - mcmd->tag); + "cmd LUN %Lx, cmd tag %Lu", + (long long unsigned int)mcmd->lun, + (long long unsigned int)cmd->lun, + (long long unsigned int)mcmd->tag); mcmd->status = SCST_MGMT_STATUS_REJECTED; } else if (mcmd->cmd_sn_set && (scst_sn_before(mcmd->cmd_sn, cmd->tgt_sn) || (mcmd->cmd_sn == cmd->tgt_sn))) { PRINT_ERROR("ABORT TASK: SN mismatch: mcmd SN %x, " "cmd SN %x, cmd tag %Lu", mcmd->cmd_sn, - cmd->tgt_sn, mcmd->tag); + cmd->tgt_sn, (long long unsigned int)mcmd->tag); mcmd->status = SCST_MGMT_STATUS_REJECTED; } else { scst_abort_cmd(cmd, mcmd, 0, 1); @@ -3922,7 +3942,8 @@ rc = scst_mgmt_translate_lun(mcmd); if (rc < 0) { PRINT_ERROR("Corresponding device for lun %Ld not " - "found", (uint64_t)mcmd->lun); + "found", + (long long unsigned int)mcmd->lun); mcmd->status = SCST_MGMT_STATUS_LUN_NOT_EXIST; mcmd->state = SCST_MGMT_CMD_STATE_DONE; } else if (rc != 0) @@ -4047,7 +4068,8 @@ TRACE_ENTRY(); - TRACE(TRACE_MGMT, "Resetting lun %Ld (mcmd %p)", tgt_dev->lun, mcmd); + TRACE(TRACE_MGMT, "Resetting lun %Ld (mcmd %p)", + (long long unsigned int)tgt_dev->lun, mcmd); mcmd->needs_unblocking = 1; @@ -4712,8 +4734,12 @@ TRACE_MGMT_DBG("sess=%p, tag_set %d, tag %Ld, lun_set %d, " "lun=%Ld, cmd_sn_set %d, cmd_sn %d, priv %p", sess, - params->tag_set, params->tag, params->lun_set, - (uint64_t)mcmd->lun, params->cmd_sn_set, params->cmd_sn, + params->tag_set, + (long long unsigned int)params->tag, + params->lun_set, + (long long unsigned int)mcmd->lun, + params->cmd_sn_set, + params->cmd_sn, params->tgt_priv); if (scst_post_rx_mgmt_cmd(sess, mcmd) != 0) @@ -5128,7 +5154,7 @@ /* ToDo: hash list */ TRACE_DBG("%s (sess=%p, tag=%llu)", "Searching in search cmd list", - sess, tag); + sess, (long long unsigned int)tag); list_for_each_entry(cmd, &sess->search_cmd_list, search_cmd_list_entry) { if (cmd->tag == tag) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-27 14:28:40
|
Revision: 399 http://scst.svn.sourceforge.net/scst/?rev=399&view=rev Author: vlnb Date: 2008-05-27 07:28:37 -0700 (Tue, 27 May 2008) Log Message: ----------- Patch from Bart Van Assche <bar...@gm...>: The patch below fixes the following checkpatch warning: WARNING: Use #include <linux/...> instead of <asm/...> This patch has been tested as follows: - Verified the patch by rereading it. - Checked that make -s clean && make -s iscsi scst && make -s -C srpt still works. - Checked that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.4 kernel, and that the patched kernel tree still compiles, installs and boots fine, and that the iscsi-scst, ib_srpt, scst_disk and scst_vdisk modules still load. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/kernel/digest.c trunk/scst/include/scst_debug.h trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_mem.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c Modified: trunk/iscsi-scst/kernel/digest.c =================================================================== --- trunk/iscsi-scst/kernel/digest.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/iscsi-scst/kernel/digest.c 2008-05-27 14:28:37 UTC (rev 399) @@ -15,7 +15,7 @@ * GNU General Public License for more details. */ -#include <asm/types.h> +#include <linux/types.h> #include <linux/scatterlist.h> #include "iscsi.h" Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/include/scst_debug.h 2008-05-27 14:28:37 UTC (rev 399) @@ -21,7 +21,7 @@ #define __SCST_DEBUG_H #include <linux/autoconf.h> /* for CONFIG_* */ -#include <asm/bug.h> /* for WARN_ON_ONCE */ +#include <linux/bug.h> /* for WARN_ON_ONCE */ #if !defined(EXTRACHECKS) && defined(CONFIG_SCSI_TARGET_EXTRACHECKS) #define EXTRACHECKS Modified: trunk/scst/src/dev_handlers/scst_vdisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_vdisk.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/dev_handlers/scst_vdisk.c 2008-05-27 14:28:37 UTC (rev 399) @@ -20,7 +20,7 @@ * GNU General Public License for more details. */ -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/string.h> Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_lib.c 2008-05-27 14:28:37 UTC (rev 399) @@ -24,8 +24,8 @@ #include <linux/sched.h> #include <linux/kthread.h> #include <linux/cdrom.h> -#include <asm/unistd.h> -#include <asm/string.h> +#include <linux/unistd.h> +#include <linux/string.h> #ifdef SCST_HIGHMEM #include <linux/highmem.h> Modified: trunk/scst/src/scst_main.c =================================================================== --- trunk/scst/src/scst_main.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_main.c 2008-05-27 14:28:37 UTC (rev 399) @@ -24,8 +24,8 @@ #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/sched.h> -#include <asm/unistd.h> -#include <asm/string.h> +#include <linux/unistd.h> +#include <linux/string.h> #include <linux/kthread.h> #include "scst.h" Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_mem.c 2008-05-27 14:28:37 UTC (rev 399) @@ -24,8 +24,8 @@ #include <linux/slab.h> #include <linux/sched.h> #include <linux/mm.h> -#include <asm/unistd.h> -#include <asm/string.h> +#include <linux/unistd.h> +#include <linux/string.h> #ifdef SCST_HIGHMEM #include <linux/highmem.h> Modified: trunk/scst/src/scst_mem.h =================================================================== --- trunk/scst/src/scst_mem.h 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_mem.h 2008-05-27 14:28:37 UTC (rev 399) @@ -14,7 +14,7 @@ * GNU General Public License for more details. */ -#include <asm/scatterlist.h> +#include <linux/scatterlist.h> #include <linux/workqueue.h> #include <linux/seq_file.h> Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_proc.c 2008-05-27 14:28:37 UTC (rev 399) @@ -24,9 +24,9 @@ #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/sched.h> -#include <asm/unistd.h> -#include <asm/string.h> -#include <asm/uaccess.h> +#include <linux/unistd.h> +#include <linux/string.h> +#include <linux/uaccess.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-05-27 14:26:15 UTC (rev 398) +++ trunk/scst/src/scst_targ.c 2008-05-27 14:28:37 UTC (rev 399) @@ -23,8 +23,8 @@ #include <linux/slab.h> #include <linux/sched.h> #include <linux/smp_lock.h> -#include <asm/unistd.h> -#include <asm/string.h> +#include <linux/unistd.h> +#include <linux/string.h> #include <linux/kthread.h> #include <linux/delay.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-28 11:17:14
|
Revision: 401 http://scst.svn.sourceforge.net/scst/?rev=401&view=rev Author: vlnb Date: 2008-05-28 04:17:08 -0700 (Wed, 28 May 2008) Log Message: ----------- 3 small patches from Bart Van Assche <bar...@gm...>: The patch below fixes the following category of checkpatch complaints: ERROR: do not use C99 // comments This patch has been verified as follows: - Verified that checkpatch does no longer complain about C99 comments. - Verified that make -s clean && make -s iscsi scst && make -s -C srpt still works. Signed-off-by: Bart Van Assche <bar...@gm...> The patch below fixes the following category of checkpatch complaints: WARNING: unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html This patch has been verified as follows: - Verified that checkpatch does no longer complain about unnecessary casts. - Verified that make -s clean && make -s iscsi scst && make -s -C srpt still works and does not trigger any new compiler warnings. Signed-off-by: Bart Van Assche <bar...@gm...> The patch below fixes the following category of checkpatch warnings: ERROR: Use of SPIN_LOCK_UNLOCKED is deprecated: see Documentation/spinlocks.txt This patch has been verified as follows: - Verified that checkpatch does no longer complain about spinlocks. - Verified that make -s clean && make -s iscsi scst && make -s -C srpt still works and does not trigger any new compiler warnings. - Verified that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.4 kernel, and that the patched kernel tree still compiles, installs and boots fine, and that the iscsi-scst, ib_srpt, scst_disk and scst_vdisk modules still load. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/nthread.c trunk/qla_isp/linux/isp_scst.c trunk/qla_isp/linux/scsi_target.c trunk/scst/include/scst_debug.h trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/scst_debug.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_targ.c Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-05-28 11:17:08 UTC (rev 401) @@ -42,11 +42,11 @@ static struct kmem_cache *iscsi_cmnd_cache; -spinlock_t iscsi_rd_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(iscsi_rd_lock); LIST_HEAD(iscsi_rd_list); DECLARE_WAIT_QUEUE_HEAD(iscsi_rd_waitQ); -spinlock_t iscsi_wr_lock = SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(iscsi_wr_lock); LIST_HEAD(iscsi_wr_list); DECLARE_WAIT_QUEUE_HEAD(iscsi_wr_waitQ); @@ -700,7 +700,7 @@ memset(sense, 0, sizeof(sense)); sense[0] = 0xf0; sense[2] = sense_key; - sense[7] = 6; // Additional sense length + sense[7] = 6; /* Additional sense length */ sense[12] = asc; sense[13] = ascq; return create_status_rsp(req, SAM_STAT_CHECK_CONDITION, sense, @@ -784,7 +784,7 @@ TRACE_DBG("%x,%x", cmnd_opcode(cmnd), exp_stat_sn); if ((int)(exp_stat_sn - conn->exp_stat_sn) > 0 && (int)(exp_stat_sn - conn->stat_sn) <= 0) { - // free pdu resources + /* free pdu resources */ cmnd->conn->exp_stat_sn = exp_stat_sn; } } @@ -2139,7 +2139,7 @@ break; } - // move this? + /* move this? */ conn->write_size = (conn->write_size + 3) & -4; iscsi_dump_pdu(&cmnd->pdu); } Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/iscsi-scst/kernel/nthread.c 2008-05-28 11:17:08 UTC (rev 401) @@ -496,7 +496,7 @@ static inline void iscsi_conn_init_read(struct iscsi_conn *conn, void *data, size_t len) { - len = (len + 3) & -4; // XXX ??? + len = (len + 3) & -4; /* XXX ??? */ conn->read_iov[0].iov_base = data; conn->read_iov[0].iov_len = len; conn->read_msg.msg_iov = conn->read_iov; @@ -1059,7 +1059,7 @@ #ifdef NET_PAGE_CALLBACKS_DEFINED { - static spinlock_t net_priv_lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(net_priv_lock); spin_lock(&net_priv_lock); if (sg_page(&sg[idx])->net_priv != NULL) { if (sg_page(&sg[idx])->net_priv != ref_cmd) { Modified: trunk/qla_isp/linux/isp_scst.c =================================================================== --- trunk/qla_isp/linux/isp_scst.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/qla_isp/linux/isp_scst.c 2008-05-28 11:17:08 UTC (rev 401) @@ -183,7 +183,7 @@ static bus_t busses[MAX_BUS]; -static spinlock_t scsi_target_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(scsi_target_lock); DECLARE_WAIT_QUEUE_HEAD(qlaispd_waitq); struct task_struct *qlaispd_task; Modified: trunk/qla_isp/linux/scsi_target.c =================================================================== --- trunk/qla_isp/linux/scsi_target.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/qla_isp/linux/scsi_target.c 2008-05-28 11:17:08 UTC (rev 401) @@ -398,7 +398,7 @@ static tmd_cmd_t *p_front = NULL, *p_last = NULL; static tmd_cmd_t *q_front = NULL, *q_last = NULL; static tmd_cmd_t *r_front = NULL, *r_last = NULL; -static spinlock_t scsi_target_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(scsi_target_lock); static int scsi_target_thread_exit = 0; static struct file_operations scsi_target_fops = { Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/include/scst_debug.h 2008-05-28 11:17:08 UTC (rev 401) @@ -91,7 +91,7 @@ #endif #ifdef DEBUG -//# define LOG_FLAG KERN_DEBUG +/*# define LOG_FLAG KERN_DEBUG*/ # define LOG_FLAG KERN_INFO # define INFO_FLAG KERN_INFO # define ERROR_FLAG KERN_INFO Modified: trunk/scst/src/dev_handlers/scst_user.c =================================================================== --- trunk/scst/src/dev_handlers/scst_user.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/src/dev_handlers/scst_user.c 2008-05-28 11:17:08 UTC (rev 401) @@ -204,10 +204,10 @@ static struct class *dev_user_sysfs_class; -static spinlock_t dev_list_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(dev_list_lock); static LIST_HEAD(dev_list); -static spinlock_t cleanup_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(cleanup_lock); static LIST_HEAD(cleanup_list); static DECLARE_WAIT_QUEUE_HEAD(cleanup_list_waitQ); static struct task_struct *cleanup_thread; Modified: trunk/scst/src/scst_debug.c =================================================================== --- trunk/scst/src/scst_debug.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/src/scst_debug.c 2008-05-28 11:17:08 UTC (rev 401) @@ -26,7 +26,7 @@ #define TRACE_BUF_SIZE 512 static char trace_buf[TRACE_BUF_SIZE]; -static spinlock_t trace_buf_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(trace_buf_lock); static inline int get_current_tid(void) { Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/src/scst_lib.c 2008-05-28 11:17:08 UTC (rev 401) @@ -3185,7 +3185,7 @@ { static int Inited; static unsigned long RandomValue; - static spinlock_t lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(lock); /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */ register long rv; register long lo; @@ -3220,7 +3220,7 @@ static void tm_dbg_timer_fn(unsigned long arg); -static spinlock_t scst_tm_dbg_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(scst_tm_dbg_lock); /* All serialized by scst_tm_dbg_lock */ struct { unsigned int tm_dbg_release:1; @@ -3504,7 +3504,7 @@ #ifdef DEBUG_SN void scst_check_debug_sn(struct scst_cmd *cmd) { - static spinlock_t lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(lock); static int type; static int cnt; unsigned long flags; Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/src/scst_mem.c 2008-05-28 11:17:08 UTC (rev 401) @@ -264,7 +264,7 @@ sz = pages_to_alloc * sizeof(obj->sg_entries[0]); - obj->sg_entries = (struct scatterlist *)kmalloc(sz, gfp_mask); + obj->sg_entries = kmalloc(sz, gfp_mask); if (unlikely(obj->sg_entries == NULL)) { TRACE(TRACE_OUT_OF_MEM, "Allocation of sgv_pool_obj " "SG vector failed (size %d)", sz); @@ -283,7 +283,7 @@ */ } else { tsz = pages_to_alloc * sizeof(obj->trans_tbl[0]); - obj->trans_tbl = (struct trans_tbl_ent *)kzalloc(tsz, gfp_mask); + obj->trans_tbl = kzalloc(tsz, gfp_mask); if (unlikely(obj->trans_tbl == NULL)) { TRACE(TRACE_OUT_OF_MEM, "Allocation of trans_tbl " "failed (size %d)", tsz); Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-05-27 14:31:31 UTC (rev 400) +++ trunk/scst/src/scst_targ.c 2008-05-28 11:17:08 UTC (rev 401) @@ -3521,7 +3521,7 @@ int other_ini, int call_dev_task_mgmt_fn) { unsigned long flags; - static spinlock_t other_ini_lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(other_ini_lock); TRACE_ENTRY(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-05-31 12:05:15
|
Revision: 403 http://scst.svn.sourceforge.net/scst/?rev=403&view=rev Author: vlnb Date: 2008-05-31 05:05:02 -0700 (Sat, 31 May 2008) Log Message: ----------- The major TM processing cleanup in scst_user module which was possible after the recent SCST changes, to fix current problems. Also there are fixes for found during development/testing problems. Particularly: - PRIO queue was removed from scst_user. Instead, all priority commands now queued in the head of the regular queue. The corresponding code was removed from fileio_tgt as well. It necessary, in the future the priority queue can be easily restored from this patch. - pre_unreg_sess() was removed from struct scst_dev_type. The corresponding code was removed from SCST core as well - Almost all /proc/scsi_tgt commands now can fail after timeout (90 seconds) with EBUSY - Fixed possible incorrect command's retry if double RESET UA is detected. - Many minor changes and cleanups Also docs were updated. Modified Paths: -------------- trunk/doc/scst_user_spec.txt trunk/iscsi-scst/README trunk/iscsi-scst/kernel/config.c trunk/iscsi-scst/kernel/iscsi.h trunk/iscsi-scst/kernel/target.c trunk/iscsi-scst/usr/ctldev.c trunk/iscsi-scst/usr/iscsid.c trunk/qla2x00t/qla2x00-target/README trunk/scst/README trunk/scst/include/scst.h trunk/scst/include/scst_const.h trunk/scst/include/scst_debug.h trunk/scst/include/scst_user.h trunk/scst/src/dev_handlers/scst_cdrom.c trunk/scst/src/dev_handlers/scst_changer.c trunk/scst/src/dev_handlers/scst_disk.c trunk/scst/src/dev_handlers/scst_modisk.c trunk/scst/src/dev_handlers/scst_processor.c trunk/scst/src/dev_handlers/scst_raid.c trunk/scst/src/dev_handlers/scst_tape.c trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_debug.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c trunk/usr/fileio/common.c trunk/usr/fileio/common.h trunk/usr/fileio/fileio.c Modified: trunk/doc/scst_user_spec.txt =================================================================== --- trunk/doc/scst_user_spec.txt 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/doc/scst_user_spec.txt 2008-05-31 12:05:02 UTC (rev 403) @@ -2,7 +2,7 @@ USER SPACE INTERFACE DESCRIPTION. - Version 0.9.6/3 + Version 0.9.6/4 I. Description. @@ -103,7 +103,6 @@ uint8_t parse_type; uint8_t on_free_cmd_type; uint8_t memory_reuse_type; - uint8_t prio_queue_type; uint8_t partial_transfers_type; uint32_t partial_len; @@ -156,18 +155,6 @@ * SCST_USER_MEM_REUSE_ALL - unlimited memory reuse is possible. - - prio_queue_type - defines if the user space handler need to receive - all management subcommands from a separate PRIO queue using - SCST_USER_REPLY_AND_GET_PRIO_CMD command. Management subcommands are: - SCST_USER_ATTACH_SESS, SCST_USER_DETACH_SESS and SCST_USER_TASK_MGMT. - Possible values are: - - * SCST_USER_PRIO_QUEUE_SINGLE - a single queue is used for regular - and management subcommands - - * SCST_USER_PRIO_QUEUE_SEPARATE - a separate PRIO queue is used for - management subcommands - - partial_transfers_type - defines if the user space handler supports partial data transfers, when a SCSI command, which required big data transfer, is broken on several subcommands with smaller data @@ -312,7 +299,7 @@ processing. The PARSE state is intended to check validity of the command, determine data transfer type and the necessary data buffer size. This subcommand is returned only if SCST_USER_SET_OPTIONS -parse_type isn'e set to SCST_USER_PARSE_STANDARD. In this case the +parse_type isn't set to SCST_USER_PARSE_STANDARD. In this case the standard SCST internal parser for this SCSI device type will do all the job. @@ -715,24 +702,9 @@ - SCST_MGMT_STATUS_FAILED - task management function failed - 5. SCST_USER_REPLY_AND_GET_PRIO_CMD -SCST_USER_REPLY_AND_GET_PRIO_CMD is the same as -SCST_USER_REPLY_AND_GET_CMD, except that it returns management (i.e. -priority) subcommands from priority queue, if usage of a separate PRIO -was configured. + 5. SCST_USER_REPLY_CMD -Management subcommands are: SCST_USER_ATTACH_SESS, SCST_USER_DETACH_SESS -and SCST_USER_TASK_MGMT. - -PRIO queue is always blocking, because poll() doesn't support, when -different threads wait with different events mask. Only one thread is -woken up on each event and if it isn't interested in such events, -another (interested) one will not be woken up. - - - 6. SCST_USER_REPLY_CMD - SCST_USER_REPLY_CMD IOCTL function allows the user space handler to return the result of a command's execution. Its argument is defined as: @@ -841,8 +813,8 @@ which involve data transfer from initiator to target) commands. So the device is configured with parse_type SCST_USER_PARSE_STANDARD, on_free_cmd_type SCST_USER_ON_FREE_CMD_IGNORE, memory_reuse_type -SCST_USER_MEM_REUSE_ALL, prio_queue_type SCST_USER_PRIO_QUEUE_SINGLE and -partial_transfers_type SCST_USER_PARTIAL_TRANSFERS_NOT_SUPPORTED. +SCST_USER_MEM_REUSE_ALL and partial_transfers_type +SCST_USER_PARTIAL_TRANSFERS_NOT_SUPPORTED. Then it prepares struct scst_user_get_cmd with reply set to 0, calls SCST_USER_REPLY_AND_GET_CMD ioctl() and waits until some initiator Modified: trunk/iscsi-scst/README =================================================================== --- trunk/iscsi-scst/README 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/README 2008-05-31 12:05:02 UTC (rev 403) @@ -32,6 +32,16 @@ Basically as in README-IET, where file names are changed as specified above. +Only vanilla kernels from kernel.org are supported, but it should work +on vendors' kernels, if you manage to successfully compile on them. The +main problem with vendor's kernels is that they often contain patches, +which will appear only in the next version of the vanilla kernel, +therefore it's quite hard to track such changes. Thus, if during +compilation for some vendor kernel your compiler complains about +redefinition of some symbol, you should either switch to vanilla kernel, +or change as necessary the corresponding to that symbol "#if +LINUX_VERSION_CODE" statement. + If during compilation you see message like "*** No rule to make target `xxx.h', needed by `yyy.o'. Stop.", then your autogenerated dependencies don't match your compiler configuration anymore. You should @@ -189,5 +199,7 @@ debugging * Tomasz Chmielewski <ma...@wp...> for testing and suggestions - + + * Bart Van Assche <bar...@gm...> for a lot of help + Vladislav Bolkhovitin <vs...@vl...>, http://scst.sourceforge.net Modified: trunk/iscsi-scst/kernel/config.c =================================================================== --- trunk/iscsi-scst/kernel/config.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/kernel/config.c 2008-05-31 12:05:02 UTC (rev 403) @@ -408,9 +408,27 @@ long err; u32 id; - if (cmd == REGISTER_USERD) { + switch (cmd) { + case ADD_TARGET: + case DEL_TARGET: + case ADD_SESSION: + case DEL_SESSION: + case GET_SESSION_INFO: + case ISCSI_PARAM_SET: + case ISCSI_PARAM_GET: + case ADD_CONN: + case DEL_CONN: + case GET_CONN_INFO: + break; + + case REGISTER_USERD: err = iscsi_check_version(arg); goto out; + + default: + PRINT_ERROR("Invalid ioctl cmd %x", cmd); + err = -EINVAL; + goto out; } if ((err = get_user(id, (u32 *) arg)) != 0) @@ -440,7 +458,7 @@ } if (!target) { - PRINT_ERROR("can't find the target %u", id); + PRINT_ERROR("Can't find the target %u", id); err = -EINVAL; goto out_unlock; } @@ -481,8 +499,7 @@ break; default: - PRINT_ERROR("invalid ioctl cmd %x", cmd); - err = -EINVAL; + sBUG(); break; } Modified: trunk/iscsi-scst/kernel/iscsi.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi.h 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/kernel/iscsi.h 2008-05-31 12:05:02 UTC (rev 403) @@ -467,7 +467,9 @@ { TRACE_DBG("cmnd %p, new ref_cnt %d", cmnd, atomic_read(&cmnd->ref_cnt)-1); - sBUG_ON(atomic_read(&cmnd->ref_cnt) == 0); + + EXTRACHECKS_BUG_ON(atomic_read(&cmnd->ref_cnt) == 0); + if (atomic_dec_and_test(&cmnd->ref_cnt)) cmnd_done(cmnd); } Modified: trunk/iscsi-scst/kernel/target.c =================================================================== --- trunk/iscsi-scst/kernel/target.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/kernel/target.c 2008-05-31 12:05:02 UTC (rev 403) @@ -119,6 +119,7 @@ target->scst_tgt = scst_register(&iscsi_template, target->name); if (!target->scst_tgt) { PRINT_ERROR("%s", "scst_register() failed"); + err = -EBUSY; goto out_free; } Modified: trunk/iscsi-scst/usr/ctldev.c =================================================================== --- trunk/iscsi-scst/usr/ctldev.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/usr/ctldev.c 2008-05-31 12:05:02 UTC (rev 403) @@ -83,6 +83,7 @@ } reg.version = (uintptr_t)ISCSI_SCST_INTERFACE_VERSION; + err = ioctl(ctlfd, REGISTER_USERD, ®); if (err < 0) { log_error("Unable to register: %s. Incompatible version of the " Modified: trunk/iscsi-scst/usr/iscsid.c =================================================================== --- trunk/iscsi-scst/usr/iscsid.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/iscsi-scst/usr/iscsid.c 2008-05-31 12:05:02 UTC (rev 403) @@ -109,7 +109,16 @@ conn->rsp.data = conn->rsp_buffer; } if (conn->rsp.datasize + len > INCOMING_BUFSIZE) { - log_warning("Dropping key (%s=%s)", key, value); + /* ToDo: multi-PDU replies */ + log_warning("Dropping key (%s=%s) due to INCOMING_BUFSIZE " + "limit %d and because only single PDU replies during " + "discovery session are implemented. If you have " + "a lot of targets, you can increase INCOMING_BUFSIZE, " + "but, since it will be against iSCSI RFC required " + "not-negotiated PDU limit, not all initiators might " + "work with it. Alternatively, you can decrease names " + "of your targets so they will fit to INCOMING_BUFSIZE " + "limit", key, value, INCOMING_BUFSIZE); return; } Modified: trunk/qla2x00t/qla2x00-target/README =================================================================== --- trunk/qla2x00t/qla2x00-target/README 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/qla2x00t/qla2x00-target/README 2008-05-31 12:05:02 UTC (rev 403) @@ -15,9 +15,7 @@ This version is compatible with SCST version 0.9.5 and higher. -Tested on stable kernels from http://www.kernel.org. The original -initiator driver was taken from kernel version 2.6.17.8, but it should -also work on other versions, including 2.6.18.x and 2.6.16.x. +The original initiator driver was taken from the kernel 2.6.17.8. See also "ToDo" file for list of known issues and unimplemented features. @@ -25,6 +23,16 @@ Installation ------------ +Only vanilla kernels from kernel.org are supported, but it should work +on vendors' kernels, if you manage to successfully compile on them. The +main problem with vendor's kernels is that they often contain patches, +which will appear only in the next version of the vanilla kernel, +therefore it's quite hard to track such changes. Thus, if during +compilation for some vendor kernel your compiler complains about +redefinition of some symbol, you should either switch to vanilla kernel, +or change as necessary the corresponding to that symbol "#if +LINUX_VERSION_CODE" statement. + At first, make sure that the link "/lib/modules/`you_kernel_version`/build" points to the source code for your currently running kernel. Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/README 2008-05-31 12:05:02 UTC (rev 403) @@ -42,11 +42,19 @@ This is quite stable (but still beta) version. -Tested mostly on "vanilla" 2.6.21.1 kernel from kernel.org. - Installation ------------ +Only vanilla kernels from kernel.org are supported, but it should work +on vendors' kernels, if you manage to successfully compile on them. The +main problem with vendor's kernels is that they often contain patches, +which will appear only in the next version of the vanilla kernel, +therefore it's quite hard to track such changes. Thus, if during +compilation for some vendor kernel your compiler complains about +redefinition of some symbol, you should either switch to vanilla kernel, +or change as necessary the corresponding to that symbol "#if +LINUX_VERSION_CODE" statement. + At first, make sure that the link "/lib/modules/`you_kernel_version`/build" points to the source code for your currently running kernel. @@ -476,10 +484,24 @@ CAUTION: If you partitioned/formatted your device with block size X, *NEVER* ======== ever try to export and then mount it (even accidentally) with another block size. Otherwise you can *instantly* damage it pretty - badly as well as all your data on it. Messages on initiator like: - "attempt to access beyond end of device" is the sign of such - damage. + badly as well as all your data on it. Messages on initiator + like: "attempt to access beyond end of device" is the sign of + such damage. + Moreover, if you want to compare how well different block sizes + work for you, you **MUST** EVERY TIME AFTER CHANGING BLOCK SIZE + **COMPLETELY** **WIPE OFF** ALL THE DATA FROM THE DEVICE. In + other words, THE **WHOLE** DEVICE **MUST** HAVE ONLY **ZEROES** + AS THE DATA AFTER YOU SWITCH TO NEW BLOCK SIZE. Switching block + sizes isn't like switching between FILEIO and BLOCKIO, after + changing block size all previously written with another block + size data MUST BE ERASED. Otherwise you will have a full set of + very weird behaviors, because blocks addressing will be + changed, but initiators in most cases will not have a + possibility to detect that old addresses written on the device + in, e.g., partition table, don't refer anymore to what they are + intended to refer. + IMPORTANT: By default for performance reasons VDISK FILEIO devices use write ========= back caching policy. This is generally safe from the consistence of journaled file systems, laying over them, point of view, but @@ -835,4 +857,6 @@ * Jianxi Chen <pa...@us...> for fixing problem with devices >2TB in size + * Bart Van Assche <bar...@gm...> for a lot of help + Vladislav Bolkhovitin <vs...@vl...>, http://scst.sourceforge.net Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/include/scst.h 2008-05-31 12:05:02 UTC (rev 403) @@ -289,12 +289,6 @@ */ #define SCST_EXEC_NEED_THREAD 2 -/************************************************************* - ** Default timeout for cmd's CDB execution - ** by SCSI mid-level (cmd's "timeout" field). - *************************************************************/ -#define SCST_DEFAULT_TIMEOUT (30*HZ) - /* * Set if cmd is finished and there is status/sense to be sent. * The status should be not sent (i.e. the flag not set) if the @@ -334,11 +328,8 @@ /* Set if session is initialized and ready */ #define SCST_SESS_SPH_READY 0 -/* Set if session is on calling pre_unreg_sess() phase */ -#define SCST_SESS_SPH_PRE_UNREG 1 - /* Set if session is shutting down */ -#define SCST_SESS_SPH_SHUTDOWN 2 +#define SCST_SESS_SPH_SHUTDOWN 1 /************************************************************* ** Cmd's async (atomic) flags @@ -384,6 +375,11 @@ #define SCST_PROC_ENTRY_NAME "scsi_tgt" /************************************************************* + ** Activities suspending timeout + *************************************************************/ +#define SCST_SUSPENDING_TIMEOUT (90 * HZ) + +/************************************************************* ** Kernel cache creation helper *************************************************************/ #ifndef KMEM_CACHE @@ -773,7 +769,7 @@ * - SCST_MGMT_STATUS_SUCCESS - the command is done with success, * no firther actions required * - The SCST_MGMT_STATUS_* error code if the command is failed and - * no firther actions required + * no further actions required * - SCST_DEV_TM_NOT_COMPLETED - regular standard actions for the command * should be done * @@ -797,15 +793,6 @@ */ int (*attach_tgt) (struct scst_tgt_dev *tgt_dev); - /* - * Called when a session, corresponding to a tgt_dev, is about to be - * unregistered and the tgt_dev - detached. Supposed to be used to - * clean out "stalled" commands, which otherwise could prevent SCST - * from entering into the suspended activity state and, so, - * unregistering the device. - */ - void (*pre_unreg_sess) (struct scst_tgt_dev *tgt_dev); - /* Called when tgt_dev (session) is detaching from the dev handler */ void (*detach_tgt) (struct scst_tgt_dev *tgt_dev); @@ -1172,7 +1159,7 @@ enum scst_cmd_queue_type queue_type; - int timeout; /* CDB execution timeout */ + int timeout; /* CDB execution timeout in seconds */ int retries; /* Amount of retries that will be done by SCSI mid-level */ /* SCSI data direction, one of SCST_DATA_* constants */ @@ -1226,6 +1213,9 @@ */ int orig_sg_cnt, orig_sg_entry, orig_entry_len; + /* Used to retry commands in case of double UA */ + int dbl_ua_orig_resp_data_len, dbl_ua_orig_data_direction; + /* List corresponding mgmt cmd, if any, protected by sess_list_lock */ struct list_head mgmt_cmd_list; @@ -2302,22 +2292,30 @@ mcmd->tgt_priv = val; } -/* - * Returns mgmt cmd's completition status (SCST_MGMT_STATUS_* constants) - */ +/* Returns mgmt cmd's completition status (SCST_MGMT_STATUS_* constants) */ static inline int scst_mgmt_cmd_get_status(struct scst_mgmt_cmd *mcmd) { return mcmd->status; } -/* - * Returns mgmt cmd's TM fn - */ +/* Returns mgmt cmd's TM fn */ static inline int scst_mgmt_cmd_get_fn(struct scst_mgmt_cmd *mcmd) { return mcmd->fn; } +/* + * Called by dev handler's task_mgmt_fn() to notify SCST core that mcmd + * is going to complete asynchronously. + */ +void scst_prepare_async_mcmd(struct scst_mgmt_cmd *mcmd); + +/* + * Called by dev handler to notify SCST core that async. mcmd is completed + * with status "status". + */ +void scst_async_mcmd_completed(struct scst_mgmt_cmd *mcmd, int status); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) static inline struct page *sg_page(struct scatterlist *sg) @@ -2450,11 +2448,16 @@ /* * Suspends and resumes any activity. - * scst_suspend_activity() doesn't return until there are any - * active commands (state after SCST_CMD_STATE_INIT). New arriving - * commands stay in that state until scst_resume_activity() is called. + * Function scst_suspend_activity() doesn't return 0, until there are any + * active commands (state after SCST_CMD_STATE_INIT). If "interruptible" + * is true, it returns after SCST_SUSPENDING_TIMEOUT or if it was interrupted + * by a signal with the coresponding error status < 0. If "interruptible" + * is false, it will wait virtually forever. + * + * New arriving commands stay in that state until scst_resume_activity() + * is called. */ -void scst_suspend_activity(void); +int scst_suspend_activity(bool interruptible); void scst_resume_activity(void); /* Modified: trunk/scst/include/scst_const.h =================================================================== --- trunk/scst/include/scst_const.h 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/include/scst_const.h 2008-05-31 12:05:02 UTC (rev 403) @@ -280,4 +280,36 @@ #define POSITION_LEN_SHORT 20 #define POSITION_LEN_LONG 32 +/************************************************************* + ** Various timeouts + *************************************************************/ +#define SCST_DEFAULT_TIMEOUT (60 * HZ) + +#define SCST_GENERIC_CHANGER_TIMEOUT (3 * HZ) +#define SCST_GENERIC_CHANGER_LONG_TIMEOUT (14000 * HZ) + +#define SCST_GENERIC_PROCESSOR_TIMEOUT (3 * HZ) +#define SCST_GENERIC_PROCESSOR_LONG_TIMEOUT (14000 * HZ) + +#define SCST_GENERIC_TAPE_SMALL_TIMEOUT (3 * HZ) +#define SCST_GENERIC_TAPE_REG_TIMEOUT (900 * HZ) +#define SCST_GENERIC_TAPE_LONG_TIMEOUT (14000 * HZ) + +#define SCST_GENERIC_MODISK_SMALL_TIMEOUT (3 * HZ) +#define SCST_GENERIC_MODISK_REG_TIMEOUT (900 * HZ) +#define SCST_GENERIC_MODISK_LONG_TIMEOUT (14000 * HZ) + +#define SCST_GENERIC_DISK_SMALL_TIMEOUT (3 * HZ) +#define SCST_GENERIC_DISK_REG_TIMEOUT (60 * HZ) +#define SCST_GENERIC_DISK_LONG_TIMEOUT (3600 * HZ) + +#define SCST_GENERIC_RAID_TIMEOUT (3 * HZ) +#define SCST_GENERIC_RAID_LONG_TIMEOUT (14000 * HZ) + +#define SCST_GENERIC_CDROM_SMALL_TIMEOUT (3 * HZ) +#define SCST_GENERIC_CDROM_REG_TIMEOUT (900 * HZ) +#define SCST_GENERIC_CDROM_LONG_TIMEOUT (14000 * HZ) + +#define SCST_MAX_OTHER_TIMEOUT (14000 * HZ) + #endif /* __SCST_CONST_H */ Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/include/scst_debug.h 2008-05-31 12:05:02 UTC (rev 403) @@ -242,6 +242,15 @@ PRINT(NO_FLAG, "%s" format, __tflag, args); \ } while (0) +#define PRINT_WARNING(format, args...) \ +do { \ + if (strcmp(INFO_FLAG, LOG_FLAG)) \ + { \ + PRINT_LOG_FLAG(LOG_FLAG, "***WARNING*** " format, args); \ + } \ + PRINT_LOG_FLAG(INFO_FLAG, "***WARNING*** " format, args); \ +} while (0) + #define PRINT_ERROR(format, args...) \ do { \ if (strcmp(ERROR_FLAG, LOG_FLAG)) { \ @@ -341,6 +350,12 @@ PRINT(INFO_FLAG, "%s: " format, LOG_PREFIX, args); \ } while (0) +#define PRINT_WARNING(format, args...) \ +do { \ + PRINT(INFO_FLAG, "%s: ***WARNING*** " \ + format, LOG_PREFIX, args); \ +} while (0) + #define PRINT_ERROR(format, args...) \ do { \ PRINT(ERROR_FLAG, "%s: ***ERROR*** " \ @@ -360,6 +375,12 @@ PRINT(INFO_FLAG, format, args); \ } while (0) +#define PRINT_WARNING(format, args...) \ +do { \ + PRINT(INFO_FLAG, "***WARNING*** " \ + format, args); \ +} while (0) + #define PRINT_ERROR(format, args...) \ do { \ PRINT(ERROR_FLAG, "***ERROR*** " \ Modified: trunk/scst/include/scst_user.h =================================================================== --- trunk/scst/include/scst_user.h 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/include/scst_user.h 2008-05-31 12:05:02 UTC (rev 403) @@ -49,10 +49,6 @@ #define SCST_USER_MEM_REUSE_ALL 3 #define SCST_USER_MAX_MEM_REUSE_OPT SCST_USER_MEM_REUSE_ALL -#define SCST_USER_PRIO_QUEUE_SINGLE 0 -#define SCST_USER_PRIO_QUEUE_SEPARATE 1 -#define SCST_USER_MAX_PRIO_QUEUE_OPT SCST_USER_PRIO_QUEUE_SEPARATE - #define SCST_USER_PARTIAL_TRANSFERS_NOT_SUPPORTED 0 #define SCST_USER_PARTIAL_TRANSFERS_SUPPORTED_ORDERED 1 #define SCST_USER_PARTIAL_TRANSFERS_SUPPORTED 2 @@ -77,20 +73,10 @@ #define UCMD_STATE_ATTACH_SESS 0x20 #define UCMD_STATE_DETACH_SESS 0x21 -/* Must be changed under cmd_lists.cmd_list_lock */ -#define UCMD_STATE_SENT_MASK 0x10000 -#define UCMD_STATE_RECV_MASK 0x20000 -#define UCMD_STATE_JAMMED_MASK 0x40000 - -#define UCMD_STATE_MASK (UCMD_STATE_SENT_MASK | \ - UCMD_STATE_RECV_MASK | \ - UCMD_STATE_JAMMED_MASK) - struct scst_user_opt { uint8_t parse_type; uint8_t on_free_cmd_type; uint8_t memory_reuse_type; - uint8_t prio_queue_type; uint8_t partial_transfers_type; int32_t partial_len; @@ -125,7 +111,7 @@ uint8_t cdb[SCST_MAX_CDB_SIZE]; int32_t cdb_len; - uint32_t timeout; + int32_t timeout; int32_t bufflen; uint8_t queue_type; @@ -165,7 +151,7 @@ uint8_t queue_type; uint8_t data_direction; uint8_t partial; - uint32_t timeout; + int32_t timeout; uint32_t sn; @@ -249,8 +235,7 @@ #define SCST_USER_SET_OPTIONS _IOW('u', 3, struct scst_user_opt) #define SCST_USER_GET_OPTIONS _IOR('u', 4, struct scst_user_opt) #define SCST_USER_REPLY_AND_GET_CMD _IOWR('u', 5, struct scst_user_get_cmd) -#define SCST_USER_REPLY_AND_GET_PRIO_CMD _IOWR('u', 6, struct scst_user_get_cmd) -#define SCST_USER_REPLY_CMD _IOW('u', 7, struct scst_user_reply_cmd) +#define SCST_USER_REPLY_CMD _IOW('u', 6, struct scst_user_reply_cmd) /* Values for scst_user_get_cmd.subcode */ #define SCST_USER_ATTACH_SESS _IOR('s', UCMD_STATE_ATTACH_SESS, struct scst_user_sess) Modified: trunk/scst/src/dev_handlers/scst_cdrom.c =================================================================== --- trunk/scst/src/dev_handlers/scst_cdrom.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_cdrom.c 2008-05-31 12:05:02 UTC (rev 403) @@ -38,10 +38,6 @@ .dev_done = cdrom_done, \ } -#define CDROM_SMALL_TIMEOUT (3 * HZ) -#define CDROM_REG_TIMEOUT (900 * HZ) -#define CDROM_LONG_TIMEOUT (14000 * HZ) - #define CDROM_DEF_BLOCK_SHIFT 11 struct cdrom_params { @@ -114,7 +110,7 @@ TRACE_DBG("%s", "Doing READ_CAPACITY"); res = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sbuff, - CDROM_REG_TIMEOUT, 3, 0); + SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", res); @@ -218,13 +214,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0) - cmd->timeout = CDROM_REG_TIMEOUT; - else if (cmd->op_flags & SCST_SMALL_TIMEOUT) - cmd->timeout = CDROM_SMALL_TIMEOUT; - else if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = CDROM_LONG_TIMEOUT; - return res; } Modified: trunk/scst/src/dev_handlers/scst_changer.c =================================================================== --- trunk/scst/src/dev_handlers/scst_changer.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_changer.c 2008-05-31 12:05:02 UTC (rev 403) @@ -38,8 +38,6 @@ } #define CHANGER_RETRIES 2 -#define CHANGER_TIMEOUT (3 * HZ) -#define CHANGER_LONG_TIMEOUT (14000 * HZ) #define READ_CAP_LEN 8 int changer_attach(struct scst_device *); @@ -85,8 +83,8 @@ retries = SCST_DEV_UA_RETRIES; do { TRACE_DBG("%s", "Doing TEST_UNIT_READY"); - res = scsi_test_unit_ready(dev->scsi_dev, CHANGER_TIMEOUT, - CHANGER_RETRIES + res = scsi_test_unit_ready(dev->scsi_dev, + SCST_GENERIC_CHANGER_TIMEOUT, CHANGER_RETRIES #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) ); #else @@ -149,11 +147,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = CHANGER_LONG_TIMEOUT; - else - cmd->timeout = CHANGER_TIMEOUT; - return res; } Modified: trunk/scst/src/dev_handlers/scst_disk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_disk.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_disk.c 2008-05-31 12:05:02 UTC (rev 403) @@ -57,10 +57,6 @@ .exec = disk_exec, \ } -#define DISK_SMALL_TIMEOUT (3 * HZ) -#define DISK_REG_TIMEOUT (60 * HZ) -#define DISK_LONG_TIMEOUT (3600 * HZ) - #define DISK_DEF_BLOCK_SHIFT 9 struct disk_params { @@ -190,7 +186,7 @@ TRACE_DBG("%s", "Doing READ_CAPACITY"); res = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sbuff, - DISK_REG_TIMEOUT, 3, 0); + SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", res); @@ -291,13 +287,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0) - cmd->timeout = DISK_REG_TIMEOUT; - else if (cmd->op_flags & SCST_SMALL_TIMEOUT) - cmd->timeout = DISK_SMALL_TIMEOUT; - else if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = DISK_LONG_TIMEOUT; - return res; } Modified: trunk/scst/src/dev_handlers/scst_modisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_modisk.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_modisk.c 2008-05-31 12:05:02 UTC (rev 403) @@ -57,10 +57,6 @@ .exec = modisk_exec, \ } -#define MODISK_SMALL_TIMEOUT (3 * HZ) -#define MODISK_REG_TIMEOUT (900 * HZ) -#define MODISK_LONG_TIMEOUT (14000 * HZ) - #define MODISK_DEF_BLOCK_SHIFT 10 struct modisk_params { @@ -201,7 +197,7 @@ TRACE_DBG("%s", "Doing READ_CAPACITY"); res = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sbuff, - MODISK_REG_TIMEOUT, 3, 0); + SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", res); @@ -308,13 +304,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0) - cmd->timeout = MODISK_REG_TIMEOUT; - else if (cmd->op_flags & SCST_SMALL_TIMEOUT) - cmd->timeout = MODISK_SMALL_TIMEOUT; - else if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = MODISK_LONG_TIMEOUT; - return res; } Modified: trunk/scst/src/dev_handlers/scst_processor.c =================================================================== --- trunk/scst/src/dev_handlers/scst_processor.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_processor.c 2008-05-31 12:05:02 UTC (rev 403) @@ -38,8 +38,6 @@ } #define PROCESSOR_RETRIES 2 -#define PROCESSOR_TIMEOUT (3 * HZ) -#define PROCESSOR_LONG_TIMEOUT (14000 * HZ) #define READ_CAP_LEN 8 int processor_attach(struct scst_device *); @@ -85,8 +83,8 @@ retries = SCST_DEV_UA_RETRIES; do { TRACE_DBG("%s", "Doing TEST_UNIT_READY"); - res = scsi_test_unit_ready(dev->scsi_dev, PROCESSOR_TIMEOUT, - PROCESSOR_RETRIES + res = scsi_test_unit_ready(dev->scsi_dev, + SCST_GENERIC_PROCESSOR_TIMEOUT, PROCESSOR_RETRIES #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) ); #else @@ -149,10 +147,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = PROCESSOR_LONG_TIMEOUT; - else - cmd->timeout = PROCESSOR_TIMEOUT; return res; } Modified: trunk/scst/src/dev_handlers/scst_raid.c =================================================================== --- trunk/scst/src/dev_handlers/scst_raid.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_raid.c 2008-05-31 12:05:02 UTC (rev 403) @@ -38,8 +38,6 @@ } #define RAID_RETRIES 2 -#define RAID_TIMEOUT (3 * HZ) -#define RAID_LONG_TIMEOUT (14000 * HZ) #define READ_CAP_LEN 8 int raid_attach(struct scst_device *); @@ -85,8 +83,8 @@ retries = SCST_DEV_UA_RETRIES; do { TRACE_DBG("%s", "Doing TEST_UNIT_READY"); - res = scsi_test_unit_ready(dev->scsi_dev, RAID_TIMEOUT, - RAID_RETRIES + res = scsi_test_unit_ready(dev->scsi_dev, + SCST_GENERIC_RAID_TIMEOUT, RAID_RETRIES #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) ); #else @@ -149,10 +147,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = RAID_LONG_TIMEOUT; - else - cmd->timeout = RAID_TIMEOUT; return res; } Modified: trunk/scst/src/dev_handlers/scst_tape.c =================================================================== --- trunk/scst/src/dev_handlers/scst_tape.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_tape.c 2008-05-31 12:05:02 UTC (rev 403) @@ -59,10 +59,6 @@ #define TAPE_RETRIES 2 -#define TAPE_SMALL_TIMEOUT (3 * HZ) -#define TAPE_REG_TIMEOUT (900 * HZ) -#define TAPE_LONG_TIMEOUT (14000 * HZ) - #define TAPE_DEF_BLOCK_SIZE 512 /* The fixed bit in READ/WRITE/VERIFY */ @@ -181,8 +177,8 @@ retries = SCST_DEV_UA_RETRIES; do { TRACE_DBG("%s", "Doing TEST_UNIT_READY"); - res = scsi_test_unit_ready(dev->scsi_dev, TAPE_SMALL_TIMEOUT, - TAPE_RETRIES + res = scsi_test_unit_ready(dev->scsi_dev, + SCST_GENERIC_TAPE_SMALL_TIMEOUT, TAPE_RETRIES #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) ); #else @@ -201,7 +197,7 @@ ((dev->scsi_dev->lun << 5) & 0xe0) : 0), 0 /* Mode Page 0 */, buffer, buffer_size, - TAPE_SMALL_TIMEOUT, TAPE_RETRIES, + SCST_GENERIC_TAPE_SMALL_TIMEOUT, TAPE_RETRIES, &data, NULL); TRACE_DBG("MODE_SENSE done: %x", res); @@ -301,13 +297,6 @@ cmd->retries = SCST_PASSTHROUGH_RETRIES; - if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0) - cmd->timeout = TAPE_REG_TIMEOUT; - else if (cmd->op_flags & SCST_SMALL_TIMEOUT) - cmd->timeout = TAPE_SMALL_TIMEOUT; - else if (cmd->op_flags & SCST_LONG_TIMEOUT) - cmd->timeout = TAPE_LONG_TIMEOUT; - return res; } Modified: trunk/scst/src/dev_handlers/scst_user.c =================================================================== --- trunk/scst/src/dev_handlers/scst_user.c 2008-05-29 17:24:18 UTC (rev 402) +++ trunk/scst/src/dev_handlers/scst_user.c 2008-05-31 12:05:02 UTC (rev 403) @@ -34,38 +34,29 @@ #endif #define DEV_USER_MAJOR 237 + #define DEV_USER_CMD_HASH_ORDER 6 -#define DEV_USER_TM_TIMEOUT (10*HZ) + #define DEV_USER_ATTACH_TIMEOUT (5*HZ) -#define DEV_USER_DETACH_TIMEOUT (5*HZ) -#define DEV_USER_PRE_UNREG_POLL_TIME (HZ/10) struct scst_user_dev { struct rw_semaphore dev_rwsem; struct scst_cmd_lists cmd_lists; - /* All 3 protected by cmd_lists.cmd_list_lock */ + + /* Protected by cmd_lists.cmd_list_lock */ struct list_head ready_cmd_list; - struct list_head prio_ready_cmd_list; - wait_queue_head_t prio_cmd_list_waitQ; - /* All, including detach_cmd_count, protected by cmd_lists.cmd_list_lock */ - unsigned short blocking:1; - unsigned short cleaning:1; - unsigned short cleanup_done:1; - unsigned short attach_cmd_active:1; - unsigned short tm_cmd_active:1; - unsigned short internal_reset_active:1; - unsigned short pre_unreg_sess_active:1; /* just a small optimization */ + /* Protected by dev_rwsem or don't need any protection */ + unsigned int blocking:1; + unsigned int cleanup_done:1; + unsigned int cleaning:1; + unsigned int tst:3; + unsigned int queue_alg:4; + unsigned int tas:1; + unsigned int swp:1; + unsigned int has_own_order_mgmt:1; - unsigned short tst:3; - unsigned short queue_alg:4; - unsigned short tas:1; - unsigned short swp:1; - unsigned short has_own_order_mgmt:1; - - unsigned short detach_cmd_count; - int (*generic_parse)(struct scst_cmd *cmd, int (*get_block)(struct scst_cmd *cmd)); @@ -77,7 +68,6 @@ uint8_t parse_type; uint8_t on_free_cmd_type; uint8_t memory_reuse_type; - uint8_t prio_queue_type; uint8_t partial_transfers_type; uint32_t partial_len; @@ -85,7 +75,7 @@ /* Both protected by cmd_lists.cmd_list_lock */ unsigned int handle_counter; - struct list_head ucmd_hash[1<<DEV_USER_CMD_HASH_ORDER]; + struct list_head ucmd_hash[1 << DEV_USER_CMD_HASH_ORDER]; struct scst_device *sdev; @@ -93,25 +83,13 @@ struct list_head dev_list_entry; char name[SCST_MAX_NAME]; - /* Protected by cmd_lists.cmd_list_lock */ - struct list_head pre_unreg_sess_list; - + /* Protected by cleanup_lock */ + unsigned char in_cleanup_list:1; struct list_head cleanup_list_entry; + /* ToDo: make it on-stack */ struct completion cleanup_cmpl; }; -struct scst_user_pre_unreg_sess_obj { - struct scst_tgt_dev *tgt_dev; - unsigned int active:1; - unsigned int exit:1; - struct list_head pre_unreg_sess_list_entry; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - struct work_struct pre_unreg_sess_work; -#else - struct delayed_work pre_unreg_sess_work; -#endif -}; - /* Most fields are unprotected, since only one thread at time can access them */ struct scst_user_cmd { struct scst_cmd *cmd; @@ -122,7 +100,6 @@ unsigned int buff_cached:1; unsigned int buf_dirty:1; unsigned int background_exec:1; - unsigned int internal_reset_tm:1; unsigned int aborted:1; struct scst_user_cmd *buf_ucmd; @@ -134,6 +111,15 @@ struct page **data_pages; struct sgv_pool_obj *sgv; + /* + * Special flags, which can be accessed asynchronously (hence "long"). + * Protected by cmd_lists.cmd_list_lock. + */ + unsigned long sent_to_user:1; + unsigned long jammed:1; + unsigned long this_state_unjammed:1; + unsigned long seen_by_user:1; /* here only as a small optimization */ + unsigned int state; struct list_head ready_cmd_list_entry; @@ -143,7 +129,11 @@ struct scst_user_get_cmd user_cmd; - struct completion *cmpl; + /* cmpl used only by ATTACH_SESS, mcmd used only by TM */ + union { + struct completion *cmpl; + struct scst_mgmt_cmd *mcmd; + }; int result; }; @@ -169,9 +159,9 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, unsigned long *flags); -static void dev_user_unjam_dev(struct scst_user_dev *dev, int tm, - struct scst_tgt_dev *tgt_dev); +static void dev_user_unjam_dev(struct scst_user_dev *dev); +static int dev_user_process_reply_on_free(struct scst_user_cmd *ucmd); static int dev_user_process_reply_tm_exec(struct scst_user_cmd *ucmd, int status); static int dev_user_process_reply_sess(struct scst_user_cmd *ucmd, int status); @@ -212,17 +202,54 @@ static DECLARE_WAIT_QUEUE_HEAD(cleanup_list_waitQ); static struct task_struct *cleanup_thread; -static inline void ucmd_get(struct scst_user_cmd *ucmd, int barrier) +/* + * Skip this command if result is not 0. Must be called under + * cmd_lists.cmd_list_lock and IRQ off. + */ +static inline bool ucmd_get_check(struct scst_user_cmd *ucmd) { + int r = atomic_inc_return(&ucmd->ucmd_ref); + int res; + if (unlikely(r == 1)) { + TRACE_DBG("ucmd %p is being destroyed", ucmd); + atomic_dec(&ucmd->ucmd_ref); + res = true; + /* + * Necessary code is serialized by cmd_list_lock in + * cmd_remove_hash() + */ + } else { + TRACE_DBG("ucmd %p, new ref_cnt %d", ucmd, + atomic_read(&ucmd->ucmd_ref)); + res = false; + } + return res; +} + +static inline void __ucmd_get(struct scst_user_cmd *ucmd, bool barrier) +{ TRACE_DBG("ucmd %p, ucmd_ref %d", ucmd, atomic_read(&ucmd->ucmd_ref)); atomic_inc(&ucmd->ucmd_ref); if (barrier) smp_mb__after_atomic_inc(); } +static inline void ucmd_get_ordered(struct scst_user_cmd *ucmd) +{ + __ucmd_get(ucmd, true); +} + +static inline void ucmd_get(struct scst_user_cmd *ucmd) +{ + __ucmd_get(ucmd, false); +} + static inline void ucmd_put(struct scst_user_cmd *ucmd) { TRACE_DBG("ucmd %p, ucmd_ref %d", ucmd, atomic_read(&ucmd->ucmd_ref)); + + EXTRACHECKS_BUG_ON(atomic_read(&ucmd->ucmd_ref) == 0); + if (atomic_dec_and_test(&ucmd->ucmd_ref)) dev_user_free_ucmd(ucmd); } @@ -298,6 +325,7 @@ static inline void cmd_remove_hash(struct scst_user_cmd *ucmd) { unsigned long flags; + spin_lock_irqsave(&ucmd->dev->cmd_lists.cmd_list_lock, flags); list_del(&ucmd->hash_list_entry); spin_unlock_irqrestore(&ucmd->dev->cmd_lists.cmd_list_lock, flags); @@ -338,7 +366,7 @@ TRACE_MEM("ucmd->first_page_offset %d", ucmd->first_page_offset); offset = ucmd->first_page_offset; - ucmd_get(ucmd, 0); + ucmd_get(ucmd); } if (ucmd->cur_data_page >= ucmd->num_data_pages) @@ -393,6 +421,7 @@ page_cache_release(page); } + kfree(ucmd->data_pages); ucmd->data_pages = NULL; @@ -532,7 +561,7 @@ sBUG_ON(ucmd->sgv != NULL); res = -1; } else { - switch (ucmd->state & ~UCMD_STATE_MASK) { + switch (ucmd->state) { case UCMD_STATE_BUF_ALLOCING: res = 1; break; @@ -711,7 +740,7 @@ min(sizeof(ucmd->user_cmd.parse_cmd.cdb), sizeof(cmd->cdb))); ucmd->user_cmd.parse_cmd.cdb_len = cmd->cdb_len; - ucmd->user_cmd.parse_cmd.timeout = cmd->timeout; + ucmd->user_cmd.parse_cmd.timeout = cmd->timeout / HZ; ucmd->user_cmd.parse_cmd.bufflen = cmd->bufflen; ucmd->user_cmd.parse_cmd.queue_type = cmd->queue_type; ucmd->user_cmd.parse_cmd.data_direction = cmd->data_direction; @@ -821,7 +850,7 @@ ucmd->user_cmd.exec_cmd.queue_type = cmd->queue_type; ucmd->user_cmd.exec_cmd.data_direction = cmd->data_direction; ucmd->user_cmd.exec_cmd.partial = 0; - ucmd->user_cmd.exec_cmd.timeout = cmd->timeout; + ucmd->user_cmd.exec_cmd.timeout = cmd->timeout / HZ; ucmd->user_cmd.exec_cmd.sn = cmd->tgt_sn; ucmd->state = UCMD_STATE_EXECING; @@ -839,7 +868,7 @@ ucmd->sgv = NULL; } else if (ucmd->data_pages != NULL) { /* We mapped pages, but for some reason didn't allocate them */ - ucmd_get(ucmd, 0); + ucmd_get(ucmd); __dev_user_free_sg_entries(ucmd); } return; @@ -864,11 +893,15 @@ if (ucmd->dev->on_free_cmd_type == SCST_USER_ON_FREE_CMD_IGNORE) { ucmd->state = UCMD_STATE_ON_FREE_SKIPPED; /* The state assignment must be before freeing sgv! */ - dev_user_free_sgv(ucmd); - ucmd_put(ucmd); - goto out; + goto out_reply; } + if (unlikely(!ucmd->seen_by_user)) { + TRACE_MGMT_DBG("Not seen by user ucmd %p", ucmd); + sBUG_ON((ucmd->sgv != NULL) || (ucmd->data_pages != NULL)); + goto out_reply; + } + ucmd->user_cmd.cmd_h = ucmd->h; ucmd->user_cmd.subcode = SCST_USER_ON_FREE_CMD; @@ -886,6 +919,10 @@ out: TRACE_EXIT(); return; + +out_reply: + dev_user_process_reply_on_free(ucmd); + goto out; } static void dev_user_set_block(struct scst_cmd *cmd, int block) @@ -940,68 +977,37 @@ if (ucmd->cmd) do_wake |= ucmd->cmd->preprocessing_only; - EXTRACHECKS_BUG_ON(ucmd->state & UCMD_STATE_JAMMED_MASK); - spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, flags); - /* Hopefully, compiler will make it as a single test/jmp */ - if (unlikely(dev->attach_cmd_active || dev->tm_cmd_active || - dev->internal_reset_active || dev->pre_unreg_sess_active || - (dev->detach_cmd_count != 0))) { - switch (ucmd->state) { - case UCMD_STATE_PARSING: - case UCMD_STATE_BUF_ALLOCING: - case UCMD_STATE_EXECING: - if (dev->pre_unreg_sess_active && - !(dev->attach_cmd_active || dev->tm_cmd_active || - dev->internal_reset_active || - (dev->detach_cmd_count != 0))) { - struct scst_user_pre_unreg_sess_obj *p, *found = NULL; - list_for_each_entry(p, &dev->pre_unreg_sess_list, - pre_unreg_sess_list_entry) { - if (p->tgt_dev == ucmd->cmd->tgt_dev) { - if (p->active) - found = p; - break; - } - } - if (found == NULL) { - TRACE_MGMT_DBG("No pre unreg sess " - "active (ucmd %p)", ucmd); - break; - } else { - TRACE_MGMT_DBG("Pre unreg sess %p " - "active (ucmd %p)", found, ucmd); - } - } - TRACE(TRACE_MGMT, "Mgmt cmd active, returning BUSY for " - "ucmd %p", ucmd); - dev_user_unjam_cmd(ucmd, 1, &flags); - spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, flags); - goto out; - } - } + ucmd->this_state_unjammed = 0; - if (unlikely(ucmd->state == UCMD_STATE_TM_EXECING) || - unlikely(ucmd->state == UCMD_STATE_ATTACH_SESS) || - unlikely(ucmd->state == UCMD_STATE_DETACH_SESS)) { - if (dev->prio_queue_type == SCST_USER_PRIO_QUEUE_SEPARATE) { - TRACE_MGMT_DBG("Adding mgmt ucmd %p to prio ready cmd " - "list", ucmd); - list_add_tail(&ucmd->ready_cmd_list_entry, - &dev->prio_ready_cmd_list); - wake_up(&dev->prio_cmd_list_waitQ); - do_wake = 0; - } else { - TRACE_MGMT_DBG("Adding mgmt ucmd %p to ready cmd " - "list", ucmd); - list_add_tail(&ucmd->ready_cmd_list_entry, - &dev->ready_cmd_list); - do_wake = 1; - } + if ((ucmd->state == UCMD_STATE_PARSING) || + (ucmd->state == UCMD_STATE_BUF_ALLOCING)) { + /* + * If we don't put such commands in the queue head, then under + * high load we might delay threads, waiting for memory + * allocations, for too long and start loosing NOPs, which + * would lead to consider us by remote initiators as + * unresponsive and stuck => broken connections, etc. If none + * of our commands completed in NOP timeout to allow the head + * commands to go, then we are really overloaded and/or stuck. + */ + TRACE_DBG("Adding ucmd %p (state %d) to head of ready " + "cmd list", ucmd, ucmd->state); + list_add(&ucmd->ready_cmd_list_entry, + &dev->ready_cmd_list); + do_wake = 1; + } else if (unlikely(ucmd->state == UCMD_STATE_TM_EXECING) || + unlikely(ucmd->state == UCMD_STATE_ATTACH_SESS) || + unlikely(ucmd->state == UCMD_STATE_DETACH_SESS)) { + TRACE_MGMT_DBG("Adding mgmt ucmd %p (state %d) to head of " + "ready cmd list", ucmd, ucmd->state); + list_add(&ucmd->ready_cmd_list_entry, + &dev->ready_cmd_list); + do_wake = 1; } else if ((ucmd->cmd != NULL) && - unlikely((ucmd->cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE))) { - TRACE_DBG("Adding ucmd %p to head ready cmd list", ucmd); + unlikely((ucmd->cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE))) { + TRACE_DBG("Adding HQ ucmd %p to head of ready cmd list", ucmd); list_add(&ucmd->ready_cmd_list_entry, &dev->ready_cmd_list); } else { TRACE_DBG("Adding ucmd %p to ready cmd list", ucmd); @@ -1015,7 +1021,19 @@ spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, flags); -out: + smp_mb(); + if (unlikely(dev->cleaning)) { + spin_lock_irqsave(&cleanup_lock, flags); + if (!dev->in_cleanup_list) { + TRACE_DBG("Adding dev %p to the cleanup list (ucmd %p)", + dev, ucmd); + list_add_tail(&dev->cleanup_list_entry, &cleanup_list); + dev->in_cleanup_list = 1; + wake_up(&cleanup_list_waitQ); + } + spin_unlock_irqrestore(&cleanup_lock, flags); + } + TRACE_EXIT(); return; } @@ -1123,6 +1141,7 @@ out_hwerr: scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + ucmd->cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP; res = -EINVAL; goto out_process; } @@ -1169,8 +1188,11 @@ return res; out_inval: - PRINT_ERROR("%s", "Invalid parse_reply parameter(s)"); + PRINT_ERROR("Invalid parse_reply parameters (LUN %lld, op %x, cmd %p)", + (long long unsigned int)cmd->lun, cmd->cdb[0], cmd); + PRINT_BUFFER("Invalid parse_reply", reply, sizeof(*reply)); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP; res = -EINVAL; goto out_process; } @@ -1231,7 +1253,7 @@ if (unlikely((cmd->data_direction == SCST_DATA_READ) || (cmd->resp_data_len != 0))) goto out_inval; - ucmd_get(ucmd, 1); + ucmd_get_ordered(ucmd); ucmd->background_exec = 1; TRACE_DBG("Background ucmd %p", ucmd); goto out_compl; @@ -1298,7 +1320,9 @@ return res; out_inval: - PRINT_ERROR("%s", "Invalid exec_reply parameter(s)"); + PRINT_ERROR("Invalid exec_reply parameters (LUN %lld, op %x, cmd %p)", + (long long unsigned int)cmd->lun, cmd->cdb[0], cmd); + PRINT_BUFFER("Invalid exec_reply", reply, sizeof(*reply)); out_hwerr: res = -EINVAL; @@ -1329,39 +1353,44 @@ spin_lock_irq(&dev->cmd_lists.cmd_list_lock); ucmd = __ucmd_find_hash(dev, reply->cmd_h); - if (ucmd == NULL) { + if (unlikely(ucmd == NULL)) { TRACE_MGMT_DBG("cmd_h %d not found", reply->cmd_h); res = -ESRCH; goto out_unlock; } + if (unlikely(ucmd_get_check(ucmd))) { + TRACE_MGMT_DBG("Found being destroyed cmd_h %d", reply->cmd_h); + res = -ESRCH; + goto out_unlock; + } + if (ucmd->background_exec) { state = UCMD_STATE_EXECING; goto unlock_process; } - if (unlikely(!(ucmd->state & UCMD_STATE_SENT_MASK))) { - if (ucmd->state & UCMD_STATE_JAMMED_MASK) { - TRACE_MGMT_DBG("Reply on jammed ucmd %p, ignoring", - ucmd); - } else { - TRACE_MGMT_DBG("Ucmd %p isn't in the sent to user " - "state %x", ucmd, ucmd->state); - res = -EBUSY; - } - goto out_unlock; + if (unlikely(ucmd->this_state_unjammed)) { + TRACE_MGMT_DBG("Reply on unjammed ucmd %p, ignoring", + ucmd); + goto out_unlock_put; } + if (unlikely(!ucmd->sent_to_user)) { + TRACE_MGMT_DBG("Ucmd %p isn't in the sent to user " + "state %x", ucmd, ucmd->state); + res = -EINVAL; + goto out_unlock_put; + } + if (unlikely(reply->subcode != ucmd->user_cmd.subcode)) goto out_wrong_state; - if (unlikely(_IOC_NR(reply->subcode) != - (ucmd->state & ~UCMD_STATE_SENT_MASK))) + if (unlikely(_IOC_NR(reply->subcode) != ucmd->state)) goto out_wrong_state; - ucmd->state &= ~UCMD_STATE_SENT_MASK; state = ucmd->state; - ucmd->state |= UCMD_STATE_RECV_MASK; + ucmd->sent_to_user = 0; unlock_process: spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); @@ -1400,6 +1429,10 @@ sBUG(); break; } + +out_put: + ucmd_put(ucmd); + out: TRACE_EXIT_RES(res); return res; @@ -1412,6 +1445,10 @@ res = -EINVAL; dev_user_unjam_cmd(ucmd, 0, NULL); +out_unlock_put: + spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); + goto out_put; + out_unlock: spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); goto out; @@ -1498,13 +1535,17 @@ TRACE_DBG("Found ready ucmd %p", u); list_del(&u->ready_cmd_list_entry); - EXTRACHECKS_BUG_ON(u->state & UCMD_STATE_JAMMED_MASK); + EXTRACHECKS_BUG_ON(u->this_state_unjammed); if (u->cmd != NULL) { if (u->state == UCMD_STATE_EXECING) { struct scst_user_dev *dev = u->dev; int rc; + + EXTRACHECKS_BUG_ON(u->jammed); + spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); + rc = scst_check_local_events(u->cmd); if (unlikely(rc != 0)) { u->cmd->scst_cmd_done(u->cmd, @@ -1517,10 +1558,7 @@ &dev->cmd_lists.cmd_list_lock); goto again; } - /* - * There is no real need to lock again here, but - * let's do it for simplicity. - */ + spin_lock_irq(&dev->cmd_lists.cmd_list_lock); } else if (unlikely(test_bit(SCST_CMD_ABORTED, &u->cmd->cmd_flags))) { @@ -1535,7 +1573,8 @@ } } } - u->state |= UCMD_STATE_SENT_MASK; + u->sent_to_user = 1; + u->seen_by_user = 1; } return u; } @@ -1600,73 +1639,9 @@ return res; } -static inline int test_prio_cmd_list(struct scst_user_dev *dev) +static int dev_user_reply_get_cmd(struct file *file, unsigned long arg) { - /* - * Prio queue is always blocking, because poll() seems doesn't - * support, when different threads wait with different events - * mask. Only one thread is woken up on each event and if it - * isn't interested in such events, another (interested) one - * will not be woken up. Does't know if it's a bug or feature. - */ - int res = !list_empty(&dev->prio_ready_cmd_list) || - dev->cleaning || dev->cleanup_done || - signal_pending(current); - return res; -} - -/* Called under cmd_lists.cmd_list_lock and IRQ off */ -static int dev_user_get_next_prio_cmd(struct scst_user_dev *dev, - struct scst_user_cmd **ucmd) -{ int res = 0; - wait_queue_t wait; - - TRACE_ENTRY(); - - init_waitqueue_entry(&wait, current); - - while (1) { - if (!test_prio_cmd_list(dev)) { - add_wait_queue_exclusive(&dev->prio_cmd_list_waitQ, - &wait); - for (;;) { - set_current_state(TASK_INTERRUPTIBLE); - if (test_prio_cmd_list(dev)) - break; - spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); - schedule(); - spin_lock_irq(&dev->cmd_lists.cmd_list_lock); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&dev->prio_cmd_list_waitQ, &wait); - } - - *ucmd = __dev_user_get_next_cmd(&dev->prio_ready_cmd_list); - if (*ucmd != NULL) - break; - - if (dev->cleaning || dev->cleanup_done) { - res = -EAGAIN; - TRACE_DBG("No ready commands, returning %d", res); - break; - } - - if (signal_pending(current)) { - res = -EINTR; - TRACE_DBG("Signal pending, returning %d", res); - break; - } - } - - TRACE_EXIT_RES(res); - return res; -} - -static int dev_user_reply_get_cmd(struct file *file, unsigned long arg, - int prio) -{ - int res = 0; struct scst_user_dev *dev; struct scst_user_get_cmd *cmd; struct scst_user_reply_cmd *reply; @@ -1712,10 +1687,7 @@ } spin_lock_irq(&dev->cmd_lists.cmd_list_lock); - if (prio && (dev->prio_queue_type == SCST_USER_PRIO_QUEUE_SEPARATE)) - res = dev_user_get_next_prio_cmd(dev, &ucmd); - else - res = dev_user_get_next_cmd(dev, &ucmd); + res = dev_user_get_next_cmd(dev, &ucmd); if (res == 0) { *cmd = ucmd->user_cmd; spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); @@ -1745,7 +1717,7 @@ switch (cmd) { case SCST_USER_REPLY_AND_GET_CMD: TRACE_DBG("%s", "REPLY_AND_GET_CMD"); - res = dev_user_reply_get_cmd(file, arg, 0); + res = dev_user_reply_get_cmd(file, arg); break; case SCST_USER_REPLY_CMD: @@ -1753,11 +1725,6 @@ res = dev_user_reply_cmd(file, arg); break; - case SCST_USER_REPLY_AND_GET_PRIO_CMD: - TRACE_DBG("%s", "REPLY_AND_GET_PRIO_CMD"); - res = dev_user_reply_get_cmd(file, arg, 1); - break; - case SCST_USER_REGISTER_DEVICE: { struct scst_user_dev_desc *dev_desc; @@ -1862,18 +1829,20 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, unsigned long *flags) { - int state = ucmd->state & ~UCMD_STATE_MASK; + int state = ucmd->state; struct scst_user_dev *dev = ucmd->dev; TRACE_ENTRY(); - if (ucmd->state & UCMD_STATE_JAMMED_MASK) + if (ucmd->this_state_unjammed) goto out; TRACE_MGMT_DBG("Unjamming ucmd %p (busy %d, state %x)", ucmd, busy, - ucmd->state); + state); - ucmd->state = state | UCMD_STATE_JAMMED_MASK; + ucmd->jammed = 1; + ucmd->this_state_unjammed = 1; + ucmd->sent_to_user = 0; switch (state) { case UCMD_STATE_PARSING: @@ -1887,6 +1856,9 @@ scst_set_cmd_error(ucmd->cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); } + + ucmd->cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP; + TRACE_MGMT_DBG("Adding ucmd %p to active list", ucmd); list_add(&ucmd->cmd->cmd_list_entry, &ucmd->cmd->cmd_lists->active_cmd_list); @@ -1912,7 +1884,7 @@ } ucmd->cmd->scst_cmd_done(ucmd->cmd, SCST_CMD_STATE_DEFAULT); - /* !! At this point cmd ans ucmd can be already freed !! */ + /* !! At this point cmd and ucmd can be already freed !! */ if (flags != NULL) spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, *flags); @@ -1968,56 +1940,8 @@ return; } -static int __unjam_check_tgt_dev(struct scst_user_cmd *ucmd, int state, - struct scst_tgt_dev *tgt_dev) +static void dev_user_unjam_dev(struct scst_user_dev *dev) { - int res = 0; - - if (ucmd->cmd == NULL) - goto out; - - if (ucmd->cmd->tgt_dev != tgt_dev) - goto out; - - switch (state & ~UCMD_STATE_MASK) { - case UCMD_STATE_PARSING: - case UCMD_STATE_BUF_ALLOCING: - case UCMD_STATE_EXECING: - break; - default: - goto out; - } - - res = 1; -out: - return res; -} - -static int __unjam_check_tm(struct scst_user_cmd *ucmd, int state) -{ - int res = 0; - - switch (state & ~UCMD_STATE_MASK) { - case UCMD_STATE_PARSING: - case UCMD_STATE_BUF_ALLOCING: - case UCMD_STATE_EXECING: - if ((ucmd->cmd != NULL) && - (!test_bit(SCST_CMD_ABORTED, - &ucmd->cmd->cmd_flags))) - goto out; - break; - default: - goto out; - } - - res = 1; -out: - return res; -} - -static void dev_user_unjam_dev(struct scst_user_dev *dev, int tm, - struct scst_tgt_dev *tgt_dev) -{ int i; unsigned long flags; struct scst_user_cmd *ucmd; @@ -2031,41 +1955,24 @@ repeat: for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) { struct list_head *head = &dev->ucmd_hash[i]; + bool repeat = false; + list_for_each_entry(ucmd, head, hash_list_entry) { - TRACE_DBG("ALL: ucmd %p, state %x, scst_cmd %p", + if (ucmd_get_check(ucmd)) + continue; + + TRACE_DBG("ucmd %p, state %x, scst_cmd %p", ucmd, ucmd->state, ucmd->cmd); - if (ucmd->state & UCMD_STATE_SENT_MASK) { - int st = ucmd->state & ~UCMD_STATE_SENT_MASK; - if (tgt_dev != NULL) { - if (__unjam_check_tgt_dev(ucmd, st, - tgt_dev) == 0) - continue; - } else if (tm) { - if (__unjam_check_tm(ucmd, st) == 0) - continue; - } + + if (ucmd->sent_to_user) { dev_user_unjam_cmd(ucmd, 0, &flags); - goto repeat; + repeat = true; } - } - } - if ((tgt_dev != NULL) || tm) { - list_for_each_entry(ucmd, &dev->ready_cmd_list, - ready_cmd_list_entry) { - TRACE_DBG("READY: ucmd %p, state %x, scst_cmd %p", - ucmd, ucmd->state, ucmd->cmd); - if (tgt_dev != NULL) { - if (__unjam_check_tgt_dev(ucmd, ucmd->state, - tgt_dev) == 0) - continue; - } else if (tm) { - if (__unjam_check_tm(ucmd, ucmd->state) == 0) - continue; - } - list_del(&ucmd->ready_cmd_list_entry); - dev_user_unjam_cmd(ucmd, 0, &flags); - goto repeat; + ucmd_put(ucmd); + + if (repeat) + goto repeat; } } @@ -2078,72 +1985,117 @@ return; } -/** - ** In order to deal with user space handler hangups we rely on remote - ** initiators, which in case if a command doesn't respond for too long - ** supposed to issue a task management command, so on that event we can - ** "unjam" the command. In order to prevent TM command from stalling, we - ** use a timer. In order to prevent too many queued TM commands, we - ** enqueue only 2 of them, the first one with the requested TM function, - ** the second - with TARGET_RESET as the most comprehensive function. - ** - ** The only exception here is DETACH_SESS subcode, where there are no TM - ** commands could be expected, so we need manually after a timeout "unjam" - ** all the commands on the device. - ** - ** We also don't queue >1 ATTACH_SESS commands and after timeout fail it. - **/ - static int dev_user_process_reply_tm_exec(struct scst_user_cmd *ucmd, int status) { int res = 0; - unsigned long flags; TRACE_ENTRY(); TRACE_MGMT_DBG("TM reply (ucmd %p, fn %d, status %d)", ucmd, ucmd->user_cmd.tm_cmd.fn, status); - ucmd->result = status; - - spin_lock_irqsave(&ucmd->dev->cmd_lists.cmd_list_lock, flags); - - if (ucmd->internal_reset_tm) { - TRACE_MGMT_DBG("Internal TM ucmd %p finished", ucmd); - ucmd->dev->internal_reset_active = 0; - } else { - TRACE_MGMT_DBG("TM ucmd %p finished", ucmd); - ucmd->dev->tm_cmd_active = 0; + if (status == SCST_MGMT_STATUS_TASK_NOT_EXIST) { + /* + * It is possible that user space seen TM cmd before cmd + * to abort or will never see it at all, because it was + * aborted on the way there. So, it is safe to return + * success instead, because, if there is the TM cmd at this + * point, then the cmd to abort apparrently does exist. + */ + status = SCST_MGMT_STATUS_SUCCESS; } - if (ucmd->cmpl != NULL) - complete_all(ucmd->cmpl); + scst_async_mcmd_completed(ucmd->mcmd, status); - spin_unlock_irqrestore(&ucmd->dev->cmd_lists.cmd_list_lock, flags); - ucmd_put(ucmd); TRACE_EXIT_RES(res); return res; } +static void dev_user_abort_ready_commands(struct scst_user_dev *dev) +{ + struct scst_user_cmd *ucmd; + unsigned long flags; + + TRACE_ENTRY(); + + spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, flags); +again: + list_for_each_entry(ucmd, &dev->ready_cmd_list, ready_cmd_list_entry) { + if ((ucmd->cmd != NULL) && !ucmd->seen_by_user && + test_bit(SCST_CMD_ABORTED, &ucmd->cmd->cmd_flags)) { + switch (ucmd->state) { + case UCMD_STATE_PARSING: + case UCMD_STATE_BUF_ALLOCING: + case UCMD_STATE_EXECING: + TRACE_MGMT_DBG("Aborting ready ucmd %p", ucmd); + list_del(&ucmd->ready_cmd_list_entry); + dev_user_unjam_cmd(ucmd, 0, &flags); + goto again; + } + } + } + + spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, flags); + + TRACE_EXIT(); + return; +} + static int dev_user_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, struct scst_tgt_dev *tgt_dev) { - int res, rc; struct scst_user_cmd *ucmd; struct scst_user_dev *dev = (struct scst_user_dev *)tgt_dev->dev->dh_priv; struct scst_user_cmd *ucmd_to_abort = NULL; TRACE_ENTRY(); + /* + * In the used approach we don't do anything with hung devices, which + * stopped responding and/or have stuck commands. We forcedly abort such + * commands only if they not yet sent to the user space or if the device + * is getting unloaded, e.g. if its handler program gets killed. This is + * because it's pretty hard to distinguish between stuck and temporary + * overloaded states of the device. There are several reasons for that: + * + * 1. Some commands need a lot of time to complete (several hours), + * so for an impatient user such command(s) will always look as + * stuck. + * + * 2. If we forcedly abort, i.e. abort before it's actually completed + * in the user space, just one command, we will have to put the whole + * device offline until we are sure that no more previously aborted + * commands will get executed. Otherwise, we might have a po... [truncated message content] |
From: <vl...@us...> - 2008-06-19 17:48:19
|
Revision: 417 http://scst.svn.sourceforge.net/scst/?rev=417&view=rev Author: vlnb Date: 2008-06-19 10:48:08 -0700 (Thu, 19 Jun 2008) Log Message: ----------- - Fixes not cleanly applies xxx2yyy patches - Updated to IET r155 - Compilation fixes - Typos fixes, including patch from Dotan Barak <do...@gm...> Modified Paths: -------------- trunk/iscsi-scst/include/iscsi_scst_ver.h trunk/scst/README trunk/scst/include/scst.h trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_proc.c trunk/scst-full_perf.patch trunk/scst-release.patch trunk/usr-full_perf.patch trunk/usr-release.patch Modified: trunk/iscsi-scst/include/iscsi_scst_ver.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-06-19 17:48:08 UTC (rev 417) @@ -13,4 +13,4 @@ * GNU General Public License for more details. */ -#define ISCSI_VERSION_STRING "1.0.0/0.4.16r151" +#define ISCSI_VERSION_STRING "1.0.0/0.4.16r155" Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst/README 2008-06-19 17:48:08 UTC (rev 417) @@ -491,7 +491,7 @@ Moreover, if you want to compare how well different block sizes work for you, you **MUST** EVERY TIME AFTER CHANGING BLOCK SIZE **COMPLETELY** **WIPE OFF** ALL THE DATA FROM THE DEVICE. In - other words, THE **WHOLE** DEVICE **MUST** HAVE ONLY **ZEROES** + other words, THE **WHOLE** DEVICE **MUST** HAVE ONLY **ZEROS** AS THE DATA AFTER YOU SWITCH TO NEW BLOCK SIZE. Switching block sizes isn't like switching between FILEIO and BLOCKIO, after changing block size all previously written with another block Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst/include/scst.h 2008-06-19 17:48:08 UTC (rev 417) @@ -1309,7 +1309,7 @@ * How much memory allowed to allocated under this object. Put here * mostly to save a possible cache miss accessing scst_max_dev_cmd_mem. */ - unsigned int max_allowed_pages; + int max_allowed_pages; }; struct scst_device { Modified: trunk/scst/src/dev_handlers/scst_vdisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_vdisk.c 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst/src/dev_handlers/scst_vdisk.c 2008-06-19 17:48:08 UTC (rev 417) @@ -21,7 +21,6 @@ * GNU General Public License for more details. */ -#include <linux/uaccess.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/string.h> Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst/src/scst_proc.c 2008-06-19 17:48:08 UTC (rev 417) @@ -27,7 +27,6 @@ #include <linux/sched.h> #include <linux/unistd.h> #include <linux/string.h> -#include <linux/uaccess.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> @@ -242,9 +241,9 @@ /* * Usage: - * echo "all|none|default" >/proc/scsi_tgt/trace_log_level - * echo "value DEC|0xHEX|0OCT" >/proc/scsi_tgt/trace_log_level - * echo "set|add|clear|del TOKEN" >/proc/scsi_tgt/trace_log_level + * echo "all|none|default" >/proc/scsi_tgt/trace_level + * echo "value DEC|0xHEX|0OCT" >/proc/scsi_tgt/trace_level + * echo "set|add|clear|del TOKEN" >/proc/scsi_tgt/trace_level * where TOKEN is one of [debug,function,line,pid,entryexit, * buff,mem,sg,out_of_mem,retry, * scsi_serializing,special,scsi,mgmt,minor,...] Modified: trunk/scst-full_perf.patch =================================================================== --- trunk/scst-full_perf.patch 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst-full_perf.patch 2008-06-19 17:48:08 UTC (rev 417) @@ -2,7 +2,7 @@ =================================================================== --- scst/src/Makefile (revision 233) +++ scst/src/Makefile (working copy) -@@ -114,7 +114,7 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) -Wextr +@@ -115,7 +115,7 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) -Wextr #EXTRA_CFLAGS += -DSTRICT_SERIALIZING @@ -11,7 +11,7 @@ #EXTRA_CFLAGS += -DUSE_EXPECTED_VALUES #EXTRA_CFLAGS += -DALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ -@@ -124,7 +124,7 @@ EXTRA_CFLAGS += -DEXTRACHECKS +@@ -125,7 +125,7 @@ EXTRA_CFLAGS += -DEXTRACHECKS #EXTRA_CFLAGS += -DTRACING @@ -24,7 +24,7 @@ =================================================================== --- scst/src/dev_handlers/Makefile (revision 230) +++ scst/src/dev_handlers/Makefile (working copy) -@@ -68,10 +68,10 @@ endif +@@ -69,10 +69,10 @@ endif EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SCST_INC_DIR) -Wextra -Wno-unused-parameter @@ -36,4 +36,4 @@ +#EXTRA_CFLAGS += -DDEBUG -g clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers Module.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers \ Modified: trunk/scst-release.patch =================================================================== --- trunk/scst-release.patch 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/scst-release.patch 2008-06-19 17:48:08 UTC (rev 417) @@ -2,7 +2,7 @@ =================================================================== --- scst/src/Makefile (revision 233) +++ scst/src/Makefile (working copy) -@@ -114,7 +114,7 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) -Wextr +@@ -115,7 +115,7 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) -Wextr #EXTRA_CFLAGS += -DSTRICT_SERIALIZING @@ -11,7 +11,7 @@ #EXTRA_CFLAGS += -DUSE_EXPECTED_VALUES #EXTRA_CFLAGS += -DALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ -@@ -122,9 +122,9 @@ EXTRA_CFLAGS += -DEXTRACHECKS +@@ -123,9 +123,9 @@ EXTRA_CFLAGS += -DEXTRACHECKS #EXTRA_CFLAGS += -fno-inline @@ -27,7 +27,7 @@ =================================================================== --- scst/src/dev_handlers/Makefile (revision 230) +++ scst/src/dev_handlers/Makefile (working copy) -@@ -68,10 +68,10 @@ endif +@@ -69,10 +69,10 @@ endif EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SCST_INC_DIR) -Wextra -Wno-unused-parameter @@ -40,4 +40,4 @@ +#EXTRA_CFLAGS += -DDEBUG -g clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers Module.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers \ Modified: trunk/usr-full_perf.patch =================================================================== --- trunk/usr-full_perf.patch 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/usr-full_perf.patch 2008-06-19 17:48:08 UTC (rev 417) @@ -2,7 +2,7 @@ =================================================================== --- usr/fileio/Makefile (revision 324) +++ usr/fileio/Makefile (working copy) -@@ -28,9 +28,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- +@@ -29,9 +29,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- PROGS = fileio_tgt LIBS = -lpthread Modified: trunk/usr-release.patch =================================================================== --- trunk/usr-release.patch 2008-06-18 09:54:38 UTC (rev 416) +++ trunk/usr-release.patch 2008-06-19 17:48:08 UTC (rev 417) @@ -2,7 +2,7 @@ =================================================================== --- usr/fileio/Makefile (revision 324) +++ usr/fileio/Makefile (working copy) -@@ -28,9 +28,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- +@@ -29,9 +29,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- PROGS = fileio_tgt LIBS = -lpthread This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-06-26 16:39:07
|
Revision: 423 http://scst.svn.sourceforge.net/scst/?rev=423&view=rev Author: vlnb Date: 2008-06-26 09:39:05 -0700 (Thu, 26 Jun 2008) Log Message: ----------- - A complete fix for the problem when a command comes with zero transfer length and READ or WRITE data transfer direction - Version changed to 1.0.0-rc2 Modified Paths: -------------- trunk/iscsi-scst/usr/chap.c trunk/iscsi-scst/usr/isns.c trunk/scst/include/scst.h trunk/scst/include/scst_user.h trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_targ.c trunk/usr/fileio/common.c Modified: trunk/iscsi-scst/usr/chap.c =================================================================== --- trunk/iscsi-scst/usr/chap.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/iscsi-scst/usr/chap.c 2008-06-26 16:39:05 UTC (rev 423) @@ -360,7 +360,7 @@ text_key_add(conn, "CHAP_I", text); /* - * FIXME: does a random challenge length provide any benefits security- + * ToDo: does a random challenge length provide any benefits security- * wise, or should we rather always use the max. allowed length of * 1024 for the (unencoded) challenge? */ @@ -578,7 +578,7 @@ if (challenge_len == conn->auth.chap.challenge_size) { if (!memcmp(challenge, conn->auth.chap.challenge, challenge_len)) { - //FIXME: RFC 3720 demands to close TCP conn. + /* ToDo: RFC 3720 demands to close TCP conn */ log_warning("CHAP target auth.: " "initiator %s reflected our challenge", conn->initiator); Modified: trunk/iscsi-scst/usr/isns.c =================================================================== --- trunk/iscsi-scst/usr/isns.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/iscsi-scst/usr/isns.c 2008-06-26 16:39:05 UTC (rev 423) @@ -550,7 +550,7 @@ transaction, sequence); if (length + sizeof(*hdr) > BUFSIZE) { - log_error("FIXME we cannot handle this yet %u!", length); + log_error("ToDo: we cannot handle this yet %u!", length); return -1; } Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/include/scst.h 2008-06-26 16:39:05 UTC (rev 423) @@ -50,7 +50,7 @@ /* Version numbers, the same as for the kernel */ #define SCST_VERSION_CODE 0x00090601 #define SCST_VERSION(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) -#define SCST_VERSION_STRING "1.0.0-rc1" +#define SCST_VERSION_STRING "1.0.0-rc2" #define SCST_INTERFACE_VERSION SCST_VERSION_STRING "$Revision$" SCST_CONST_VERSION /************************************************************* Modified: trunk/scst/include/scst_user.h =================================================================== --- trunk/scst/include/scst_user.h 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/include/scst_user.h 2008-06-26 16:39:05 UTC (rev 423) @@ -26,7 +26,7 @@ #define DEV_USER_NAME "scst_user" #define DEV_USER_PATH "/dev/" -#define DEV_USER_VERSION_NAME "1.0.0-rc1" +#define DEV_USER_VERSION_NAME "1.0.0-rc2" #define DEV_USER_VERSION DEV_USER_VERSION_NAME "$Revision$" SCST_CONST_VERSION /* Modified: trunk/scst/src/dev_handlers/scst_user.c =================================================================== --- trunk/scst/src/dev_handlers/scst_user.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/src/dev_handlers/scst_user.c 2008-06-26 16:39:05 UTC (rev 423) @@ -490,11 +490,7 @@ TRACE_ENTRY(); - /* User space can return from PARSE bufflen 0 and direction non-NONE */ - if (unlikely(bufflen == 0)) { - cmd->data_direction = SCST_DATA_NONE; - goto out; - } + sBUG_ON(bufflen == 0); gfp_mask = __GFP_NOWARN; gfp_mask |= (scst_cmd_atomic(cmd) ? GFP_ATOMIC : GFP_KERNEL); Modified: trunk/scst/src/dev_handlers/scst_vdisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_vdisk.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/src/dev_handlers/scst_vdisk.c 2008-06-26 16:39:05 UTC (rev 423) @@ -1094,9 +1094,11 @@ length = scst_get_buf_first(cmd, &address); TRACE_DBG("length %d", length); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out_free; } @@ -1257,10 +1259,13 @@ length = scst_get_buf_first(cmd, &address); TRACE_DBG("length %d", length); if (unlikely(length < SCST_STANDARD_SENSE_LEN)) { - PRINT_ERROR("scst_get_buf_first() failed or too small " - "requested buffer (returned %d)", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list)); + if (length != 0) { + PRINT_ERROR("scst_get_buf_first() failed or too small " + "requested buffer (returned %d)", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE( + scst_sense_invalid_field_in_parm_list)); + } if (length > 0) goto out_put; else @@ -1423,9 +1428,11 @@ length = scst_get_buf_first(cmd, &address); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out_free; } @@ -1576,9 +1583,11 @@ length = scst_get_buf_first(cmd, &address); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out; } @@ -1708,9 +1717,11 @@ length = scst_get_buf_first(cmd, &address); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out; } @@ -1760,9 +1771,11 @@ length = scst_get_buf_first(cmd, &address); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out; } @@ -1816,14 +1829,16 @@ length = scst_get_buf_first(cmd, &address); if (unlikely(length <= 0)) { - PRINT_ERROR("scst_get_buf_first() failed: %d", length); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + if (length < 0) { + PRINT_ERROR("scst_get_buf_first() failed: %d", length); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + } goto out; } virt_dev = (struct scst_vdisk_dev *)cmd->dev->dh_priv; - /* FIXME when you have > 8TB ROM device. */ + /* ToDo when you have > 8TB ROM device. */ nblocks = (uint32_t)virt_dev->nblocks; /* Header */ @@ -2459,7 +2474,8 @@ scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_read_error)); } - scst_put_buf(cmd, address_sav); + if (compare) + scst_put_buf(cmd, address_sav); goto out_set_fs; } if (compare && memcmp(address, mem_verify, len_mem) != 0) { Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/src/scst_lib.c 2008-06-26 16:39:05 UTC (rev 423) @@ -1646,7 +1646,6 @@ int atomic = scst_cmd_atomic(cmd); int flags; struct scst_tgt_dev *tgt_dev = cmd->tgt_dev; - int bufflen = cmd->bufflen; TRACE_ENTRY(); @@ -1656,21 +1655,7 @@ if (cmd->no_sgv) flags |= SCST_POOL_ALLOC_NO_CACHED; - if (unlikely(cmd->bufflen == 0)) { - /* ToDo: remove when 1.0.1 will be started */ - TRACE(TRACE_MGMT_MINOR, "Warning: data direction %d or/and " - "zero buffer length. Opcode 0x%x, handler %s, target " - "%s", cmd->data_direction, cmd->cdb[0], - cmd->dev->handler->name, cmd->tgtt->name); - /* - * Be on the safe side and alloc stub buffer. Neither target - * drivers, nor user space will touch it, since bufflen - * remains 0. - */ - bufflen = PAGE_SIZE; - } - - cmd->sg = sgv_pool_alloc(tgt_dev->pool, bufflen, gfp_mask, flags, + cmd->sg = sgv_pool_alloc(tgt_dev->pool, cmd->bufflen, gfp_mask, flags, &cmd->sg_cnt, &cmd->sgv, &cmd->dev->dev_mem_lim, NULL); if (cmd->sg == NULL) goto out; @@ -1916,7 +1901,7 @@ cmd->data_direction = ptr->direction; cmd->op_flags = ptr->flags; res = (*ptr->get_trans_len)(cmd, ptr->off); -#if 0 /* ToDo: enable when 1.0.1 will be started and fix all scst_get_buf_first() returns 0 cases */ + if (unlikely(cmd->bufflen == 0)) { /* * According to SPC bufflen 0 for data transfer commands isn't @@ -1924,7 +1909,6 @@ */ cmd->data_direction = SCST_DATA_NONE; } -#endif out: TRACE_EXIT(); @@ -2355,8 +2339,10 @@ buffer_size = scst_get_buf_first(cmd, &buffer); if (unlikely(buffer_size <= 0)) { - PRINT_ERROR("%s: Unable to get the buffer " - "(%d)", __func__, buffer_size); + if (buffer_size < 0) { + PRINT_ERROR("%s: Unable to get the buffer " + "(%d)", __func__, buffer_size); + } goto out; } @@ -2408,8 +2394,10 @@ case MODE_SELECT: buffer_size = scst_get_buf_first(cmd, &buffer); if (unlikely(buffer_size <= 0)) { - PRINT_ERROR("%s: Unable to get the buffer (%d)", - __func__, buffer_size); + if (buffer_size < 0) { + PRINT_ERROR("%s: Unable to get the buffer (%d)", + __func__, buffer_size); + } goto out; } break; Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/scst/src/scst_targ.c 2008-06-26 16:39:05 UTC (rev 423) @@ -1293,7 +1293,9 @@ } buffer_size = scst_get_buf_first(cmd, &buffer); - if (unlikely(buffer_size <= 0)) + if (unlikely(buffer_size == 0)) + goto out_compl; + else if (unlikely(buffer_size < 0)) goto out_err; if (buffer_size < 16) @@ -1340,13 +1342,17 @@ /* Set the response header */ buffer_size = scst_get_buf_first(cmd, &buffer); - if (unlikely(buffer_size <= 0)) + if (unlikely(buffer_size == 0)) + goto out_compl; + else if (unlikely(buffer_size < 0)) goto out_err; + dev_cnt *= 8; buffer[0] = (dev_cnt >> 24) & 0xff; buffer[1] = (dev_cnt >> 16) & 0xff; buffer[2] = (dev_cnt >> 8) & 0xff; buffer[3] = dev_cnt & 0xff; + scst_put_buf(cmd, buffer); dev_cnt += 8; @@ -2220,9 +2226,16 @@ uint8_t *address; length = scst_get_buf_first(cmd, &address); - if (length <= 0) + if (length < 0) { + PRINT_ERROR("%s", "Unable to get " + "MODE_SENSE buffer"); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE( + scst_sense_hardw_error)); goto out; - if (length > 2 && cmd->cdb[0] == MODE_SENSE) + } else if (length == 0) { + goto out; + } else if (length > 2 && cmd->cdb[0] == MODE_SENSE) address[2] |= 0x80; /* Write Protect*/ else if (length > 3 && cmd->cdb[0] == MODE_SENSE_10) address[3] |= 0x80; /* Write Protect*/ @@ -2252,12 +2265,13 @@ } #endif buffer[SCST_INQ_BYTE3] &= ~SCST_INQ_NORMACA_BIT; - } else { + } else if (buflen != 0) { PRINT_ERROR("%s", "Unable to get INQUIRY " "buffer"); scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + SCST_LOAD_SENSE(scst_sense_hardw_error)); } + if (buflen > 0) scst_put_buf(cmd, buffer); } Modified: trunk/usr/fileio/common.c =================================================================== --- trunk/usr/fileio/common.c 2008-06-26 16:35:10 UTC (rev 422) +++ trunk/usr/fileio/common.c 2008-06-26 16:39:05 UTC (rev 423) @@ -1424,7 +1424,7 @@ goto out; } - /* FIXME when you have > 8TB ROM device. */ + /* ToDo when you have > 8TB ROM device. */ nblocks = (uint32_t)dev->nblocks; /* Header */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <swg...@us...> - 2008-07-08 07:59:47
|
Revision: 434 http://scst.svn.sourceforge.net/scst/?rev=434&view=rev Author: swgruszka Date: 2008-07-08 00:59:42 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Add release2debug and debug2release Makefile targets for qla_isp. Leave qla_isp in release 'state' as other stuff. Modified Paths: -------------- trunk/Makefile trunk/qla_isp/linux/isp_pci.c trunk/qla_isp/linux/isp_scst.c Added Paths: ----------- trunk/qla_isp-release.patch Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-07-07 18:00:32 UTC (rev 433) +++ trunk/Makefile 2008-07-08 07:59:42 UTC (rev 434) @@ -264,6 +264,7 @@ patch -p0 <usr-release.patch patch -p0 <qla2x00t-release.patch patch -p0 <iscsi-release.patch + patch -p0 <qla_isp-release.patch perf2debug: echo "Changing current debug state from full performance to full debug" @@ -278,6 +279,7 @@ patch -p0 -R <usr-release.patch patch -p0 -R <qla2x00t-release.patch patch -p0 -R <iscsi-release.patch + patch -p0 -R <qla_isp-release.patch .PHONY: all install uninstall clean extraclean help \ qla qla_install qla_uninstall qla_clean qla_extraclean \ Modified: trunk/qla_isp/linux/isp_pci.c =================================================================== --- trunk/qla_isp/linux/isp_pci.c 2008-07-07 18:00:32 UTC (rev 433) +++ trunk/qla_isp/linux/isp_pci.c 2008-07-08 07:59:42 UTC (rev 434) @@ -548,7 +548,7 @@ if (isp_debug) { isp->isp_dblev = isp_debug; } else { - isp->isp_dblev = ISP_LOGCONFIG|ISP_LOGINFO|ISP_LOGWARN|ISP_LOGERR; + isp->isp_dblev = ISP_LOGERR; } pci_read_config_word(pdev, PCI_COMMAND, &cmd); Modified: trunk/qla_isp/linux/isp_scst.c =================================================================== --- trunk/qla_isp/linux/isp_scst.c 2008-07-07 18:00:32 UTC (rev 433) +++ trunk/qla_isp/linux/isp_scst.c 2008-07-08 07:59:42 UTC (rev 434) @@ -156,7 +156,7 @@ struct scst_proc_data proc_data; }; -#define DEBUG 1 +//#define DEBUG 1 #ifdef DEBUG #define SDprintk if (debug) printk Added: trunk/qla_isp-release.patch =================================================================== --- trunk/qla_isp-release.patch (rev 0) +++ trunk/qla_isp-release.patch 2008-07-08 07:59:42 UTC (rev 434) @@ -0,0 +1,24 @@ +diff -uprN -X/home/stasiu/work/linux-2.6/Documentation/dontdiff qla_isp/linux/isp_pci.c qla_isp-1.0.0/linux/isp_pci.c +--- qla_isp/linux/isp_pci.c 2008-07-08 09:38:11.000000000 +0200 ++++ qla_isp-1.0.0/linux/isp_pci.c 2008-07-06 12:50:35.000000000 +0200 +@@ -548,7 +548,7 @@ isplinux_pci_init_one(struct Scsi_Host * + if (isp_debug) { + isp->isp_dblev = isp_debug; + } else { +- isp->isp_dblev = ISP_LOGCONFIG|ISP_LOGINFO|ISP_LOGWARN|ISP_LOGERR; ++ isp->isp_dblev = ISP_LOGERR; + } + + pci_read_config_word(pdev, PCI_COMMAND, &cmd); +diff -uprN -X/home/stasiu/work/linux-2.6/Documentation/dontdiff qla_isp/linux/isp_scst.c qla_isp-1.0.0/linux/isp_scst.c +--- qla_isp/linux/isp_scst.c 2008-07-08 09:38:11.000000000 +0200 ++++ qla_isp-1.0.0/linux/isp_scst.c 2008-07-06 12:49:07.000000000 +0200 +@@ -156,7 +156,7 @@ struct bus { + struct scst_proc_data proc_data; + }; + +-#define DEBUG 1 ++//#define DEBUG 1 + + #ifdef DEBUG + #define SDprintk if (debug) printk This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-07-08 19:21:23
|
Revision: 436 http://scst.svn.sourceforge.net/scst/?rev=436&view=rev Author: vlnb Date: 2008-07-08 12:21:22 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Pending changes to match the 1.0.0 released packeges Modified Paths: -------------- trunk/Makefile trunk/iscsi-scst/Makefile trunk/iscsi-scst/README trunk/iscsi-scst/kernel/Makefile trunk/qla2x00t/qla2x00-target/Makefile trunk/scst/src/scst_main.c trunk/scstadmin/Changes trunk/usr/fileio/Makefile trunk/usr/fileio/README Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/Makefile 2008-07-08 19:21:22 UTC (rev 436) @@ -257,6 +257,7 @@ patch -p0 <usr-full_perf.patch patch -p0 <qla2x00t-full_perf.patch patch -p0 <iscsi-full_perf.patch + patch -p0 <qla_isp-release.patch debug2release: echo "Changing current debug state from full debug to release" @@ -272,6 +273,7 @@ patch -p0 -R <usr-full_perf.patch patch -p0 -R <qla2x00t-full_perf.patch patch -p0 -R <iscsi-full_perf.patch + patch -p0 -R <qla_isp-release.patch release2debug: echo "Changing current debug state from release to full debug" Modified: trunk/iscsi-scst/Makefile =================================================================== --- trunk/iscsi-scst/Makefile 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/iscsi-scst/Makefile 2008-07-08 19:21:22 UTC (rev 436) @@ -5,7 +5,11 @@ # removes any old dependencies. DON'T put your own dependencies here # unless it's something special (not a .c file). -SCST_DIR := $(shell pwd)/../scst/src +SCST_INC_DIR := /usr/local/include/scst +#SCST_INC_DIR := $(SUBDIRS)/../../scst/include +SCST_DIR := $(SCST_INC_DIR) +#SCST_DIR := $(shell pwd)/../scst/src + SUBDIRS := $(shell pwd) ifeq ($(KVER),) @@ -22,7 +26,7 @@ all: include/iscsi_scst_itf_ver.h progs mods mods: Modules.symvers Module.symvers - $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/kernel modules + $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(shell pwd)/kernel modules progs: $(MAKE) -C usr Modified: trunk/iscsi-scst/README =================================================================== --- trunk/iscsi-scst/README 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/iscsi-scst/README 2008-07-08 19:21:22 UTC (rev 436) @@ -109,6 +109,8 @@ Usage ----- +See in doc/iscsi-scst-howto.txt examples how to configure iSCSI-SCST. + ISCSI parameters like iSNS, CHAP and target parameters are configured in iscsi-scstd.conf. All LUN information is configured using the regular SCST interface. It is highly recommended to use scstadmin utility for Modified: trunk/iscsi-scst/kernel/Makefile =================================================================== --- trunk/iscsi-scst/kernel/Makefile 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/iscsi-scst/kernel/Makefile 2008-07-08 19:21:22 UTC (rev 436) @@ -20,9 +20,6 @@ # # Note 2! The CFLAGS definitions are now in the main makefile. -#SCST_INC_DIR := /usr/local/include/scst -SCST_INC_DIR := $(SUBDIRS)/../../scst/include - EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter Modified: trunk/qla2x00t/qla2x00-target/Makefile =================================================================== --- trunk/qla2x00t/qla2x00-target/Makefile 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/qla2x00t/qla2x00-target/Makefile 2008-07-08 19:21:22 UTC (rev 436) @@ -26,10 +26,10 @@ # - install and uninstall must be made as root # -#SCST_INC_DIR := /usr/local/include/scst -#SCST_DIR := $(SCST_INC_DIR) -SCST_INC_DIR := $(SUBDIRS)/../../scst/include -SCST_DIR := $(shell pwd)/../../scst/src +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) -DFC_TARGET_SUPPORT Modified: trunk/scst/src/scst_main.c =================================================================== --- trunk/scst/src/scst_main.c 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/scst/src/scst_main.c 2008-07-08 19:21:22 UTC (rev 436) @@ -469,6 +469,7 @@ int scst_suspend_activity(bool interruptible) { int res = 0; + bool rep = false; TRACE_ENTRY(); @@ -508,6 +509,7 @@ "forever until the corresponding user space " "program recovers and starts responding or gets " "killed.", atomic_read(&scst_cmd_count)); + rep = true; } res = scst_susp_wait(interruptible); @@ -524,7 +526,8 @@ if (res != 0) goto out_clear; - PRINT_INFO("%s", "All active commands completed"); + if (rep) + PRINT_INFO("%s", "All active commands completed"); out_up: mutex_unlock(&scst_suspend_mutex); Modified: trunk/scstadmin/Changes =================================================================== --- trunk/scstadmin/Changes 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/scstadmin/Changes 2008-07-08 19:21:22 UTC (rev 436) @@ -1,21 +1,8 @@ -Changes since 0.9.2-pre2: +Changes since 1.0.0 RC1 -- List SCST sessions -- Verify specified config file against live configuration and show differences -- Write config file based on live configuration -- Force-apply configuration, even config deletions with a force flag. -- Added new option types -- Added support for specifying a blocksize -- Added "-reload-config" to init script +- Updated SCST/SCST.pm to add one more option mapping NV -> NV_CACHE. +- Install/uninstall added. -Changes since 0.9.5-pre0: - -- Renamed scst to scstadmin -- Fixed writeConfiguration() to properly write DEVICE lines with no options -- Removed the comment which prevented a target from being enabled in enableTarget() -- Updated init.d/scst to use scstadmin instead of scst_db -- Fixup of README file - Changes since 0.9.6-pre2: - Updated SCST/SCST.pm for vdisk/vcdrom from cdrom_fileio/disk_fileio @@ -34,7 +21,20 @@ - Fixed handling of disabled handlers (like dev_disk, dev_cdrom, etc from compile time) - Minor bug fixes -Changes since 1.0.0 RC1 +Changes since 0.9.5-pre0: -- Updated SCST/SCST.pm to add one more option mapping NV -> NV_CACHE. -- Install/uninstall added. +- Renamed scst to scstadmin +- Fixed writeConfiguration() to properly write DEVICE lines with no options +- Removed the comment which prevented a target from being enabled in enableTarget() +- Updated init.d/scst to use scstadmin instead of scst_db +- Fixup of README file + +Changes since 0.9.2-pre2: + +- List SCST sessions +- Verify specified config file against live configuration and show differences +- Write config file based on live configuration +- Force-apply configuration, even config deletions with a force flag. +- Added new option types +- Added support for specifying a blocksize +- Added "-reload-config" to init script Modified: trunk/usr/fileio/Makefile =================================================================== --- trunk/usr/fileio/Makefile 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/usr/fileio/Makefile 2008-07-08 19:21:22 UTC (rev 436) @@ -20,7 +20,8 @@ #SRCS_C = #OBJS_C = $(SRCS_C:.c=.o) -SCST_INC_DIR := ../../scst/include +#SCST_INC_DIR := ../../scst/include +SCST_INC_DIR := /usr/local/include/scst INSTALL_DIR := /usr/local/bin/scst CFLAGS += -O2 -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes \ Modified: trunk/usr/fileio/README =================================================================== --- trunk/usr/fileio/README 2008-07-08 16:41:52 UTC (rev 435) +++ trunk/usr/fileio/README 2008-07-08 19:21:22 UTC (rev 436) @@ -5,14 +5,14 @@ -------------------------- User space program fileio_tgt uses interface of SCST's scst_user dev -handler as well as allows to see how it works in various modes. -Fileio_tgt provides mostly the same functionality as the kernel space -SCST's scst_vdisk handler with the only exceptions that it supports -O_DIRECT mode and doesn't support BLOCKIO one. O_DIRECT mode is -basically the same as BLOCKIO, but also supports files, so for some -loads it could be significantly faster, than the regular FILEIO access. -All the words about BLOCKIO mode from SCST's README file apply to -O_DIRECT mode as well. +handler and allows to see how it works in various modes. Fileio_tgt +provides mostly the same functionality as the kernel space SCST's +scst_vdisk handler with the only exceptions that it supports O_DIRECT +mode and doesn't support BLOCKIO one. O_DIRECT mode is basically the +same as BLOCKIO, but also supports files, so for some loads it could be +significantly faster, than the regular FILEIO access. All the words +about BLOCKIO mode from SCST's README file apply to O_DIRECT mode as +well. Installation ------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-07-09 16:44:11
|
Revision: 442 http://scst.svn.sourceforge.net/scst/?rev=442&view=rev Author: vlnb Date: 2008-07-09 09:44:01 -0700 (Wed, 09 Jul 2008) Log Message: ----------- - Version changed to 1.0.1 - Switched back to the debug mode Modified Paths: -------------- trunk/iscsi-full_perf.patch trunk/iscsi-release.patch trunk/iscsi-scst/README trunk/iscsi-scst/include/iscsi_scst_ver.h trunk/iscsi-scst/kernel/Makefile trunk/qla2x00t/qla2x00-target/ChangeLog trunk/qla2x00t/qla2x00-target/Makefile trunk/qla2x00t/qla2x00-target/README trunk/qla2x00t/qla2x00-target/qla2x00t.h trunk/qla_isp/linux/isp_pci.c trunk/qla_isp/linux/isp_scst.c trunk/scst/ChangeLog trunk/scst/README trunk/scst/include/scst.h trunk/scst/include/scst_user.h trunk/scst/src/Makefile trunk/scst/src/dev_handlers/Makefile trunk/scstadmin/scstadmin trunk/usr/fileio/Makefile trunk/usr/fileio/README trunk/usr/fileio/fileio.c trunk/usr-full_perf.patch trunk/usr-release.patch Modified: trunk/iscsi-full_perf.patch =================================================================== --- trunk/iscsi-full_perf.patch 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/iscsi-full_perf.patch 2008-07-09 16:44:01 UTC (rev 442) @@ -2,7 +2,7 @@ =================================================================== --- iscsi-scst/kernel/Makefile (revision 324) +++ iscsi-scst/kernel/Makefile (working copy) -@@ -26,9 +26,9 @@ SCST_INC_DIR := $(SUBDIRS)/../../scst/in +@@ -23,9 +23,9 @@ SCST_INC_DIR := $(SUBDIRS)/../../scst/in EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter Modified: trunk/iscsi-release.patch =================================================================== --- trunk/iscsi-release.patch 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/iscsi-release.patch 2008-07-09 16:44:01 UTC (rev 442) @@ -2,7 +2,7 @@ =================================================================== --- iscsi-scst/kernel/Makefile (revision 324) +++ iscsi-scst/kernel/Makefile (working copy) -@@ -26,9 +26,9 @@ SCST_INC_DIR := $(SUBDIRS)/../../scst/in +@@ -23,9 +23,9 @@ SCST_INC_DIR := $(SUBDIRS)/../../scst/in EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter Modified: trunk/iscsi-scst/README =================================================================== --- trunk/iscsi-scst/README 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/iscsi-scst/README 2008-07-09 16:44:01 UTC (rev 442) @@ -1,8 +1,8 @@ iSCSI SCST target driver ======================== -Version 1.0.0/0.4.16r155, 7 July 2008 -------------------------------------- +Version 1.0.1/0.4.16r155, XX XXXX 2008 +-------------------------------------- This driver is a forked with all respects version of iSCSI Enterprise Target (IET) (http://iscsitarget.sourceforge.net/) with updates to work Modified: trunk/iscsi-scst/include/iscsi_scst_ver.h =================================================================== --- trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/iscsi-scst/include/iscsi_scst_ver.h 2008-07-09 16:44:01 UTC (rev 442) @@ -13,4 +13,4 @@ * GNU General Public License for more details. */ -#define ISCSI_VERSION_STRING "1.0.0/0.4.16r155" +#define ISCSI_VERSION_STRING "1.0.1/0.4.16r155" Modified: trunk/iscsi-scst/kernel/Makefile =================================================================== --- trunk/iscsi-scst/kernel/Makefile 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/iscsi-scst/kernel/Makefile 2008-07-09 16:44:01 UTC (rev 442) @@ -23,9 +23,9 @@ EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter -#EXTRA_CFLAGS += -DEXTRACHECKS -EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG -g +EXTRA_CFLAGS += -DEXTRACHECKS +#EXTRA_CFLAGS += -DTRACING +EXTRA_CFLAGS += -DDEBUG -g #EXTRA_CFLAGS += -DDEBUG_DIGEST_FAILURES Modified: trunk/qla2x00t/qla2x00-target/ChangeLog =================================================================== --- trunk/qla2x00t/qla2x00-target/ChangeLog 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla2x00t/qla2x00-target/ChangeLog 2008-07-09 16:44:01 UTC (rev 442) @@ -1,3 +1,8 @@ +Summary of changes between versions 1.0.0 and 1.0.1 +--------------------------------------------------- + + + Summary of changes between versions 0.9.5 and 1.0.0 --------------------------------------------------- Modified: trunk/qla2x00t/qla2x00-target/Makefile =================================================================== --- trunk/qla2x00t/qla2x00-target/Makefile 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla2x00t/qla2x00-target/Makefile 2008-07-09 16:44:01 UTC (rev 442) @@ -35,9 +35,9 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra -#EXTRA_CFLAGS += -DEXTRACHECKS -EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG_TGT -g +EXTRA_CFLAGS += -DEXTRACHECKS +#EXTRA_CFLAGS += -DTRACING +EXTRA_CFLAGS += -DDEBUG_TGT -g #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD ifeq ($(KVER),) Modified: trunk/qla2x00t/qla2x00-target/README =================================================================== --- trunk/qla2x00t/qla2x00-target/README 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla2x00t/qla2x00-target/README 2008-07-09 16:44:01 UTC (rev 442) @@ -1,7 +1,7 @@ Target driver for Qlogic 2200/2300 Fibre Channel cards ====================================================== -Version 1.0.0, 7 July 2008 +Version 1.0.1, X XXXX 2008 -------------------------- This driver has all required features and looks to be quite stable (for Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.h =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.h 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.h 2008-07-09 16:44:01 UTC (rev 442) @@ -38,7 +38,7 @@ /* Version numbers, the same as for the kernel */ #define Q2T_VERSION(a,b,c,d) (((a) << 030) + ((b) << 020) + (c) << 010 + (d)) #define Q2T_VERSION_CODE Q2T_VERSION(1,0,0,0) -#define Q2T_VERSION_STRING "1.0.0" +#define Q2T_VERSION_STRING "1.0.1" #define Q2T_MAX_CDB_LEN 16 #define Q2T_TIMEOUT 10 /* in seconds */ Modified: trunk/qla_isp/linux/isp_pci.c =================================================================== --- trunk/qla_isp/linux/isp_pci.c 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla_isp/linux/isp_pci.c 2008-07-09 16:44:01 UTC (rev 442) @@ -548,7 +548,7 @@ if (isp_debug) { isp->isp_dblev = isp_debug; } else { - isp->isp_dblev = ISP_LOGERR; + isp->isp_dblev = ISP_LOGCONFIG|ISP_LOGINFO|ISP_LOGWARN|ISP_LOGERR; } pci_read_config_word(pdev, PCI_COMMAND, &cmd); Modified: trunk/qla_isp/linux/isp_scst.c =================================================================== --- trunk/qla_isp/linux/isp_scst.c 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/qla_isp/linux/isp_scst.c 2008-07-09 16:44:01 UTC (rev 442) @@ -156,7 +156,7 @@ struct scst_proc_data proc_data; }; -//#define DEBUG 1 +#define DEBUG 1 #ifdef DEBUG #define SDprintk if (debug) printk Modified: trunk/scst/ChangeLog =================================================================== --- trunk/scst/ChangeLog 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/ChangeLog 2008-07-09 16:44:01 UTC (rev 442) @@ -1,3 +1,8 @@ +Summary of changes between versions 1.0.0 and 1.0.1 +--------------------------------------------------- + + + Summary of changes between versions 0.9.5 and 1.0.0 --------------------------------------------------- Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/README 2008-07-09 16:44:01 UTC (rev 442) @@ -1,7 +1,7 @@ Generic SCSI target mid-level for Linux (SCST) ============================================== -Version 1.0.0, 7 July 2008 +Version 1.0.1, X XXXX 2008 -------------------------- SCST is designed to provide unified, consistent interface between SCSI Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/include/scst.h 2008-07-09 16:44:01 UTC (rev 442) @@ -48,9 +48,9 @@ #endif /* Version numbers, the same as for the kernel */ -#define SCST_VERSION_CODE 0x01000000 +#define SCST_VERSION_CODE 0x01000100 #define SCST_VERSION(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) -#define SCST_VERSION_STRING "1.0.0" +#define SCST_VERSION_STRING "1.0.1" #define SCST_INTERFACE_VERSION SCST_VERSION_STRING "$Revision$" SCST_CONST_VERSION /************************************************************* Modified: trunk/scst/include/scst_user.h =================================================================== --- trunk/scst/include/scst_user.h 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/include/scst_user.h 2008-07-09 16:44:01 UTC (rev 442) @@ -26,7 +26,7 @@ #define DEV_USER_NAME "scst_user" #define DEV_USER_PATH "/dev/" -#define DEV_USER_VERSION_NAME "1.0.0" +#define DEV_USER_VERSION_NAME "1.0.1" #define DEV_USER_VERSION DEV_USER_VERSION_NAME "$Revision$" SCST_CONST_VERSION /* Modified: trunk/scst/src/Makefile =================================================================== --- trunk/scst/src/Makefile 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/src/Makefile 2008-07-09 16:44:01 UTC (rev 442) @@ -115,7 +115,7 @@ #EXTRA_CFLAGS += -DSTRICT_SERIALIZING -#EXTRA_CFLAGS += -DEXTRACHECKS +EXTRA_CFLAGS += -DEXTRACHECKS #EXTRA_CFLAGS += -DUSE_EXPECTED_VALUES #EXTRA_CFLAGS += -DALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ @@ -123,9 +123,9 @@ #EXTRA_CFLAGS += -fno-inline -EXTRA_CFLAGS += -DTRACING +#EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG -g +EXTRA_CFLAGS += -DDEBUG -g #EXTRA_CFLAGS += -DDEBUG_TM -DTM_DBG_GO_OFFLINE=0 #EXTRA_CFLAGS += -DDEBUG_RETRY #EXTRA_CFLAGS += -DDEBUG_OOM Modified: trunk/scst/src/dev_handlers/Makefile =================================================================== --- trunk/scst/src/dev_handlers/Makefile 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scst/src/dev_handlers/Makefile 2008-07-09 16:44:01 UTC (rev 442) @@ -69,10 +69,10 @@ EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SCST_INC_DIR) -Wextra -Wno-unused-parameter -#EXTRA_CFLAGS += -DEXTRACHECKS +EXTRA_CFLAGS += -DEXTRACHECKS -EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG -g +#EXTRA_CFLAGS += -DTRACING +EXTRA_CFLAGS += -DDEBUG -g clean: rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers \ Modified: trunk/scstadmin/scstadmin =================================================================== --- trunk/scstadmin/scstadmin 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/scstadmin/scstadmin 2008-07-09 16:44:01 UTC (rev 442) @@ -1,5 +1,5 @@ #!/usr/bin/perl -$Version = 'SCST Configurator v1.0.0'; +$Version = 'SCST Configurator v1.0.1'; # Configures SCST # Modified: trunk/usr/fileio/Makefile =================================================================== --- trunk/usr/fileio/Makefile 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/usr/fileio/Makefile 2008-07-09 16:44:01 UTC (rev 442) @@ -30,9 +30,9 @@ PROGS = fileio_tgt LIBS = -lpthread -#CFLAGS += -DEXTRACHECKS -CFLAGS += -DTRACING -#CFLAGS += -DDEBUG -g +CFLAGS += -DEXTRACHECKS +#CFLAGS += -DTRACING +CFLAGS += -DDEBUG -g #CFLAGS += -DDEBUG_NOMEM #CFLAGS += -DDEBUG_SENSE Modified: trunk/usr/fileio/README =================================================================== --- trunk/usr/fileio/README 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/usr/fileio/README 2008-07-09 16:44:01 UTC (rev 442) @@ -1,7 +1,7 @@ User space FILEIO handler ========================= -Version 1.0.0, 7 July 2008 +Version 1.0.1, X XXXX 2008 -------------------------- User space program fileio_tgt uses interface of SCST's scst_user dev Modified: trunk/usr/fileio/fileio.c =================================================================== --- trunk/usr/fileio/fileio.c 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/usr/fileio/fileio.c 2008-07-09 16:44:01 UTC (rev 442) @@ -66,7 +66,7 @@ #endif /* defined(DEBUG) || defined(TRACING) */ #define DEF_BLOCK_SHIFT 9 -#define VERSION_STR "1.0.0" +#define VERSION_STR "1.0.1" #define THREADS 7 static struct option const long_options[] = Modified: trunk/usr-full_perf.patch =================================================================== --- trunk/usr-full_perf.patch 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/usr-full_perf.patch 2008-07-09 16:44:01 UTC (rev 442) @@ -2,7 +2,7 @@ =================================================================== --- usr/fileio/Makefile (revision 324) +++ usr/fileio/Makefile (working copy) -@@ -29,9 +29,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- +@@ -30,9 +30,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- PROGS = fileio_tgt LIBS = -lpthread Modified: trunk/usr-release.patch =================================================================== --- trunk/usr-release.patch 2008-07-09 09:50:33 UTC (rev 441) +++ trunk/usr-release.patch 2008-07-09 16:44:01 UTC (rev 442) @@ -2,7 +2,7 @@ =================================================================== --- usr/fileio/Makefile (revision 324) +++ usr/fileio/Makefile (working copy) -@@ -29,9 +29,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- +@@ -30,9 +30,9 @@ CFLAGS += -O2 -Wall -Wextra -Wno-unused- PROGS = fileio_tgt LIBS = -lpthread This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-07-09 17:28:37
|
Revision: 445 http://scst.svn.sourceforge.net/scst/?rev=445&view=rev Author: vlnb Date: 2008-07-09 10:28:36 -0700 (Wed, 09 Jul 2008) Log Message: ----------- The patch below implements the following changes: - The script specialize-patch now acts as if #define INSIDE_KERNEL_TREE 1 is effective. - The script generate-kernel-patch now renames sBUG_ON() into BUG_ON() and sBUG() into BUG(). The same script removes the definitions of the sBUG_ON(), sBUG() and WARN_ON_ONCE() macro's from the header file scst_debug.h. The last macro is only removed for kernel versions later than 2.6.19. This patch has been tested as follows: - Compared the output of the command "scripts/generate-kernel-patch 2.6.25" before and after the changes. - Verified the newly generated patch with checkpatch. Checkpatch statistics are now as follows: 521 WARNING: line over 80 characters 12 WARNING: consider using strict_strtoul in preference to simple_strtoul 10 WARNING: printk() should include KERN_ facility level 3 WARNING: CVS style keyword markers, these will _not_ be updated 2 WARNING: do not add new typedefs 1 WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt - Verified that the generated kernel patch still applies cleanly to the 2.6.25.10 kernel and that this kernel still compiles, installs and boots fine. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/scripts/generate-kernel-patch trunk/scripts/specialize-patch trunk/scst/include/scst_debug.h Modified: trunk/scripts/generate-kernel-patch =================================================================== --- trunk/scripts/generate-kernel-patch 2008-07-09 17:19:24 UTC (rev 444) +++ trunk/scripts/generate-kernel-patch 2008-07-09 17:28:36 UTC (rev 445) @@ -64,9 +64,10 @@ @@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@ EOF if [ "${2%.[ch]}" != "$2" ]; then - sed -e 's/^ \([^ ]*:\)$/\1/' -e 's/^/+/' < "$1" + sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' \ + -e 's/^ \([^ ]*:\)$/\1/' < "$1" else - sed -e 's/^/+/' < "$1" + sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' < "$1" fi fi } Modified: trunk/scripts/specialize-patch =================================================================== --- trunk/scripts/specialize-patch 2008-07-09 17:19:24 UTC (rev 444) +++ trunk/scripts/specialize-patch 2008-07-09 17:28:36 UTC (rev 445) @@ -46,11 +46,13 @@ gsub("LINUX_VERSION_CODE", LINUX_VERSION_CODE, stmnt) + gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt) + do { last_stmnt = stmnt - pattern = "! ([0-9]+)" + pattern = "! *([0-9]+)" while (match(stmnt, pattern, op) != 0) { sub(pattern, op[1] == 0, stmnt) @@ -110,7 +112,7 @@ { # Only act on preprocessor conditional expressions with regard to the Linux # kernel version, and do not interpret other expressions. - if ($0 ~ "LINUX_VERSION_CODE") + if ($0 ~ "LINUX_VERSION_CODE" || $0 ~ "INSIDE_KERNEL_TREE") { $0 = evaluated } Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-07-09 17:19:24 UTC (rev 444) +++ trunk/scst/include/scst_debug.h 2008-07-09 17:28:36 UTC (rev 445) @@ -39,6 +39,7 @@ #define DEBUG #endif +#if !defined(INSIDE_KERNEL_TREE) #ifdef DEBUG #ifndef EXTRACHECKS @@ -69,8 +70,9 @@ #define sBUG_ON(p) BUG_ON(p) #endif +#endif -#ifndef WARN_ON_ONCE +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #define WARN_ON_ONCE(condition) ({ \ static int __warned; \ typeof(condition) __ret_warn_once = (condition); \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2008-07-10 10:49:13
|
Revision: 453 http://scst.svn.sourceforge.net/scst/?rev=453&view=rev Author: vlnb Date: 2008-07-10 03:49:06 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Apparently the SCST code with debugging and/or tracing enabled compiles fine as an external module. When applying the SCST kernel patch to the mainstream kernel tree with debugging and/or tracing enabled however, the resulting code triggers a compiler error. This is because the symbols DEBUG and TRACING conflict with symbols with the same named defined in unrelated kernel headers. The patch below resolves these conflicts by renaming the following preprocessor symbols: - DEBUG into CONFIG_SCST_DEBUG. - DEBUG_DIGEST_FAILURES into CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES. - DEBUG_OOM into CONFIG_SCST_DEBUG_OOM. - DEBUG_RETRY into CONFIG_SCST_DEBUG_RETRY. - DEBUG_SN into CONFIG_SCST_DEBUG_SN. - DEBUG_TM into CONFIG_SCST_DEBUG_TM. - EXTRACHECKS into CONFIG_SCST_EXTRACHECKS. - SCST_HIGHMEM into CONFIG_SCST_HIGHMEM. - STRICT_SERIALIZING into CONFIG_SCST_STRICT_SERIALIZING. - TM_DBG_GO_OFFLINE into CONFIG_SCST_TM_DBG_GO_OFFLINE. Mapped 0/1 values into macro undefined / macro defined. - TRACING into CONFIG_SCST_TRACING. - USE_EXPECTED_VALUES into CONFIG_SCST_USE_EXPECTED_VALUES. - In qla_isp/linux/isp_scst.c, renamed DEBUG into DEBUG_ISP_SCST. - In qla_isp/..., renamed SCSI_TARGET in SCST_SCSI_TARGET. - In qla_isp/..., renamed SCSI_TARGET_DEV in SCST_SCSI_TARGET_DEV. Additionally, all CONFIG_SCSI_TARGET* macro's are renamed into CONFIG_SCST* in order to avoid confusion between the STGT CONFIG-symbols and the SCST CONFIG- symbols. The following additional options are now configurable through Kconfig: - CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES - CONFIG_SCST_STRICT_SERIALIZING - CONFIG_SCST_STRICT_SECURITY - CONFIG_SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ - CONFIG_SCST_ABORT_CONSIDER_FINISHED_TASKS_AS_NOT_EXISTING - CONFIG_SCST_USE_EXPECTED_VALUES - CONFIG_SCST_DEBUG_OOM - CONFIG_SCST_DEBUG_RETRY - CONFIG_SCST_DEBUG_SN - CONFIG_SCST_DEBUG_TM - CONFIG_SCST_TM_DBG_GO_OFFLINE The patch below has been verified as follows: - Verified that the following command does not print any new warning messages: make -s clean && make -C srpt -s clean && make -s scst iscsi-scst && make -C srpt -s - Verified as follows that the internal SCST patches still apply cleanly: for p in *patch; do patch -p0 --dry-run -f -s <$p; done - Checked that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.7 kernel, and that the patched kernel tree still compiles, installs and boots fine, that the iscsi-scst, ib_srpt, scst_disk and scst_vdisk modules still load, and that iSCSI communication still works fine. All SCST kernel configuration options that could be enabled have been enabled during this test. Signed-off-by: Bart Van Assche <bar...@gm...> Modified Paths: -------------- trunk/iscsi-full_perf.patch trunk/iscsi-release.patch trunk/iscsi-scst/README trunk/iscsi-scst/kernel/Kconfig trunk/iscsi-scst/kernel/Makefile trunk/iscsi-scst/kernel/config.c trunk/iscsi-scst/kernel/conn.c trunk/iscsi-scst/kernel/digest.c trunk/iscsi-scst/kernel/iscsi.c trunk/iscsi-scst/kernel/iscsi.h trunk/iscsi-scst/kernel/iscsi_dbg.h trunk/iscsi-scst/kernel/nthread.c trunk/mpt/Makefile trunk/mpt/in-tree/Makefile trunk/mpt/mpt_scst.c trunk/qla2x00t/qla2x00-target/Makefile trunk/qla2x00t/qla2x00-target/README trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/qla2x00t/qla2x00-target/qla2x00t.h trunk/qla2x00t-full_perf.patch trunk/qla2x00t-release.patch trunk/scst/ChangeLog trunk/scst/README trunk/scst/ToDo trunk/scst/include/scst.h trunk/scst/include/scst_debug.h trunk/scst/kernel/in-tree/Kconfig.scst trunk/scst/kernel/in-tree/Makefile.dev_handlers trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.15.patch trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.7.patch trunk/scst/kernel/in-tree/Makefile.scst trunk/scst/src/Makefile trunk/scst/src/dev_handlers/Makefile trunk/scst/src/dev_handlers/scst_dev_handler.h trunk/scst/src/dev_handlers/scst_user.c trunk/scst/src/dev_handlers/scst_vdisk.c trunk/scst/src/scst_debug.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_main.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_mem.h trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c trunk/scst-full_perf.patch trunk/scst-release.patch trunk/srpt/src/Makefile Modified: trunk/iscsi-full_perf.patch =================================================================== --- trunk/iscsi-full_perf.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-full_perf.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -6,11 +6,11 @@ EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter --EXTRA_CFLAGS += -DEXTRACHECKS -+#EXTRA_CFLAGS += -DEXTRACHECKS - #EXTRA_CFLAGS += -DTRACING --EXTRA_CFLAGS += -DDEBUG -g -+#EXTRA_CFLAGS += -DDEBUG -g +-EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS ++#EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS + #EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +-EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g ++#EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g - #EXTRA_CFLAGS += -DDEBUG_DIGEST_FAILURES + #EXTRA_CFLAGS += -DCONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES Modified: trunk/iscsi-release.patch =================================================================== --- trunk/iscsi-release.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-release.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -6,12 +6,12 @@ EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter --EXTRA_CFLAGS += -DEXTRACHECKS --#EXTRA_CFLAGS += -DTRACING --EXTRA_CFLAGS += -DDEBUG -g -+#EXTRA_CFLAGS += -DEXTRACHECKS -+EXTRA_CFLAGS += -DTRACING -+#EXTRA_CFLAGS += -DDEBUG -g +-EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +-#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +-EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g ++#EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS ++EXTRA_CFLAGS += -DCONFIG_SCST_TRACING ++#EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g - #EXTRA_CFLAGS += -DDEBUG_DIGEST_FAILURES + #EXTRA_CFLAGS += -DCONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES Modified: trunk/iscsi-scst/README =================================================================== --- trunk/iscsi-scst/README 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/README 2008-07-10 10:49:06 UTC (rev 453) @@ -162,16 +162,17 @@ There are the following compilation options, that could be commented in/out in the kernel's module Makefile: - - DEBUG - turns on some debugging code, including some logging. Makes - the driver considerably bigger and slower, producing large amount of + - CONFIG_SCST_DEBUG - turns on some debugging code, including some logging. + Makes the driver considerably bigger and slower, producing large amount of log data. - - TRACING - turns on ability to log events. Makes the driver considerably - bigger and lead to some performance loss. + - CONFIG_SCST_TRACING - turns on ability to log events. Makes the driver + considerably bigger and leads to some performance loss. - - EXTRACHECKS - adds extra validity checks in the various places. + - CONFIG_SCST_EXTRACHECKS - adds extra validity checks in the various places. - - DEBUG_DIGEST_FAILURES - simulates digest failures in random places. + - CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES - simulates digest failures in + random places. Creating version of put_page_callback patch for your kernel ----------------------------------------------------------- Modified: trunk/iscsi-scst/kernel/Kconfig =================================================================== --- trunk/iscsi-scst/kernel/Kconfig 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/Kconfig 2008-07-10 10:49:06 UTC (rev 453) @@ -1,5 +1,22 @@ config SCST_ISCSI tristate "SCST iSCSI Support" depends on SCSI - ---help--- - iSCSI target support. The iSCSI protocol has been defined in RFC 3720. + help + iSCSI target support. The iSCSI protocol has been defined in + RFC 3720. + +config SCST_ISCSI_DEBUG_DIGEST_FAILURES + bool "Simulate iSCSI digest failures" + depends on SCST_ISCSI + help + Simulates iSCSI digest failures in random places. Even when iSCSI + traffic is sent over a TCP connection, the 16-bit TCP checksum is too + weak for the requirements of a storage protocol. Furthermore, there + are also instances where the TCP checksum does not protect iSCSI + data, as when data is corrupted while being transferred on a PCI bus + or while in memory. The iSCSI protocol therefore defines a 32-bit CRC + digest on iSCSI packets in order to detect data corruption on an + end-to-end basis. CRCs can be used on iSCSI PDU headers and/or data. + Enabling this option allows to test digest failure recovery in the + iSCSI initiator that is talking to SCST. If unsure, disable this + option. Modified: trunk/iscsi-scst/kernel/Makefile =================================================================== --- trunk/iscsi-scst/kernel/Makefile 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/Makefile 2008-07-10 10:49:06 UTC (rev 453) @@ -23,11 +23,11 @@ EXTRA_CFLAGS += -I$(src)/../include -I$(SCST_INC_DIR) # -Wextra -Wno-unused-parameter -EXTRA_CFLAGS += -DEXTRACHECKS -#EXTRA_CFLAGS += -DTRACING -EXTRA_CFLAGS += -DDEBUG -g +EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g -#EXTRA_CFLAGS += -DDEBUG_DIGEST_FAILURES +#EXTRA_CFLAGS += -DCONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES obj-m += iscsi-scst.o iscsi-scst-objs := iscsi.o nthread.o config.o digest.o \ Modified: trunk/iscsi-scst/kernel/config.c =================================================================== --- trunk/iscsi-scst/kernel/config.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/config.c 2008-07-10 10:49:06 UTC (rev 453) @@ -19,7 +19,7 @@ #define ISCSI_PROC_VERSION_NAME "version" -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) #define ISCSI_PROC_LOG_ENTRY_NAME "trace_level" @@ -71,19 +71,19 @@ seq_printf(seq, "%s\n", ISCSI_VERSION_STRING); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS seq_printf(seq, "EXTRACHECKS\n"); #endif -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING seq_printf(seq, "TRACING\n"); #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG seq_printf(seq, "DEBUG\n"); #endif -#ifdef DEBUG_DIGEST_FAILURES +#ifdef CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES seq_printf(seq, "DEBUG_DIGEST_FAILURES\n"); #endif @@ -96,7 +96,7 @@ .show = iscsi_version_info_show, }; -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) static struct scst_proc_data iscsi_log_proc_data = { SCST_DEF_RW_SEQ_OP(iscsi_proc_log_entry_write) .show = iscsi_log_info_show, @@ -122,7 +122,7 @@ goto out; } -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) /* create the proc file entry for the device */ iscsi_log_proc_data.data = (void *)templ->name; p = scst_create_proc_entry(root, ISCSI_PROC_LOG_ENTRY_NAME, @@ -141,7 +141,7 @@ TRACE_EXIT_RES(res); return res; -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) out_remove_ver: remove_proc_entry(ISCSI_PROC_VERSION_NAME, root); goto out; @@ -156,7 +156,7 @@ root = scst_proc_get_tgt_root(templ); if (root) { -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) remove_proc_entry(ISCSI_PROC_LOG_ENTRY_NAME, root); #endif remove_proc_entry(ISCSI_PROC_VERSION_NAME, root); @@ -540,7 +540,7 @@ .release = release, }; -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG void iscsi_dump_iov(struct msghdr *msg) { if (trace_flag & TRACE_D_IOV) { @@ -604,4 +604,4 @@ printk("Data: (%d)\n", pdu->datasize); } } -#endif /* DEBUG */ +#endif /* CONFIG_SCST_DEBUG */ Modified: trunk/iscsi-scst/kernel/conn.c =================================================================== --- trunk/iscsi-scst/kernel/conn.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/conn.c 2008-07-10 10:49:06 UTC (rev 453) @@ -447,7 +447,7 @@ return 0; } -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS void iscsi_extracheck_is_rd_thread(struct iscsi_conn *conn) { @@ -477,4 +477,4 @@ } } -#endif /* EXTRACHECKS */ +#endif /* CONFIG_SCST_EXTRACHECKS */ Modified: trunk/iscsi-scst/kernel/digest.c =================================================================== --- trunk/iscsi-scst/kernel/digest.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/digest.c 2008-07-10 10:49:06 UTC (rev 453) @@ -61,7 +61,7 @@ { u32 crc = ~0; -#ifdef DEBUG_DIGEST_FAILURES +#ifdef CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES if (((scst_random() % 100000) == 752)) { PRINT_INFO("%s", "Simulating digest failure"); return 0; Modified: trunk/iscsi-scst/kernel/iscsi.c =================================================================== --- trunk/iscsi-scst/kernel/iscsi.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/iscsi.c 2008-07-10 10:49:06 UTC (rev 453) @@ -36,7 +36,7 @@ static char ctr_name[] = "iscsi-scst-ctl"; static int iscsi_template_registered; -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) unsigned long iscsi_trace_flag = ISCSI_DEFAULT_LOG_FLAGS; #endif @@ -276,7 +276,7 @@ if (cmnd->own_sg) { TRACE_DBG("%s", "own_sg"); scst_free(cmnd->sg, cmnd->sg_cnt); -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG cmnd->own_sg = 0; cmnd->sg = NULL; cmnd->sg_cnt = -1; @@ -289,7 +289,7 @@ "new value %d)", cmnd, sess, atomic_read(&sess->active_cmds)-1); atomic_dec(&sess->active_cmds); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS if (unlikely(atomic_read(&sess->active_cmds) < 0)) { PRINT_CRIT_ERROR("active_cmds < 0 (%d)!!", atomic_read(&sess->active_cmds)); @@ -392,7 +392,7 @@ TRACE_DBG("%p", req); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS sBUG_ON(req->release_called); req->release_called = 1; #endif @@ -420,7 +420,7 @@ atomic_read(&sess->active_cmds)-1); atomic_dec(&sess->active_cmds); req->dec_active_cmnds = 0; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS if (unlikely(atomic_read(&sess->active_cmds) < 0)) { PRINT_CRIT_ERROR("active_cmds < 0 (%d)!!", atomic_read(&sess->active_cmds)); @@ -443,7 +443,7 @@ { TRACE_DBG("%p", cmnd); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS sBUG_ON(cmnd->release_called); cmnd->release_called = 1; #endif @@ -2507,7 +2507,7 @@ list_del(&conn->wr_list_entry); /* go through */ case ISCSI_CONN_WR_STATE_IDLE: -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->wr_task = current; #endif conn->wr_state = ISCSI_CONN_WR_STATE_PROCESSING; @@ -2529,7 +2529,7 @@ } spin_lock_bh(&iscsi_wr_lock); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->wr_task = NULL; #endif if ((rc <= 0) || test_write_ready(conn)) { @@ -2661,7 +2661,7 @@ } iscsi_cmnd_init_write(rsp, ISCSI_INIT_WRITE_REMOVE_HASH); } -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS else sBUG(); #endif Modified: trunk/iscsi-scst/kernel/iscsi.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi.h 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/iscsi.h 2008-07-10 10:49:06 UTC (rev 453) @@ -160,7 +160,7 @@ struct list_head wr_list_entry; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS struct task_struct *wr_task; #endif @@ -195,7 +195,7 @@ struct list_head rd_list_entry; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS struct task_struct *rd_task; #endif @@ -258,7 +258,7 @@ unsigned int ddigest_checked:1; unsigned int rejected:1; unsigned int reject_reason:2; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS unsigned int on_rx_digest_list:1; unsigned int release_called:1; #endif @@ -498,7 +498,7 @@ "of req %p", cmnd, req); list_add_tail(&cmnd->rx_ddigest_cmd_list_entry, &req->rx_ddigest_cmd_list); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS cmnd->on_rx_digest_list = 1; #endif } @@ -507,7 +507,7 @@ { TRACE_DBG("Deleting RX digest cmd %p from digest list", cmnd); list_del(&cmnd->rx_ddigest_cmd_list_entry); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS cmnd->on_rx_digest_list = 0; #endif } @@ -548,7 +548,7 @@ atomic_dec(&conn->conn_ref_cnt); } -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS extern void iscsi_extracheck_is_rd_thread(struct iscsi_conn *conn); extern void iscsi_extracheck_is_wr_thread(struct iscsi_conn *conn); #else Modified: trunk/iscsi-scst/kernel/iscsi_dbg.h =================================================================== --- trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/iscsi_dbg.h 2008-07-10 10:49:06 UTC (rev 453) @@ -32,7 +32,7 @@ #define TRACE_ALL_NO_DATA (TRACE_ALL & ~TRACE_D_IOV & ~TRACE_D_DUMP_PDU & ~TRACE_D_DATA) -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_LINE | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_MINOR | TRACE_MGMT_DEBUG | \ TRACE_MINOR | TRACE_SPECIAL | TRACE_CONN_OC) @@ -41,7 +41,7 @@ TRACE_MINOR | TRACE_SPECIAL) #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG struct msghdr; struct iscsi_pdu; extern void iscsi_dump_iov(struct msghdr *msg); @@ -51,12 +51,12 @@ #define iscsi_dump_pdu(x) do {} while (0) #endif -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) extern unsigned long iscsi_trace_flag; #define trace_flag iscsi_trace_flag #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define TRACE_CONN_CLOSE(args...) TRACE(TRACE_CONN_OC, args) #define TRACE_CONN_CLOSE_DBG(args...) TRACE(TRACE_CONN_OC_DBG, args) @@ -64,7 +64,7 @@ #define TRACE_WRITE(args...) TRACE(TRACE_D_WRITE, args) #define TRACE_READ(args...) TRACE(TRACE_D_READ, args) -#else /* DEBUG */ +#else /* CONFIG_SCST_DEBUG */ #define TRACE_CONN_CLOSE(format, args...) {} #define TRACE_CONN_CLOSE_DBG(format, args...) {} #define TRACE_NET_PAGE(format, args...) {} Modified: trunk/iscsi-scst/kernel/nthread.c =================================================================== --- trunk/iscsi-scst/kernel/nthread.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/iscsi-scst/kernel/nthread.c 2008-07-10 10:49:06 UTC (rev 453) @@ -365,7 +365,7 @@ TRACE_CONN_CLOSE_DBG("conn %p, conn_ref_cnt %d left, wr_state %d, " "exp_cmd_sn %u", conn, atomic_read(&conn->conn_ref_cnt), conn->wr_state, session->exp_cmd_sn); -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG { #ifdef NET_PAGE_CALLBACKS_DEFINED struct iscsi_cmnd *rsp; @@ -467,7 +467,7 @@ TRACE_ENTRY(); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->rd_task = current; #endif close_conn(conn); @@ -782,7 +782,7 @@ sBUG_ON(conn->rd_state == ISCSI_CONN_RD_STATE_PROCESSING); conn->rd_data_ready = 0; conn->rd_state = ISCSI_CONN_RD_STATE_PROCESSING; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->rd_task = current; #endif spin_unlock_bh(&iscsi_rd_lock); @@ -794,7 +794,7 @@ if (closed) continue; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->rd_task = NULL; #endif if ((rc == 0) || conn->rd_data_ready) { @@ -1165,7 +1165,7 @@ /* else go through */ out_err: -#ifndef DEBUG +#ifndef CONFIG_SCST_DEBUG if (!conn->closing) #endif { @@ -1189,7 +1189,7 @@ res = 0; break; default: -#ifndef DEBUG +#ifndef CONFIG_SCST_DEBUG if (!conn->closing) #endif { @@ -1379,7 +1379,7 @@ conn->wr_state = ISCSI_CONN_WR_STATE_PROCESSING; conn->wr_space_ready = 0; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->wr_task = current; #endif spin_unlock_bh(&iscsi_wr_lock); @@ -1389,7 +1389,7 @@ rc = process_write_queue(conn); spin_lock_bh(&iscsi_wr_lock); -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS conn->wr_task = NULL; #endif if ((rc == -EAGAIN) && !conn->wr_space_ready) { Modified: trunk/mpt/Makefile =================================================================== --- trunk/mpt/Makefile 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/mpt/Makefile 2008-07-10 10:49:06 UTC (rev 453) @@ -29,9 +29,9 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(FUSION_INC_DIR) -Iinclude/scsi -EXTRA_CFLAGS += -DEXTRACHECKS -#EXTRA_CFLAGS += -DTRACING -EXTRA_CFLAGS += -DDEBUG +EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD ifeq ($(KVER),) Modified: trunk/mpt/in-tree/Makefile =================================================================== --- trunk/mpt/in-tree/Makefile 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/mpt/in-tree/Makefile 2008-07-10 10:49:06 UTC (rev 453) @@ -2,9 +2,9 @@ FUSION_INC_DIR := drivers/message/fusion EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(FUSION_INC_DIR) -Iinclude/scsi -EXTRA_CFLAGS += -DEXTRACHECKS -#EXTRA_CFLAGS += -DTRACING -EXTRA_CFLAGS += -DDEBUG +EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD obj-$(CONFIG_FUSION_SCST) += mpt_scst.o Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/mpt/mpt_scst.c 2008-07-10 10:49:06 UTC (rev 453) @@ -44,14 +44,14 @@ #define MYNAM "mpt_scst" -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING static int trace_mpi = 0; #define TRACE_MPI 0x80000000 #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG static char *mpt_state_string[] = { "0", "new", @@ -63,12 +63,12 @@ }; #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_MINOR | \ TRACE_MGMT_DEBUG | TRACE_MINOR | TRACE_SPECIAL) #else -# ifdef TRACING +# ifdef CONFIG_SCST_TRACING #define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | TRACE_SPECIAL) # endif @@ -126,11 +126,11 @@ u32 offset, LinkServiceBufferPostReply_t *rep, int index); static void stm_set_scsi_port_page1(MPT_STM_PRIV *priv, int sleep); -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define trace_flag mpt_trace_flag unsigned long mpt_trace_flag = TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_SPECIAL; #else -# ifdef TRACING +# ifdef CONFIG_SCST_TRACING #define trace_flag mpt_trace_flag unsigned long mpt_trace_flag = TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_SPECIAL; # endif @@ -475,7 +475,7 @@ CMD *cmd; struct scst_cmd *scst_cmd; struct mpt_sess *sess = mpt_cmd->sess; -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif /* @@ -1300,7 +1300,7 @@ cpu_to_le32(MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_END_OF_LIST)); -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -2793,7 +2793,7 @@ } } -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)rep; @@ -2900,7 +2900,7 @@ priv->io_state[index] |= IO_STATE_POSTED; -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; int i; @@ -2958,7 +2958,7 @@ } } -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -2995,7 +2995,7 @@ priv->io_state[index] |= IO_STATE_POSTED; -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -3046,7 +3046,7 @@ ((u8 *)priv->hw->fc_link_serv_buf[index].fc_els - (u8 *)priv->hw); stm_set_dma_addr(sge_simple->Address, dma_addr); -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -3212,7 +3212,7 @@ } priv->io_state[index] |= IO_STATE_STATUS_SENT; -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -3269,7 +3269,7 @@ p_index = (int *)(sge_simple + 1); *p_index = index; -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)req; @@ -3406,7 +3406,7 @@ static int stm_target_mode_abort(MPT_STM_PRIV *priv) { -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif int i; @@ -3794,7 +3794,7 @@ stm_scsi_configuration(MPT_STM_PRIV *priv, int sleep) { -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif SCSIPortPage0_t *ScsiPort0; @@ -3875,7 +3875,7 @@ static void stm_set_scsi_port_page1(MPT_STM_PRIV *priv, int sleep) { -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif SCSIPortPage1_t *ScsiPort1; @@ -4268,7 +4268,7 @@ return (-1); } -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)priv->hw->config_buf; @@ -4375,7 +4375,7 @@ return (-1); } -#ifdef TRACING +#ifdef CONFIG_SCST_TRACING if(trace_mpi) { u32 *p = (u32 *)priv->hw->config_buf; @@ -4837,7 +4837,7 @@ stmapp_abts_process(MPT_STM_PRIV *priv, int rx_id, LinkServiceBufferPostReply_t *rep, int index) { -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif volatile int *io_state; @@ -4886,7 +4886,7 @@ stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, u32 offset, LinkServiceBufferPostReply_t *rep, int index) { -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG MPT_ADAPTER *ioc = priv->ioc; #endif FC_ELS *fc_els_buf; @@ -5450,7 +5450,7 @@ TRACE_EXIT(); } -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) #define MPT_PROC_LOG_ENTRY_NAME "trace_level" @@ -5491,7 +5491,7 @@ static int mpt_proc_log_entry_build(struct scst_tgt_template *templ) { int res = 0; -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) struct proc_dir_entry *p, *root; TRACE_ENTRY(); @@ -5520,7 +5520,7 @@ static void mpt_proc_log_entry_clean(struct scst_tgt_template *templ) { -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) struct proc_dir_entry *root; TRACE_ENTRY(); Modified: trunk/qla2x00t/qla2x00-target/Makefile =================================================================== --- trunk/qla2x00t/qla2x00-target/Makefile 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t/qla2x00-target/Makefile 2008-07-10 10:49:06 UTC (rev 453) @@ -35,8 +35,8 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra -EXTRA_CFLAGS += -DEXTRACHECKS -#EXTRA_CFLAGS += -DTRACING +EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING EXTRA_CFLAGS += -DDEBUG_TGT -g #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD Modified: trunk/qla2x00t/qla2x00-target/README =================================================================== --- trunk/qla2x00t/qla2x00-target/README 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t/qla2x00-target/README 2008-07-10 10:49:06 UTC (rev 453) @@ -84,8 +84,8 @@ the driver considerably bigger and slower, producing large amount of log data. - - TRACING - turns on ability to log events. Makes the driver considerably - bigger and lead to some performance loss. + - CONFIG_SCST_TRACING - turns on ability to log events. Makes the driver + considerably bigger and leads to some performance loss. - DEBUG_WORK_IN_THREAD - makes SCST process incoming commands and call the driver's callbacks in SCST thread context instead of tasklet Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2008-07-10 10:49:06 UTC (rev 453) @@ -47,12 +47,12 @@ #error "FC_TARGET_SUPPORT is NOT DEFINED" #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define Q2T_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_MINOR | \ TRACE_MGMT_DEBUG | TRACE_MINOR | TRACE_SPECIAL) #else -# ifdef TRACING +# ifdef CONFIG_SCST_TRACING #define Q2T_DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | \ TRACE_SPECIAL) # endif @@ -79,7 +79,7 @@ * Global Variables */ -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) #define trace_flag q2t_trace_flag unsigned long q2t_trace_flag = Q2T_DEFAULT_LOG_FLAGS; #endif @@ -2135,7 +2135,7 @@ return; } -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) #define Q2T_PROC_LOG_ENTRY_NAME "trace_level" @@ -2176,7 +2176,7 @@ static int q2t_proc_log_entry_build(struct scst_tgt_template *templ) { int res = 0; -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) struct proc_dir_entry *p, *root; TRACE_ENTRY(); @@ -2205,7 +2205,7 @@ static void q2t_proc_log_entry_clean(struct scst_tgt_template *templ) { -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) struct proc_dir_entry *root; TRACE_ENTRY(); Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.h =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.h 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.h 2008-07-10 10:49:06 UTC (rev 453) @@ -26,11 +26,8 @@ #include <qla_def.h> #include "qla2x_tgt_def.h" -/* Undefine the initiator driver's own DEBUG symbol */ -#undef DEBUG - #ifdef DEBUG_TGT -#define DEBUG +#define CONFIG_SCST_DEBUG #endif #include <scst_debug.h> Modified: trunk/qla2x00t-full_perf.patch =================================================================== --- trunk/qla2x00t-full_perf.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t-full_perf.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -6,9 +6,9 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra --EXTRA_CFLAGS += -DEXTRACHECKS -+#EXTRA_CFLAGS += -DEXTRACHECKS - #EXTRA_CFLAGS += -DTRACING +-EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS ++#EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS + #EXTRA_CFLAGS += -DCONFIG_SCST_TRACING -EXTRA_CFLAGS += -DDEBUG_TGT -g +#EXTRA_CFLAGS += -DDEBUG_TGT -g #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD Modified: trunk/qla2x00t-release.patch =================================================================== --- trunk/qla2x00t-release.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/qla2x00t-release.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -6,11 +6,11 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra --EXTRA_CFLAGS += -DEXTRACHECKS --#EXTRA_CFLAGS += -DTRACING +-EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS +-#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING -EXTRA_CFLAGS += -DDEBUG_TGT -g -+#EXTRA_CFLAGS += -DEXTRACHECKS -+EXTRA_CFLAGS += -DTRACING ++#EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS ++EXTRA_CFLAGS += -DCONFIG_SCST_TRACING +#EXTRA_CFLAGS += -DDEBUG_TGT -g #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD Modified: trunk/scst/ChangeLog =================================================================== --- trunk/scst/ChangeLog 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/ChangeLog 2008-07-10 10:49:06 UTC (rev 453) @@ -97,7 +97,7 @@ --------------------------------------------------- - Fixed many found task management related problems, especially in the - RESETs area. DEBUG_TM compilation option added (see README). + RESETs area. CONFIG_SCST_DEBUG_TM compilation option added (see README). - Updated to work on kernels version 2.6.18+. @@ -198,8 +198,8 @@ - UA generating after MODE SELECT and LOG SELECT implemented - - STRICT_SERIALIZING compile-time option added for those who need most - robust task management and willing to pay some performance cost for + - CONFIG_SCST_STRICT_SERIALIZING compile-time option added for those who need + the most robust task management and willing to pay some performance cost for that (see README) - IRQ spinlocks were replaced by BH ones, where appropriate. Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/README 2008-07-10 10:49:06 UTC (rev 453) @@ -64,7 +64,7 @@ in the kernel. Patch scst_exec_req_fifo.patch from "kernel" directory does that. If it doesn't apply to your kernel, apply it manually, it only adds one of those functions and nothing more. You may not patch the -kernel if you don't need pass-through support or STRICT_SERIALIZING is +kernel if you don't need pass-through support or CONFIG_SCST_STRICT_SERIALIZING is defined during the compilation (see description below). To compile SCST type 'make scst'. It will build SCST itself and its @@ -184,24 +184,24 @@ There are the following compilation options, that could be commented in/out in Makefile: - - DEBUG - if defined, turns on some debugging code, including some - logging. Makes the driver considerably bigger and slower, producing - large amount of log data. + - CONFIG_SCST_DEBUG - if defined, turns on some debugging code, + including some logging. Makes the driver considerably bigger and slower, + producing large amount of log data. - - TRACING - if defined, turns on ability to log events. Makes the - driver considerably bigger and lead to some performance loss. + - CONFIG_SCST_TRACING - if defined, turns on ability to log events. Makes the + driver considerably bigger and leads to some performance loss. - - EXTRACHECKS - if defined, adds extra validity checks in the various - places. + - CONFIG_SCST_EXTRACHECKS - if defined, adds extra validity checks in + the various places. - - USE_EXPECTED_VALUES - if not defined (default), initiator supplied - expected data transfer length and direction will be used only for + - CONFIG_SCST_USE_EXPECTED_VALUES - if not defined (default), initiator + supplied expected data transfer length and direction will be used only for verification purposes to return error or warn in case if one of them is invalid. Instead, locally decoded from SCSI command values will be used. This is necessary for security reasons, because otherwise a faulty initiator can crash target by supplying invalid value in one of those parameters. This is especially important in case of - pass-through mode. If USE_EXPECTED_VALUES is defined, initiator + pass-through mode. If CONFIG_SCST_USE_EXPECTED_VALUES is defined, initiator supplied expected data transfer length and direction will override the locally decoded values. This might be necessary if internal SCST commands translation table doesn't contain SCSI command, which is @@ -212,16 +212,16 @@ scs...@li.... Note, that not all SCSI transports support supplying expected values. - - DEBUG_TM - if defined, turns on task management functions debugging, - when on LUN 0 in the default access control group some of the + - CONFIG_SCST_DEBUG_TM - if defined, turns on task management functions + debugging, when on LUN 0 in the default access control group some of the commands will be delayed for about 60 sec., so making the remote initiator send TM functions, eg ABORT TASK and TARGET RESET. Also - define TM_DBG_GO_OFFLINE symbol in the Makefile to 1 if you want that - the device eventually become completely unresponsive, or to 0 - otherwise to circle around ABORTs and RESETs code. Needs DEBUG turned - on. + define CONFIG_SCST_TM_DBG_GO_OFFLINE symbol in the Makefile if you + want that the device eventually become completely unresponsive, or + otherwise to circle around ABORTs and RESETs code. Needs CONFIG_SCST_DEBUG + turned on. - - STRICT_SERIALIZING - if defined, makes SCST send all commands to + - CONFIG_SCST_STRICT_SERIALIZING - if defined, makes SCST send all commands to underlying SCSI device synchronously, one after one. This makes task management more reliable, with cost of some performance penalty. This is mostly actual for stateful SCSI devices like tapes, where the @@ -233,8 +233,8 @@ need as much error recovery reliability as possible. As a side effect, no kernel patching is necessary. - - ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ - if defined, it will be allowed - to submit pass-through commands to real SCSI devices via the SCSI + - CONFIG_SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ - if defined, it will be + allowed to submit pass-through commands to real SCSI devices via the SCSI middle layer using scsi_execute_async() function from soft IRQ context (tasklets). This used to be the default, but currently it seems the SCSI middle layer starts expecting only thread context on @@ -245,20 +245,20 @@ scsi_execute_async() function, you will get a warning message in the kernel log. - - SCST_HIGHMEM - if defined on HIGHMEM systems with 2.6 kernels, it + - CONFIG_SCST_HIGHMEM - if defined on HIGHMEM systems with 2.6 kernels, it allows SCST to use HIGHMEM. This is very experimental feature, which is currently broken and unsupported, since it is unclear, if it brings something valuable, except some performance hit. Note, that - SCST_HIGHMEM isn't required for HIGHMEM systems and SCST will work + CONFIG_SCST_HIGHMEM isn't required for HIGHMEM systems and SCST will work fine on them with SCST_HIGHMEM off. - - SCST_STRICT_SECURITY - if defined, makes SCST zero allocated data + - CONFIG_SCST_STRICT_SECURITY - if defined, makes SCST zero allocated data buffers. Undefining it (default) considerably improves performance and eases CPU load, but could create a security hole (information leakage), so enable it, if you have strict security requirements. - - ABORT_CONSIDER_FINISHED_TASKS_AS_NOT_EXISTING - if defined, in case - when TASK MANAGEMENT function ABORT TASK is trying to abort a + - CONFIG_SCST_ABORT_CONSIDER_FINISHED_TASKS_AS_NOT_EXISTING - if defined, + in case when TASK MANAGEMENT function ABORT TASK is trying to abort a command, which has already finished, remote initiator, which sent the ABORT TASK request, will receive TASK NOT EXIST (or ABORT FAILED) response for the ABORT TASK request. This is more logical response, @@ -649,18 +649,20 @@ 1. For SCST: - - Disable in Makefile STRICT_SERIALIZING, EXTRACHECKS, TRACING, DEBUG*, - SCST_STRICT_SECURITY, SCST_HIGHMEM + - Disable in Makefile CONFIG_SCST_STRICT_SERIALIZING, CONFIG_SCST_EXTRACHECKS, + CONFIG_SCST_TRACING, DEBUG*, CONFIG_SCST_STRICT_SECURITY, + CONFIG_SCST_HIGHMEM - - For pass-through devices enable ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ. + - For pass-through devices enable + CONFIG_SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ. 2. For target drivers: - - Disable in Makefiles EXTRACHECKS, TRACING, DEBUG* + - Disable in Makefiles CONFIG_SCST_EXTRACHECKS, CONFIG_SCST_TRACING, DEBUG* 3. For device handlers, including VDISK: - - Disable in Makefile TRACING, DEBUG + - Disable in Makefile CONFIG_SCST_TRACING and CONFIG_SCST_DEBUG. - If your initiator(s) use dedicated exported from the target virtual SCSI devices and have more or equal amount of memory, than the @@ -673,7 +675,7 @@ than for performance. If you use SCST version taken directly from the SVN repository, you can -set the above options, except ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ, using +set the above options, except CONFIG_SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ, using debug2perf Makefile target. 4. For other target and initiator software parts: Modified: trunk/scst/ToDo =================================================================== --- trunk/scst/ToDo 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/ToDo 2008-07-10 10:49:06 UTC (rev 453) @@ -30,7 +30,7 @@ - HIGHMEM cleanup. Looks like HIGHMEM usage doesn't worth the effort and performance hit, at least until VDISK handler doesn't use the page cache directly, so disable it for now, although the code looks ready. - To enable it, set SCST_HIGHMEM in 1 in scst_priv.h. HIGHMEM is not + To enable it, set CONFIG_SCST_HIGHMEM in 1 in scst_priv.h. HIGHMEM is not supported on 2.4 and is not going to be. - Small ToDo's spread all over the code. Modified: trunk/scst/include/scst.h =================================================================== --- trunk/scst/include/scst.h 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/include/scst.h 2008-07-10 10:49:06 UTC (rev 453) @@ -27,7 +27,7 @@ #include <linux/interrupt.h> #include <linux/proc_fs.h> -#ifdef SCST_HIGHMEM +#ifdef CONFIG_SCST_HIGHMEM #include <asm/kmap_types.h> #endif #include <scsi/scsi_cmnd.h> @@ -365,7 +365,7 @@ #define SCST_TGT_DEV_AFTER_RX_DATA_ATOMIC 9 #define SCST_TGT_DEV_AFTER_EXEC_ATOMIC 10 -#ifdef DEBUG_TM +#ifdef CONFIG_SCST_DEBUG_TM #define SCST_TGT_DEV_UNDER_TM_DBG 20 #endif @@ -1045,13 +1045,13 @@ /* * Set if the cmd was delayed by task management debugging code. - * Used only if DEBUG_TM is on. + * Used only if CONFIG_SCST_DEBUG_TM is on. */ unsigned int tm_dbg_delayed:1; /* * Set if the cmd must be ignored by task management debugging code. - * Used only if DEBUG_TM is on. + * Used only if CONFIG_SCST_DEBUG_TM is on. */ unsigned int tm_dbg_immut:1; @@ -2006,7 +2006,7 @@ static inline int scst_cmd_atomic(struct scst_cmd *cmd) { int res = cmd->atomic; -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS if (unlikely(in_atomic() && !res)) { printk(KERN_ERR "ERROR: in_atomic() and non-atomic cmd\n"); dump_stack(); @@ -2393,7 +2393,7 @@ if ((i >= cmd->sg_cnt) || unlikely(sg == NULL)) goto out; -#ifdef SCST_HIGHMEM /* HIGHMEM isn't currently supported */ +#ifdef CONFIG_SCST_HIGHMEM /* HIGHMEM isn't currently supported */ /* * HIGHMEM pages not merged (clustered), so if it's * not HIGHMEM page, kmap() is the same as page_address() @@ -2432,7 +2432,7 @@ static inline void scst_put_buf(struct scst_cmd *cmd, void *buf) { -#ifdef SCST_HIGHMEM /* HIGHMEM isn't currently supported */ +#ifdef CONFIG_SCST_HIGHMEM /* HIGHMEM isn't currently supported */ if (cmd->sg_cnt) { if (scst_cmd_atomic(cmd)) { enum km_type km; @@ -2455,7 +2455,7 @@ static inline int scst_get_buf_count(struct scst_cmd *cmd) { int res; -#ifdef SCST_HIGHMEM +#ifdef CONFIG_SCST_HIGHMEM res = (cmd->bufflen >> PAGE_SHIFT) + 1; #else res = (cmd->sg_cnt == 0) ? 1 : cmd->sg_cnt; Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/include/scst_debug.h 2008-07-10 10:49:06 UTC (rev 453) @@ -27,25 +27,9 @@ #include <linux/bug.h> /* for WARN_ON_ONCE */ #endif -#if !defined(EXTRACHECKS) && defined(CONFIG_SCSI_TARGET_EXTRACHECKS) -#define EXTRACHECKS -#endif - -#if !defined(TRACING) && defined(CONFIG_SCSI_TARGET_TRACING) -#define TRACING -#endif - -#if !defined(DEBUG) && defined(CONFIG_SCSI_TARGET_DEBUG) -#define DEBUG -#endif - #if !defined(INSIDE_KERNEL_TREE) -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG -#ifndef EXTRACHECKS -#define EXTRACHECKS -#endif - #ifndef CONFIG_DEBUG_BUGVERBOSE #define sBUG() do { \ printk(KERN_CRIT "BUG at %s:%d\n", \ @@ -86,7 +70,7 @@ }) #endif -#ifdef EXTRACHECKS +#ifdef CONFIG_SCST_EXTRACHECKS #define EXTRACHECKS_BUG_ON(a) sBUG_ON(a) #define EXTRACHECKS_WARN_ON(a) WARN_ON(a) #define EXTRACHECKS_WARN_ON_ONCE(a) WARN_ON_ONCE(a) @@ -96,7 +80,7 @@ #define EXTRACHECKS_WARN_ON_ONCE(a) #endif -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG /*# define LOG_FLAG KERN_DEBUG*/ # define LOG_FLAG KERN_INFO # define INFO_FLAG KERN_INFO @@ -139,9 +123,9 @@ #define __LOG_PREFIX NULL #endif -#if defined(DEBUG) || defined(TRACING) +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) -#ifndef DEBUG +#ifndef CONFIG_SCST_DEBUG #define ___unlikely(a) (a) #else #define ___unlikely(a) unlikely(a) @@ -183,15 +167,15 @@ } \ } while (0) -#else /* DEBUG || TRACING */ +#else /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */ #define TRACE(trace, args...) {} #define PRINT_BUFFER(message, buff, len) {} #define PRINT_BUFF_FLAG(flag, message, buff, len) {} -#endif /* DEBUG || TRACING */ +#endif /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */ -#ifdef DEBUG +#ifdef CONFIG_SCST_DEBUG #define __TRACE(trace, format, args...) \ do { \ @@ -333,7 +317,7 @@ } \ } while (0) -#else /* DEBUG */ +#else /* CONFIG_SCST_DEBUG */ #define TRACE_MEM(format, args...) {} #define TRACE_SG(format, args...) {} @@ -400,9 +384,9 @@ #endif /* LOG_PREFIX */ -#endif /* DEBUG */ +#endif /* CONFIG_SCST_DEBUG */ -#if defined(DEBUG) && defined(CONFIG_DEBUG_SLAB) +#if defined(CONFIG_SCST_DEBUG) && defined(CONFIG_DEBUG_SLAB) #define SCST_SLAB_FLAGS (SLAB_RED_ZONE | SLAB_POISON) #else #define SCST_SLAB_FLAGS 0L Modified: trunk/scst/kernel/in-tree/Kconfig.scst =================================================================== --- trunk/scst/kernel/in-tree/Kconfig.scst 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Kconfig.scst 2008-07-10 10:49:06 UTC (rev 453) @@ -1,96 +1,211 @@ menu "SCSI target middle level support" -config SCSI_TARGET +config SCST tristate "SCSI target middle level support" default SCSI depends on SCSI && PROC_FS - ---help--- + help SCSI TARGET is designed to provide unified, consistent interface between SCSI target drivers and Linux kernel and simplify target drivers development as much as possible. -config SCSI_TARGET_DISK +config SCST_DISK tristate "SCSI target disk support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for disk device. -config SCSI_TARGET_TAPE +config SCST_TAPE tristate "SCSI target tape support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for tape device. -config SCSI_TARGET_CDROM +config SCST_CDROM tristate "SCSI target cdrom support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for cdrom device. -config SCSI_TARGET_MODISK +config SCST_MODISK tristate "SCSI target MO disk support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for MO disk device. -config SCSI_TARGET_CHANGER +config SCST_CHANGER tristate "SCSI target changer support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for changer device. -config SCSI_TARGET_PROCESSOR +config SCST_PROCESSOR tristate "SCSI target processor support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for processor device. -config SCSI_TARGET_RAID +config SCST_RAID tristate "SCSI target storage array controller (raid) support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for raid storage array controller (raid) device. -config SCSI_TARGET_VDISK +config SCST_VDISK tristate "SCSI target virtual disk and/or cdrom support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST + help SCSI TARGET handler for virtual disk and/or cdrom device. -config SCSI_TARGET_USER +config SCST_USER tristate "SCSI user space virtual target devices support" - default SCSI_TARGET - depends on SCSI && PROC_FS && SCSI_TARGET && ! HIGHMEM - ---help--- + default SCST + depends on SCSI && PROC_FS && SCST && ! HIGHMEM + help SCSI TARGET handler for virtual user space device. source "drivers/scst/iscsi-scst/Kconfig" -config SCSI_TARGET_EXTRACHECKS - bool "Extra consistency checks" - ---help--- - Enable additional consistency checks in the SCSI middle level target - code. This may be helpful for SCST developers. +config SCST_STRICT_SERIALIZING + bool "Strict serialization" + help + Enable strict SCSI command serialization. When enabled, SCST sends + all SCSI commands to the underlying SCSI device synchronously, one + after one. This makes task management more reliable, at the cost of + a performance penalty. This is most useful for stateful SCSI devices + like tapes, where the result of the execution of a command + depends on the device settings configured by previous commands. Disk + and RAID devices are stateless in most cases. The current SCSI core + in Linux doesn't allow to abort all commands reliably if they have + been sent asynchronously to a stateful device. + Enable this option if you use stateful device(s) and need as much + error recovery reliability as possible. If unsure, leave this + option disabled. -config SCSI_TARGET_TRACING +config SCST_STRICT_SECURITY + bool "Strict security" + help + Makes SCST clear (zero-fill) allocated data buffers. Note: this has a + significant performance penalty. If unsure, leave this option + disabled. + +config SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ + bool "Allow pass-through commands to be sent from soft-IRQ context" + help + Allows SCST to submit SCSI pass-through commands to real SCSI devices + via the SCSI middle layer using scsi_execute_async() function from + soft-IRQ context (tasklets). This used to be the default, but + currently it seems the SCSI middle layer starts expecting only thread + context on the IO submit path, so it is disabled now by default. + Enabling it will decrease amount of context switches and improve + performance. It is more or less safe. In the worst case, if in your + configuration the SCSI middle layer really doesn't expect SIRQ + context in scsi_execute_async() function, you will get a warning + message in the kernel log. If unsure, leave this option disabled. + +config SCST_ABORT_CONSIDER_FINISHED_TASKS_AS_NOT_EXISTING + bool "Send back UNKNOWN TASK when an already finished task is aborted." + help + Controls which response is sent by SCST to the initiator in case + the initiator attempts to abort (ABORT TASK) an already finished + request. If this option is enabled, the response UNKNOWN TASK is + sent back to the initiator. However, some initiators, particularly + the VMware iSCSI initiator, interpret the UNKNOWN TASK response as + if the target got crazy and try to RESET it. Then sometimes the + initiator gets crazy itself. If unsure, leave this option disabled. + +config SCST_USE_EXPECTED_VALUES + bool "Prefer initiator-supplied SCSI command attributes" + help + When SCST receives a SCSI command from an initiator, such a SCSI + command has both data transfer length and direction attributes. + There are two possible sources for these attributes: either the + values computed by SCST from its internal command translation table + or the values supplied by the initiator. The former are used by + default because of security reasons. Invalid initiator-supplied + attributes can crash the target, especially in pass-through mode. + Only consider enabling this option when SCST logs the following + message: "Unknown opcode XX for YY. Should you update + scst_scsi_op_table?" and when the initiator complains. Please + report any unrecognized commands to scs...@li.... + If unsure, leave this option disabled. + +config SCST_EXTRACHECKS + bool "Extra consistency checks" + help + Enable additional consistency checks in the SCSI middle level target + code. This may be helpful for SCST developers. If unsure, leave this + option disabled. + +config SCST_TRACING bool "Tracing support" - ---help--- - Enable SCSI middle level tracing support. Tracing can be controlled - dynamically via /proc/scsi_tgt/trace_level. The traced information - is sent to the kernel log and may be very helpful when analyzing - the cause of a communication problem between initiator and target. + help + Enable SCSI middle level tracing support. Tracing can be controlled + dynamically via /proc/scsi_tgt/trace_level. The traced information + is sent to the kernel log and may be very helpful when analyzing + the cause of a communication problem between initiator and target. + If unsure, leave this option disabled. -config SCSI_TARGET_DEBUG - bool "Debug support" - ---help--- - SCSI TARGET debugging. +config SCST_DEBUG + bool "Debugging support." + help + Enables support for debugging SCST. This may be helpful for SCST + developers. If unsure, leave this option disabled. +config SCST_DEBUG_OOM + bool "Out-of-memory debugging support." + help + Let SCST's internal memory allocation function + (scst_alloc_sg_entries()) fail about once in every 10000 calls, at + least if the flag __GFP_NOFAIL has not been set. This allows SCST + developers to test the behavior of SCST in out-of-memory conditions. + This may be helpful for SCST developers. If unsure, leave this + option disabled. + +config SCST_DEBUG_RETRY + bool "SCSI command retry debugging support." + help + Let SCST's internal SCSI command transfer function + (scst_rdy_to_xfer()) fail about once in every 100 calls. This allows + SCST developers to test the behavior of SCST when SCSI queues fill + up. This may be helpful for SCST developers. If unsure, leave this + option disabled. + +config SCST_DEBUG_SN + bool "SCSI sequence number debugging support." + help + Allows to test SCSI command ordering via sequence numbers by + randomly changing the type of SCSI commands into + SCST_CMD_QUEUE_ORDERED, SCST_CMD_QUEUE_HEAD_OF_QUEUE or + SCST_CMD_QUEUE_SIMPLE for about one in 300 SCSI commands. + This may be helpful for SCST developers. If unsure, leave this + option disabled. + +config SCST_DEBUG_TM + bool "Task management debugging support." + depends on SCST_DEBUG + help + Enables support for debugging of SCST's task management functions. + When enabled, some of the commands on LUN 0 in the default access + control group will be delayed for about 60 seconds. This will + cause the remote initiator send SCSI task management functions, + e.g. ABORT TASK and TARGET RESET. If unsure, leave this option + disabled. + +config SCST_TM_DBG_GO_OFFLINE + bool "Let devices become completely unresponsive." + depends on SCST_DEBUG_TM + help + Enable this option if you want that the device eventually becomes + completely unresponsive. When disabled, the device will receive + ABORT and RESET commands. If unsure, leave this option disabled. + endmenu Modified: trunk/scst/kernel/in-tree/Makefile.dev_handlers =================================================================== --- trunk/scst/kernel/in-tree/Makefile.dev_handlers 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.dev_handlers 2008-07-10 10:49:06 UTC (rev 453) @@ -3,12 +3,12 @@ obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ scst_vdisk.o scst_raid.o scst_processor.o scst_user.o -obj-$(CONFIG_SCSI_TARGET_DISK) += scst_disk.o -obj-$(CONFIG_SCSI_TARGET_TAPE) += scst_tape.o -obj-$(CONFIG_SCSI_TARGET_CDROM) += scst_cdrom.o -obj-$(CONFIG_SCSI_TARGET_MODISK) += scst_modisk.o -obj-$(CONFIG_SCSI_TARGET_CHANGER) += scst_changer.o -obj-$(CONFIG_SCSI_TARGET_RAID) += scst_raid.o -obj-$(CONFIG_SCSI_TARGET_PROCESSOR) += scst_processor.o -obj-$(CONFIG_SCSI_TARGET_VDISK) += scst_vdisk.o -obj-$(CONFIG_SCSI_TARGET_USER) += scst_user.o +obj-$(CONFIG_SCST_DISK) += scst_disk.o +obj-$(CONFIG_SCST_TAPE) += scst_tape.o +obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCST_MODISK) += scst_modisk.o +obj-$(CONFIG_SCST_CHANGER) += scst_changer.o +obj-$(CONFIG_SCST_RAID) += scst_raid.o +obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o +obj-$(CONFIG_SCST_USER) += scst_user.o Modified: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.15.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.15.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.15.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -4,7 +4,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx/ -+obj-$(CONFIG_SCSI_TARGET) += scsi_tgt/ ++obj-$(CONFIG_SCST) += scsi_tgt/ obj-$(CONFIG_SCSI_LPFC) += lpfc/ obj-$(CONFIG_SCSI_PAS16) += pas16.o obj-$(CONFIG_SCSI_SEAGATE) += seagate.o Modified: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -5,7 +5,7 @@ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/ obj-$(CONFIG_SCSI) += scsi/ -+obj-$(CONFIG_SCSI_TARGET) += scst/ ++obj-$(CONFIG_SCST) += scst/ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_FUSION) += message/ obj-$(CONFIG_FIREWIRE) += firewire/ Modified: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.25.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -5,7 +5,7 @@ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/ obj-$(CONFIG_SCSI) += scsi/ -+obj-$(CONFIG_SCSI_TARGET) += scst/ ++obj-$(CONFIG_SCST) += scst/ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_FUSION) += message/ obj-$(CONFIG_FIREWIRE) += firewire/ Modified: trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.7.patch =================================================================== --- trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.7.patch 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.drivers.Linux-2.6.7.patch 2008-07-10 10:49:06 UTC (rev 453) @@ -4,7 +4,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx/ -+obj-$(CONFIG_SCSI_TARGET) += scsi_tgt/ ++obj-$(CONFIG_SCST) += scsi_tgt/ obj-$(CONFIG_SCSI_PAS16) += pas16.o obj-$(CONFIG_SCSI_SEAGATE) += seagate.o obj-$(CONFIG_SCSI_FD_8xx) += seagate.o Modified: trunk/scst/kernel/in-tree/Makefile.scst =================================================================== --- trunk/scst/kernel/in-tree/Makefile.scst 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/kernel/in-tree/Makefile.scst 2008-07-10 10:49:06 UTC (rev 453) @@ -7,5 +7,5 @@ scst-y += scst_mem.o scst-y += scst_debug.o -obj-$(CONFIG_SCSI_TARGET) += scst.o dev_handlers/ iscsi-scst/ +obj-$(CONFIG_SCST) += scst.o dev_handlers/ iscsi-scst/ Modified: trunk/scst/src/Makefile =================================================================== --- trunk/scst/src/Makefile 2008-07-10 07:05:47 UTC (rev 452) +++ trunk/scst/src/Makefile 2008-07-10 10:49:06 UTC (rev 453) @@ -41,7 +41,7 @@ scst-y += scst_proc.o scst-y += scst_mem.o scst-y += scst_debug.o -obj-$(CONFIG_SCSI_TARGET) ... [truncated message content] |
From: <vl...@us...> - 2006-10-26 16:51:54
|
Revision: 16 http://svn.sourceforge.net/scst/?rev=16&view=rev Author: vlnb Date: 2006-10-26 09:51:41 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Removing of Module.symvers added Modified Paths: -------------- trunk/qla2x00t/Makefile trunk/qla2x00t/qla2x00-target/Makefile trunk/scst/src/Makefile trunk/scst/src/dev_handlers/Makefile Modified: trunk/qla2x00t/Makefile =================================================================== --- trunk/qla2x00t/Makefile 2006-10-26 16:09:56 UTC (rev 15) +++ trunk/qla2x00t/Makefile 2006-10-26 16:51:41 UTC (rev 16) @@ -40,7 +40,7 @@ endif clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers Module.symvers rm -rf .tmp_versions extraclean: clean Modified: trunk/qla2x00t/qla2x00-target/Makefile =================================================================== --- trunk/qla2x00t/qla2x00-target/Makefile 2006-10-26 16:09:56 UTC (rev 15) +++ trunk/qla2x00t/qla2x00-target/Makefile 2006-10-26 16:51:41 UTC (rev 16) @@ -91,7 +91,7 @@ endif clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers Module.symvers rm -rf .tmp_versions extraclean: clean Modified: trunk/scst/src/Makefile =================================================================== --- trunk/scst/src/Makefile 2006-10-26 16:09:56 UTC (rev 15) +++ trunk/scst/src/Makefile 2006-10-26 16:51:41 UTC (rev 16) @@ -99,7 +99,7 @@ #EXTRA_CFLAGS += -DSCST_HIGHMEM clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers Module.symvers rm -rf .tmp_versions cd $(DEV_HANDLERS_DIR) && $(MAKE) $@ Modified: trunk/scst/src/dev_handlers/Makefile =================================================================== --- trunk/scst/src/dev_handlers/Makefile 2006-10-26 16:09:56 UTC (rev 15) +++ trunk/scst/src/dev_handlers/Makefile 2006-10-26 16:51:41 UTC (rev 16) @@ -56,7 +56,7 @@ EXTRA_CFLAGS += -DDEBUG clean: - rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers Module.symvers rm -rf .tmp_versions extraclean: clean This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2006-11-02 18:38:56
|
Revision: 23 http://svn.sourceforge.net/scst/?rev=23&view=rev Author: vlnb Date: 2006-11-02 03:20:46 -0800 (Thu, 02 Nov 2006) Log Message: ----------- TRACE_MEM() cleanups Modified Paths: -------------- trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/scst/src/dev_handlers/scst_cdrom.c trunk/scst/src/dev_handlers/scst_disk.c trunk/scst/src/dev_handlers/scst_fileio.c trunk/scst/src/dev_handlers/scst_modisk.c trunk/scst/src/dev_handlers/scst_tape.c trunk/scst/src/scst.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-11-02 11:20:46 UTC (rev 23) @@ -53,21 +53,6 @@ #include <scst_debug.h> #include <scst_debug.c> -#ifndef MEMCPY -/* Debugging to see how many memcopys/memsets happen */ -#define MEMCPY(d, s, l) do { \ - TRACE_MEM("memcpy to %p size %zd", d, (size_t)l); \ - memcpy(d, s, l); \ - } while (0) -#endif - -#ifndef MEMSET -#define MEMSET(d, c, l) do { \ - TRACE_MEM("memset of %p size %zd", d, (size_t)l); \ - memset(d, c, l); \ - } while (0) -#endif - #ifndef FC_TARGET_SUPPORT #error "FC_TARGET_SUPPORT is NOT DEFINED" #endif @@ -217,7 +202,7 @@ if (ha->tgt != NULL) ha->tgt->notify_ack_expected++; - MEMSET(ntfy, 0, sizeof(*ntfy)); + memset(ntfy, 0, sizeof(*ntfy)); ntfy->entry_type = NOTIFY_ACK_TYPE; ntfy->entry_count = 1; SET_TARGET_ID(ha, ntfy->target, target_id); @@ -302,7 +287,6 @@ BUG_ON(sess == NULL); tgt = sess->tgt; - TRACE_MEM("kfree for sess %p (tgt %p)", sess, tgt); kfree(sess); if (tgt == NULL) @@ -414,7 +398,6 @@ scst_tgt_set_tgt_priv(scst_tgt, NULL); - TRACE_MEM("kfree for tgt %p", tgt); kfree(tgt); TRACE_EXIT_RES(res); @@ -598,7 +581,7 @@ * that. */ - MEMSET(cont_pkt64, 0, sizeof(*cont_pkt64)); + memset(cont_pkt64, 0, sizeof(*cont_pkt64)); cont_pkt64->entry_count = 1; cont_pkt64->sys_define = 0; @@ -665,10 +648,10 @@ ctio_m1->scsi_status |= __constant_cpu_to_le16(SS_SENSE_LEN_VALID); ctio_m1->sense_length = cpu_to_le16(prm->sense_buffer_len); - MEMCPY(ctio_m1->sense_data, prm->sense_buffer, + memcpy(ctio_m1->sense_data, prm->sense_buffer, prm->sense_buffer_len); } else { - MEMSET(ctio_m1->sense_data, 0, sizeof(ctio_m1->sense_data)); + memset(ctio_m1->sense_data, 0, sizeof(ctio_m1->sense_data)); ctio_m1->sense_length = 0; } @@ -800,7 +783,7 @@ TRACE_DBG("%s", "Building additional status " "packet"); - MEMCPY(ctio_m1, prm.pkt, sizeof(*ctio_m1)); + memcpy(ctio_m1, prm.pkt, sizeof(*ctio_m1)); ctio_m1->entry_count = 1; /* Real finish is ctio_m1's finish */ @@ -965,7 +948,6 @@ static inline void q2t_free_cmd(struct q2t_cmd *cmd) { - TRACE_MEM("kfree for cmd (q2t_cmd) %p", cmd); kmem_cache_free(q2t_cmd_cachep, cmd); } @@ -1367,7 +1349,6 @@ } cmd = kmem_cache_alloc(q2t_cmd_cachep, GFP_ATOMIC); - TRACE_MEM("kmem_cache_alloc(GFP_ATOMIC) for cmd (%zd): %p", sizeof(*cmd), cmd); if (cmd == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of cmd failed"); res = -ENOMEM; @@ -1375,15 +1356,13 @@ } TRACE_BUFFER("ATIO Coming Up", atio, sizeof(*atio)); - MEMSET(cmd, 0, sizeof(*cmd)); - MEMCPY(&cmd->atio, atio, sizeof(*atio)); + memset(cmd, 0, sizeof(*cmd)); + memcpy(&cmd->atio, atio, sizeof(*atio)); cmd->state = Q2T_STATE_NEW; sess = q2t_find_sess_by_lid(tgt, loop_id); if (unlikely(sess == NULL)) { sess = kzalloc(sizeof(*sess), GFP_ATOMIC); - TRACE_MEM("kzalloc(GFP_ATOMIC) for sess (%zd): %p", - sizeof(*sess), sess); if (sess == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of sess failed"); @@ -1431,7 +1410,6 @@ return res; out_free_sess: - TRACE_MEM("kfree for sess %p", sess); kfree(sess); smp_mb__before_atomic_dec(); if (atomic_dec_and_test(&tgt->sess_count)) @@ -1470,8 +1448,6 @@ } mcmd = kzalloc(sizeof(*mcmd), GFP_ATOMIC); - TRACE_MEM("kzalloc(GFP_ATOMIC) for mcmd (%zd): %p", - sizeof(*mcmd), mcmd); if (mcmd == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of mgmt cmd failed"); res = -ENOMEM; @@ -1535,7 +1511,6 @@ return res; out_free: - TRACE_MEM("kfree for mcmd %p", mcmd); kfree(mcmd); goto out; } @@ -1563,7 +1538,6 @@ } mcmd = kzalloc(sizeof(*mcmd), GFP_ATOMIC); - TRACE_MEM("kzalloc(GFP_ATOMIC) for mcmd (%zd): %p", sizeof(*mcmd), mcmd); if (mcmd == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of mgmt cmd failed"); res = -ENOMEM; @@ -1587,7 +1561,6 @@ return res; out_free: - TRACE_MEM("kfree for mcmd %p", mcmd); kfree(mcmd); goto out; } @@ -1617,7 +1590,6 @@ /* scst_mgmt_cmd_set_tgt_priv(scst_mcmd, NULL); */ scst_mcmd->tgt_priv = NULL; - TRACE_MEM("kfree for mcmd %p", mcmd); kfree(mcmd); out: @@ -1982,8 +1954,6 @@ switch (action) { case ENABLE_TARGET_MODE : tgt = kzalloc(sizeof(*tgt), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for tgt (%zd): %p", - sizeof(*tgt), tgt); if (tgt == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of tgt failed"); @@ -2021,7 +1991,6 @@ PRINT_ERROR("qla2x00tgt(%ld): scst_register() " "failed for host %ld(%p)", ha->instance, ha->host_no, ha); - TRACE_MEM("kfree for tgt %p", tgt); kfree(tgt); goto out; } Modified: trunk/scst/src/dev_handlers/scst_cdrom.c =================================================================== --- trunk/scst/src/dev_handlers/scst_cdrom.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/dev_handlers/scst_cdrom.c 2006-11-02 11:20:46 UTC (rev 23) @@ -95,8 +95,6 @@ } cdrom = kzalloc(sizeof(*cdrom), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for struct cdrom_params (%zu): %p", - sizeof(*cdrom), cdrom); if (cdrom == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Unable to allocate struct cdrom_params"); @@ -105,7 +103,6 @@ } buffer = kzalloc(buffer_size, GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for %d: %p", buffer_size, buffer); if (!buffer) { TRACE(TRACE_OUT_OF_MEM, "%s", "Memory allocation failure"); res = -ENOMEM; @@ -158,16 +155,13 @@ } out_free_buf: - TRACE_MEM("kfree for buffer: %p", buffer); kfree(buffer); out_free_cdrom: if (res == 0) dev->dh_priv = cdrom; - else { - TRACE_MEM("kfree for cdrom: %p", cdrom); + else kfree(cdrom); - } out: TRACE_EXIT(); @@ -189,7 +183,6 @@ TRACE_ENTRY(); - TRACE_MEM("kfree for cdrom: %p", cdrom); kfree(cdrom); dev->dh_priv = NULL; Modified: trunk/scst/src/dev_handlers/scst_disk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_disk.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/dev_handlers/scst_disk.c 2006-11-02 11:20:46 UTC (rev 23) @@ -171,8 +171,6 @@ } disk = kzalloc(sizeof(*disk), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for struct disk_params (%zu): %p", - sizeof(*disk), disk); if (disk == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Unable to allocate struct disk_params"); @@ -181,7 +179,6 @@ } buffer = kzalloc(buffer_size, GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for %d: %p", buffer_size, buffer); if (!buffer) { TRACE(TRACE_OUT_OF_MEM, "%s", "Memory allocation failure"); res = -ENOMEM; @@ -231,16 +228,13 @@ } out_free_buf: - TRACE_MEM("kfree for buffer: %p", buffer); kfree(buffer); out_free_disk: if (res == 0) dev->dh_priv = disk; - else { - TRACE_MEM("kfree for disk: %p", disk); + else kfree(disk); - } out: TRACE_EXIT_RES(res); @@ -262,7 +256,6 @@ TRACE_ENTRY(); - TRACE_MEM("kfree for disk: %p", disk); kfree(disk); dev->dh_priv = NULL; Modified: trunk/scst/src/dev_handlers/scst_fileio.c =================================================================== --- trunk/scst/src/dev_handlers/scst_fileio.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/dev_handlers/scst_fileio.c 2006-11-02 11:20:46 UTC (rev 23) @@ -700,8 +700,6 @@ TRACE_ENTRY(); ftgt_dev = kzalloc(sizeof(*ftgt_dev), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for ftgt_dev (%zd): %p", - sizeof(*ftgt_dev), ftgt_dev); if (ftgt_dev == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of per-session " "virtual device failed"); @@ -755,7 +753,6 @@ filp_close(ftgt_dev->fd, NULL); out_free: - TRACE_MEM("kfree ftgt_dev: %p", ftgt_dev); kfree(ftgt_dev); goto out; } @@ -780,12 +777,9 @@ if (ftgt_dev->fd) filp_close(ftgt_dev->fd, NULL); - if (ftgt_dev->iv != NULL) { - TRACE_MEM("kfree ftgt_dev->iv: %p", ftgt_dev->iv); + if (ftgt_dev->iv != NULL) kfree(ftgt_dev->iv); - } - TRACE_MEM("kfree ftgt_dev: %p", ftgt_dev); kfree(ftgt_dev); tgt_dev->dh_priv = NULL; @@ -1892,13 +1886,9 @@ iv_count = scst_get_buf_count(cmd); if (iv_count > ftgt_dev->iv_count) { - if (ftgt_dev->iv != NULL) { - TRACE_MEM("kfree ftgt_dev->iv: %p", ftgt_dev->iv); + if (ftgt_dev->iv != NULL) kfree(ftgt_dev->iv); - } ftgt_dev->iv = kmalloc(sizeof(*ftgt_dev->iv) * iv_count, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for iv (%zd): %p", - sizeof(*ftgt_dev->iv) * iv_count, ftgt_dev->iv); if (ftgt_dev->iv == NULL) { PRINT_ERROR_PR("Unable to allocate iv (%d)", iv_count); scst_set_busy(cmd); @@ -2260,7 +2250,6 @@ { struct scst_fileio_dev *dev; dev = kzalloc(sizeof(*dev), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for dev (%zd): %p", sizeof(*dev), dev); if (dev == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of virtual " "device failed"); @@ -2551,8 +2540,6 @@ len = strlen(file_name) + 1; virt_dev->file_name = kmalloc(len, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p", - len, virt_dev->file_name); if (virt_dev->file_name == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of file_name failed"); @@ -2598,9 +2585,7 @@ list_del(&virt_dev->fileio_dev_list_entry); - TRACE_MEM("kfree for file_name: %p", virt_dev->file_name); kfree(virt_dev->file_name); - TRACE_MEM("kfree for virt_dev: %p", virt_dev); kfree(virt_dev); } res = length; @@ -2615,12 +2600,9 @@ out_free_vpath: list_del(&virt_dev->fileio_dev_list_entry); - - TRACE_MEM("kfree for file_name: %p", virt_dev->file_name); kfree(virt_dev->file_name); out_free_vdev: - TRACE_MEM("kfree for virt_dev: %p", virt_dev); kfree(virt_dev); goto out_up; } @@ -2681,8 +2663,6 @@ if (!virt_dev->cdrom_empty) { len = strlen(file_name) + 1; virt_dev->file_name = kmalloc(len, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p", - len, virt_dev->file_name); if (virt_dev->file_name == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of file_name failed"); @@ -2711,12 +2691,9 @@ out_free_vpath: list_del(&virt_dev->fileio_dev_list_entry); - - TRACE_MEM("kfree for file_name: %p", virt_dev->file_name); kfree(virt_dev->file_name); out_free_vdev: - TRACE_MEM("kfree for virt_dev: %p", virt_dev); kfree(virt_dev); goto out; } @@ -2749,11 +2726,8 @@ list_del(&virt_dev->fileio_dev_list_entry); - if (virt_dev->file_name) { - TRACE_MEM("kfree for file_name: %p", virt_dev->file_name); + if (virt_dev->file_name) kfree(virt_dev->file_name); - } - TRACE_MEM("kfree for virt_dev: %p", virt_dev); kfree(virt_dev); out: @@ -2810,8 +2784,6 @@ if (!virt_dev->cdrom_empty) { len = strlen(file_name) + 1; fn = kmalloc(len, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for file_name (%d): %p", - len, fn); if (fn == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of file_name failed"); @@ -2908,10 +2880,8 @@ virt_dev->name); } - if (old_fn) { - TRACE_MEM("kfree for old_fn: %p", old_fn); + if (old_fn) kfree(old_fn); - } out_resume: scst_resume_activity(); @@ -2921,19 +2891,16 @@ out_free: virt_dev->file_name = old_fn; - TRACE_MEM("kfree for fn: %p", fn); kfree(fn); goto out; out_free_resume: virt_dev->file_name = old_fn; - TRACE_MEM("kfree for fn: %p", fn); kfree(fn); goto out_resume; out_err_resume: virt_dev->file_name = old_fn; - TRACE_MEM("kfree for fn: %p", fn); kfree(fn); scst_resume_activity(); cdrom_fileio_close(name); @@ -3161,9 +3128,7 @@ PRINT_INFO_PR("Virtual device %s unregistered", virt_dev->name); TRACE_DBG("virt_id %d", virt_dev->virt_id); - TRACE_MEM("kfree for file_name: %p", virt_dev->file_name); kfree(virt_dev->file_name); - TRACE_MEM("kfree for virt_dev: %p", virt_dev); kfree(virt_dev); } up(&scst_fileio_mutex); Modified: trunk/scst/src/dev_handlers/scst_modisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_modisk.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/dev_handlers/scst_modisk.c 2006-11-02 11:20:46 UTC (rev 23) @@ -171,8 +171,6 @@ } modisk = kzalloc(sizeof(*modisk), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for struct modisk_params (%zu): %p", - sizeof(*modisk), modisk); if (modisk == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Unable to allocate struct modisk_params"); @@ -193,7 +191,6 @@ } buffer = kzalloc(buffer_size, GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for %d: %p", buffer_size, buffer); if (!buffer) { TRACE(TRACE_OUT_OF_MEM, "%s", "Memory allocation failure"); res = -ENOMEM; @@ -245,16 +242,13 @@ } out_free_buf: - TRACE_MEM("kfree for buffer: %p", buffer); kfree(buffer); out_free_modisk: if (res == 0) dev->dh_priv = modisk; - else { - TRACE_MEM("kfree for modisk: %p", modisk); + else kfree(modisk); - } out: TRACE_EXIT_RES(res); @@ -276,7 +270,6 @@ TRACE_ENTRY(); - TRACE_MEM("kfree for modisk: %p", modisk); kfree(modisk); dev->dh_priv = NULL; Modified: trunk/scst/src/dev_handlers/scst_tape.c =================================================================== --- trunk/scst/src/dev_handlers/scst_tape.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/dev_handlers/scst_tape.c 2006-11-02 11:20:46 UTC (rev 23) @@ -181,8 +181,6 @@ } tape = kzalloc(sizeof(*tape), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for struct tape_params (%zu): %p", - sizeof(*tape), tape); if (tape == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Unable to allocate struct tape_params"); @@ -192,7 +190,6 @@ spin_lock_init(&tape->tp_lock); buffer = kmalloc(buffer_size, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for %d: %p", buffer_size, buffer); if (!buffer) { TRACE(TRACE_OUT_OF_MEM, "%s", "Memory allocation failure"); res = -ENOMEM; @@ -243,16 +240,13 @@ } out_free_buf: - TRACE_MEM("kfree for buffer: %p", buffer); kfree(buffer); out_free_req: if (res == 0) dev->dh_priv = tape; - else { - TRACE_MEM("kfree for tape: %p", tape); + else kfree(tape); - } out: TRACE_EXIT_RES(res); @@ -274,7 +268,6 @@ TRACE_ENTRY(); - TRACE_MEM("kfree for tape: %p", tape); kfree(tape); dev->dh_priv = NULL; Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/scst.c 2006-11-02 11:20:46 UTC (rev 23) @@ -238,8 +238,6 @@ TRACE_ENTRY(); tgt = kzalloc(sizeof(*tgt), GFP_KERNEL); - TRACE_MEM("kzalloc(GFP_KERNEL) for tgt (%zd): %p", - sizeof(*tgt), tgt); if (tgt == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "kzalloc() failed"); goto out; @@ -272,7 +270,6 @@ return tgt; out_free: - TRACE_MEM("kfree() for tgt %p", tgt); kfree(tgt); goto out; } @@ -314,7 +311,6 @@ del_timer_sync(&tgt->retry_timer); - TRACE_MEM("kfree for tgt: %p", tgt); kfree(tgt); TRACE_EXIT(); Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/scst_lib.c 2006-11-02 11:20:46 UTC (rev 23) @@ -150,7 +150,6 @@ TRACE_ENTRY(); dev = kzalloc(sizeof(*dev), gfp_mask); - TRACE_MEM("kzalloc() for dev (%zd): %p", sizeof(*dev), dev); if (dev == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of scst_device failed"); @@ -185,7 +184,6 @@ } #endif - TRACE_MEM("kfree for dev: %p", dev); kfree(dev); TRACE_EXIT(); @@ -200,7 +198,6 @@ TRACE_ENTRY(); res = kmem_cache_alloc(scst_acgd_cachep, GFP_KERNEL); - TRACE_MEM("kmem_cache_alloc() for acg_dev (%zd): %p", sizeof(*res), res); if (res == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of scst_acg_dev failed"); goto out; @@ -226,7 +223,6 @@ list_del(&acg_dev->acg_dev_list_entry); list_del(&acg_dev->dev_acg_dev_list_entry); - TRACE_MEM("kfree for acg_dev: %p", acg_dev); kmem_cache_free(scst_acgd_cachep, acg_dev); TRACE_EXIT(); @@ -241,7 +237,6 @@ TRACE_ENTRY(); acg = kzalloc(sizeof(*acg), GFP_KERNEL); - TRACE_MEM("kzalloc() for acg (%zd): %p", sizeof(*acg), acg); if (acg == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of acg failed"); goto out; @@ -302,16 +297,12 @@ acn_list_entry) { list_del(&n->acn_list_entry); - TRACE_MEM("kfree() for scst_acn->name: %p", n->name); kfree(n->name); - TRACE_MEM("kfree() for scst_acn: %p", n); kfree(n); } INIT_LIST_HEAD(&acg->acn_list); - TRACE_MEM("kfree for acg: %p", acg); kfree(acg); - out: TRACE_EXIT_RES(res); return res; @@ -331,8 +322,6 @@ TRACE_ENTRY(); tgt_dev = kmem_cache_alloc(scst_tgtd_cachep, GFP_KERNEL); - TRACE_MEM("kmem_cache_alloc(GFP_KERNEL) for tgt_dev (%zd): %p", - sizeof(*tgt_dev), tgt_dev); if (tgt_dev != NULL) memset(tgt_dev, 0, sizeof(*tgt_dev)); else { @@ -394,7 +383,6 @@ return tgt_dev; out_free: - TRACE_MEM("kfree for tgt_dev: %p", tgt_dev); kmem_cache_free(scst_tgtd_cachep, tgt_dev); tgt_dev = NULL; goto out; @@ -463,7 +451,6 @@ TRACE_DBG("%s", "Dev handler's detach_tgt() returned"); } - TRACE_MEM("kfree for tgt_dev: %p", tgt_dev); kmem_cache_free(scst_tgtd_cachep, tgt_dev); TRACE_EXIT(); @@ -649,7 +636,6 @@ } n = kmalloc(sizeof(*n), GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for scst_acn (%zd): %p", sizeof(*n), n); if (n == NULL) { PRINT_ERROR_PR("%s", "Unable to allocate scst_acn"); res = -ENOMEM; @@ -658,8 +644,6 @@ len = strlen(name); nm = kmalloc(len + 1, GFP_KERNEL); - TRACE_MEM("kmalloc(GFP_KERNEL) for scst_acn->name (%d): %p", - len + 1, nm); if (nm == NULL) { PRINT_ERROR_PR("%s", "Unable to allocate scst_acn->name"); res = -ENOMEM; @@ -676,7 +660,6 @@ return res; out_free: - TRACE_MEM("kfree() for scst_acn: %p", n); kfree(n); goto out; } @@ -693,9 +676,7 @@ { if (strcmp(n->name, name) == 0) { list_del(&n->acn_list_entry); - TRACE_MEM("kfree() for scst_acn->name: %p", n->name); kfree(n->name); - TRACE_MEM("kfree() for scst_acn: %p", n); kfree(n); res = 0; break; @@ -720,11 +701,8 @@ if (scsi_cmd && (req = scsi_cmd->sc_request)) { if (req) { - if (req->sr_bufflen) { - TRACE_MEM("kfree for req->sr_buffer: %p", - req->sr_buffer); + if (req->sr_bufflen) kfree(req->sr_buffer); - } scsi_release_request(req); } } @@ -823,7 +801,6 @@ TRACE_ENTRY(); sess = kmem_cache_alloc(scst_sess_cachep, gfp_mask); - TRACE_MEM("kmem_cache_alloc() for sess (%zd): %p", sizeof(*sess), sess); if (sess != NULL) memset(sess, 0, sizeof(*sess)); else { @@ -842,8 +819,6 @@ len = strlen(initiator_name); nm = kmalloc(len + 1, gfp_mask); - TRACE_MEM("kmalloc(GFP_KERNEL) for sess->initiator_name (%d): %p", - len + 1, nm); if (nm == NULL) { PRINT_ERROR_PR("%s", "Unable to allocate sess->initiator_name"); goto out_free; @@ -857,7 +832,6 @@ return sess; out_free: - TRACE_MEM("kfree() for sess: %p", sess); kmem_cache_free(scst_sess_cachep, sess); sess = NULL; goto out; @@ -881,10 +855,7 @@ up(&scst_mutex); - TRACE_MEM("kfree for sess->initiator_name: %p", sess->initiator_name); kfree(sess->initiator_name); - - TRACE_MEM("kfree for sess: %p", sess); kmem_cache_free(scst_sess_cachep, sess); TRACE_EXIT(); @@ -939,7 +910,6 @@ TRACE_ENTRY(); cmd = kmem_cache_alloc(scst_cmd_cachep, gfp_mask); - TRACE_MEM("kmem_cache_alloc() for cmd (%zd): %p", sizeof(*cmd), cmd); if (cmd != NULL) memset(cmd, 0, sizeof(*cmd)); else { @@ -1112,8 +1082,6 @@ TRACE_ENTRY(); mcmd = mempool_alloc(scst_mgmt_mempool, gfp_mask); - TRACE_MEM("mempool_alloc() for mgmt cmd (%zd): %p", sizeof(*mcmd), - mcmd); if (mcmd == NULL) { PRINT_ERROR("%s", "Allocation of management command " "failed, some commands and their data could leak"); @@ -1143,7 +1111,6 @@ if (mcmd->mcmd_tgt_dev != NULL) scst_dec_cmd_count(); - TRACE_MEM("mempool_free for mgmt cmd: %p", mcmd); mempool_free(mcmd, scst_mgmt_mempool); TRACE_EXIT(); @@ -1755,8 +1722,6 @@ list_del(&UA_entry->UA_list_entry); - - TRACE_MEM("mempool_free for UA_entry: %p", UA_entry); mempool_free(UA_entry, scst_ua_mempool); if (list_empty(&cmd->tgt_dev->UA_list)) { @@ -1784,8 +1749,6 @@ TRACE_ENTRY(); UA_entry = mempool_alloc(scst_ua_mempool, GFP_ATOMIC); - TRACE_MEM("mempool_alloc(GFP_ATOMIC) for UA_entry (%zd): %p", - sizeof(*UA_entry), UA_entry); if (UA_entry == NULL) { PRINT_ERROR_PR("%s", "UNIT ATTENTION memory " "allocation failed. The UNIT ATTENTION " @@ -1876,7 +1839,6 @@ TRACE_MGMT_DBG("Clearing UA for tgt_dev lun %d", tgt_dev->acg_dev->lun); list_del(&UA_entry->UA_list_entry); - TRACE_MEM("kfree for UA_entry: %p", UA_entry); kfree(UA_entry); } INIT_LIST_HEAD(&tgt_dev->UA_list); Modified: trunk/scst/src/scst_priv.h =================================================================== --- trunk/scst/src/scst_priv.h 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/scst_priv.h 2006-11-02 11:20:46 UTC (rev 23) @@ -251,7 +251,6 @@ void scst_free_cmd(struct scst_cmd *cmd); static inline void scst_destroy_cmd(struct scst_cmd *cmd) { - TRACE_MEM("kfree for cmd: %p", cmd); kmem_cache_free(scst_cmd_cachep, cmd); return; } Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2006-11-02 10:54:10 UTC (rev 22) +++ trunk/scst/src/scst_proc.c 2006-11-02 11:20:46 UTC (rev 23) @@ -619,7 +619,6 @@ TRACE_ENTRY(); name = kmalloc(len, GFP_KERNEL); - TRACE_MEM("kmalloc() for acg_dev (%d): %p", len, name); if (name == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of name failed"); goto out_nomem; @@ -644,7 +643,6 @@ scst_proc_del_free_acg(acg, 0); out_free: - TRACE_MEM("kfree for name: %p", name); kfree(name); out_nomem: @@ -666,7 +664,6 @@ if (res == 0) { if (remove_proc) scst_proc_del_acg_tree(acg_proc_root, name); - TRACE_MEM("kfree for name: %p", name); kfree(name); } } @@ -2231,9 +2228,7 @@ list_for_each_entry_safe(n, nn, &acg->acn_list, acn_list_entry) { list_del(&n->acn_list_entry); - TRACE_MEM("kfree() for scst_acn->name: %p", n->name); kfree(n->name); - TRACE_MEM("kfree() for scst_acn: %p", n); kfree(n); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2006-11-14 12:57:12
|
Revision: 33 http://svn.sourceforge.net/scst/?rev=33&view=rev Author: vlnb Date: 2006-11-14 04:56:57 -0800 (Tue, 14 Nov 2006) Log Message: ----------- The initial commit of 0.9.5-pre1 version Added Paths: ----------- trunk/scstadmin/ trunk/scstadmin/Changes trunk/scstadmin/LICENSE trunk/scstadmin/README trunk/scstadmin/SCST/ trunk/scstadmin/SCST/SCST.pm trunk/scstadmin/examples/ trunk/scstadmin/examples/scst.conf trunk/scstadmin/examples/scst_example.sql trunk/scstadmin/init.d/ trunk/scstadmin/init.d/scst trunk/scstadmin/scst.conf trunk/scstadmin/scst_db/ trunk/scstadmin/scst_db/scst_db trunk/scstadmin/scst_db/scst_db.conf trunk/scstadmin/scst_db/scst_schema.sql trunk/scstadmin/scstadmin Added: trunk/scstadmin/Changes =================================================================== --- trunk/scstadmin/Changes (rev 0) +++ trunk/scstadmin/Changes 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,17 @@ +Changes since 0.9.2-pre2: + +- List SCST sessions +- Verify specified config file against live configuration and show differences +- Write config file based on live configuration +- Force-apply configuration, even config deletions with a force flag. +- Added new option types +- Added support for specifying a blocksize +- Added "-reload-config" to init script + +Changes since 0.9.5-pre0: + +- Renamed scst to scstadmin +- Fixed writeConfiguration() to properly write DEVICE lines with no options +- Removed the comment which prevented a target from being enabled in enableTarget() +- Updated init.d/scst to use scstadmin instead of scst_db +- Fixup of README file Added: trunk/scstadmin/LICENSE =================================================================== --- trunk/scstadmin/LICENSE (rev 0) +++ trunk/scstadmin/LICENSE 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + Added: trunk/scstadmin/README =================================================================== --- trunk/scstadmin/README (rev 0) +++ trunk/scstadmin/README 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,53 @@ +SCST Configuration/Administration scripts. Here you'll find scstadmin which reads +a configuration file /etc/scst.conf, or one if your choosing. With it you can manually +or automatically configure every aspect of SCST incuding enabling/disabling target mode +on your target SCSI controller. The old directory contains scst_db which uses a mysql +backend database to configure SCST but doesn't handle all the things scstadmin handles. +The perl module SCST::SCST is very generic and tries to handle error checking as well. + +The init script was written for debian but should work on most distributions. + + SCST This is the SCST Perl module required by scstadmin and scst_db. + Copy the SCST directory to your perl5 lib directory: + #> cp -r SCST /usr/lib/perl5/ + + scstadmin Script which can accept operations on a command line or from + a configuration file. See scst.conf. For command help, + #> scstadmin + + old Script which configures SCST using configurations + found in a database. See the examples directory database + schema and example data. You will need to edit the + config file scst_db.conf to refect your environment. + + scst.conf Configuration file for scst script. Usually stored + in /etc. + + examples Configuration examples. + + init.d/scst Init script to start SCST on boot which uses scstadmin. + + +Getting Started: + +The scstadmin script is much more functional than scst_db at this point but uses a +standard text-based config file. The original thought behind scst_db was to write +a daemon process which would except network connections and issue SCST commands. A +client app would then connect to that port. + +Copy scst.conf to /etc and edit it to your liking. if you have an existing configuration +then have scstadmin write it out to a config file for you: + +#> scstadmin -WriteConfig /etc/scst.conf + +When removing devices, users or groups from the config file keep in mind that +"scstadmin -config" will NOT remove those configurations from the running system unless +you use the -ForceConfig flag. Also, using the init script to reload the configuration + +#> /etc/init.d/scst -reload-config + +will also not remove configurations from a running system. + + +Ma...@gm... + Added: trunk/scstadmin/SCST/SCST.pm =================================================================== --- trunk/scstadmin/SCST/SCST.pm (rev 0) +++ trunk/scstadmin/SCST/SCST.pm 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,1011 @@ +package SCST::SCST; + +# Author: Mark R. Buechler +# Copyright (c) 2005, 2006 Mark R. Buechler + +use 5.005; +use IO::Handle; +use IO::File; +use strict; +use Carp; + +my $TRUE = 1; +my $FALSE = 0; + +my $_SCST_DIR_ = '/proc/scsi_tgt'; +my $_SCST_IO_ = $_SCST_DIR_.'/scsi_tgt'; +my $_SCST_CDROM_IO_ = $_SCST_DIR_.'/dev_cdrom/dev_cdrom'; +my $_SCST_CHANGER_IO_ = $_SCST_DIR_.'/dev_changer/dev_changer'; +my $_SCST_DISK_IO_ = $_SCST_DIR_.'/dev_disk/dev_disk'; +my $_SCST_DISK_FILE_IO_ = $_SCST_DIR_.'/disk_fileio/disk_fileio'; +my $_SCST_CDROM_FILE_IO_ = $_SCST_DIR_.'/cdrom_fileio/cdrom_fileio'; +my $_SCST_DISKP_IO_ = $_SCST_DIR_.'/dev_disk_perf/dev_disk_perf'; +my $_SCST_MODISK_IO_ = $_SCST_DIR_.'/dev_modisk/dev_modisk'; +my $_SCST_MODISKP_IO_ = $_SCST_DIR_.'/dev_modisk_perf/dev_modisk_perf'; +my $_SCST_TAPE_IO_ = $_SCST_DIR_.'/dev_tape/dev_tape'; +my $_SCST_TAPEP_IO_ = $_SCST_DIR_.'/dev_tape_perf/dev_tape_perf'; +my $_SCST_GROUPS_DIR_ = $_SCST_DIR_.'/groups'; +my $_SCST_SGV_STATS_ = $_SCST_DIR_.'/sgv'; +my $_SCST_SESSIONS_ = $_SCST_DIR_.'/sessions'; +my $_SCST_VERSION_IO_ = $_SCST_DIR_.'/version'; + +my $_SCST_USERS_IO_ = 'names'; +my $_SCST_DEVICES_IO_ = 'devices'; + +my @_AVAILABLE_OPTIONS_ = ('WRITE_THROUGH', 'O_DIRECT', 'READ_ONLY', 'NULLIO', 'NV_CACHE'); + +use vars qw(@ISA @EXPORT $VERSION $CDROM_TYPE $CHANGER_TYPE $DISK_TYPE $DISKFILE_TYPE + $CDROMFILE_TYPE $DISKPERF_TYPE $MODISK_TYPE $MODISKPERF_TYPE $TAPE_TYPE + $TAPEPERF_TYPE); + +$CDROM_TYPE = 1; +$CHANGER_TYPE = 2; +$DISK_TYPE = 3; +$DISKFILE_TYPE = 4; +$CDROMFILE_TYPE = 5; +$DISKPERF_TYPE = 6; +$MODISK_TYPE = 7; +$MODISKPERF_TYPE = 8; +$TAPE_TYPE = 9; +$TAPEPERF_TYPE = 10; + +$VERSION = 0.6; + +my $_SCST_MIN_MAJOR_ = 0; +my $_SCST_MIN_MINOR_ = 9; +my $_SCST_MIN_RELEASE_ = 5; + +my %_IO_MAP_ = ($CDROM_TYPE => $_SCST_CDROM_IO_, + $CHANGER_TYPE => $_SCST_CHANGER_IO_, + $DISK_TYPE => $_SCST_DISK_IO_, + $DISKFILE_TYPE => $_SCST_DISK_FILE_IO_, + $CDROMFILE_TYPE => $_SCST_CDROM_FILE_IO_, + $DISKPERF_TYPE => $_SCST_DISKP_IO_, + $MODISK_TYPE => $_SCST_MODISK_IO_, + $MODISKPERF_TYPE => $_SCST_MODISKP_IO_, + $TAPE_TYPE => $_SCST_TAPE_IO_, + $TAPEPERF_TYPE => $_SCST_TAPEP_IO_); + +my %_TYPE_MAP_ = ('dev_cdrom' => $CDROM_TYPE, + 'dev_changer' => $CHANGER_TYPE, + 'dev_disk' => $DISK_TYPE, + 'disk_fileio' => $DISKFILE_TYPE, + 'cdrom_fileio' => $CDROMFILE_TYPE, + 'dev_disk_perf' => $DISKPERF_TYPE, + 'dev_modisk' => $MODISK_TYPE, + 'dev_modisk_perf' => $MODISKPERF_TYPE, + 'dev_tape' => $TAPE_TYPE, + 'dev_tape_perf' => $TAPEPERF_TYPE); + +sub new { + my $this = shift; + my $debug = shift; + my $badVersion = $TRUE; + + my $class = ref($this) || $this; + my $self = {}; + + bless($self, $class); + + $self->{'debug'} = $debug if $debug; + + my $scstVersion = $self->scstVersion(); + + my($major, $minor, $release) = split(/\./, $scstVersion, 3); + + $badVersion = $FALSE if (($major > $_SCST_MIN_MAJOR_) || + (($major == $_SCST_MIN_MAJOR_) && ($minor > $_SCST_MIN_MINOR_)) || + (($major == $_SCST_MIN_MAJOR_) && ($minor == $_SCST_MIN_MINOR_) && ($release >= $_SCST_MIN_RELEASE_))); + + croak("This module requires at least SCST version $_SCST_MIN_MAJOR_\.$_SCST_MIN_MINOR_\.". + "$_SCST_MIN_RELEASE_ and version $scstVersion was found") if ($badVersion); + + return $self; +} + +sub scstVersion { + my $self = shift; + + my $io = new IO::File $_SCST_VERSION_IO_, O_RDONLY; + return $TRUE if (!$io); + + my $version = <$io>; + chomp $version; + + return $version; +} + +sub groups { + my $self = shift; + my @groups; + my $dirHandle = new IO::Handle; + + opendir $dirHandle, $_SCST_GROUPS_DIR_ or return undef; + + foreach my $entry (readdir($dirHandle)) { + next if (($entry eq '.') || ($entry eq '..')); + + push @groups, $entry; + } + + close $dirHandle; + + return \@groups; +} + +sub groupExists { + my $self = shift; + my $group = shift; + my $groups = $self->groups(); + + foreach my $_group (@{$groups}) { + return $TRUE if ($group eq $_group); + } + + return $FALSE; +} + +sub addGroup { + my $self = shift; + my $group = shift; + + return 2 if ($self->groupExists($group)); + + my $io = new IO::File $_SCST_IO_, O_WRONLY; + return $TRUE if (!$io); + + my $cmd = "add_group $group\n"; + + if ($self->{'debug'}) { + print "DBG($$): $_SCST_IO_ -> $cmd\n"; + } else { + print $io $cmd; + } + + close $io; + + return $FALSE if ($self->{'debug'}); + return !$self->groupExists($group); +} + +sub removeGroup { + my $self = shift; + my $group = shift; + + return 2 if (!$self->groupExists($group)); + + my $io = new IO::File $_SCST_IO_, O_WRONLY; + return $TRUE if (!$io); + + my $cmd = "del_group $group\n"; + + if ($self->{'debug'}) { + print "DBG($$): $_SCST_IO_ -> $cmd\n"; + } else { + print $io $cmd; + } + + close $io; + + return $FALSE if ($self->{'debug'}); + return $self->groupExists($group); +} + +sub sgvStats { + my $self = shift; + my $io = new IO::File $_SCST_SGV_STATS_, O_RDONLY; + my %stats; + my $first = $TRUE; + + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + if ($first || !$line) { + $first = $FALSE; + next; + } + + my $size; + my $stat; + my $hit; + my $total; + + if ($line !~ /^\s/) { + ($stat, $hit, $total) = split(/\s+/, $line); + + $size = 'ALL'; + if ($stat eq 'big') { + $total = $hit; + $hit = -1; + } + } else { + (undef, $stat, $hit, $total) = split(/\s+/, $line); + + if ($stat =~ /(\d+)K$/) { + $size = $1; + $stat =~ s/\-$size\K//; + } + } + + $stats{$stat}->{$size}->{'HITS'} = $hit; + $stats{$stat}->{$size}->{'TOTAL'} = $total; + } + + close $io; + + return \%stats; +} + +sub sessions { + my $self = shift; + my $io = new IO::File $_SCST_SESSIONS_, O_RDONLY; + my %sessions; + my $first = $TRUE; + + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + if ($first) { + $first = $FALSE; + next; + } + + my($target, $user, $group, $commands) = split(/\s+/, $line); + + $sessions{$target}->{$group}->{$user} = $commands; + } + + close $io; + + return \%sessions; +} + +sub devices { + my $self = shift; + my $io = new IO::File $_SCST_IO_, O_RDONLY; + my %devices; + my $first = $TRUE; + + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + if ($first) { + $first = $FALSE; + next; + } + + my($vname, $handler) = split(/\s+/, $line); + $devices{$vname} = $_TYPE_MAP_{$handler}; + } + + close $io; + + return \%devices; +} + +sub handlerDevices { + my $self = shift; + my $handler = shift; + my $handler_io = $_IO_MAP_{$handler}; + my $first = $TRUE; + my %devices; + + return undef if (!$handler_io); + return undef if (!$self->handlerExists($handler)); + + my $io = new IO::File $handler_io, O_RDONLY; + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + if ($first) { + $first = $FALSE; + next; + } + + my ($vname, $size, $blocksize, $options, $path) = split(/\s+/, $line); + + if ($options =~ /^\//) { + $path = $options; + $options = ""; + } + + $devices{$vname}->{'OPTIONS'} = $self->cleanupString($options); + $devices{$vname}->{'SIZE'} = $self->cleanupString($size); + $devices{$vname}->{'PATH'} = $self->cleanupString($path); + $devices{$vname}->{'BLOCKSIZE'} = $self->cleanupString($blocksize); + } + + close $io; + + return \%devices; +} + +sub handlerDeviceExists { + my $self = shift; + my $handler = shift; + my $device = shift; + my $devices = $self->handlerDevices($handler); + + return -1 if (!defined($devices)); + return $TRUE if (defined($$devices{$device})); + + return $FALSE; +} + +sub openDevice { + my $self = shift; + my $handler = shift; + my $device = shift; + my $path = shift; + my $options = shift; + my $blocksize = shift; + my $handler_io = $_IO_MAP_{$handler}; + + return $TRUE if ($self->checkOptions($options)); + return $TRUE if (!$handler_io); + return $TRUE if (!$self->handlerExists($handler)); + return 2 if ($self->handlerDeviceExists($handler, $device)); + + $options = $self->cleanupString($options); + + my $cmd = "open $device $path $blocksize $options\n"; + + $cmd = $self->cleanupString($cmd); + + my $rc = $self->handler_private($handler_io, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return !$self->handlerDeviceExists($handler, $device); +} + +sub closeDevice { + my $self = shift; + my $handler = shift; + my $device = shift; + my $path = shift; + my $handler_io = $_IO_MAP_{$handler}; + + return $TRUE if (!$handler_io); + return $TRUE if (!$self->handlerExists($handler)); + return 2 if (!$self->handlerDeviceExists($handler, $device)); + + my $cmd = "close $device $path\n"; + + my $rc = $self->handler_private($handler_io, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return $self->handlerDeviceExists($handler, $device); +} + +sub userExists { + my $self = shift; + my $user = shift; + my $group = shift; + + my $users = $self->users($group); + + return -1 if (!defined($users)); + + foreach my $_user (@{$users}) { + return $TRUE if ($user eq $_user); + } + + return $FALSE; +} + +sub users { + my $self = shift; + my $group = shift; + my @users; + + return undef if (!$self->groupExists($group)); + + my $io = new IO::File $_SCST_GROUPS_DIR_."/$group/".$_SCST_USERS_IO_, O_RDONLY; + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + push @users, $line; + } + + close $io; + + return \@users; +} + +sub addUser { + my $self = shift; + my $user = shift; + my $group = shift; + + return $TRUE if (!$self->groupExists($group)); + return 2 if ($self->userExists($user, $group)); + + my $cmd = "add $user\n"; + + my $rc = $self->group_private($group, $_SCST_USERS_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return !$self->userExists($user, $group); +} + +sub removeUser { + my $self = shift; + my $user = shift; + my $group = shift; + + return $TRUE if (!$self->groupExists($group)); + return 2 if (!$self->userExists($user, $group)); + + my $cmd = "del $user\n"; + + my $rc = $self->group_private($group, $_SCST_USERS_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return $self->userExists($user, $group); +} + +sub clearUsers { + my $self = shift; + my $group = shift; + + return $TRUE if (!$self->groupExists($group)); + + my $cmd = "clear\n"; + + my $rc = $self->group_private($group, $_SCST_USERS_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + + my $users = $self->users($group); + + return ($#{$users} + 1); +} + +sub handlerExists { + my $self = shift; + my $handler = shift; + my $handlers = $self->handlers(); + + foreach my $_handler (@{$handlers}) { + return $TRUE if ($handler eq $_handler); + } + + return $FALSE; +} + +sub handlers { + my $self = shift; + my @handlers; + + my $dirHandle = new IO::Handle; + + opendir $dirHandle, $_SCST_DIR_ or return undef; + + foreach my $entry (readdir($dirHandle)) { + next if (($entry eq '.') || ($entry eq '..')); + + if ((-d $_SCST_DIR_.'/'.$entry ) && (-f $_SCST_DIR_.'/'.$entry.'/type')) { + push @handlers, $_TYPE_MAP_{$entry} if ($_TYPE_MAP_{$entry}); + } + } + + close $dirHandle; + + return \@handlers; +} + +sub groupDeviceExists { + my $self = shift; + my $device = shift; + my $group = shift; + my $lun = shift; + my $devices = $self->groupDevices($group); + + return -1 if (!defined($devices)); + + if (defined($lun)) { + return $TRUE if ($$devices{$device} eq $lun); + } else { + return $TRUE if (defined($$devices{$device})); + } + + return $FALSE; +} + +sub groupDevices { + my $self = shift; + my $group = shift; + my %devices; + my $first = $TRUE; + + return undef if (!$self->groupExists($group)); + + my $io = new IO::File $_SCST_GROUPS_DIR_."/$group/".$_SCST_DEVICES_IO_, O_RDONLY; + return undef if (!$io); + + while (my $line = <$io>) { + chomp $line; + + if ($first) { + $first = $FALSE; + next; + } + + my($vname, $lun) = split(/\s+/, $line); + + $devices{$vname} = $lun; + } + + close $io; + + return \%devices; +} + +sub assignDeviceToGroup { + my $self = shift; + my $device = shift; + my $group = shift; + my $lun = shift; + + return $TRUE if (!$self->groupExists($group)); + return 2 if ($self->groupDeviceExists($device, $group, $lun)); + + my $cmd = "add $device $lun\n"; + + my $rc = $self->group_private($group, $_SCST_DEVICES_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return !$self->groupDeviceExists($device, $group, $lun); +} + +sub assignDeviceToHandler { + my $self = shift; + my $device = shift; + my $handler = shift; + my $handler_io = $_IO_MAP_{$handler}; + + return $TRUE if (!$handler_io); + return $TRUE if (!$self->handlerExists($handler)); + return 2 if ($self->handlerDeviceExists($handler, $device)); + + my $cmd = "assign $device $handler\n"; + + my $rc = $self->scst_private($cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if($rc); + return !$self->handlerDeviceExists($handler, $device); +} + +sub removeDeviceFromGroup { + my $self = shift; + my $device = shift; + my $group = shift; + + return $TRUE if (!$self->groupExists($group)); + return 2 if (!$self->groupDeviceExists($device, $group)); + + my $cmd = "del $device\n"; + + my $rc = $self->group_private($group, $_SCST_DEVICES_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + return $self->groupDeviceExists($device, $group); +} + +sub clearGroupDevices { + my $self = shift; + my $group = shift; + + return $TRUE if (!$self->groupExists($group)); + + my $cmd = "clear\n"; + + my $rc = $self->group_private($group, $_SCST_DEVICES_IO_, $cmd); + + return $FALSE if ($self->{'debug'}); + return $rc if ($rc); + + my $devices = $self->groupDevices($group); + + return (keys %{$devices}); +} + +sub handler_private { + my $self = shift; + my $handler_io = shift; + my $cmd = shift; + + my $io = new IO::File $handler_io, O_WRONLY; + return $TRUE if (!$io); + + if ($self->{'debug'}) { + print "DBG($$): '$handler_io' -> '$cmd'\n"; + } else { + print $io "$cmd\0"; + } + + close $io; + + return $FALSE; +} + +sub scst_private { + my $self = shift; + my $cmd = shift; + + my $io = new IO::File $_SCST_IO_, O_WRONLY; + return $TRUE if (!$io); + + if ($self->{'debug'}) { + print "DBG($$): '$_SCST_IO_' -> '$cmd'\n"; + } else { + print $io "$cmd\0"; + } + + close $io; + + return $FALSE; +} + +sub group_private { + my $self = shift; + my $group = shift; + my $file = shift; + my $cmd = shift; + + my $io = new IO::File $_SCST_GROUPS_DIR_."/$group/".$file, O_WRONLY; + return $TRUE if (!$io); + + if ($self->{'debug'}) { + print "DBG($$): $_SCST_GROUPS_DIR_/$group/$file -> $cmd\n"; + } else { + print $io "$cmd\0"; + } + + close $io; + + return $FALSE; +} + +sub checkOptions { + my $self = shift; + my $options = shift; + + return if (!$options); + + foreach my $option (split(/\s+/, $options)) { + foreach my $avail (@_AVAILABLE_OPTIONS_) { + return $FALSE if ($avail eq $option); + } + } + + return $TRUE; +} + +sub cleanupString { + my $self = shift; + my $string = shift; + + $string =~ s/^\s+//; + $string =~ s/\s+$//; + + return $string; +} + +;1 __END__ + +=head1 NAME + +SCST::SCST - Generic SCST methods. + +=head1 SYNOPSIS + + use SCST::SCST; + + $p = SCST::SCST->new(); + + print "Using SCST version".$p->scstVersion()."\n"; + + if ($p->handlerDeviceExists($SCST::SCST::DISKFILE_TYPE)) { + print "openDevice() failed\n" + if ($p->openDevice($SCST::SCST::DISKFILE_TYPE, 'DISK01', '/vdisk/disk01.dsk')); + } + + undef $p; + +=head1 DESCRIPTION + +Generic SCST methods. + +=head2 Methods + +=over 5 + +=item SCST::SCST->new(); + +Create a new SCST object. If the argument $debug is non-zero no changes +will be made. + +Arguments: (bool) $debug + +Returns: (object) $new + +=item SCST::SCST->scstVersion(); + +Returns the version of SCST running. + +Arguments: void + +Returns: (string) $version + +=item SCST::SCST->groups(); + +Returns a list of security groups configured. + +Arguments: void + +Returns: (array ref) $groups + +=item SCST::SCST->groupExists(); + +Checks for a specified group's existance. + +Arguments: (string) $group + +Returns: (boolean) $groupExists + +=item SCST::SCST->addGroup(); + +Adds a security group to SCST's configuration. Returns 0 upon success, 1 if +unsuccessfull and 2 if the group already exists. + +Arguments: (string) $group + +Returns: (int) $success + +=item SCST::SCST->removeGroup(); + +Removes a group from SCST's configuration. Returns 0 upon success, 1 if +unsuccessfull and 2 if group does not exist. + +=item SCST::SCST->sgvStats(); + +Returns a hash of stats gathered from /proc/scsi_tgt/sgv. + +Arguments: void + +Returns: (hash ref) $stats + +Hash Layout: See /proc/scsi_tgt/sgv for tokens. This methods simply hashes +what's found there and returns it with no further processing. + +=item SCST::SCST->sessions(); + +Returns a hash of current SCST initiator sessions. + +Arguments: void + +Returns: (hash ref) $sessions + +Hash Layout: See /proc/scsi_tgt/sessions for tokens. This methods simply hashes +what's found there and returns it with no further processing. + +=item SCST::SCST->devices(); + +Returns a hash of devices configured without regard to device handler. + +Arguments: void + +Returns: (hash ref) $devices + +Hash Layout: (string) $device = (int) $handler + +=item SCST::SCST->handlerDevices(); + +Returns a hash of devices configured for a specified device handler. + +Arguments: (int) $handler + +Returns: (hash ref) $devices + +Hash Layout: (string) $device -> SIZE = (int) $deviceSize + (string) $device -> PATH = (string) $devicePath + (string) $device -> OPTIONS = (string) $options (comma seperated) + +=item SCST::SCST->handlerDeviceExists(); + +Checks for a specified device is configured for a specified device handler. + +Arguments: (int) $handler, (string) $device + +Returns: (boolean) $deviceExists + +=item SCST::SCST->openDevice(); + +Opens an already existing specified device for the specified device handler. +Returns 0 upon success, 1 if unsuccessfull and 2 if the device already exists. + +Available options for the parameter $options are: WRITE_THROUGH, READ_ONLY, O_DIRECT + +Arguments: (int) $handler, (string) $device, (string) $path [, (string) $options] + +Returns: (int) $success + +=item SCST::SCST->closeDevice(); + +Closes an open device configured for the specified device handler. Returns +0 upon success, 1 if unsuccessfull and 2 of the device does not exist. + +Arguments: (int) $handler, (string) $device, (string) $path + +Returns: (int) $success + +=item SCST::SCST->userExists(); + +Checks for a specified user with the specified security group. + +Arguments: (string) $user, (string) $group + +Returns (boolean) $userExists + +=item SCST::SCST->users(); + +Returns a list of users configured for a given security group. + +Arguments: (string) $group + +Returns: (hash ref) $users + +=item SCST::SCST->addUser(); + +Adds the specified user to the specified security group. Returns 0 +upon success, 1 if unsuccessfull and 2 if the user already exists. + +Arguments: (string) $user, (string) $group + +Returns: (int) $success + +=item SCST::SCST->removeUser(); + +Removed the specified user from the specified security group. Returns +0 upon success, 1 if unsuccessfull and 2 if the user does not exist. + +Arguments: (string) $user, (string) $group + +Returns: (int) $success + +=item SCST::SCST->clearUsers(); + +Removes all users from the specified security group. Returns 0 upon +success or 1 if unsuccessfull. + +Arguments: (string) $group + +Returns: (int) $success + +=item SCST::SCST->handlerExists(); + +Checks if a specified device handler exists within SCST's configuration. + +Arguments: (int) $handler + +Returns: (boolean) $handlerExists + +=item SCST::SCST->handlers(); + +Returns a list of configured device handlers. + +Arguments: void + +Returns: (array ref) $handlers + +=item SCST::SCST->groupDeviceExists(); + +Checks if a specified device is assigned to a specified security group. +If the optional $lun argument is specified, this method also matches +the lun. + +Arguments: (string) $device, (string) $group [, (int) $lun] + +Returns: (boolean) $deviceExists + +=item SCST::SCST->groupDevices(); + +Returns a hash if devices assigned to the specified security group. + +Arguments: (string) $group + +Returns: (hash ref) $devices + +Hash Layout: (string) $device = (int) $lun + +=item SCST::SCST->assignDeviceToGroup(); + +Assigns the specified device to the specified security group. Returns +0 upon success, 1 if unsuccessfull and 2 if the device has already +been assigned to the specified security group. + +Arguments: (string) $device, (string) $group, (int) $lun + +Returns: (int) $success + +=item SCST::SCST->assignDeviceToHandler(); + +Assigns specified device to specified handler. Returns 0 upon success, +1 if unsuccessfull and 2 if the specified device is already assigned to +the specified handler. + +Arguments: (string) $device, (string) $handler + +Returns: (int) $success + +=item SCST::SCST->removeDeviceFromGroup(); + +Removes the specified device from the specified security group. Returns +0 upon success, 1 if unsuccessfull and 2 if the device has not been +assigned to the specified security group. + +Arguments: (string) $device, (string) $group + +Returns: (int) $success + +=item SCST::SCST->clearGroupDevices(); + +Removes all devices from the specified security group. Returns 0 upon +success or 1 if unsuccessfull. + +Arguments: (string) $group + +Returns: (int) $success + +=back + +=head1 WARNING + +None at this time. + +=head1 NOTES + +If the $debug parameter is specified on package new(), no actions are +performed. Rather they are printed to STDOUT and 0 is returned. + +Available Device Handlers: + +CDROM_TYPE, +CHANGER_TYPE, +DISK_TYPE, +DISKFILE_TYPE, +CDROMFILE_TYPE, +DISKPERF_TYPE, +MODISK_TYPE, +MODISKPERF_TYPE, +TAPE_TYPE, +TAPEPERF_TYPE + +To specify a device handler to a method, use the following syntax: + +$SCST::SCST::<handler type> + +For example: + +$SCST::SCST::MODISK_TYPE + +=cut Added: trunk/scstadmin/examples/scst.conf =================================================================== --- trunk/scstadmin/examples/scst.conf (rev 0) +++ trunk/scstadmin/examples/scst.conf 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,91 @@ +# Automatically generated by scst. + +[HANDLER disk_fileio] +DEVICE GW15K000,/dev/evms/GW15K000,512 +DEVICE GW15K001,/dev/evms/GW15K001,512 +DEVICE MP15K004,/dev/evms/MP15K004,512 +DEVICE MP15K005,/dev/evms/MP15K005,512 +DEVICE MP15K006,/dev/evms/MP15K006,512 +DEVICE MP15K007,/dev/evms/MP15K007,512 +DEVICE MP15K008,/dev/evms/MP15K008,512 +DEVICE MP15K009,/dev/evms/MP15K009,512 +DEVICE MP15K00a,/dev/evms/MP15K00a,512 +DEVICE MP15K00b,/dev/evms/MP15K00b,512 +DEVICE MP15K00c,/dev/evms/MP15K00c,512 +DEVICE MP15K00d,/dev/evms/MP15K00d,512 +DEVICE MP15K00e,/dev/evms/MP15K00e,512 +DEVICE MS10K006,/dev/evms/MS10K002,512 +DEVICE MS15K000,/dev/evms/MS15K000,512 +DEVICE MS15K001,/dev/evms/MS15K001,512 +DEVICE MS15K002,/dev/evms/MS15K002,512 +DEVICE MS15K005,/dev/evms/MS15K003,512 +DEVICE RG10K000,/dev/evms/RG10K000,512 +DEVICE RG72K001,/dev/evms/RG72K001,512 + +[HANDLER cdrom_fileio] + +[GROUP CORBIN2_a] +USER 21:00:00:e0:8b:11:8d:8a + +[GROUP CORBIN3_a] +USER 21:00:00:e0:8b:03:9e:1a + +[GROUP MENTASM_a] +USER 21:00:00:e0:8b:11:06:8a + +[GROUP PC1_a] +USER 21:00:00:e0:8b:11:3f:8d + +[GROUP PC2_a] +USER 21:00:00:e0:8b:03:d8:4a + +[GROUP PC3_a] +USER 21:00:00:e0:8b:13:ba:01 + +[GROUP PC4_a] +USER 21:00:00:e0:8b:11:a6:8b + +[GROUP RAISTLIN_a] +USER 21:00:00:e0:8b:11:75:8b + +[ASSIGNMENT CORBIN2_a] +DEVICE MP15K009,0 +DEVICE MS10K006,1 +DEVICE RG10K000,2 +DEVICE RG72K001,3 + +[ASSIGNMENT CORBIN3_a] +DEVICE MP15K00d,0 + +[ASSIGNMENT Default] +DEVICE GW15K000,0 +DEVICE GW15K001,1 + +[ASSIGNMENT MENTASM_a] +DEVICE MP15K006,0 +DEVICE MP15K008,1 +DEVICE MP15K00e,2 + +[ASSIGNMENT PC1_a] +DEVICE MS15K000,0 + +[ASSIGNMENT PC2_a] +DEVICE MS15K005,0 + +[ASSIGNMENT PC3_a] +DEVICE MP15K00c,0 + +[ASSIGNMENT PC4_a] +DEVICE MP15K005,0 +DEVICE MP15K007,1 + +[ASSIGNMENT RAISTLIN_a] +DEVICE MP15K00a,0 +DEVICE MP15K00b,1 + +[TARGETS enable] +HOST 0x50060b0000397178 +HOST 0x50060b000039717a + +[TARGETS disable] + Added: trunk/scstadmin/examples/scst_example.sql =================================================================== --- trunk/scstadmin/examples/scst_example.sql (rev 0) +++ trunk/scstadmin/examples/scst_example.sql 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,185 @@ +-- MySQL dump 10.10 +-- +-- Host: localhost Database: scst +-- ------------------------------------------------------ +-- Server version 5.0.26-Debian_1-log + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `assignments` +-- + +DROP TABLE IF EXISTS `assignments`; +CREATE TABLE `assignments` ( + `device_id` int(8) NOT NULL default '0', + `type_id` char(2) default NULL, + `group_id` int(4) NOT NULL default '0', + `host_id` int(2) NOT NULL default '0', + `target_id` int(2) NOT NULL default '0', + `target_lun` int(3) NOT NULL default '0', + PRIMARY KEY (`device_id`,`group_id`,`host_id`,`target_id`,`target_lun`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `assignments` +-- + +LOCK TABLES `assignments` WRITE; +/*!40000 ALTER TABLE `assignments` DISABLE KEYS */; +INSERT INTO `assignments` VALUES (5,'MS',13,0,0,0),(5,'MP',11,0,0,0),(13,'MP',6,0,0,0),(0,'GW',1,0,0,0),(1,'GW',1,0,0,1),(12,'MP',12,0,0,0),(6,'MP',8,0,0,0),(8,'MP',8,0,0,1),(9,'MP',9,0,0,0),(10,'MP',10,0,0,0),(11,'MP',10,0,0,1),(7,'MP',11,0,0,1),(14,'MP',8,0,0,2),(0,'MS',7,0,0,0),(1,'RG',9,0,0,3),(0,'RG',9,0,0,2),(6,'MS',9,0,0,1); +/*!40000 ALTER TABLE `assignments` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `device_types` +-- + +DROP TABLE IF EXISTS `device_types`; +CREATE TABLE `device_types` ( + `type_id` char(2) NOT NULL default '', + `type_name` char(100) NOT NULL default '', + PRIMARY KEY (`type_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `device_types` +-- + +LOCK TABLES `device_types` WRITE; +/*!40000 ALTER TABLE `device_types` DISABLE KEYS */; +INSERT INTO `device_types` VALUES ('GW','Gateway Communication Device'),('MP','Mirrored Pair Device'),('SV','Snapshot Device'),('SD','Single Disk Device (Unprotected)'),('SS','Stripe Set (VERY Unprotected)'),('RG','Raid 5 Group Device'),('MS','Mirrored Stripe Device'); +/*!40000 ALTER TABLE `device_types` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `devices` +-- + +DROP TABLE IF EXISTS `devices`; +CREATE TABLE `devices` ( + `device_id` int(8) NOT NULL default '0', + `type_id` char(2) NOT NULL default '', + `perf_id` char(3) NOT NULL default '', + `md_uuid` char(40) default NULL, + `device_path` char(100) default NULL, + `options` char(50) default NULL, + `blocksize` int(6) default NULL, + `scst_handlr_id` int(2) NOT NULL default '0', + PRIMARY KEY (`device_id`,`type_id`) +) ENGINE=MyISAM AUTO_INCREMENT=29 DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `devices` +-- + +LOCK TABLES `devices` WRITE; +/*!40000 ALTER TABLE `devices` DISABLE KEYS */; +INSERT INTO `devices` VALUES (7,'MP','15K','','/dev/evms/MP15K007',NULL,NULL,2),(5,'MP','15K','','/dev/evms/MP15K005',NULL,NULL,2),(6,'MP','15K','','/dev/evms/MP15K006',NULL,NULL,2),(4,'MP','15K','','/dev/evms/MP15K004',NULL,NULL,2),(8,'MP','15K','','/dev/evms/MP15K008',NULL,NULL,2),(9,'MP','15K','','/dev/evms/MP15K009',NULL,NULL,2),(10,'MP','15K','','/dev/evms/MP15K00a',NULL,NULL,2),(11,'MP','15K','','/dev/evms/MP15K00b',NULL,NULL,2),(12,'MP','15K','','/dev/evms/MP15K00c',NULL,NULL,2),(0,'GW','15K','','/dev/evms/GW15K000',NULL,NULL,2),(1,'GW','15K','','/dev/evms/GW15K001',NULL,NULL,2),(13,'MP','15K','','/dev/evms/MP15K00d',NULL,NULL,2),(14,'MP','15K','','/dev/evms/MP15K00e',NULL,NULL,2),(6,'MS','10K','','/dev/evms/MS10K002',NULL,NULL,2),(5,'MS','15K','','/dev/evms/MS15K003',NULL,NULL,2),(1,'RG','72K','','/dev/evms/RG72K001',NULL,NULL,2),(2,'MS','15K','','/dev/evms/MS15K002',NULL,NULL,2),(1,'MS','15K','','/dev/evms/MS15K001',NULL,NULL,2),(0,'MS','15K','','/dev/evms/MS15K000',NULL,NULL,2),(0,'RG','10K','','/dev/evms/RG10K000',NULL,NULL,2); +/*!40000 ALTER TABLE `devices` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `group_users` +-- + +DROP TABLE IF EXISTS `group_users`; +CREATE TABLE `group_users` ( + `group_id` int(16) NOT NULL default '0', + `user_id` char(32) NOT NULL default '', + PRIMARY KEY (`group_id`,`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `group_users` +-- + +LOCK TABLES `group_users` WRITE; +/*!40000 ALTER TABLE `group_users` DISABLE KEYS */; +INSERT INTO `group_users` VALUES (6,'20:00:00:e0:8b:03:9e:1a'),(6,'21:00:00:e0:8b:03:9e:1a'),(7,'20:00:00:e0:8b:11:3f:8d'),(7,'21:00:00:e0:8b:11:3f:8d'),(8,'20:00:00:e0:8b:11:06:8a'),(8,'21:00:00:e0:8b:11:06:8a'),(9,'20:00:00:e0:8b:11:8d:8a'),(9,'21:00:00:e0:8b:11:8d:8a'),(10,'20:00:00:e0:8b:11:75:8b'),(10,'21:00:00:e0:8b:11:75:8b'),(11,'20:00:00:e0:8b:11:a6:8b'),(11,'21:00:00:e0:8b:11:a6:8b'),(12,'20:00:00:e0:8b:13:ba:01'),(12,'21:00:00:e0:8b:13:ba:01'),(13,'20:00:00:e0:8b:03:d8:4a'),(13,'21:00:00:e0:8b:03:d8:4a'); +/*!40000 ALTER TABLE `group_users` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `perf_types` +-- + +DROP TABLE IF EXISTS `perf_types`; +CREATE TABLE `perf_types` ( + `perf_id` char(3) NOT NULL default '', + `perf_name` char(100) NOT NULL default '', + PRIMARY KEY (`perf_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `perf_types` +-- + +LOCK TABLES `perf_types` WRITE; +/*!40000 ALTER TABLE `perf_types` DISABLE KEYS */; +INSERT INTO `perf_types` VALUES ('15K','15K RPM UltraSCSI-2'),('10F','10K RPM Fibre'),('72I','7200 RPM ATA/SATA'),('54I','5400 RPM ATA/SATA'),('10I','10K RPM ATA/SATA'); +/*!40000 ALTER TABLE `perf_types` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `scst_handlers` +-- + +DROP TABLE IF EXISTS `scst_handlers`; +CREATE TABLE `scst_handlers` ( + `scst_handlr_id` int(2) NOT NULL default '0', + `handler_name` char(32) NOT NULL default '', + `autoload` enum('N','Y') NOT NULL default 'N', + PRIMARY KEY (`scst_handlr_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `scst_handlers` +-- + +LOCK TABLES `scst_handlers` WRITE; +/*!40000 ALTER TABLE `scst_handlers` DISABLE KEYS */; +INSERT INTO `scst_handlers` VALUES (1,'disk','N'),(2,'disk_fileio','Y'),(3,'cdrom','N'),(4,'changer','N'),(5,'disk_perf','N'),(6,'modisk','N'),(7,'modisk_perf','N'),(8,'tape','N'),(9,'tape_perf','N'); +/*!40000 ALTER TABLE `scst_handlers` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `security_groups` +-- + +DROP TABLE IF EXISTS `security_groups`; +CREATE TABLE `security_groups` ( + `group_id` int(4) NOT NULL auto_increment, + `group_name` char(100) NOT NULL default '', + PRIMARY KEY (`group_id`) +) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `security_groups` +-- + +LOCK TABLES `security_groups` WRITE; +/*!40000 ALTER TABLE `security_groups` DISABLE KEYS */; +INSERT INTO `security_groups` VALUES (1,'Default'),(6,'CORBIN3_a'),(12,'PC3_a'),(7,'PC1_a'),(8,'MENTASM_a'),(9,'CORBIN2_a'),(10,'RAISTLIN_a'),(11,'PC4_a'),(13,'PC2_a'); +/*!40000 ALTER TABLE `security_groups` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2006-11-06 20:47:39 Added: trunk/scstadmin/init.d/scst =================================================================== --- trunk/scstadmin/init.d/scst (rev 0) +++ trunk/scstadmin/init.d/scst 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,71 @@ +#!/bin/sh + +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin +SCST_CMD=/usr/local/sbin/scstadmin +SCST_CFG=/etc/scst.conf + +# Modules to load/unload +SCST_MODULES="scst_fileio scst_disk scst_cdrom" + +OPTIONS="" + +test -x $SCST_CMD -a -f $SCST_CFG || exit 0 + +case "$1" in + start) + echo -n "Loading and configuring SCSI Target Mid-level: scst " + + modprobe qla2x00tgt || { echo "[qla2x00tgt failed]" ; exit 1 ; } + + for module in ${SCST_MODULES}; do + modprobe ${module} || { echo "[${module} failed]" ; exit 1 ; } + done + + $SCST_CMD -config $SCST_CFG + + RC=$? + + if [ $RC -ne 0 ]; + then + echo "[config failed]" + fi + + echo "." + ;; + stop) + echo -n "Stopping SCSI Target Mid-level: scst " + + for module in ${SCST_MODULES}; do + rmmod ${module} || { echo "[${module} failed]" ; } + done + + rmmod qla2x00tgt || { echo "[qla2x00tgt failed]" ; } + rmmod scsi_tgt || { echo "[scsi_tgt failed]" ; } + + echo "." + ;; + force-reload|restart) + $0 stop + sleep 1 + $0 start + ;; + reload-config) + echo -n "Reloading configuration: scst " + + $SCST_CMD -config $SCST_CFG + + RC=$? + + if [ $RC -ne 0 ]; + then + echo "[config failed]" + fi + + echo "." + ;; + *) + echo "Usage: /etc/init.d/scst {start|stop|restart|force-reload|reload-config}" + exit 1 +esac + +exit 0 Property changes on: trunk/scstadmin/init.d/scst ___________________________________________________________________ Name: svn:executable + * Added: trunk/scstadmin/scst.conf =================================================================== --- trunk/scstadmin/scst.conf (rev 0) +++ trunk/scstadmin/scst.conf 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,51 @@ +# SCST Configurator v0.2 + +# Handler devices +[HANDLER disk] +# DEVICE <H:C:I:L> + +[HANDLER disk_fileio] +# DEVICE <vname>,<path>,<WRITE_THROUGH|READ_ONLY|O_DIRECT|NV_CACHE|NULLIO>,<block size> +DEVICE DISK01,/tmp/test1.dsk,READ_ONLY|WRITE_THROUGH +DEVICE DISK02,/tmp/test2.dsk +DEVICE DISK03,/tmp/test3.dsk,O_DIRECT +DEVICE DISK04,/tmp/test4.dsk,,512 + +[HANDLER disk_perf] + +[HANDLER cdrom] +# DEVICE <H:C:I:L> + +[HANDLER changer] +# DEVICE <H:C:I:L> + +[HANDLER modisk] +# DEVICE <H:C:I:L> + +[HANDLER modisk_perf] + +[HANDLER tape] +# DEVICE <H:C:I:L> + +[HANDLER tape_perf] + +# Security Group +[GROUP Test] +# USER <user> +USER 50060b000001369d + +# Device Assignments +[ASSIGNMENT Test] +# DEVICE <device>,<vlun> +DEVICE DISK01,0 +DEVICE DISK02,1 +DEVICE DISK03 + +# Target to enable +[TARGETS enable] +HOST 50:06:0B:00:00:39:71:78 +HOST host4 + +# Targets to disable +[TARGETS disable] +HOST host5 Added: trunk/scstadmin/scst_db/scst_db =================================================================== --- trunk/scstadmin/scst_db/scst_db (rev 0) +++ trunk/scstadmin/scst_db/scst_db 2006-11-14 12:56:57 UTC (rev 33) @@ -0,0 +1,556 @@ +#!/usr/bin/perl +$Version = 'SCST DB Configurator v0.51'; + +# Configures SCST +# +# Written by Mark R. Buechler 12/07/04 + +sub usage + { + die <<"EndUsage"; +$Version + +Usage: +General Operations + -config <config> : Configure SCST given the specified configuration file. + -check : Check database configuration against current configuration. + +Options + -ForceConfig : Force all confuration changes, even deletions (DANGER!). + +Debugging (limited support) + -debug : Debug mode - don\'t do anything destructive. + +Examples: + Configure SCST: + scst_db config scst_db.conf + +EndUsage + } + +use SCST::SCST; +use Getopt::Long; +use IO::Handle; +use IO::File; +use DBI; +use POSIX; +use strict; + +my $_DEF_CONFIG_ = '/etc/scst_db.conf'; + +my $TRUE = 1; +my $FALSE = 0; + +my $_MAX_LUNS_ = 255; +my $_DEFAULT_GROUP_ = 'Default'; + +my $_MDADM_ = '/sbin/mdadm'; +my $_MDSTAT_ = '/proc/mdstat'; +my $_MD_DEV_ = '/dev/'; + +my $SCST; +my $DEVICES; +my %USERS; +my %ASSIGNMENTS; +my %HANDLERS; +my %GROUPS; +my $_DEBUG_; + +my %MD_DEVICES; + +my %_HANDLER_MAP_ = ('cdrom' => $SCST::SCST::CDROM_TYPE, + 'changer' => $SCST::SCST::CHANGER_TYPE, + 'disk' => $SCST::SCST::DISK_TYPE, + 'disk_fileio' => $SCST::SCST::DISKFILE_TYPE, + 'cdrom_fileio' => $SCST::SCST::CDROMFILE_TYPE, + 'disk_perf' => $SCST::SCST::DISKPERF_TYPE, + 'modisk' => $SCST::SCST::MODISK_TYPE, + 'modisk_perf' => $SCST::SCST::MODISKPERF_TYPE, + 'tape' => $SCST::SCST::TAPE_TYPE, + 'tape_perf' => $SCST::SCST::TAPEPERF_TYPE); + +my %_REVERSE_MAP_ = ($SCST::SCST::CDROM_TYPE => 'cdrom', + $SCST::SCST::CHANGER_TYPE => 'changer', + $SCST::SCST::DISK_TYPE => 'disk', + $SCST::SCST::DISKFILE_TYPE => 'disk_fileio', + $SCST::SCST::CDROMFILE_TYPE... [truncated message content] |
From: <vl...@us...> - 2006-12-04 10:53:26
|
Revision: 39 http://svn.sourceforge.net/scst/?rev=39&view=rev Author: vlnb Date: 2006-12-04 02:53:25 -0800 (Mon, 04 Dec 2006) Log Message: ----------- Updated version to 0.9.6 and Makefiles to bring the debug options back Modified Paths: -------------- trunk/qla2x00t/qla2x00-target/ChangeLog trunk/qla2x00t/qla2x00-target/Makefile trunk/qla2x00t/qla2x00-target/README trunk/qla2x00t/qla2x00-target/qla2x00t.h trunk/scst/README trunk/scst/include/scsi_tgt.h trunk/scst/src/Makefile trunk/scst/src/dev_handlers/Makefile Modified: trunk/qla2x00t/qla2x00-target/ChangeLog =================================================================== --- trunk/qla2x00t/qla2x00-target/ChangeLog 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/qla2x00t/qla2x00-target/ChangeLog 2006-12-04 10:53:25 UTC (rev 39) @@ -1,3 +1,8 @@ +Summary of changes between versions 0.9.5 and 0.9.6 +--------------------------------------------------- + + + Summary of changes between versions 0.9.3.8 and 0.9.5 ----------------------------------------------------- Modified: trunk/qla2x00t/qla2x00-target/Makefile =================================================================== --- trunk/qla2x00t/qla2x00-target/Makefile 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/qla2x00t/qla2x00-target/Makefile 2006-12-04 10:53:25 UTC (rev 39) @@ -26,17 +26,17 @@ # - install and uninstall must be made as root # -SCST_INC_DIR := /usr/local/include/scst -#SCST_INC_DIR := $(SUBDIRS)/../../scst/include -#SCST_DIR := $(shell pwd)/../../scst/src -SCST_DIR := $(shell pwd)/../../scst-0.9.5/src +#SCST_INC_DIR := /usr/local/include/scst +SCST_INC_DIR := $(SUBDIRS)/../../scst/include +SCST_DIR := $(shell pwd)/../../scst/src +#SCST_DIR := $(shell pwd)/../../scst-0.9.5/src EXTRA_CFLAGS += -I$(SCST_INC_DIR) -DFC_TARGET_SUPPORT INSTALL_DIR := /lib/modules/$(shell uname -r)/extra EXTRA_CFLAGS += -DEXTRACHECKS -EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG_TGT +#EXTRA_CFLAGS += -DTRACING +EXTRA_CFLAGS += -DDEBUG_TGT #EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD ifeq ($(KVER),) Modified: trunk/qla2x00t/qla2x00-target/README =================================================================== --- trunk/qla2x00t/qla2x00-target/README 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/qla2x00t/qla2x00-target/README 2006-12-04 10:53:25 UTC (rev 39) @@ -1,7 +1,7 @@ Target driver for Qlogic 2200/2300 Fibre Channel cards ====================================================== -Version 0.9.5, 01 Dec 2006 +Version 0.9.6, XX XXX 200X -------------------------- This driver has all required features and looks to be quite stable (for Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.h =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.h 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.h 2006-12-04 10:53:25 UTC (rev 39) @@ -31,7 +31,7 @@ /* Version numbers, the same as for the kernel */ #define Q2T_VERSION(a,b,c,d) (((a) << 030) + ((b) << 020) + (c) << 010 + (d)) #define Q2T_VERSION_CODE Q2T_VERSION(0,9,5,0) -#define Q2T_VERSION_STRING "0.9.5" +#define Q2T_VERSION_STRING "0.9.6-pre1" #define Q2T_MAX_CDB_LEN 16 #define Q2T_TIMEOUT 10 /* in seconds */ Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/scst/README 2006-12-04 10:53:25 UTC (rev 39) @@ -1,7 +1,7 @@ Generic SCSI target mid-level for Linux (SCST) ============================================== -Version 0.9.5, 01 Dec 2006 +Version 0.9.6, XX XXX 200X -------------------------- SCST is designed to provide unified, consistent interface between SCSI Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/scst/include/scsi_tgt.h 2006-12-04 10:53:25 UTC (rev 39) @@ -30,9 +30,9 @@ #include <../drivers/scsi/scsi.h> /* Version numbers, the same as for the kernel */ -#define SCST_VERSION_CODE 0x000905 +#define SCST_VERSION_CODE 0x000906 #define SCST_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define SCST_VERSION_STRING "0.9.5" +#define SCST_VERSION_STRING "0.9.6-pre1" /************************************************************* ** States of command processing state machine Modified: trunk/scst/src/Makefile =================================================================== --- trunk/scst/src/Makefile 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/scst/src/Makefile 2006-12-04 10:53:25 UTC (rev 39) @@ -76,13 +76,13 @@ #EXTRA_CFLAGS += -DSTRICT_SERIALIZING EXTRA_CFLAGS += -DEXTRACHECKS -EXTRA_CFLAGS += -DFILEIO_ONLY +#EXTRA_CFLAGS += -DFILEIO_ONLY #EXTRA_CFLAGS += -fno-inline -EXTRA_CFLAGS += -DTRACING +#EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG +EXTRA_CFLAGS += -DDEBUG #EXTRA_CFLAGS += -DDEBUG_TM -DTM_DBG_GO_OFFLINE=0 #EXTRA_CFLAGS += -DDEBUG_RETRY #EXTRA_CFLAGS += -DDEBUG_OOM Modified: trunk/scst/src/dev_handlers/Makefile =================================================================== --- trunk/scst/src/dev_handlers/Makefile 2006-12-01 19:01:35 UTC (rev 38) +++ trunk/scst/src/dev_handlers/Makefile 2006-12-04 10:53:25 UTC (rev 39) @@ -51,9 +51,9 @@ EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../include #EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../../include -I$(SUBDIRS)/.. -EXTRA_CFLAGS += -DTRACING +#EXTRA_CFLAGS += -DTRACING -#EXTRA_CFLAGS += -DDEBUG +EXTRA_CFLAGS += -DDEBUG clean: rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend Modules.symvers Module.symvers This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vl...@us...> - 2006-12-13 11:43:00
|
Revision: 49 http://svn.sourceforge.net/scst/?rev=49&view=rev Author: vlnb Date: 2006-12-13 03:42:59 -0800 (Wed, 13 Dec 2006) Log Message: ----------- LSI/MPT target driver added Modified Paths: -------------- trunk/Makefile trunk/scst/src/Makefile Added Paths: ----------- trunk/mpt/ trunk/mpt/Kconfig trunk/mpt/Makefile trunk/mpt/README trunk/mpt/in-tree/ trunk/mpt/in-tree/Kconfig.diff trunk/mpt/in-tree/Makefile.diff trunk/mpt/mpt_scst.c trunk/mpt/mpt_scst.h trunk/mpt/scsi3.h trunk/scst/kernel/in-tree/Makefile.scsi.Linux-2.6.15.patch Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2006-12-13 11:32:36 UTC (rev 48) +++ trunk/Makefile 2006-12-13 11:42:59 UTC (rev 49) @@ -21,28 +21,34 @@ SCST_DIR=scst QLA_INI_DIR=qla2x00t QLA_DIR=qla2x00t/qla2x00-target +LSI_DIR=mpt all: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi + @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi install: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi + @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi uninstall: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi + @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi clean: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi + @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi extraclean: cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi + @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi scst: cd $(SCST_DIR) && $(MAKE) @@ -76,6 +82,21 @@ cd $(QLA_INI_DIR)/.. && $(MAKE) extraclean cd $(QLA_DIR) && $(MAKE) extraclean +lsi: + cd $(LSI_DIR) && $(MAKE) + +lsi_install: + cd $(LSI_DIR) && $(MAKE) install + +lsi_uninstall: + cd $(LSI_DIR) && $(MAKE) uninstall + +lsi_clean: + cd $(LSI_DIR) && $(MAKE) clean + +lsi_extraclean: + cd $(LSI_DIR) && $(MAKE) extraclean + help: @echo " all (the default) : make all" @echo " clean : clean files" @@ -94,9 +115,16 @@ @echo " qla_extraclean : 2.6 qla target: clean + clean dependencies" @echo " qla_install : 2.6 qla target: install" @echo " qla_uninstall : 2.6 qla target: uninstall" + @echo "" + @echo " lsi : make lsi target" + @echo " lsi_clean : lsi target: clean " + @echo " lsi_extraclean : lsi target: clean + clean dependencies" + @echo " lsi_install : lsi target: install" + @echo " lsi_uninstall : lsi target: uninstall" @echo " Notes :" @echo " - install and uninstall must be made as root" .PHONY: all install uninstall clean extraclean help \ qla qla_install qla_uninstall qla_clean qla_extraclean \ + lsi lsi_install lsi_uninstall lsi_clean lsi_extraclean \ scst scst_install scst_uninstall scst_clean scst_extraclean Added: trunk/mpt/Kconfig =================================================================== --- trunk/mpt/Kconfig (rev 0) +++ trunk/mpt/Kconfig 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,10 @@ + +config FUSION_SCST + tristate "Fusion MPT SCST driver" + depends on FUSION + ---help--- + This module enables target mode for use by the SCST middle + level drivers. You will also need the SCST middle level + drivers from http://scst.sf.net/. + + If unsure whether you really want or need this, say N. Added: trunk/mpt/Makefile =================================================================== --- trunk/mpt/Makefile (rev 0) +++ trunk/mpt/Makefile 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,90 @@ +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# +# Main targets: +# all (the default) : make all +# clean : clean files +# extraclean : clean + clean dependencies +# install : install +# uninstall : uninstall +# +# Notes : +# - install and uninstall must be made as root +# + +#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) + +EXTRA_CFLAGS += -DEXTRACHECKS +#EXTRA_CFLAGS += -DTRACING +#EXTRA_CFLAGS += -DDEBUG +#EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD + +ifeq ($(KVER),) + ifeq ($(KDIR),) + KDIR := /lib/modules/$(shell uname -r)/build + endif +else + KDIR := /lib/modules/$(KVER)/build +endif + +LSI_INC_DIR := $(KDIR)/drivers/message/fusion +EXTRA_CFLAGS += -I$(LSI_INC_DIR) + +ifneq ($(KERNELRELEASE),) +obj-m := mpt_scst.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=n + +install: all + $(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)/mpt_scst.ko + -/sbin/depmod -a +endif + +clean: + rm -f *.o *.ko .*.cmd *.mod.c .*.d .depend *~ Modules.symvers Module.symvers + rm -rf .tmp_versions + +extraclean: clean + +.PHONY: all tgt install uninstall clean extraclean Added: trunk/mpt/README =================================================================== --- trunk/mpt/README (rev 0) +++ trunk/mpt/README 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,12 @@ +Target driver for LSI/MPT XXX cards +=================================== + +Version X.X.X, XX XXX 200X +-------------------------- + +This driver was originally developed by Hu Gang and then is developed by +Erik Habbinga <eri...@in...>. It is on the early stage +of development. + +The current maintainer of this driver is Erik. Please send him all +question related to it (CC: scs...@li...). Added: trunk/mpt/in-tree/Kconfig.diff =================================================================== --- trunk/mpt/in-tree/Kconfig.diff (rev 0) +++ trunk/mpt/in-tree/Kconfig.diff 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,10 @@ +--- Kconfig_orig 2006-03-05 22:07:54.000000000 +0300 ++++ Kconfig 2006-12-13 13:00:41.000000000 +0300 +@@ -100,4 +100,7 @@ + + If unsure whether you really want or need this, say N. + ++config FUSION_SCST ++ source "drivers/message/fusion/mpt_scst/Kconfig" ++ + endmenu Added: trunk/mpt/in-tree/Makefile.diff =================================================================== --- trunk/mpt/in-tree/Makefile.diff (rev 0) +++ trunk/mpt/in-tree/Makefile.diff 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,30 @@ +--- Makefile_orig 2006-03-05 22:07:54.000000000 +0300 ++++ Makefile 2006-12-13 14:11:52.000000000 +0300 +@@ -8,7 +8,6 @@ + #EXTRA_CFLAGS += -DMPT_DEBUG_EXIT + #EXTRA_CFLAGS += -DMPT_DEBUG_FAIL + +- + # + # driver/module specifics... + # +@@ -30,9 +29,19 @@ + #CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL + # + ++SCST_INC_DIR := /usr/local/include/scst ++SCST_DIR := $(SCST_INC_DIR) ++ ++CFLAGS_mpt_scst.o += -I$(SCST_INC_DIR) -I$(src) ++CFLAGS_mpt_scst.o += -DEXTRACHECKS ++#CFLAGS_mpt_scst.o += -DTRACING ++#CFLAGS_mpt_scst.o += -DDEBUG ++#CFLAGS_mpt_scst.o += -DDEBUG_WORK_IN_THREAD ++ + #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC + + obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o ++obj-$(CONFIG_FUSION_SCST) += mpt_scst/mpt_scst.o + obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o + obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o + obj-$(CONFIG_FUSION_CTL) += mptctl.o Added: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c (rev 0) +++ trunk/mpt/mpt_scst.c 2006-12-13 11:42:59 UTC (rev 49) @@ -0,0 +1,5241 @@ +/* + * mpt_scst.c + * + * Copyright (C) 2005 Beijing Soul Technology Co., Ltd. + * Copyright (C) 2002, 2003, 2004 LSI Logic Corporation + * Copyright (C) 2004 Vladislav Bolkhovitin <vs...@vl...> + * and Leonid Stoljar + * + * MPT SCSI target mode driver for SCST. + * + * Originally By: Stephen Shirron + * Port to SCST By: Hu Gang <hu...@so...> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include <linux/module.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/version.h> +#include <linux/blkdev.h> +#include <linux/interrupt.h> +#include <scsi/scsi.h> +#include <scsi/scsi_host.h> + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) +#include <linux/pci.h> +#endif + +#include "scsi_tgt.h" + +#include <scst_debug.h> + +#include <scst_debug.c> +#include <linux/proc_fs.h> + +#include "mpt_scst.h" + +#define MYNAM "mpt_scst" + +#ifdef TRACING +static int trace_mpi = 0; + +#define TRACE_MPI 0x80000000 + +static char *mpt_state_string[] = { + "0", + "new", + "need data", + "data in", + "data out", + "processed", + "NULL", +}; +#endif + +static MPT_STM_PRIV *mpt_stm_priv[MPT_MAX_ADAPTERS+1]; + +static int set_aliases_in_fcportpage1 = 1; +static int num_aliases = 0; +static int stm_context = 0; + +static int mpt_stm_adapter_online(MPT_STM_PRIV *priv); +static void mpt_stm_adapter_dispose(MPT_STM_PRIV *priv); +static int mpt_stm_adapter_install(MPT_ADAPTER *ioc); + +static int __init _mpt_stm_init(void); + +static void stmapp_set_status(MPT_STM_PRIV *priv, CMD *cmd, int status); +static void stmapp_tgt_command(MPT_STM_PRIV *priv, u32 reply_word); +static void stm_cmd_buf_post(MPT_STM_PRIV *priv, int index); + +static void stm_tgt_reply_high_pri(MPT_ADAPTER *ioc, + TargetCmdBufferPostErrorReply_t *rep); +static void stm_target_reply_error(MPT_ADAPTER *ioc, TargetErrorReply_t *rep); +static void stmapp_target_error(MPT_STM_PRIV *priv, u32 reply_word, int index, + int status, int reason); +static void stm_link_service_reply(MPT_ADAPTER *ioc, + LinkServiceBufferPostReply_t *rep); +static void stm_link_service_rsp_reply(MPT_ADAPTER *ioc, + LinkServiceRspRequest_t *req, LinkServiceRspReply_t *rep); +static void stmapp_set_sense_info(MPT_STM_PRIV *priv, + CMD *cmd, int sense_key, int asc, int ascq); +static void stmapp_srr_adjust_offset(MPT_STM_PRIV *priv, int index); +static void stmapp_srr_convert_ta_to_tss(MPT_STM_PRIV *priv, int index); +static void stmapp_abts_process(MPT_STM_PRIV *priv, + int rx_id, LinkServiceBufferPostReply_t *rep, int index); +static int stm_do_config_action(MPT_STM_PRIV *priv, + int action, int type, int number, int address, int length, + int sleep); +static int stm_get_config_page(MPT_STM_PRIV *priv, + int type, int number, int address, int sleep); +static int stm_set_config_page(MPT_STM_PRIV *priv, + int type, int number, int address, int sleep); +static void stm_cmd_buf_post_list(MPT_STM_PRIV *priv, int index); +static int stm_send_target_status(MPT_STM_PRIV *priv, + u32 reply_word, int index, int flags, int lun, int tag); +static void stm_send_els(MPT_STM_PRIV *priv, LinkServiceBufferPostReply_t *rep, + int index, int length); +static void stm_link_serv_buf_post(MPT_STM_PRIV *priv, int index); + +static void stm_wait(MPT_STM_PRIV *priv, int milliseconds, int sleep); +static int stm_wait_for(MPT_STM_PRIV *priv, volatile int *flag, int seconds, + int sleep); +static void stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, + u32 offset, LinkServiceBufferPostReply_t *rep, int index); + +static int +mpt_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, + struct scst_tgt *scst_tgt) +{ + struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + MPT_ADAPTER *ioc = tgt->priv->ioc; + int res = 0, len = 0; + MPT_STM_PRIV *priv = tgt->priv; + + TRACE_ENTRY(); + TRACE_DBG("res %d, buffer %p, length %d, %d, priv %p, tgt %p", + res, buffer, length, len, priv, tgt); + + BUG_ON(tgt == NULL); + BUG_ON(ioc == NULL); + + len = snprintf(buffer, length, + "ProductID :0x%04x (%s)\n" + "Target Enable :%s\n", + ioc->facts.ProductID, + ioc->prod_name, + tgt->target_enable ? "True" : "False"); +#define LEN_CHECK(res, buffer, length) \ + TRACE_DBG("res %d, buffer %p, length %d, %d", res, buffer, length, len); \ + res += len; buffer += len; length -= len; \ + if (length <= 0) goto out; + + LEN_CHECK(res, buffer, length) + + if (ioc->bus_type == SCSI) { + int i = 0; + len = snprintf(buffer, length, + "Target ID :%d\n" + "Capabilities :0x%x\n" + "PhysicalInterface:0x%x\n", + tgt->target_id, + priv->SCSIPortPage0.Capabilities, + priv->SCSIPortPage0.PhysicalInterface); + LEN_CHECK(res, buffer, length) + + len = snprintf(buffer, length, + "Configuration :0x%x\n" + "OnBusTimerValue :0x%x\n" + "TargetConfig :0x%x\n" + "IDConfig :0x%x\n", + priv->SCSIPortPage1.Configuration, + priv->SCSIPortPage1.OnBusTimerValue, + priv->SCSIPortPage1.TargetConfig, + priv->SCSIPortPage1.IDConfig); + LEN_CHECK(res, buffer, length); + + len = snprintf(buffer, length, + "PortFlags :0x%x\n" + "PortSettings :0x%x\n", + priv->SCSIPortPage2.PortFlags, + priv->SCSIPortPage2.PortSettings); + LEN_CHECK(res, buffer, length); +#if 0 + for (i = 0; i < 16; i++) { + len = snprintf(buffer, length, + " DeviceSeting %02d: 0x%x 0x%x 0x%x\n", + priv->SCSIPortPage2.DeviceSettings[i].Timeout, + priv->SCSIPortPage2.DeviceSettings[i].SyncFactor, + priv->SCSIPortPage2.DeviceSettings[i].DeviceFlags); + LEN_CHECK(res, buffer, length); + } +#endif + for (i = 0; i < NUM_SCSI_DEVICES; i++) { + len = snprintf(buffer, length, + " Device %02d: 0x%x, 0x%x\n", + i, + priv->SCSIDevicePage1[i].RequestedParameters, + priv->SCSIDevicePage1[i].Configuration); + LEN_CHECK(res, buffer, length); + } + } + + if (ioc->bus_type == FC) { + len = snprintf(buffer, length, + "WWN :%08X%08X:%08X%08X\n", + ioc->fc_port_page0[0].WWNN.High, + ioc->fc_port_page0[0].WWNN.Low, + ioc->fc_port_page0[0].WWPN.High, + ioc->fc_port_page0[0].WWPN.Low); + LEN_CHECK(res, buffer, length); + } +#undef LEN_CHECK +out: + TRACE_EXIT_RES(res); + + return res; +} + +static int +mpt_proc_write(struct file *file, const char *buf, unsigned long length, + struct scst_tgt *scst_tgt) +{ + + struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + MPT_ADAPTER *ioc = tgt->priv->ioc; + int res = 0; + char tmp[32+1]; + + TRACE_ENTRY(); + res = min(32, (int)length); + memcpy(tmp, buf, res); + tmp[res] = 0; + + TRACE_DBG("buff '%s'", tmp); + if (strncmp("target:enable", tmp, strlen("target:enable")) == 0) { + TRACE_DBG("Enable Target, %d, %d", ioc->id, tgt->target_enable); + if (tgt->target_enable != 1) { + mpt_stm_adapter_online(mpt_stm_priv[ioc->id]); + tgt->target_enable = 1; + } + } + + if (strncmp("target:disable", tmp, strlen("target:disable")) == 0) { + TRACE_DBG("Disable Target %d, %d", ioc->id, tgt->target_enable); + if (tgt->target_enable != 0) { + /* FIXME */ + tgt->target_enable = 0; + } + } + +#ifdef DEBUG + if (strncmp("target_id:", tmp, strlen("target_id:")) == 0) { + char *s = tmp + strlen("target_id:"); + TRACE_DBG("target id is '%s'", s); + } +#endif + + TRACE_EXIT_RES(res); + + return length; +} + +static int mpt_proc_info(char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_tgt *tgt, int inout) +{ + if (inout) { + return mpt_proc_write(NULL, buffer, length, tgt); + } + return mpt_proc_read(buffer, start, offset, length, eof, tgt); +} + + +static int mpt_target_detect(struct scst_tgt_template *temp1); +static int mpt_target_release(struct scst_tgt *scst_tgt); +static int mpt_xmit_response(struct scst_cmd *scst_cmd); +static int mpt_rdy_to_xfer(struct scst_cmd *scst_cmd); +static void mpt_on_free_cmd(struct scst_cmd *scst_cmd); +static void mpt_task_mgmt_fn_done(struct scst_mgmt_cmd *mcmd); +static int mpt_handle_task_mgmt(MPT_STM_PRIV * priv, u32 reply_word, + int task_mgmt, int lun); +static int mpt_send_cmd_to_scst(struct mpt_cmd *cmd, int context); + +static struct scst_tgt_template tgt_template = { + .name = MYNAM, + .sg_tablesize = 128, /* FIXME */ + .use_clustering = 1, +#ifdef DEBUG_WORK_IN_THREAD + .xmit_response_atomic = 0, + .rdy_to_xfer_atomic = 0, +#else + .xmit_response_atomic = 1, + .rdy_to_xfer_atomic = 1, +#endif + .detect = mpt_target_detect, + .release = mpt_target_release, + .xmit_response = mpt_xmit_response, + .rdy_to_xfer = mpt_rdy_to_xfer, + .on_free_cmd = mpt_on_free_cmd, + .task_mgmt_fn_done = mpt_task_mgmt_fn_done, + .proc_info = mpt_proc_info, +}; + +static inline void +mpt_msg_frame_free(MPT_STM_PRIV *priv, int index) +{ + MPT_ADAPTER *ioc = priv->ioc; + if (priv->current_mf[index] != NULL) { + TRACE_DBG("%s: free mf index %d, %p", ioc->name, + MF_TO_INDEX(priv->current_mf[index]), + priv->current_mf[index]); + mpt_free_msg_frame(_HANDLE_IOC_ID, priv->current_mf[index]); + priv->current_mf[index] = NULL; + } +} + +static inline MPT_FRAME_HDR * +mpt_msg_frame_alloc(MPT_ADAPTER *ioc, int index) +{ + MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; + MPT_FRAME_HDR *mf; + + if (index != -1) { + TRACE_DBG("%s: current_mf %p, index %d", + ioc->name, priv->current_mf[index], index); + WARN_ON(priv->current_mf[index] != NULL); + } + + mf = mpt_get_msg_frame(stm_context, _IOC_ID); + + if (mf == NULL) { + BUG_ON(1); + } + + if (index != -1) { + priv->current_mf[index] = mf; + } + + TRACE_DBG("%s: alloc mf index %d, %p, %d", ioc->name, + MF_TO_INDEX(mf), mf, index); + + return mf; +} + +static int _mpt_ada_nums = 0; + +static int +mptstm_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + MPT_ADAPTER *ioc = pci_get_drvdata(pdev); + int ret = 0; + struct mpt_tgt *tgt; + + TRACE_ENTRY(); + ret = mpt_stm_adapter_install(ioc); + if (ret != 0) { + goto out; + } + + tgt = kmalloc(sizeof(*tgt), GFP_KERNEL); + TRACE_MEM("kmalloc(GFP_KERNEL) for tgt (%d), %p", + sizeof(*tgt), tgt); + if (tgt == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", + "Allocation of tgt failed"); + ret = -ENOMEM; + goto out; + } + memset(tgt, 0, sizeof(*tgt)); + tgt->priv = mpt_stm_priv[ioc->id]; + tgt->target_enable = 0; + tgt->target_id = 0; + atomic_set(&tgt->sess_count, 0); + init_waitqueue_head(&tgt->waitQ); + + tgt->scst_tgt = scst_register(&tgt_template); + if (tgt->scst_tgt == NULL) { + PRINT_ERROR(MYNAM ": scst_register() " + "failed for host %p", pdev); + + ret = -ENODEV; + goto out; + } + scst_tgt_set_tgt_priv(tgt->scst_tgt, tgt); + mpt_stm_priv[ioc->id]->tgt = tgt; + + _mpt_ada_nums ++; + + out: + + TRACE_EXIT_RES(ret); + + return ret; +} + +static void +mptstm_remove(struct pci_dev *pdev) +{ + MPT_ADAPTER *ioc = pci_get_drvdata(pdev); + MPT_STM_PRIV *priv; + + priv = mpt_stm_priv[ioc->id]; + if (priv != NULL) { + mpt_stm_adapter_dispose(priv); + } +} + +static struct mpt_pci_driver mptstm_driver = { + .probe = mptstm_probe, + .remove = mptstm_remove, +}; + +/* + * mpt_target_detect + * + * this function is intended to detect the target adapters that are present in + * the system. Each found adapter should be registered by calling + * scst_register(). The function should return a value >= 0 to signify + * the number of detected target adapters. A negative value should be + * returned whenever there is an error. + */ +static int mpt_target_detect(struct scst_tgt_template *templ) +{ + int ret = 0; + + TRACE_ENTRY(); + ret = _mpt_stm_init(); + if (ret != 0) { + goto out; + } + + if (mpt_device_driver_register(&mptstm_driver, MPTSTM_DRIVER)) { + printk(KERN_WARNING MYNAM + ": failed to register for device driver callbacks\n"); + ret = -ENODEV; + goto out; + } + + ret = _mpt_ada_nums; + + out: + TRACE_EXIT_RES(ret); + + return ret; +} + +static struct scst_cmd * +_stm_target_command(MPT_STM_PRIV *priv, int reply_word, + struct mpt_cmd *mpt_cmd) +{ + u8 *cdb; + int lun, tag, dl, alias, index, init_index, task_mgmt; + char alias_lun[32]; + CMD *cmd; + struct scst_cmd *scst_cmd; + struct mpt_sess *sess = mpt_cmd->sess; +#ifdef DEBUG + MPT_ADAPTER *ioc = priv->ioc; +#endif + /* + * Get the CBD, LUN, tag, Task Mgmt flags, and data length from the + * receive packet + */ + TRACE_ENTRY(); + + index = GET_IO_INDEX(reply_word); + init_index = GET_INITIATOR_INDEX(reply_word); + + cmd = &priv->hw->cmd_buf[index]; + + if (IsScsi(priv)) { + SCSI_CMD *scsi_cmd = (SCSI_CMD *)cmd->cmd; + + cdb = scsi_cmd->CDB; + lun = get2bytes(scsi_cmd->LogicalUnitNumber, 0); + tag = scsi_cmd->Tag; + task_mgmt = scsi_cmd->TaskManagementFlags; + dl = 0; + /*TRACE_DBG("AliasID %d, %d", scsi_cmd->AliasID, priv->port_id);*/ + if (reply_word & TARGET_MODE_REPLY_ALIAS_MASK) { + alias = (scsi_cmd->AliasID - priv->port_id) & 15; + sprintf(alias_lun, "alias %d lun %d", alias, lun); + } else { + alias = 0; + sprintf(alias_lun, "lun %d", lun); + } + } else if (IsSas(priv)) { + SSP_CMD *ssp_cmd = (SSP_CMD *)cmd->cmd; + + cdb = ssp_cmd->CDB; + lun = get2bytes(ssp_cmd->LogicalUnitNumber, 0); + if (ssp_cmd->FrameType == SSP_TASK_FRAME) { + SSP_TASK *ssp_task = (SSP_TASK *)cmd->cmd; + + tag = ssp_task->ManagedTaskTag; + task_mgmt = ssp_task->TaskManagementFunction; + } else { + tag = ssp_cmd->InitiatorTag; + task_mgmt = 0; + } + dl = 0; + alias = 0; + sprintf(alias_lun, "lun %d", lun); + } else { + FCP_CMD *fcp_cmd = (FCP_CMD *)cmd->cmd; + + cdb = fcp_cmd->FcpCdb; + lun = get2bytes(fcp_cmd->FcpLun, 0); + tag = 0; + task_mgmt = fcp_cmd->FcpCntl[2]; + dl = be32_to_cpu(fcp_cmd->FcpDl); + if (reply_word & TARGET_MODE_REPLY_ALIAS_MASK) { + alias = fcp_cmd->AliasIndex; + sprintf(alias_lun, "alias %d lun %d", alias, lun); + } else { + alias = 0; + sprintf(alias_lun, "lun %d", lun); + } + } + + cmd->reply_word = reply_word; + cmd->alias = alias; + cmd->lun = lun; + cmd->tag = tag; + + TRACE_DBG("%s: cmd %p, re_word %x, alias %x, lun %x, tag %x," + "%s, init_idx %d, %p, %d", + ioc->name, cmd, reply_word, alias, lun, tag, alias_lun, + init_index, priv->scst_cmd[index], dl); + + mpt_cmd->CMD = cmd; + { + uint16_t _lun = lun; + _lun = swab16(le16_to_cpu(_lun)); + scst_cmd = scst_rx_cmd(sess->scst_sess, (uint8_t *)&_lun, + sizeof(_lun), cdb, MPT_MAX_CDB_LEN, SCST_ATOMIC); + } + if (scst_cmd == NULL) { + PRINT_ERROR(MYNAM ": scst_rx_cmd() failed for %p", cmd); + goto out; + } + TRACE_DBG("scst cmd %p, index %d", priv->scst_cmd[index], index); + + WARN_ON(priv->scst_cmd[index] != 0); + priv->scst_cmd[index] = scst_cmd; + + scst_cmd_set_tag(scst_cmd, tag); + scst_cmd_set_tgt_priv(scst_cmd, mpt_cmd); + + /* FIXME scst_cmd_set_expected */ +out: + TRACE_EXIT(); + + return scst_cmd; +} + +static void +mpt_send_busy(struct mpt_cmd *cmd) +{ + stmapp_set_status(cmd->priv, cmd->CMD, STS_BUSY); +} + +static void +mpt_alloc_session_done(struct scst_session *scst_sess, void *data, int result) +{ + struct mpt_sess *sess = (struct mpt_sess *) data; + struct mpt_tgt *tgt = sess->tgt; + struct mpt_cmd *cmd = NULL; + int rc = 0; + + TRACE_ENTRY(); + if (result == 0) { + scst_sess_set_tgt_priv(scst_sess, sess); + + while (!list_empty(&sess->delayed_cmds)) { + cmd = list_entry(sess->delayed_cmds.next, + typeof(*cmd), delayed_cmds_entry); + list_del(&cmd->delayed_cmds_entry); + if (rc == 0) + rc = mpt_send_cmd_to_scst(cmd, SCST_CONTEXT_THREAD); + if (rc != 0) { + PRINT_INFO(MYNAM ": Unable to get the command, sending BUSY state %p", + cmd); + mpt_send_busy(cmd); + kfree(cmd); + } + } + } else { + PRINT_INFO(MYNAM ": Session initialization failed, " + "sending BUSY status to all deferred commands %p", + cmd); + while (!list_empty(&sess->delayed_cmds)) { + cmd = list_entry(sess->delayed_cmds.next, + typeof(*cmd), delayed_cmds_entry); + list_del(&cmd->delayed_cmds_entry); + TRACE(TRACE_MGMT, "Command <%p> Busy", cmd); + mpt_send_busy(cmd); + kfree(cmd); + } + tgt->sess[sess->init_index] = NULL; + + TRACE_MEM("kfree for sess %p", sess); + kfree(sess); + + if (atomic_dec_and_test(&tgt->sess_count)) + wake_up_all(&tgt->waitQ); + } + + __clear_bit(MPT_SESS_INITING, &sess->sess_flags); + + TRACE_EXIT(); + return; +} + +static int +mpt_send_cmd_to_scst(struct mpt_cmd *cmd, int context) +{ + int res = 0; + + TRACE_ENTRY(); + + cmd->scst_cmd = _stm_target_command(cmd->priv, cmd->reply_word, cmd); + if (cmd->scst_cmd == NULL) { + res = -EFAULT; + goto out; + } +#ifdef DEBUG_WORK_IN_THREAD + context = SCST_CONTEXT_THREAD; +#endif + scst_cmd_init_done(cmd->scst_cmd, context); + + out: + TRACE_EXIT_RES(res); + + return res; +} + +static void +stm_send_target_status_deferred(MPT_STM_PRIV *priv, + u32 reply_word, int index) +{ + int ret = 0; + MPT_ADAPTER *ioc = priv->ioc; + MPT_FRAME_HDR *mf; + TargetStatusSendRequest_t *req; + + TRACE_ENTRY(); + mf = priv->status_deferred_mf[index]; + TRACE_DBG("mf %p, index %d", mf, index); + req = (TargetStatusSendRequest_t *)mf; + + priv->io_state[index] |= IO_STATE_STATUS_SENT; + + priv->current_mf[index] = mf; + priv->status_deferred_mf[index] = NULL; + if (priv->io_state[index] & IO_STATE_HIGH_PRIORITY) { + ret = mpt_send_handshake_request(stm_context, _IOC_ID, + sizeof(*req), (u32 *)req _HS_SLEEP); + } else { + mpt_put_msg_frame(stm_context, _IOC_ID, mf); + } + + TRACE_EXIT_RES(ret); +} + +static void +stm_data_done(MPT_ADAPTER *ioc, u32 reply_word, + struct scst_cmd *scst_cmd, struct mpt_cmd *cmd, int index) +{ + MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; + uint8_t *buf = NULL; + + TRACE_ENTRY(); + TRACE_DBG("scst cmd %p, index %d, data done", scst_cmd, index); + + if (scst_cmd_get_resp_data_len(scst_cmd) > 0) { + TRACE_DBG("clear the data flags <%p>", scst_cmd); + if (scst_cmd_get_sg_cnt(scst_cmd)) { + pci_unmap_sg(priv->ioc->pcidev, + scst_cmd_get_sg(scst_cmd), + scst_cmd_get_sg_cnt(scst_cmd), + scst_to_dma_dir(scst_cmd_get_data_direction(scst_cmd))); + } else { + pci_unmap_single(priv->ioc->pcidev, cmd->dma_handle, + scst_get_buf_first(scst_cmd, &buf), + scst_to_dma_dir(scst_cmd_get_data_direction(scst_cmd))); + } + } + TRACE_EXIT(); +} + +void +stm_tgt_reply(MPT_ADAPTER *ioc, u32 reply_word) +{ + MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; + int index; + struct scst_cmd *scst_cmd; + struct mpt_cmd *cmd; + volatile int *io_state; + + TRACE_ENTRY(); + + index = GET_IO_INDEX(reply_word); + scst_cmd = priv->scst_cmd[index]; + io_state = priv->io_state + index; + + TRACE_DBG("index %d, state %x, scst cmd %p, current_mf %p", + index, *io_state, scst_cmd, priv->current_mf[index]); + /* + * if scst_cmd is NULL it show the command buffer not using by + * SCST, let parse the CDB + */ + if (scst_cmd == NULL) { + WARN_ON((*io_state & ~IO_STATE_HIGH_PRIORITY) != IO_STATE_POSTED); + *io_state &= ~IO_STATE_POSTED; + + mpt_msg_frame_free(priv, index); + + stmapp_tgt_command(priv, reply_word); + goto out; + } + + cmd = (struct mpt_cmd *)scst_cmd_get_tgt_priv(scst_cmd); + TRACE_DBG("scst cmd %p, index %d, cmd %p, cmd state %s", + scst_cmd, index, cmd, mpt_state_string[cmd->state]); + + if (cmd->state == MPT_STATE_NEED_DATA) { + int context = SCST_CONTEXT_TASKLET; + int rx_status = SCST_RX_STATUS_SUCCESS; + + cmd->state = MPT_STATE_DATA_IN; + +#ifdef DEBUG_WORK_IN_THREAD + context = SCST_CONTEXT_THREAD; +#endif + TRACE_DBG("Data received, context %x, rx_status %d", + context, rx_status); + + BUG_ON(!(*io_state & IO_STATE_DATA_SENT)); + mpt_msg_frame_free(priv, index); + if (*io_state & IO_STATE_DATA_SENT) { + *io_state &= ~IO_STATE_DATA_SENT; + stm_data_done(ioc, reply_word, scst_cmd, cmd, index); + } +#if 0 + if ((*io_state & ~IO_STATE_HIGH_PRIORITY) == IO_STATE_AUTO_REPOST) { + TRACE_DBG("%s", "io state auto repost"); + *io_state = IO_STATE_POSTED; + } else if ((*io_state & ~IO_STATE_HIGH_PRIORITY) == 0) { + TRACE_DBG("%s", "io state"); + stm_cmd_buf_post(priv, index); + } +#endif + scst_rx_data(scst_cmd, rx_status, context); + + goto out; + } + + if (*io_state & IO_STATE_STATUS_SENT) { + /* + * status (and maybe data too) was being sent, so repost the + * command buffer + */ + *io_state &= ~IO_STATE_STATUS_SENT; + mpt_msg_frame_free(priv, index); + if (*io_state & IO_STATE_DATA_SENT) { + *io_state &= ~IO_STATE_DATA_SENT; + stm_data_done(ioc, reply_word, scst_cmd, cmd, index); + } + if ((*io_state & ~IO_STATE_HIGH_PRIORITY) == IO_STATE_AUTO_REPOST) { + TRACE_DBG("%s", "io state auto repost"); + *io_state = IO_STATE_POSTED; + } else if ((*io_state & ~IO_STATE_HIGH_PRIORITY) == 0) { + TRACE_DBG("%s", "io state"); + stm_cmd_buf_post(priv, index); + } + + scst_tgt_cmd_done(scst_cmd); + + goto out; + } + + /* + * data (but not status) was being sent, so if status needs to be + * set now, go ahead and do it; otherwise do nothing + */ + if (*io_state & IO_STATE_DATA_SENT) { + *io_state &= ~IO_STATE_DATA_SENT; + mpt_msg_frame_free(priv, index); + stm_data_done(ioc, reply_word, scst_cmd, cmd, index); + if (*io_state & IO_STATE_STATUS_DEFERRED) { + *io_state &= ~IO_STATE_STATUS_DEFERRED; + stm_send_target_status_deferred(priv, reply_word, index); + } + cmd->state = MPT_STATE_PROCESSED; + goto out; + } + + /* + * just insert into list + * bug how can i handle it + */ + if (*io_state == 0 && cmd->state == MPT_STATE_NEW) { + WARN_ON(1); + goto out; + } +#if 0 + if (*io_state == IO_STATE_POSTED) { + TRACE_DBG("%s", "io state posted"); + /* + * command buffer was posted, so we now have a SCSI command + */ + *io_state &= ~IO_STATE_POSTED; + goto out; + } +#endif + WARN_ON(1); + out: + + TRACE_EXIT(); +} + +static int +mpt_is_task_mgm(MPT_STM_PRIV *priv, u32 reply_word, int *lun) +{ + int task_mgmt = 0, index; + CMD *cmd; + //struct mpt_tgt *tgt = priv->tgt; + + TRACE_ENTRY(); + + index = GET_IO_INDEX(reply_word); + cmd = &priv->hw->cmd_buf[index]; + + if (IsScsi(priv)) { + SCSI_CMD *scsi_cmd = (SCSI_CMD *)cmd->cmd; + task_mgmt = scsi_cmd->TaskManagementFlags; + *lun = get2bytes(scsi_cmd->LogicalUnitNumber, 0); + } else if (IsSas(priv)) { + SSP_CMD *ssp_cmd = (SSP_CMD *)cmd->cmd; + if (ssp_cmd->FrameType == SSP_TASK_FRAME) { + SSP_TASK *ssp_task = (SSP_TASK *)cmd->cmd; + task_mgmt = ssp_task->TaskManagementFunction; + } + *lun = get2bytes(ssp_cmd->LogicalUnitNumber, 0); + } else { + FCP_CMD *fcp_cmd = (FCP_CMD *)cmd->cmd; + task_mgmt = fcp_cmd->FcpCntl[2]; + *lun = get2bytes(fcp_cmd->FcpLun, 0); + } + TRACE_EXIT_RES(task_mgmt); + + return task_mgmt; +} + +static void +stmapp_tgt_command(MPT_STM_PRIV *priv, u32 reply_word) +{ + struct mpt_tgt *tgt = NULL; + struct mpt_sess *sess = NULL; + struct mpt_cmd *cmd = NULL; + int init_index, res = 0, task_mgmt, lun; + + TRACE_ENTRY(); + + tgt = priv->tgt; + + task_mgmt = mpt_is_task_mgm(priv, reply_word, &lun); + if (task_mgmt) { + mpt_handle_task_mgmt(priv, reply_word, task_mgmt, lun); + } + + init_index = GET_INITIATOR_INDEX(reply_word); + + if (test_bit(MPT_TGT_SHUTDOWN, &tgt->tgt_flags)) { + TRACE_DBG("New command while the device %p is shutting down", tgt); + res = -EFAULT; + goto out; + } + + cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC); + TRACE_MEM("kmalloc(GFP_ATOMIC) for cmd (%d): %p", sizeof(*cmd), cmd); + if (cmd == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of cmd failed"); + res = -ENOMEM; + goto out; + } + + memset(cmd, 0, sizeof(*cmd)); + cmd->priv = priv; + cmd->reply_word = reply_word; + cmd->state = MPT_STATE_NEW; + + sess = tgt->sess[init_index]; + if (sess == NULL) { + sess = kmalloc(sizeof(*sess), GFP_ATOMIC); + if (sess == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", + "Allocation of sess failed"); + res = -ENOMEM; + goto out_free_cmd; + } + /* WWPN */ + + atomic_inc(&tgt->sess_count); + smp_mb__after_atomic_inc(); + + memset(sess, 0, sizeof(*sess)); + sess->tgt = tgt; + sess->init_index = init_index; + INIT_LIST_HEAD(&sess->delayed_cmds); + + sess->scst_sess = scst_register_session(tgt->scst_tgt, 1, + "", sess, mpt_alloc_session_done); + if (sess->scst_sess == NULL) { + PRINT_ERROR(MYNAM ": scst_register_session failed %p", + tgt); + res = -EFAULT; + goto out_free_sess; + } + + __set_bit(MPT_SESS_INITING, &sess->sess_flags); + + tgt->sess[init_index] = sess; + scst_sess_set_tgt_priv(sess->scst_sess, sess); + + cmd->sess = sess; + list_add_tail(&cmd->delayed_cmds_entry, &sess->delayed_cmds); + goto out; + } + + /* seesion is ready let us do it */ + cmd->sess = sess; + if (test_bit(MPT_SESS_INITING, &sess->sess_flags)) { + list_add_tail(&cmd->delayed_cmds_entry, &sess->delayed_cmds); + } else { + res = mpt_send_cmd_to_scst(cmd, SCST_CONTEXT_TASKLET); + /*res = mpt_send_cmd_to_scst(cmd, SCST_CONTEXT_DIRECT_ATOMIC);*/ + if (res != 0) + goto out_free_cmd; + } + + out: + TRACE_EXIT(); + return; + + out_free_sess: + TRACE_MEM("kfree for sess %p", sess); + kfree(sess); + + if (atomic_dec_and_test(&tgt->sess_count)) + wake_up_all(&tgt->waitQ); + /* go through */ + out_free_cmd: + TRACE_MEM("kfree for cmd %p", cmd); + kfree(cmd); + goto out; +} + +/* + * mpt_target_release + * + * this function is + * intended to free up the resources allocated to the device. The function + * should return 0 to indicate successful release or a negative value if + * there are some issues with the release. In the current version of SCST + * the return value is ignored. Must be defined. + */ +static int mpt_target_release(struct scst_tgt *scst_tgt) +{ + /* FIXME */ + return 0; +} + +struct mpt_prm +{ + struct mpt_tgt *tgt; + uint16_t seg_cnt; + unsigned short use_sg; + struct scatterlist *sg; + unsigned int bufflen; + void *buffer; + scst_data_direction data_direction; + uint16_t rq_result; + uint16_t scsi_status; + unsigned char *sense_buffer; + unsigned int sense_buffer_len; + struct mpt_cmd *cmd; +}; + +static inline void +mpt_dump_sge(MPT_SGE *sge, struct scatterlist *sg) +{ + if (sge) { + void *address = NULL; + struct page *page = NULL; + address = bus_to_virt(sge->address); + page = virt_to_page(address); + TRACE_DBG("address %p, length %x, count %d, page %p", + address, sge->length, page_count(page), page); + TRACE_BUFFER("sge data", address, min(sge->length, (u32)0x10)); + } + if (sg) { + TRACE_DBG("sg %p, page %p, %p, offset %d, dma address %x, len %d", + sg, sg->page, page_address(sg->page), + sg->offset, sg->dma_address, sg->length); + TRACE_BUFFER("sg data", page_address(sg->page), (u32)0x10); + } +} + +/* FIXME + * + * use_sg can not bigger then NUM_SGES + * + */ +static inline void +mpt_sge_to_sgl(struct mpt_prm *prm, MPT_STM_PRIV *priv, MPT_SGL *sgl) +{ + unsigned int bufflen = prm->bufflen; + TRACE_ENTRY(); + TRACE_DBG("bufflen %d, %p", bufflen, prm->buffer); + if (prm->use_sg) { + int i; + prm->sg = (struct scatterlist *)prm->buffer; + prm->seg_cnt = + pci_map_sg(priv->ioc->pcidev, prm->sg, prm->use_sg, + scst_to_dma_dir(prm->data_direction)); + + pci_dma_sync_sg_for_cpu(priv->ioc->pcidev, prm->sg, + prm->use_sg, + scst_to_dma_dir(prm->data_direction)); + for (i = 0; i < prm->use_sg; i++) { + sgl->sge[i].length = sg_dma_len(&prm->sg[i]); + sgl->sge[i].address = sg_dma_address(&prm->sg[i]); + + TRACE_DBG("%d, %d", bufflen, prm->sg[i].length); + if (bufflen < prm->sg[i].length) { + sgl->sge[i].length = bufflen; + } + mpt_dump_sge(&sgl->sge[i], &prm->sg[i]); + bufflen -= sgl->sge[i].length; + } + pci_dma_sync_sg_for_device(priv->ioc->pcidev, prm->sg, + prm->use_sg, + scst_to_dma_dir(prm->data_direction)); + } else { + prm->cmd->dma_handle = + pci_map_single(priv->ioc->pcidev, prm->buffer, + prm->bufflen, + scst_to_dma_dir(prm->data_direction)); + + pci_dma_sync_single_for_cpu(priv->ioc->pcidev, prm->cmd->dma_handle, prm->bufflen, scst_to_dma_dir(prm->data_direction)); + sgl->sge[0].length = prm->bufflen; + sgl->sge[0].address = virt_to_phys(prm->buffer); + + mpt_dump_sge(&sgl->sge[0], NULL); + pci_dma_sync_single_for_device(priv->ioc->pcidev, prm->cmd->dma_handle, prm->bufflen, scst_to_dma_dir(prm->data_direction)); + + prm->seg_cnt = 1; + } + + sgl->num_sges = prm->seg_cnt; + + TRACE_EXIT(); +} + +static inline void +mpt_set_sense_info(MPT_STM_PRIV *priv, CMD *cmd, int len, u8 *sense_buf) +{ + u8 *info = NULL; + + TRACE_ENTRY(); + + if (IsScsi(priv)) { + SCSI_RSP *rsp = (SCSI_RSP *)cmd->rsp; + + rsp->Status = STS_CHECK_CONDITION; + rsp->Valid |= SCSI_SENSE_LEN_VALID; + rsp->SenseDataListLength = cpu_to_be32(len); + info = rsp->SenseData; + if (rsp->Valid & SCSI_RSP_LEN_VALID) { + info += be32_to_cpu(rsp->PktFailuresListLength); + } + } else if (IsSas(priv)) { + SSP_RSP *rsp = (SSP_RSP *)cmd->rsp; + + rsp->Status = STS_CHECK_CONDITION; + rsp->DataPres |= SSP_SENSE_LEN_VALID; + rsp->SenseDataLength = cpu_to_be32(len); + info = rsp->ResponseSenseData; + if (rsp->DataPres & SSP_RSP_LEN_VALID) { + info += be32_to_cpu(rsp->ResponseDataLength); + } + } else { + FCP_RSP *rsp = (FCP_RSP *)cmd->rsp; + + rsp->FcpStatus = STS_CHECK_CONDITION; + rsp->FcpFlags |= FCP_SENSE_LEN_VALID; + rsp->FcpSenseLength = cpu_to_be32(len); + info = rsp->FcpSenseData - sizeof(rsp->FcpResponseData); + if (rsp->FcpFlags & FCP_RSP_LEN_VALID) { + info += be32_to_cpu(rsp->FcpResponseLength); + } + } + + BUG_ON(info == NULL); + memcpy(info, sense_buf, len); +/*out:*/ + + TRACE_EXIT(); +} + +static int +mpt_send_tgt_data(MPT_STM_PRIV *priv, u32 reply_word, + int index, int flags, int lun, int tag, MPT_SGL *sgl, + int length, int offset) +{ + MPT_ADAPTER *ioc = priv->ioc; + TargetAssistRequest_t *req; + MPT_STM_SIMPLE *sge_simple; + MPT_STM_CHAIN *sge_chain = NULL; + u32 sge_flags; + int chain_length, i, j, k, init_index, res = 1; + dma_addr_t dma_addr; + + TRACE_ENTRY(); + req = (TargetAssistRequest_t *)mpt_msg_frame_alloc(ioc,index); + memset(req, 0, sizeof(*req)); + + if (priv->exiting) { + flags &= ~TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER; + } + + if (priv->io_state[index] & IO_STATE_HIGH_PRIORITY) { + flags |= TARGET_ASSIST_FLAGS_HIGH_PRIORITY; + if (flags & TARGET_ASSIST_FLAGS_AUTO_STATUS) { + flags |= TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER; + priv->io_state[index] |= IO_STATE_AUTO_REPOST; + } + } + + if (priv->fcp2_capable/* && priv->initiators != NULL*/) { + init_index = GET_INITIATOR_INDEX(reply_word); + /*init = priv->initiators[init_index]; + if (init != NULL && init->confirm_capable) { + flags |= TARGET_ASSIST_FLAGS_CONFIRMED; + }*/ + } + TRACE_DBG("flags %x, tag %x, lun %x, offset %x, length %x", + flags, tag, lun, offset, length); + + req->StatusCode = 0; + req->TargetAssistFlags = (u8)flags; + req->Function = MPI_FUNCTION_TARGET_ASSIST; + req->QueueTag = (u16)tag; + req->ReplyWord = cpu_to_le32(reply_word); + req->LUN[0] = (u8)(lun >> 8); + req->LUN[1] = (u8)lun; + req->RelativeOffset = cpu_to_le32(offset); + req->DataLength = cpu_to_le32(length); + sge_flags = + MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_SIMPLE_ELEMENT | + MPI_SGE_FLAGS_MPT_STM_ADDRESSING); + if (flags & TARGET_ASSIST_FLAGS_DATA_DIRECTION) + sge_flags |= MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_HOST_TO_IOC); + sge_simple = (MPT_STM_SIMPLE *)&req->SGL; + for (i = 0, j = 0, k = 0; i < (int)sgl->num_sges; i++, j++) { + if (k == 0) { + /* still in mf, haven't chained yet -- do we need to? */ + if (j == priv->num_sge_target_assist) { + /* yes, we need to chain */ + /* overwrite the last element in the mf with a chain */ + sge_chain = (MPT_STM_CHAIN *)(sge_simple - 1); + sge_chain->Flags = + (u8)(MPI_SGE_FLAGS_CHAIN_ELEMENT | + MPI_SGE_FLAGS_MPT_STM_ADDRESSING); + dma_addr = priv->hw_dma + + ((u8 *)priv->hw->cmd_buf[index].chain_sge - + (u8 *)priv->hw); + stm_set_dma_addr(sge_chain->Address, dma_addr); + /* set the "last element" flag in the mf */ + sge_simple = (MPT_STM_SIMPLE *)(sge_chain - 1); + sge_simple->FlagsLength |= + cpu_to_le32(MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_LAST_ELEMENT)); + /* redo the last element in the mf */ + sge_simple = + (MPT_STM_SIMPLE *)priv->hw->cmd_buf[index].chain_sge; + sge_simple->FlagsLength = + cpu_to_le32(sgl->sge[i-1].length | sge_flags); + stm_set_dma_addr(sge_simple->Address, sgl->sge[i-1].address); + mpt_dump_sge(&sgl->sge[i-1], NULL); + sge_simple++; + /* say we've chained */ + req->ChainOffset = + ((u8 *)sge_chain - (u8 *)req) / sizeof(u32); + j = 1; + k++; + } + } else { + /* now in chain, do we need to chain again? */ + if (j == priv->num_sge_chain) { + /* yes, we need to chain */ + /* fix up the previous chain element */ + chain_length = sizeof(MPT_STM_CHAIN) + + (priv->num_sge_chain - 1) * sizeof(MPT_STM_SIMPLE); + sge_chain->Length = cpu_to_le16(chain_length); + sge_chain->NextChainOffset = + (chain_length - sizeof(MPT_STM_CHAIN)) / sizeof(u32); + /* overwrite the last element in the chain with another chain */ + sge_chain = (MPT_STM_CHAIN *)(sge_simple - 1); + sge_chain->Flags = + (u8)(MPI_SGE_FLAGS_CHAIN_ELEMENT | + MPI_SGE_FLAGS_MPT_STM_ADDRESSING); + dma_addr = priv->hw_dma + ((u8 *)sge_simple - (u8 *)priv->hw); + stm_set_dma_addr(sge_chain->Address, dma_addr); + /* set the "last element" flag in the previous chain */ + sge_simple = (MPT_STM_SIMPLE *)(sge_chain - 1); + sge_simple->FlagsLength |= + cpu_to_le32(MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_LAST_ELEMENT)); + /* redo the last element in the previous chain */ + sge_simple = (MPT_STM_SIMPLE *)(sge_chain + 1); + sge_simple->FlagsLength = + cpu_to_le32(sgl->sge[i-1].length | sge_flags); + stm_set_dma_addr(sge_simple->Address, sgl->sge[i-1].address); + mpt_dump_sge(&sgl->sge[i-1], NULL); + sge_simple++; + /* say we've chained */ + j = 1; + k++; + } + } + sge_simple->FlagsLength = cpu_to_le32(sgl->sge[i].length | sge_flags); + stm_set_dma_addr(sge_simple->Address, sgl->sge[i].address); + mpt_dump_sge(&sgl->sge[i], NULL); + sge_simple++; + } + /* did we chain? */ + if (k != 0) { + /* fix up the last chain element */ + sge_chain->Length = cpu_to_le16(j * sizeof(MPT_STM_SIMPLE)); + sge_chain->NextChainOffset = 0; + } + /* fix up the last element */ + sge_simple--; + sge_simple->FlagsLength |= + cpu_to_le32(MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_LAST_ELEMENT | + MPI_SGE_FLAGS_END_OF_BUFFER | + MPI_SGE_FLAGS_END_OF_LIST)); +#ifdef TRACING +if(trace_mpi) +{ + u32 *p = (u32 *)req; + int i; + //dma_addr_t _data; + //u8 *_buf; + + TRACE(TRACE_MPI, "%s stm_send_target_data %d", + ioc->name, index); + for (i = 0; i < (sizeof(*req) - sizeof(req->SGL)) / 4; i++) { + TRACE(TRACE_MPI, "%s req[%02x] = %08x", + ioc->name, i * 4, le32_to_cpu(p[i])); + } + TRACE(TRACE_MPI, "%s num_sges = %d, j = %d, k = %d", + ioc->name, sgl->num_sges, j, k); + p = (u32 *)&req->SGL; + for (i = 0; i < ((k != 0) ? priv->num_sge_target_assist : j); i++) { +#if MPT_STM_64_BIT_DMA + TRACE(TRACE_MPI, "%s req sgl[%04x] = %08x %08x %08x", + ioc->name, i * 12, le32_to_cpu(p[i*3]), + le32_to_cpu(p[i*3+1]), le32_to_cpu(p[i*3+2])); +#else + _data = le32_to_cpu(p[i*2+1]); + _buf = (u8 *)phys_to_virt(_data); + TRACE(TRACE_MPI, "%s req sgl[%04x] = %08x %08x,%x,%x,%x,%x,%p", + ioc->name, i * 8, le32_to_cpu(p[i*2]), le32_to_cpu(p[i*2+1]), + _buf[0], _buf[1], _buf[2], _buf[3], _buf); +#endif + } + p = (u32 *)priv->hw->cmd_buf[index].chain_sge; + for (i = 0; i < ((k != 0) ? (k - 1) * priv->num_sge_chain + j : 0); i++) { +#if MPT_STM_64_BIT_DMA + TRACE(TRACE_MPI, "%s chain sgl[%04x] = %08x %08x %08x", + ioc->name, i * 12, le32_to_cpu(p[i*3]), + le32_to_cpu(p[i*3+1]), le32_to_cpu(p[i*3+2])); +#else + _data = le32_to_cpu(p[i*2+1]); + _buf = (u8 *)phys_to_virt(_data); + TRACE(TRACE_MPI, "%s req sgl[%04x] = %08x %08x,%x,%x,%x,%x,%p", + ioc->name, i * 8, le32_to_cpu(p[i*2]), le32_to_cpu(p[i*2+1]), + _buf[0], _buf[1], _buf[2], _buf[3], _buf); +#endif + } + } +#endif + res = 0; + + priv->io_state[index] |= IO_STATE_DATA_SENT; + if (flags & TARGET_ASSIST_FLAGS_AUTO_STATUS) + priv->io_state[index] |= IO_STATE_STATUS_SENT; + + + if (priv->io_state[index] & IO_STATE_HIGH_PRIORITY) { + res =mpt_send_handshake_request(stm_context, _IOC_ID, + ioc->req_sz, (u32 *)req _HS_SLEEP); + } else { + mpt_put_msg_frame(stm_context, _IOC_ID, (MPT_FRAME_HDR *)req); + } + + TRACE_EXIT_RES(res); + + return res; +} + +/* + * calling mpt_send_target_data + * + */ +static void +mpt_send_target_data(struct mpt_prm *prm, int flags) +{ + MPT_STM_PRIV *priv; + u32 reply_word; + int index, lun, tag, length, offset; + MPT_SGL *sgl; + + TRACE_ENTRY(); + priv = prm->tgt->priv; + sgl = &priv->sgl; + + mpt_sge_to_sgl(prm, priv, sgl); + + reply_word = prm->cmd->CMD->reply_word; + index = GET_IO_INDEX(reply_word); + + lun = prm->cmd->CMD->lun; + tag = prm->cmd->CMD->tag; + + if (prm->data_direction == SCST_DATA_READ) { + flags |= TARGET_ASSIST_FLAGS_DATA_DIRECTION; + } + + length = prm->bufflen; + offset = 0; +#if 0 + TRACE_DBG("priv %p, reply_word %x, index %x, flags %x, lun %x, " + "tag %x, sgl %p, length %x, offset %x", + priv, reply_word, index, flags, lun, tag, + sgl, length, offset); +#endif + mpt_send_tgt_data(priv, reply_word, index, flags, lun, tag, + sgl, length, offset); + + TRACE_EXIT(); + return; +} + +/* + * this function is equivalent to the SCSI queuecommand(). The target should + * transmit the response data and the status in the struct scst_cmd. See + * below for details. Must be defined. + */ +static int +mpt_xmit_response(struct scst_cmd *scst_cmd) +{ + int res = SCST_TGT_RES_SUCCESS; + struct mpt_sess *sess; + struct mpt_prm prm = { 0 }; + int resp_flags; + //uint16_t full_req_cnt; + //int data_sense_flag = 0; + + TRACE_ENTRY(); + prm.cmd = (struct mpt_cmd *)scst_cmd_get_tgt_priv(scst_cmd); + sess = (struct mpt_sess *) + scst_sess_get_tgt_priv(scst_cmd_get_session(scst_cmd)); + + prm.sg = NULL; + prm.bufflen = scst_cmd_get_resp_data_len(scst_cmd); + prm.buffer = scst_cmd->sg; + prm.use_sg = scst_cmd->sg_cnt; + prm.data_direction = scst_cmd_get_data_direction(scst_cmd); + prm.rq_result = scst_cmd_get_status(scst_cmd); + prm.sense_buffer = scst_cmd_get_sense_buffer(scst_cmd); + prm.sense_buffer_len = scst_cmd_get_sense_buffer_len(scst_cmd); + prm.tgt = sess->tgt; + prm.seg_cnt = 0; + resp_flags = scst_cmd_get_tgt_resp_flags(scst_cmd); + + /* FIXME */ + prm.sense_buffer_len = 14; + + TRACE_DBG("rq_result=%x, resp_flags=%x, %x, %d", prm.rq_result, + resp_flags, prm.bufflen, prm.sense_buffer_len); + if (prm.rq_result != 0) + TRACE_BUFFER("Sense", prm.sense_buffer, prm.sense_buffer_len); + + if ((resp_flags & SCST_TSC_FLAG_STATUS) == 0) { + /* ToDo, after it's done in SCST */ + PRINT_ERROR(MYNAM ": SCST_TSC_FLAG_STATUS not set: " + "feature not implemented %p", scst_cmd); + res = SCST_TGT_RES_FATAL_ERROR; + goto out_tgt_free; + } + + if (test_bit(MPT_SESS_SHUTDOWN, &sess->sess_flags)) { + TRACE_DBG("cmd %p while session %p is shutting down", + prm.cmd, sess); + res = SCST_TGT_RES_SUCCESS; + goto out_tgt_free; + } + + if (SCST_SENSE_VALID(prm.sense_buffer)) { + mpt_set_sense_info(prm.tgt->priv, prm.cmd->CMD, + prm.sense_buffer_len, prm.sense_buffer); + } + + if (scst_cmd_get_resp_data_len(scst_cmd) > 0) { + int flags = 0; + if (prm.rq_result == 0) { + flags |= TARGET_ASSIST_FLAGS_AUTO_STATUS; + } + if (scst_get_may_need_dma_sync(scst_cmd)) { + dma_sync_sg(&(prm.tgt->priv->ioc->pcidev->dev), + scst_cmd->sg, scst_cmd->sg_cnt, + scst_to_tgt_dma_dir(scst_cmd_get_data_direction(scst_cmd))); + } + mpt_send_target_data(&prm, flags); + + if (prm.rq_result == 0) { + goto out; + } + } + { + int flags = 0; + u32 reply_word = prm.cmd->CMD->reply_word; + int index = GET_IO_INDEX(reply_word); + int lun = prm.cmd->CMD->lun; + int tag = prm.cmd->CMD->tag; + MPT_STM_PRIV *priv = prm.tgt->priv; + + if (prm.rq_result == 0) { + flags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS; + } + + flags |= TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER; + priv->io_state[index] |= IO_STATE_AUTO_REPOST; + + TRACE_DBG("scst cmd %p, index %d, flags %d", + scst_cmd, index, flags); + + stm_send_target_status(priv, reply_word, index, + flags, lun, tag); + } + + out: + TRACE_EXIT_RES(res); + + return res; + + out_tgt_free: + scst_tgt_cmd_done(scst_cmd); + goto out; +} + +/* + * this function + * informs the driver that data buffer corresponding to the said command + * have now been allocated and it is OK to receive data for this command. + * This function is necessary because a SCSI target does not have any + * control over the commands it receives. Most lower-level protocols have a + * corresponding function which informs the initiator that buffers have + * been allocated e.g., XFER_RDY in Fibre Channel. After the data is + * actually received the low-level driver should call scst_rx_data() + * in order to continue processing this command. Returns one of the + * SCST_TGT_RES_* constants, described below. Pay attention to + * "atomic" attribute of the command, which can be get via + * scst_cmd_get_atomic(): it is true if the function called in the + * atomic (non-sleeping) context. Must be defined. + */ +static int mpt_rdy_to_xfer(struct scst_cmd *scst_cmd) +{ + int res = SCST_TGT_RES_SUCCESS; + struct mpt_sess *sess; + /*unsigned long flags = 0;*/ + struct mpt_prm prm = { 0 }; + + TRACE_ENTRY(); + prm.cmd = (struct mpt_cmd *)scst_cmd_get_tgt_priv(scst_cmd); + sess = (struct mpt_sess *) + scst_sess_get_tgt_priv(scst_cmd_get_session(scst_cmd)); + + prm.sg = (struct scatterlist *)NULL; + prm.bufflen = scst_cmd->bufflen; + prm.buffer = scst_cmd->sg; + prm.use_sg = scst_cmd->sg_cnt; + prm.data_direction = scst_cmd_get_data_direction(scst_cmd); + prm.tgt = sess->tgt; + + if (test_bit(MPT_SESS_SHUTDOWN, &sess->sess_flags)) { + TRACE_DBG("cmd %p while session %p is shutting down", + prm.cmd, sess); + scst_rx_data(scst_cmd, SCST_RX_STATUS_ERROR_FATAL, + SCST_CONTEXT_THREAD); + res = SCST_TGT_RES_SUCCESS; + goto out; + } + + prm.cmd->state = MPT_STATE_NEED_DATA; + + mpt_send_target_data(&prm, 0); + + out: + TRACE_EXIT_RES(res); + + return res; +} + +/* + * this function + * called to notify the driver that the command is about to be freed. + * Necessary, because for aborted commands <bf/xmit_response()/ could not be + * called. Could be used on IRQ context. Must be defined. + */ +static void mpt_on_free_cmd(struct scst_cmd *scst_cmd) +{ + struct mpt_cmd *cmd = + (struct mpt_cmd *)scst_cmd_get_tgt_priv(scst_cmd); + MPT_STM_PRIV *priv = cmd->priv; + int index = GET_IO_INDEX(cmd->reply_word); + //MPT_ADAPTER *ioc = priv->ioc; + + TRACE_ENTRY(); + + TRACE_DBG("scst_cmd is %p, cmd %p, %p", + priv->scst_cmd[index], cmd, scst_cmd); + WARN_ON(priv->scst_cmd[index] != scst_cmd); + priv->scst_cmd[index] = NULL; + + scst_cmd_set_tgt_priv(scst_cmd, NULL); + +#if 1 + memset(cmd, 0, sizeof(*cmd)); +#endif + kfree(cmd); + + TRACE_EXIT(); +} + +/* + * this function informs the driver that a received task management + * function has been completed. Completion status could be get via + * scst_mgmt_cmd_get_status(). No return value expected. Must be + * defined, if the target supports task management functionality. + */ +static void +mpt_task_mgmt_fn_done(struct scst_mgmt_cmd *mgmt_cmd) +{ + TRACE_ENTRY(); + WARN_ON(1); + TRACE_EXIT(); +} + +static void +mpt_local_task_mgmt(struct mpt_sess *sess, int task_mgmt, int lun) +{ + struct mpt_cmd *cmd, *t; + + TRACE_ENTRY(); + switch (task_mgmt) { + case IMM_NTFY_TARGET_RESET: + while (!list_empty(&sess->delayed_cmds)) { + cmd = list_entry(sess->delayed_cmds.next, + typeof(*cmd), delayed_cmds_entry); + list_del(&cmd->delayed_cmds_entry); + kfree(cmd); + } + break; + + case IMM_NTFY_LUN_RESET1: + case IMM_NTFY_LUN_RESET2: + case IMM_NTFY_CLEAR_TS: + case IMM_NTFY_ABORT_TS: + list_for_each_entry_safe(cmd, t, &sess->delayed_cmds, + delayed_cmds_entry) + { + if (cmd->CMD->lun == lun) { + list_del(&cmd->delayed_cmds_entry); + kfree(cmd); + } + } + break; + + case IMM_NTFY_CLEAR_ACA: + default: + break; + } + TRACE_EXIT(); +} + +static int +mpt_handle_task_mgmt(MPT_STM_PRIV *priv, u32 reply_word, + int task_mgmt, int _lun) +{ + int res = 0, rc = 0; + struct mpt_mgmt_cmd *mcmd; + struct mpt_tgt *tgt; + struct mpt_sess *sess; + int init_index; + uint16_t lun = _lun; + + TRACE_ENTRY(); + + TRACE_DBG("task_mgmt %d", task_mgmt); + tgt = priv->tgt; + init_index = GET_INITIATOR_INDEX(reply_word); + + sess = tgt->sess[init_index]; + if (sess == NULL) { + TRACE(TRACE_MGMT, "mpt_scst(%s): task mgmt fn %p for " + "unexisting session", priv->ioc->name, tgt); + res = -EFAULT; + goto out; + } + + if (test_bit(MPT_SESS_INITING, &sess->sess_flags)) { + TRACE(TRACE_MGMT, "mpt_scst(%s): task mgmt fn %p for " + "inited session", priv->ioc->name, tgt); + mpt_local_task_mgmt(sess, reply_word, task_mgmt); + res = -EFAULT; + goto out; + } + + mcmd = kmalloc(sizeof(*mcmd), GFP_ATOMIC); + TRACE_MEM("kmalloc(GFP_ATOMIC) for mcmd (%d): %p", + sizeof(*mcmd), mcmd); + if (mcmd == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of mgmt cmd failed"); + res = -ENOMEM; + goto out; + } + + memset(mcmd, 0, sizeof(*mcmd)); + mcmd->sess = sess; + mcmd->task_mgmt = task_mgmt; + + switch(task_mgmt) { + case IMM_NTFY_CLEAR_ACA: + TRACE(TRACE_MGMT, "%s", "IMM_NTFY_CLEAR_ACA received"); + rc = scst_rx_mgmt_fn_lun(sess->scst_sess, SCST_CLEAR_ACA, + (uint8_t *)&lun, sizeof(lun), + SCST_ATOMIC, mcmd); + break; + case IMM_NTFY_TARGET_RESET: + TRACE(TRACE_MGMT, "%s", "IMM_NTFY_TARGET_RESET received"); + rc = scst_rx_mgmt_fn_lun(sess->scst_sess, SCST_TARGET_RESET, + (uint8_t *)&lun, sizeof(lun), + SCST_ATOMIC, mcmd); + break; + case IMM_NTFY_LUN_RESET1: + case IMM_NTFY_LUN_RESET2: + TRACE(TRACE_MGMT, "%s", "IMM_NTFY_LUN_RESET received"); + rc = scst_rx_mgmt_fn_lun(sess->scst_sess, SCST_LUN_RESET, + (uint8_t *)&lun, sizeof(lun), + SCST_ATOMIC, mcmd); + break; + case IMM_NTFY_CLEAR_TS: + TRACE(TRACE_MGMT, "%s", "IMM_NTFY_CLEAR_TS received"); + rc = scst_rx_mgmt_fn_lun(sess->scst_sess, SCST_CLEAR_TASK_SET, + (uint8_t *)&lun, sizeof(lun), + SCST_ATOMIC, mcmd); + break; + + case IMM_NTFY_ABORT_TS: + TRACE(TRACE_MGMT, "%s", "IMM_NTFY_ABORT_TS received"); + rc = scst_rx_mgmt_fn_lun(sess->scst_sess, SCST_ABORT_TASK_SET, + (uint8_t *)&lun, sizeof(lun), + SCST_ATOMIC, mcmd); + break; + + default: + PRINT_ERROR("mpt_scst(%s): Unknown task mgmt fn 0x%x", + priv->ioc->name, task_mgmt); + break; + } + if (rc != 0) { + PRINT_ERROR("mpt_scst(%s): scst_rx_mgmt_fn_lun() failed: %d", + priv->ioc->name, rc); + res = -EFAULT; + goto out_free; + } + + out: + TRACE_EXIT_RES(res); + return res; + + out_free: + TRACE_MEM("kmem_cache_free for mcmd %p", mcmd); + kfree(mcmd); + goto out; +} + + + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/* + * called when any target mode reply is received + * if mf_req is null, then this is a turbo reply; otherwise it's not + */ +static int +stm_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf_req, MPT_FRAME_HDR *mf_rep) +{ + MPT_STM_PRIV *priv = mpt_stm_priv[ioc->id]; + MPIDefaultReply_t *rep = (MPIDefaultReply_t *)mf_rep; + int ioc_status; + + TRACE_ENTRY(); + if (mf_req == NULL) { + TRACE_DBG("%s: got turbo reply, reply %x", + ioc->name, CAST_PTR_TO_U32(mf_rep)); + /* + * this is a received SCSI command, so go handle it + */ + stm_tgt_reply(ioc, CAST_PTR_TO_U32(mf_rep)); + return 0; + } + +#if 0 + if (rep->Function == MPI_FUNCTION_EVENT_NOTIFICATION) { + /* + * this is an event notification -- do nothing for now + * (this short-cuts the switch() below and avoids the printk) + */ + return (0); + } +#endif + ioc_status = le16_to_cpu(rep->IOCStatus); + + TRACE_DBG("%s: request %p, reply %p (%02x), %d", + ioc->name, mf_req, mf_rep, rep->Function, ioc_status); + TRACE_DBG("%s: mf index = %d", ioc->name, MF_TO_INDEX(mf_req)); + + if (ioc_status & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) { + TRACE_DBG("%s Function = %02x, IOCStatus = %04x, IOCLogInfo = %08x", + ioc->name, rep->Function, ioc_status, + le32_to_cpu(rep->IOCLogInfo)); + } + + ioc_status &= MPI_IOCSTATUS_MASK; + switch (rep->Function) { + case MPI_FUNCTION_CONFIG: + /* + * this signals that the config is done + */ + priv->config_pending = 0; + memcpy(&priv->config_rep, rep, sizeof(ConfigReply_t)); + /* + * don't free the message frame, since we're remembering it + * in priv->config_mf, and we'll be using it over and over + */ + return (0); + + case MPI_FUNCTION_PORT_ENABLE: + /* + * this signals that the port enable is done + */ + priv->port_enable_loginfo = le32_to_cpu(rep->IOCLogInfo); + priv->port_enable_pending = 0; + return (1); + + case MPI_FUNCTION_TARGET_CMD_BUFFER_POST: + case MPI_FUNCTION_TARGET_CMD_BUF_LIST_POST: + /* + * this is the response to a command buffer post; if status + * is success, then this just acknowledges the posting of a + * command buffer, so do nothing + * + * we can also get here for High Priority I/O (such as getting + * a command while not being allowed to disconnect from the SCSI + * bus), and if we're shutting down + */ + if (ioc_status == MPI_IOCSTATUS_SUCCESS) { + TRACE_EXIT(); + return 1; + } + if (priv->target_mode_abort_pending && + ioc_status == MPI_IOCSTATUS_TARGET_ABORTED) { + TRACE_EXIT(); + return (0); + } + if (ioc_status == MPI_IOCSTATUS_TARGET_PRIORITY_IO) { + stm_tgt_reply_high_pri(ioc, + (TargetCmdBufferPostErrorReply_t *)rep); + TRACE_EXIT(); + return (0); + } + TRACE_DBG(":%s TargetCmdBufPostReq IOCStatus = %04x", + ioc->name, ioc_status); + if (ioc_status == MPI_IOCSTATUS_INSUFFICIENT_RESOURCES) { + /* + * this should never happen since we carefully count + * our resources, but if it does, tolerate it -- don't + * repost the errant command buffer, lest we create an + * endless loop + */ + WARN_ON(1); + return (0); + } + if (ioc_status == MPI_IOCSTATUS_TARGET_NO_CONNECTION) { + printk(KERN_ERR MYNAM + ": %s: Got MPI_IOCSTATUS_TARGET_NO_CONNECTION\n", + ioc->name); + return (0); + } + if (rep->MsgLength > sizeof(*rep)/sizeof(u32)) { + TRACE_DBG("MsgLength is %d, %d", + rep->MsgLength, sizeof(*rep)/sizeof(u32)); + WARN_ON(1); + /* + * the TargetCmdBufferPostErrorReply and TargetErrorReply + * structures are nearly identical; the exception is that + * the former does not have a TransferCount field, while + * the latter does; add one + */ + ((TargetErrorReply_t *)rep)->TransferCount = 0; + stm_target_reply_error(ioc, (TargetErrorReply_t *)rep); + return (0); + } + WARN_ON(1); + ret... [truncated message content] |
From: <vl...@us...> - 2006-12-14 16:22:31
|
Revision: 56 http://svn.sourceforge.net/scst/?rev=56&view=rev Author: vlnb Date: 2006-12-14 08:22:29 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Various changes and fixes Modified Paths: -------------- trunk/mpt/mpt_scst.c trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/qla2x00t/qla2x00-target/qla2x00t.h trunk/scst/include/scsi_tgt.h trunk/scst/include/scst_debug.h trunk/scst/src/dev_handlers/scst_fileio.c trunk/scst/src/scst.c trunk/scst/src/scst_lib.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_mem.h trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/mpt/mpt_scst.c 2006-12-14 16:22:29 UTC (rev 56) @@ -126,8 +126,8 @@ TRACE_DBG("res %d, buffer %p, length %d, %d, priv %p, tgt %p", res, buffer, length, len, priv, tgt); - BUG_ON(tgt == NULL); - BUG_ON(ioc == NULL); + sBUG_ON(tgt == NULL); + sBUG_ON(ioc == NULL); len = snprintf(buffer, length, "ProductID :0x%04x (%s)\n" @@ -318,7 +318,7 @@ mf = mpt_get_msg_frame(stm_context, _IOC_ID); if (mf == NULL) { - BUG_ON(1); + sBUG_ON(1); } if (index != -1) { @@ -725,7 +725,7 @@ TRACE_DBG("Data received, context %x, rx_status %d", context, rx_status); - BUG_ON(!(*io_state & IO_STATE_DATA_SENT)); + sBUG_ON(!(*io_state & IO_STATE_DATA_SENT)); mpt_msg_frame_free(priv, index); if (*io_state & IO_STATE_DATA_SENT) { *io_state &= ~IO_STATE_DATA_SENT; @@ -1092,7 +1092,7 @@ } } - BUG_ON(info == NULL); + sBUG_ON(info == NULL); memcpy(info, sense_buf, len); /*out:*/ Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-14 16:22:29 UTC (rev 56) @@ -43,14 +43,6 @@ #include "qla2x00t.h" -/* Undefine the initiator driver's own DEBUG symbol */ -#undef DEBUG - -#ifdef DEBUG_TGT -#define DEBUG -#endif - -#include <scst_debug.h> #include <scst_debug.c> #ifndef FC_TARGET_SUPPORT @@ -282,9 +274,9 @@ TRACE_ENTRY(); - BUG_ON(scst_sess == NULL); + sBUG_ON(scst_sess == NULL); sess = (struct q2t_sess *)scst_sess_get_tgt_priv(scst_sess); - BUG_ON(sess == NULL); + sBUG_ON(sess == NULL); tgt = sess->tgt; kfree(sess); @@ -406,7 +398,7 @@ { int res = 0; - BUG_ON(prm->sg_cnt == 0); + sBUG_ON(prm->sg_cnt == 0); /* 32 bit S/G Data Transfer */ prm->seg_cnt = pci_map_sg(prm->tgt->ha->pdev, prm->sg, prm->sg_cnt, @@ -1123,7 +1115,7 @@ static void q2t_ctio_completion(scsi_qla_host_t *ha, uint32_t handle) { TRACE_ENTRY(); - BUG_ON(ha == NULL); + sBUG_ON(ha == NULL); if (ha->tgt != NULL) { q2t_do_ctio_completion(ha, handle, @@ -1716,7 +1708,7 @@ TRACE_ENTRY(); - BUG_ON((ha == NULL) || (pkt == NULL)); + sBUG_ON((ha == NULL) || (pkt == NULL)); TRACE(TRACE_SCSI, "pkt %p: T %02x C %02x S %02x handle %#x", pkt, pkt->entry_type, pkt->entry_count, pkt->entry_status, @@ -1902,7 +1894,7 @@ { TRACE_ENTRY(); - BUG_ON(ha == NULL); + sBUG_ON(ha == NULL); if (ha->tgt == NULL) { TRACE(TRACE_DEBUG|TRACE_MGMT, @@ -1963,7 +1955,7 @@ TRACE_ENTRY(); - BUG_ON(ha == NULL); + sBUG_ON(ha == NULL); switch (action) { case ENABLE_TARGET_MODE : Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.h =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.h 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.h 2006-12-14 16:22:29 UTC (rev 56) @@ -28,6 +28,15 @@ #include <qla_def.h> #include "qla2x_tgt_def.h" +/* Undefine the initiator driver's own DEBUG symbol */ +#undef DEBUG + +#ifdef DEBUG_TGT +#define DEBUG +#endif + +#include <scst_debug.h> + /* Version numbers, the same as for the kernel */ #define Q2T_VERSION(a,b,c,d) (((a) << 030) + ((b) << 020) + (c) << 010 + (d)) #define Q2T_VERSION_CODE Q2T_VERSION(0,9,6,0) @@ -157,7 +166,7 @@ uint16_t lid) { struct q2t_sess *sess, *sess_tmp; - BUG_ON(tgt == NULL); + sBUG_ON(tgt == NULL); list_for_each_entry_safe(sess, sess_tmp, &tgt->sess_list, list) { if (lid == (sess->loop_id)) return sess; Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/include/scsi_tgt.h 2006-12-14 16:22:29 UTC (rev 56) @@ -56,26 +56,29 @@ /* Allocation of the cmd's data buffer */ #define SCST_CMD_STATE_PREPARE_SPACE 5 +/* Allocation of the cmd's data buffer */ +#define SCST_CMD_STATE_PREPROCESS_DONE 6 + /* Target driver's rdy_to_xfer() is going to be called */ -#define SCST_CMD_STATE_RDY_TO_XFER 6 +#define SCST_CMD_STATE_RDY_TO_XFER 7 /* Waiting for data from the initiator (until scst_rx_data() called) */ -#define SCST_CMD_STATE_DATA_WAIT 7 +#define SCST_CMD_STATE_DATA_WAIT 8 /* CDB is going to be sent to SCSI mid-level for execution */ -#define SCST_CMD_STATE_SEND_TO_MIDLEV 8 +#define SCST_CMD_STATE_SEND_TO_MIDLEV 9 /* Waiting for CDB's execution finish */ -#define SCST_CMD_STATE_EXECUTING 9 +#define SCST_CMD_STATE_EXECUTING 10 /* Dev handler's dev_done() is going to be called */ -#define SCST_CMD_STATE_DEV_DONE 10 +#define SCST_CMD_STATE_DEV_DONE 11 /* Target driver's xmit_response() is going to be called */ -#define SCST_CMD_STATE_XMIT_RESP 11 +#define SCST_CMD_STATE_XMIT_RESP 12 /* Waiting for response's transmission finish */ -#define SCST_CMD_STATE_XMIT_WAIT 12 +#define SCST_CMD_STATE_XMIT_WAIT 13 /* The cmd finished */ #define SCST_CMD_STATE_FINISHED 14 @@ -156,23 +159,48 @@ #define SCST_RX_STATUS_SUCCESS 0 /* - * Data receiving finished with error, so set the sense and + * Data receiving finished with error, so set the sense and * finish the command, including xmit_response() call */ #define SCST_RX_STATUS_ERROR 1 /* - * Data receiving finished with error and the sense is set, + * Data receiving finished with error and the sense is set, * so finish the command, including xmit_response() call */ #define SCST_RX_STATUS_ERROR_SENSE_SET 2 /* - * Data receiving finished with fatal error, so finish the command, + * Data receiving finished with fatal error, so finish the command, * but don't call xmit_response() */ #define SCST_RX_STATUS_ERROR_FATAL 3 +/************************************************************* + ** Values for status parameter of scst_restart_cmd() + *************************************************************/ + +/* Success */ +#define SCST_PREPROCESS_STATUS_SUCCESS 0 + +/* + * Command's processing finished with error, so set the sense and + * finish the command, including xmit_response() call + */ +#define SCST_PREPROCESS_STATUS_ERROR 1 + +/* + * Command's processing finished with error and the sense is set, + * so finish the command, including xmit_response() call + */ +#define SCST_PREPROCESS_STATUS_ERROR_SENSE_SET 2 + +/* + * Command's processing finished with fatal error, so finish the command, + * but don't call xmit_response() + */ +#define SCST_PREPROCESS_STATUS_ERROR_FATAL 3 + /************************************************************* ** Allowed return codes for xmit_response(), rdy_to_xfer(), ** report_aen() @@ -213,19 +241,6 @@ */ #define SCST_EXEC_NEED_THREAD 2 -/************************************************************* - ** Allowed return codes for dev handler's task_mgmt_fn() - *************************************************************/ - -/* The command is done with success, no firther actions required */ -#define SCST_DEV_TM_COMPLETED_SUCCESS 0 - -/* The command is failed, no firther actions required */ -#define SCST_DEV_TM_COMPLETED_FAILED -1 - -/* Regular standard actions for the command should be done */ -#define SCST_DEV_TM_NOT_COMPLETED 1 - /************************************************************* ** Default timeout for cmd's CDB execution ** by SCSI mid-level (cmd's "timeout" field). @@ -286,11 +301,22 @@ #define SCST_ABORT_ALL_TASKS 9 /************************************************************* - ** Values for mgmt cmd's "status" + ** Values for mgmt cmd's status field. Codes taken from iSCSI *************************************************************/ -#define SCST_MGMT_STATUS_SUCCESS 0 -#define SCST_MGMT_STATUS_FAILED -1 +#define SCST_MGMT_STATUS_SUCCESS 0 +#define SCST_MGMT_STATUS_TASK_NOT_EXIST -1 +#define SCST_MGMT_STATUS_LUN_NOT_EXIST -2 +#define SCST_MGMT_STATUS_FN_NOT_SUPPORTED -5 +#define SCST_MGMT_STATUS_REJECTED -255 +#define SCST_MGMT_STATUS_FAILED -129 +/************************************************************* + ** Additional return code for dev handler's task_mgmt_fn() + *************************************************************/ + +/* Regular standard actions for the command should be done */ +#define SCST_DEV_TM_NOT_COMPLETED 1 + /************************************************************* ** Session initialization phases *************************************************************/ @@ -478,12 +504,6 @@ /* public: */ /* - * Name of the template. Must be unique to identify - * the template. MUST HAVE - */ - const char name[15]; - - /* * SG tablesize allows to check whether scatter/gather can be used * or not. */ @@ -495,17 +515,23 @@ unsigned unchecked_isa_dma:1; /* - * True, if this target adapter wants to use clustering - * (i.e. smaller number of segments). + * True, if this target adapter can benefit from using SG-vector + * clustering (i.e. smaller number of segments). */ unsigned use_clustering:1; /* + * True, if this target adapter doesn't support SG-vector clustering + */ + unsigned no_clustering:1; + + /* * True, if corresponding function supports execution in * the atomic (non-sleeping) context */ unsigned xmit_response_atomic:1; unsigned rdy_to_xfer_atomic:1; + unsigned preprocessing_done_atomic:1; /* True, if the template doesn't need the entry in /proc */ unsigned no_proc_entry:1; @@ -521,27 +547,6 @@ unsigned tm_sync_reply:1; /* - * This function should detect the target adapters that - * are present in the system. The function should return a value - * >= 0 to signify the number of detected target adapters. - * A negative value should be returned whenever there is - * an error. - * - * MUST HAVE - */ - int (*detect) (struct scst_tgt_template *tgt_template); - - /* - * This function should free up the resources allocated to the device. - * The function should return 0 to indicate successful release - * or a negative value if there are some issues with the release. - * In the current version the return value is ignored. - * - * MUST HAVE - */ - int (*release) (struct scst_tgt *tgt); - - /* * This function is equivalent to the SCSI * queuecommand. The target should transmit the response * buffer and the status in the scst_cmd struct. @@ -561,25 +566,6 @@ int (*xmit_response) (struct scst_cmd *cmd); /* - * This function allows the target driver to handle data buffer - * allocations on its own. - * Shall return 0 in case of success, and != 0 (preferrably -ENOMEM) - * in case of error. In case of returning successfully, - * scst_cmd->data_buf_alloced will be set by SCST. - * - * If allocation in atomic context - cf. scst_cmd_atomic() - is not - * desired or fails and consequently != 0 is returned, this function - * will be re-called in thread context. - * - * Please note that the driver will have to handle all relevant details - * such as scatterlist setup, highmem, freeing the allocated memory, ... - * itself. - * - * OPTIONAL. - */ - int (*alloc_data_buf) (struct scst_cmd *cmd); - - /* * This function informs the driver that data * buffer corresponding to the said command have now been * allocated and it is OK to receive data for this command. @@ -597,7 +583,7 @@ * by scst_cmd_atomic(): it is true if the function called in the * atomic (non-sleeping) context. * - * MUST HAVE. + * OPTIONAL */ int (*rdy_to_xfer) (struct scst_cmd *cmd); @@ -606,11 +592,55 @@ * Necessary, because for aborted commands xmit_response() could not * be called. Could be called on IRQ context. * - * MUST HAVE + * OPTIONAL */ void (*on_free_cmd) (struct scst_cmd *cmd); /* + * This function allows the target driver to handle data buffer + * allocations on its own. + * Shall return 0 in case of success or < 0 (preferrably -ENOMEM) + * in case of error, or > 0 if the regular SCST allocation should be + * done. In case of returning successfully, scst_cmd->data_buf_alloced + * will be set by SCST. + * + * If allocation in atomic context - cf. scst_cmd_atomic() - is not + * desired or fails and consequently < 0 is returned, this function + * will be re-called in thread context. + * + * Please note that the driver will have to handle all relevant details + * such as scatterlist setup, highmem, freeing the allocated memory, ... + * itself. + * + * OPTIONAL. + */ + int (*alloc_data_buf) (struct scst_cmd *cmd); + + /* + * This function informs the driver that data + * buffer corresponding to the said command have now been + * allocated and other preprocessing tasks have been done. + * A target driver could need to do some actions at this stage. + * After the target driver done the needed actions, it shall call + * scst_restart_cmd() in order to continue processing this command. + * + * Called only if the cmd is queued using scst_cmd_init_stage1_done() + * instead of scst_cmd_init_done(). + * + * Returns void, the result is expected to be returned using + * scst_restart_cmd(). + * + * This command is expected to be NON-BLOCKING. + * + * Pay attention to "atomic" attribute of the cmd, which can be get + * by scst_cmd_atomic(): it is true if the function called in the + * atomic (non-sleeping) context. + * + * OPTIONAL. + */ + void (*preprocessing_done) (struct scst_cmd *cmd); + + /* * This function informs the driver that a * received task management function has been completed. This * function is necessary because low-level protocols have some @@ -631,6 +661,27 @@ void (*task_mgmt_fn_done) (struct scst_mgmt_cmd *mgmt_cmd); /* + * This function should detect the target adapters that + * are present in the system. The function should return a value + * >= 0 to signify the number of detected target adapters. + * A negative value should be returned whenever there is + * an error. + * + * MUST HAVE + */ + int (*detect) (struct scst_tgt_template *tgt_template); + + /* + * This function should free up the resources allocated to the device. + * The function should return 0 to indicate successful release + * or a negative value if there are some issues with the release. + * In the current version the return value is ignored. + * + * MUST HAVE + */ + int (*release) (struct scst_tgt *tgt); + + /* * This function is used for Asynchronous Event Notification. * It is the responsibility of the driver to notify any/all * initiators about the Asynchronous Event reported. @@ -652,6 +703,12 @@ int (*proc_info) (char *buffer, char **start, off_t offset, int length, int *eof, struct scst_tgt *tgt, int inout); + /* + * Name of the template. Must be unique to identify + * the template. MUST HAVE + */ + const char name[50]; + /* Private, must be inited to 0 by memset() */ /* List of targets per template, protected by scst_mutex */ @@ -767,9 +824,9 @@ /* * Called to execute a task management command. * Returns: - * - SCST_DEV_TM_COMPLETED_SUCCESS - the command is done with success, + * - SCST_MGMT_STATUS_SUCCESS - the command is done with success, * no firther actions required - * - SCST_DEV_TM_COMPLETED_FAILED - the command is failed, + * - The SCST_MGMT_STATUS_* error code if the command is failed and * no firther actions required * - SCST_DEV_TM_NOT_COMPLETED - regular standard actions for the command * should be done @@ -1020,6 +1077,21 @@ */ unsigned int may_need_dma_sync:1; + /* + * Set if scst_cmd_init_stage1_done() called and the target + * want that preprocessing_done() will be called + */ + unsigned int preprocessing_only:1; + + /* + * Set if scst_cmd_init_stage1_done() called and the target want + * that the SN for the cmd isn't assigned until scst_restart_cmd() + */ + unsigned int no_sn:1; + + /* Set if the cmd's must not use sgv cache for data buffer */ + unsigned int no_sgv:1; + /**************************************************************/ unsigned long cmd_flags; /* cmd's async flags */ @@ -1100,6 +1172,9 @@ uint16_t host_status; /* set by low-level driver to indicate status */ uint16_t driver_status; /* set by mid-level */ + /* Used for storage of target driver private stuff */ + void *tgt_priv; + /* * Used to restore the SG vector if it was modified by * scst_set_resp_data_len() @@ -1114,18 +1189,15 @@ /* List entry for dev's blocked_cmd_list */ struct list_head blocked_cmd_list_entry; + /* Used for storage of dev handler private stuff */ + void *dh_priv; + /* * Fileio private fields */ struct list_head fileio_cmd_list_entry; int fileio_in_list; - /* Used for storage of target driver private stuff */ - void *tgt_priv; - - /* Used for storage of dev handler private stuff */ - void *dh_priv; - /* * Used to store previous tgt_dev if dev handler returns * SCST_CMD_STATE_REINIT state @@ -1537,6 +1609,31 @@ void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context); /* + * Notifies SCST that the driver finished the first stage of the command + * initialization, and the command is ready for execution, but after + * SCST done the command's preprocessing preprocessing_done() function + * should be called. The second argument sets preferred command execition + * context. See SCST_CONTEXT_* constants for details. + */ +static inline void scst_cmd_init_stage1_done(struct scst_cmd *cmd, + int pref_context, int set_sn) +{ + cmd->preprocessing_only = 1; + cmd->no_sn = !set_sn; + scst_cmd_init_done(cmd, pref_context); +} + +/* + * Notifies SCST that the driver finished its part of the command's + * preprocessing and it is ready for further processing. + * The second argument sets data receiving completion status + * (see SCST_PREPROCESS_STATUS_* constants for details) + * The third argument sets preferred command execition context + * (see SCST_CONTEXT_* constants for details) + */ +void scst_restart_cmd(struct scst_cmd *cmd, int status, int pref_context); + +/* * Notifies SCST that the driver received all the necessary data * and the command is ready for further processing. * The second argument sets data receiving completion status @@ -1862,6 +1959,19 @@ } /* + * Get/Set functions for no_sgv flag + */ +static inline int scst_cmd_get_no_sgv(struct scst_cmd *cmd) +{ + return cmd->no_sgv; +} + +static inline void scst_cmd_set_no_sgv(struct scst_cmd *cmd) +{ + cmd->no_sgv = 1; +} + +/* * Returns 1 if the cmd was aborted, so its status is invalid and no * reply shall be sent to the remote initiator. A target driver should * only clear internal resources, associated with cmd. @@ -2087,4 +2197,16 @@ void scst_get(void); void scst_put(void); +/* + * Allocates and returns pointer to SG vector with data size "size". + * If use_clustering is not 0, segments in the vector will be merged, + * when possible. In *count returned the count of entries in the vector. + * Returns NULL for failure. + */ +struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, + int use_clustering, int *count); + +/* Frees SG vector returned by scst_alloc() */ +void scst_free(struct scatterlist *sg, int count); + #endif /* __SCST_H */ Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/include/scst_debug.h 2006-12-14 16:22:29 UTC (rev 56) @@ -20,9 +20,7 @@ #ifndef __SCST_DEBUG_H #define __SCST_DEBUG_H -#include <linux/config.h> /* for CONFIG_SCSI_TARGET_EXTRACHEKS - CONFIG_SCSI_TARGET_TRACING - CONFIG_SCSI_TARGET_DEBUG */ +#include <linux/config.h> /* for CONFIG_* */ #if !defined(EXTRACHECKS) && defined(CONFIG_SCSI_TARGET_EXTRACHECKS) #define EXTRACHECKS @@ -37,6 +35,34 @@ #endif #ifdef DEBUG +#ifndef CONFIG_DEBUG_BUGVERBOSE +#define sBUG() do { \ + printk(KERN_CRIT "BUG at %s:%d\n", \ + __FILE__, __LINE__); \ + BUG(); \ +} while (0) +#else +#define sBUG() BUG() +#endif +#define sBUG_ON(p) do { \ + if (unlikely(p)) { \ + printk(KERN_CRIT "BUG at %s:%d (%s)\n", \ + __FILE__, __LINE__, #p); \ + BUG(); \ + } \ +} while (0) +#else +#define sBUG() BUG() +#define sBUG_ON(p) BUG_ON(p) +#endif + +#ifdef EXTRACHECKS +#define EXTRACHECKS_BUG_ON(a) sBUG_ON(a) +#else +#define EXTRACHECKS_BUG_ON(a) +#endif + +#ifdef DEBUG //# define LOG_FLAG KERN_DEBUG # define LOG_FLAG KERN_INFO Modified: trunk/scst/src/dev_handlers/scst_fileio.c =================================================================== --- trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 16:22:29 UTC (rev 56) @@ -45,7 +45,7 @@ /* 8 byte ASCII Vendor of the FILE IO target */ #define SCST_FIO_VENDOR "SCST_FIO" /* 4 byte ASCII Product Revision Level of the FILE IO target - left aligned */ -#define SCST_FIO_REV " 095" +#define SCST_FIO_REV " 096" #define READ_CAP_LEN 8 #define READ_CAP16_LEN 32 @@ -2217,7 +2217,7 @@ static int fileio_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, struct scst_tgt_dev *tgt_dev) { - int res = SCST_DEV_TM_COMPLETED_SUCCESS; + int res = SCST_DEV_TM_NOT_COMPLETED; TRACE_ENTRY(); Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst.c 2006-12-14 16:22:29 UTC (rev 56) @@ -147,20 +147,6 @@ goto out; } - if (!vtt->rdy_to_xfer) { - PRINT_ERROR_PR("Target driver %s doesn't have a " - "rdy_to_xfer() method.", vtt->name); - res = -EINVAL; - goto out; - } - - if (!vtt->on_free_cmd) { - PRINT_ERROR_PR("Target driver %s doesn't have a " - "on_free_cmd() method.", vtt->name); - res = -EINVAL; - goto out; - } - if (!vtt->no_proc_entry) { res = scst_build_proc_target_dir_entries(vtt); if (res < 0) { @@ -295,7 +281,7 @@ down(&scst_mutex); list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) { - BUG_ON(!sess->shutting_down); + sBUG_ON(!sess->shutting_down); } up(&scst_mutex); @@ -1245,6 +1231,7 @@ EXPORT_SYMBOL(scst_cmd_init_done); EXPORT_SYMBOL(scst_tgt_cmd_done); +EXPORT_SYMBOL(scst_restart_cmd); EXPORT_SYMBOL(scst_rx_cmd); EXPORT_SYMBOL(scst_rx_data); EXPORT_SYMBOL(scst_rx_mgmt_fn_tag); @@ -1272,6 +1259,9 @@ EXPORT_SYMBOL(scst_get); EXPORT_SYMBOL(scst_put); +EXPORT_SYMBOL(scst_alloc); +EXPORT_SYMBOL(scst_free); + /* * Other Commands */ Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_lib.c 2006-12-14 16:22:29 UTC (rev 56) @@ -180,7 +180,7 @@ { PRINT_ERROR_PR("%s: dev_tgt_dev_list or dev_acg_dev_list " "is not empty!", __FUNCTION__); - BUG(); + sBUG(); } #endif @@ -732,7 +732,7 @@ res->bufflen = bufsize; if (bufsize > 0) { if (scst_alloc_space(res) != 0) - PRINT_ERROR("Unable to create buffer (size %d) for " + PRINT_ERROR_PR("Unable to create buffer (size %d) for " "internal cmd", bufsize); goto out_free_res; } @@ -799,7 +799,7 @@ TRACE_ENTRY(); - BUG_ON(orig_cmd); + sBUG_ON(orig_cmd); len = scst_get_buf_first(cmd, &buf); @@ -1091,7 +1091,7 @@ TRACE_ENTRY(); - BUG_ON(cmd->blocking); + sBUG_ON(cmd->blocking); #if defined(EXTRACHECKS) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) if (cmd->scsi_req) { @@ -1101,9 +1101,11 @@ } #endif - TRACE_DBG("Calling target's on_free_cmd(%p)", cmd); - cmd->tgtt->on_free_cmd(cmd); - TRACE_DBG("%s", "Target's on_free_cmd() returned"); + if (cmd->tgtt->on_free_cmd != NULL) { + TRACE_DBG("Calling target's on_free_cmd(%p)", cmd); + cmd->tgtt->on_free_cmd(cmd); + TRACE_DBG("%s", "Target's on_free_cmd() returned"); + } if (likely(cmd->dev != NULL)) { struct scst_dev_type *handler = cmd->dev->handler; @@ -1226,7 +1228,7 @@ mcmd = mempool_alloc(scst_mgmt_mempool, gfp_mask); if (mcmd == NULL) { - PRINT_ERROR("%s", "Allocation of management command " + PRINT_ERROR_PR("%s", "Allocation of management command " "failed, some commands and their data could leak"); goto out; } @@ -1310,14 +1312,14 @@ int gfp_mask; int res = -ENOMEM; int ini_unchecked_isa_dma, ini_use_clustering; + int use_clustering = 0; struct sgv_pool *pool; - struct sgv_pool_obj *sgv; TRACE_ENTRY(); if (cmd->data_buf_alloced) { TRACE_MEM("%s", "data_buf_alloced set, returning"); - BUG_ON(cmd->sg == NULL); + sBUG_ON(cmd->sg == NULL); res = 0; goto out; } @@ -1340,10 +1342,12 @@ ini_use_clustering = 0; } - if (cmd->tgtt->use_clustering || ini_use_clustering) + if ((cmd->tgtt->use_clustering || ini_use_clustering) && + !cmd->tgtt->no_clustering) { TRACE_MEM("%s", "Use clustering"); pool = &scst_sgv.norm_clust; + use_clustering = 1; } if (cmd->tgtt->unchecked_isa_dma || ini_unchecked_isa_dma) { @@ -1357,9 +1361,17 @@ #endif } - sgv = sgv_pool_alloc(pool, cmd->bufflen, gfp_mask, &cmd->sg_cnt); - if (sgv == NULL) - goto out; + if (cmd->no_sgv) { + cmd->sg = scst_alloc(cmd->bufflen, gfp_mask, use_clustering, + &cmd->sg_cnt); + if (cmd->sg == NULL) + goto out; + } else { + cmd->sg = sgv_pool_alloc(pool, cmd->bufflen, gfp_mask, + &cmd->sg_cnt, &cmd->sgv); + if (cmd->sg == NULL) + goto out; + } if (unlikely(cmd->sg_cnt > ini_sg)) { static int ll; @@ -1370,7 +1382,7 @@ ini_sg); ll++; } - goto out_sgv_free; + goto out_sg_free; } if (unlikely(cmd->sg_cnt > tgt_sg)) { @@ -1382,11 +1394,8 @@ cmd->sg_cnt, tgt_sg); ll++; } - goto out_sgv_free; + goto out_sg_free; } - - cmd->sgv = sgv; - cmd->sg = sgv_pool_sg(sgv); res = 0; @@ -1394,8 +1403,13 @@ TRACE_EXIT(); return res; -out_sgv_free: - sgv_pool_free(sgv); +out_sg_free: + if (cmd->no_sgv) + scst_free(cmd->sg, cmd->sg_cnt); + else + sgv_pool_free(cmd->sgv); + cmd->sgv = NULL; + cmd->sg = NULL; cmd->sg_cnt = 0; goto out; } @@ -1412,7 +1426,8 @@ if (cmd->sgv) { scst_check_restore_sg_buff(cmd); sgv_pool_free(cmd->sgv); - } + } else if (cmd->sg) + scst_free(cmd->sg, cmd->sg_cnt); cmd->sgv = NULL; cmd->sg_cnt = 0; @@ -1454,6 +1469,7 @@ #else *buf = page_address(sg[i].page); #endif + *buf += sg[i].offset; res = sg[i].length; cmd->get_sg_buf_entry_num++; @@ -1982,7 +1998,7 @@ int res = 0; struct scst_device *dev = cmd->dev; - BUG_ON(cmd->blocking); + sBUG_ON(cmd->blocking); atomic_inc(&dev->on_dev_count); @@ -2073,7 +2089,7 @@ if (likely(!cmd->internal) && likely(!cmd->retry)) { int expected_sn; if (cmd->tgt_dev == NULL) - BUG(); + sBUG(); expected_sn = cmd->tgt_dev->expected_sn; if (cmd->sn == expected_sn) brk = 1; @@ -2137,13 +2153,18 @@ } void scst_inc_expected_sn_unblock(struct scst_tgt_dev *tgt_dev, - struct scst_cmd *cmd_sn, int locked) + struct scst_cmd *out_of_sn_cmd, int locked) { struct scst_cmd *cmd; TRACE_ENTRY(); - cmd = scst_inc_expected_sn(tgt_dev, cmd_sn); + if (out_of_sn_cmd->no_sn) { + TRACE(TRACE_SCSI_SERIALIZING, "cmd %p with no_sn", out_of_sn_cmd); + goto out; + } + + cmd = scst_inc_expected_sn(tgt_dev, out_of_sn_cmd); if (cmd != NULL) { unsigned long flags = 0; if (!locked) @@ -2153,10 +2174,11 @@ list_move(&cmd->cmd_list_entry, &scst_active_cmd_list); if (!locked) spin_unlock_irqrestore(&scst_list_lock, flags); - if (!cmd_sn->processible_env) + if (!out_of_sn_cmd->processible_env) wake_up(&scst_list_waitQ); } +out: TRACE_EXIT(); return; } @@ -2294,7 +2316,7 @@ break; default: - BUG(); + sBUG(); } list_move_tail(&cmd->cmd_list_entry, &tm_dbg_delayed_cmd_list); cmd->tm_dbg_delayed = 1; @@ -2345,7 +2367,7 @@ } break; default: - BUG(); + sBUG(); } tm_dbg_on_state_passes = tm_dbg_on_state_num_passes[tm_dbg_state]; Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_mem.c 2006-12-14 16:22:29 UTC (rev 56) @@ -43,6 +43,7 @@ */ atomic_t sgv_big_total_alloc; +atomic_t sgv_other_total_alloc; static int scst_check_clustering(struct scatterlist *sg, int cur, int hint) { @@ -111,15 +112,15 @@ goto out; } -static void sgv_free_sg(struct sgv_pool_obj *obj) +static void scst_free_sg_entries(struct scatterlist *sg, int sg_count) { int i; - TRACE_MEM("obj=%p, sg_count=%d", obj, obj->sg_count); + TRACE_MEM("sg=%p, sg_count=%d", sg, sg_count); - for (i = 0; i < obj->sg_count; i++) { - struct page *p = obj->entries[i].page; - int len = obj->entries[i].length; + for (i = 0; i < sg_count; i++) { + struct page *p = sg[i].page; + int len = sg[i].length; int pages = (len >> PAGE_SHIFT) + ((len & ~PAGE_MASK) != 0); @@ -149,13 +150,12 @@ p += 1 << order; } } - obj->sg_count = 0; } -static int sgv_alloc_sg(struct sgv_pool_obj *obj, int pages, - unsigned long mask, int clustered) +static int scst_alloc_sg_entries(struct scatterlist *sg, int pages, + unsigned long gfp_mask, int clustered, struct trans_tbl_ent *trans_tbl) { - int res = 0; + int sg_count = 0; int pg, i, j; int merged = -1; @@ -168,100 +168,55 @@ mask |= __GFP_ZERO; #endif - obj->sg_count = 0; for (pg = 0; pg < pages; pg++) { #ifdef DEBUG_OOM if ((scst_random() % 10000) == 55) - obj->entries[obj->sg_count].page = NULL; + sg[sg_count].page = NULL; else #endif - obj->entries[obj->sg_count].page = alloc_pages(mask, 0); - if (obj->entries[obj->sg_count].page == NULL) { + sg[sg_count].page = alloc_pages(gfp_mask, 0); + if (sg[sg_count].page == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of " - "sgv_pool_obj page failed"); - res = -ENOMEM; - goto out_free; + "sg page failed"); + goto out_no_mem; } - obj->entries[obj->sg_count].length = PAGE_SIZE; + sg[sg_count].length = PAGE_SIZE; if (clustered) { - merged = scst_check_clustering(obj->entries, - obj->sg_count, merged); + merged = scst_check_clustering(sg, sg_count, merged); if (merged == -1) - obj->sg_count++; + sg_count++; } else - obj->sg_count++; + sg_count++; TRACE_MEM("pg=%d, merged=%d, sg_count=%d", pg, merged, - obj->sg_count); + sg_count); } - if (clustered) { + if (clustered && trans_tbl) { pg = 0; for (i = 0; i < pages; i++) { - int n = obj->entries[i].length >> PAGE_SHIFT; - obj->trans_tbl[i].pg_count = pg; + int n = sg[i].length >> PAGE_SHIFT; + trans_tbl[i].pg_count = pg; for (j = 0; j < n; j++) - obj->trans_tbl[pg++].sg_num = i+1; + trans_tbl[pg++].sg_num = i+1; } } out: - TRACE_MEM("res=%d, sg_count=%d", res, obj->sg_count); - return res; + TRACE_MEM("sg_count=%d", sg_count); + return sg_count; -out_free: - sgv_free_sg(obj); +out_no_mem: + scst_free_sg_entries(sg, sg_count); + sg_count = 0; goto out; } -struct sgv_pool_obj *sgv_pool_alloc_big(int size, int pages, - unsigned long mask, int *count, int clustered) +struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, int size, + unsigned long gfp_mask, int *count, struct sgv_pool_obj **sgv) { struct sgv_pool_obj *obj; - int elen, cnt = 0; - - elen = sizeof(*obj) + pages * (sizeof(obj->entries[0]) + - clustered ? sizeof(obj->trans_tbl[0]) : 0); - obj = kzalloc(elen, mask & ~(__GFP_HIGHMEM|GFP_DMA)); - if (obj == NULL) { - TRACE(TRACE_OUT_OF_MEM, "Allocation big of sgv_pool_obj " - "failed (elen=%d, size=%d)", elen, size); - goto out; - } - obj->entries = (struct scatterlist*)&obj->trans_tbl[pages]; - - atomic_inc(&sgv_big_total_alloc); - - if (sgv_alloc_sg(obj, pages, mask, clustered) != 0) - goto out_free; - cnt = obj->sg_count; - if (size & ~PAGE_MASK) { - obj->entries[cnt-1].length -= - PAGE_SIZE - (size & ~PAGE_MASK); - } - *count = cnt; - -out: - TRACE_MEM("obj=%p (count=%d)", obj, cnt); - return obj; - -out_free: - kfree(obj); - obj = NULL; - goto out; -} - -void __sgv_pool_free_big(struct sgv_pool_obj *obj) -{ - TRACE_MEM("obj=%p", obj); - sgv_free_sg(obj); - kfree(obj); -} - -struct sgv_pool_obj *sgv_pool_alloc(struct sgv_pool *pool, int size, - unsigned long mask, int *count) -{ - struct sgv_pool_obj *obj; int order, pages, cnt, sg; + struct scatterlist *res = NULL; if (unlikely(size == 0)) return NULL; @@ -273,17 +228,18 @@ if (order >= SGV_POOL_ELEMENTS) { obj = NULL; - if (mask & GFP_ATOMIC) + if (gfp_mask & GFP_ATOMIC) goto out; - obj = sgv_pool_alloc_big(size, pages, mask, count, - pool->clustered); + atomic_inc(&sgv_big_total_alloc); + atomic_dec(&sgv_other_total_alloc); + res = scst_alloc(size, gfp_mask, pool->clustered, count); goto out; } obj = kmem_cache_alloc(pool->caches[order], - mask & ~(__GFP_HIGHMEM|GFP_DMA)); + gfp_mask & ~(__GFP_HIGHMEM|GFP_DMA)); if (obj == NULL) { - if (!(mask & GFP_ATOMIC)) { + if (!(gfp_mask & GFP_ATOMIC)) { TRACE(TRACE_OUT_OF_MEM, "Allocation of sgv_pool_obj " "failed (size %d)", size); } @@ -293,7 +249,7 @@ if (obj->owner_cache != pool->caches[order]) { int esz, epg, eorder; - if (mask & GFP_ATOMIC) + if (gfp_mask & GFP_ATOMIC) goto out_free; esz = (1 << order) * sizeof(obj->entries[0]); @@ -304,15 +260,16 @@ obj->eorder = eorder; obj->entries = (struct scatterlist*)__get_free_pages( - mask|__GFP_ZERO, eorder); + gfp_mask|__GFP_ZERO, eorder); if (obj->entries == NULL) { TRACE(TRACE_OUT_OF_MEM, "Allocation of sgv_pool_obj " "SG vector order %d failed", eorder); goto out_free; } - if (sgv_alloc_sg(obj, (1 << order), mask, - pool->clustered) != 0) + obj->sg_count = scst_alloc_sg_entries(obj->entries, (1 << order), + gfp_mask, pool->clustered, obj->trans_tbl); + if (obj->sg_count <= 0) goto out_free_entries; obj->owner_cache = pool->caches[order]; @@ -343,8 +300,11 @@ "sg_count=%d, count=%d, last_len=%d)", obj, size, pages, obj->sg_count, *count, obj->entries[obj->orig_sg].length); + res = obj->entries; + *sgv = obj; + out: - return obj; + return res; out_free_entries: free_pages((unsigned long)obj->entries, obj->eorder); @@ -373,7 +333,7 @@ struct sgv_pool_obj *obj = data; TRACE_MEM("Destructor for sgv_obj %p", obj); if (obj->entries) { - sgv_free_sg(obj); + scst_free_sg_entries(obj->entries, obj->sg_count); free_pages((unsigned long)obj->entries, obj->eorder); } } @@ -401,6 +361,44 @@ SGV_DTOR_NAME(4), SGV_DTOR_NAME(5), SGV_DTOR_NAME(6), SGV_DTOR_NAME(7), SGV_DTOR_NAME(8), SGV_DTOR_NAME(9), SGV_DTOR_NAME(10) }; +struct scatterlist *scst_alloc(int size, unsigned long gfp_mask, + int use_clustering, int *count) +{ + struct scatterlist *res; + int pages = (size >> PAGE_SHIFT) + ((size & ~PAGE_MASK) != 0); + + TRACE_ENTRY(); + + atomic_inc(&sgv_other_total_alloc); + + res = kzalloc(pages*sizeof(*res), gfp_mask); + if (res == NULL) + goto out; + + *count = scst_alloc_sg_entries(res, pages, gfp_mask, use_clustering, + NULL); + if (*count <= 0) + goto out_free; + +out: + TRACE_MEM("Alloced sg %p (count %d)", res, *count); + + TRACE_EXIT_HRES((int)res); + return res; + +out_free: + kfree(res); + res = NULL; + goto out; +} + +void scst_free(struct scatterlist *sg, int count) +{ + TRACE_MEM("Freeing sg=%p", sg); + scst_free_sg_entries(sg, count); + kfree(sg); +} + int sgv_pool_init(struct sgv_pool *pool, const char *name, int clustered) { int res = -ENOMEM; @@ -476,7 +474,7 @@ TRACE_ENTRY(); - pool = kmalloc(sizeof(*pool), GFP_KERNEL); + pool = kzalloc(sizeof(*pool), GFP_KERNEL); if (pool == NULL) { TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of sgv_pool failed"); goto out; @@ -513,6 +511,7 @@ TRACE_ENTRY(); atomic_set(&sgv_big_total_alloc, 0); + atomic_set(&sgv_other_total_alloc, 0); res = sgv_pool_init(&pools->norm, "sgv", 0); if (res != 0) Modified: trunk/scst/src/scst_mem.h =================================================================== --- trunk/scst/src/scst_mem.h 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_mem.h 2006-12-14 16:22:29 UTC (rev 56) @@ -70,6 +70,7 @@ }; extern atomic_t sgv_big_total_alloc; +extern atomic_t sgv_other_total_alloc; extern struct sgv_pool *sgv_pool_create(const char *name, int clustered); extern void sgv_pool_destroy(struct sgv_pool *pool); @@ -78,19 +79,13 @@ int clustered); extern void sgv_pool_deinit(struct sgv_pool *pool); -extern struct sgv_pool_obj *sgv_pool_alloc(struct sgv_pool *pool, int size, - unsigned long flags, int *count); -extern void __sgv_pool_free_big(struct sgv_pool_obj *obj); - -static inline void sgv_pool_free(struct sgv_pool_obj *obj) +extern struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, int size, + unsigned long gfp_mask, int *count, struct sgv_pool_obj **sgv); +static inline void sgv_pool_free(struct sgv_pool_obj *sgv) { - TRACE_MEM("Freeing sgv_obj %p", obj); - if (obj->owner_cache != NULL) { - obj->entries[obj->orig_sg].length = obj->orig_length; - kmem_cache_free(obj->owner_cache, obj); - } - else - __sgv_pool_free_big(obj); + TRACE_MEM("Freeing sgv_obj %p", sgv); + sgv->entries[sgv->orig_sg].length = sgv->orig_length; + kmem_cache_free(sgv->owner_cache, sgv); } static inline struct scatterlist *sgv_pool_sg(struct sgv_pool_obj *obj) Modified: trunk/scst/src/scst_priv.h =================================================================== --- trunk/scst/src/scst_priv.h 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_priv.h 2006-12-14 16:22:29 UTC (rev 56) @@ -275,7 +275,7 @@ #ifdef STRICT_SERIALIZING scsi_do_req(sreq, cmnd, buffer, bufflen, done, timeout, retries); #elif defined(FILEIO_ONLY) - BUG(); + sBUG(); #else scsi_do_req_fifo(sreq, cmnd, buffer, bufflen, done, timeout, retries); #endif @@ -290,7 +290,7 @@ return scsi_execute_async(sdev, cmd, cmd_len, data_direction, buffer, bufflen, use_sg, timeout, retries, privdata, done, gfp); #elif defined(FILEIO_ONLY) - BUG(); + sBUG(); return -1; #else return scsi_execute_async_fifo(sdev, cmd, cmd_len, data_direction, Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_proc.c 2006-12-14 16:22:29 UTC (rev 56) @@ -414,7 +414,7 @@ } } if (level == 0) { - PRINT_ERROR("Unknown token \"%s\"", p); + PRINT_ERROR_PR("Unknown token \"%s\"", p); res = -EINVAL; goto out_free; } @@ -828,6 +828,11 @@ if (scst_proc_update_size(size, offset, length, &st)) goto stop_output; + size = scnprintf(buffer + st.len, length - st.len, "\n%-32s %-11d\n", + "other", atomic_read(&sgv_other_total_alloc)); + if (scst_proc_update_size(size, offset, length, &st)) + goto stop_output; + *eof = 1; stop_output: Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2006-12-14 15:52:16 UTC (rev 55) +++ trunk/scst/src/scst_targ.c 2006-12-14 16:22:29 UTC (rev 56) @@ -30,7 +30,8 @@ #include "scsi_tgt.h" #include "scst_priv.h" -static int scst_do_job_init(struct list_head *init_cmd_list); +static int scst_do_job_init(void); +static int scst_process_init_cmd(struct scst_cmd *cmd); static int __scst_process_active_cmd(struct scst_cmd *cmd, int context, int left_locked); @@ -61,6 +62,20 @@ return res; } +/* Called under scst_list_lock and IRQs disabled */ +static inline void scst_cmd_set_sn(struct scst_cmd *cmd) +{ + /* ToDo: cmd->queue_type */ + + /* scst_list_lock is enough to protect that */ + cmd->sn = cmd->tgt_dev->next_sn; + cmd->tgt_dev->next_sn++; + cmd->no_sn = 0; + + TRACE(TRACE_DEBUG/*TRACE_SCSI_SERIALIZING*/, "cmd(%p)->sn: %d", + cmd, cmd->sn); +} + static inline void scst_schedule_tasklet(void) { struct tasklet_struct *t = &scst_tasklets[smp_processor_id()]; @@ -97,7 +112,7 @@ #ifdef EXTRACHECKS if (unlikely(sess->shutting_down)) { PRINT_ERROR_PR("%s", "New cmd while shutting down the session"); - BUG(); + sBUG(); } #endif @@ -130,6 +145,13 @@ return cmd; } +static void scst_setup_to_active(struct scst_cmd *cmd) +{ + cmd->state = SCST_CMD_STATE_XMIT_RESP; + TRACE_DBG("Adding cmd %p to active cmd list", cmd); + list_add_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); +} + void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context) { int res = 0; @@ -144,6 +166,7 @@ TRACE_BUFF_FLAG(TRACE_SCSI|TRACE_RECV_BOT, "Recieving CDB", cmd->cdb, cmd->cdb_len); +#ifdef EXTRACHECKS if (unlikely(in_irq()) && ((pref_context == SCST_CONTEXT_DIRECT) || (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) { @@ -152,6 +175,7 @@ cmd->tgtt->name); pref_context = SCST_CONTEXT_TASKLET; } +#endif spin_lock_irqsave(&scst_list_lock, flags); @@ -171,79 +195,79 @@ goto out_unlock_flags; case SCST_SESS_IPH_FAILED: scst_set_busy(cmd); - cmd->state = SCST_CMD_STATE_XMIT_RESP; - TRACE_DBG("Adding cmd %p to active cmd list", cmd); - list_add_tail(&cmd->cmd_list_entry, - &scst_active_cmd_list); + scst_setup_to_active(cmd); goto active; default: - BUG(); + sBUG(); } } +#ifdef EXTRACHECKS if (unlikely(cmd->lun == (lun_t)-1)) { - PRINT_ERROR("Wrong LUN %d, finishing cmd", -1); + PRINT_ERROR_PR("Wrong LUN %d, finishing cmd", -1); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_lun_not_supported)); - cmd->state = SCST_CMD_STATE_XMIT_RESP; - TRACE_DBG("Moving cmd %p to active cmd list", cmd); - list_add_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); + scst_setup_to_active(cmd); goto active; } if (unlikely(cmd->cdb_len == 0)) { - PRINT_ERROR("Wrong CDB len %d, finishing cmd", 0); + PRINT_ERROR_PR("Wrong CDB len %d, finishing cmd", 0); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode)); - cmd->state = SCST_CMD_STATE_XMIT_RESP; - TRACE_DBG("Adding cmd %p to active cmd list", cmd); - list_add_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); + scst_setup_to_active(cmd); goto active; } +#endif + TRACE_DBG("Adding cmd %p to init cmd list", cmd); + list_add_tail(&cmd->cmd_list_entry, &scst_init_cmd_list); + cmd->state = SCST_CMD_STATE_INIT; - TRACE_DBG("Moving cmd %p to init cmd list", cmd); - list_add_tail(&cmd->cmd_list_entry, &scst_init_cmd_list); + switch (pref_context) { + case SCST_CONTEXT_TASKLET: + scst_schedule_tasklet(); + goto out_unlock_flags; - switch (pref_context) { case SCST_CONTEXT_DIRECT: case SCST_CONTEXT_DIRECT_ATOMIC: - res = scst_do_job_init(&scst_init_cmd_list); - if (res > 0) + if (cmd->no_sn) + res = scst_process_init_cmd(cmd); + else + res = scst_do_job_init(); + if (unlikely(res > 0)) goto out_unlock_flags; break; case SCST_CONTEXT_THREAD: goto out_thread_unlock_flags; - case SCST_CONTEXT_TASKLET: - scst_schedule_tasklet(); - goto out_unlock_flags; - default: - PRINT_ERROR_PR("Context %x is undefined, using thread one", - pref_context); + PRINT_ERROR_PR("Context %x is undefined, using the thread one", + pref_context); goto out_thread_unlock_flags; } active: + /* Here cmd must be in active cmd list */ switch (pref_context) { + case SCST_CONTEXT_TASKLET: + scst_schedule_tasklet(); + goto out_unlock_flags; + case SCST_CONTEXT_DIRECT: case SCST_CONTEXT_DIRECT_ATOMIC: scst_process_active_cmd(cmd, pref_context, &flags, 0); + /* For *NEED_THREAD wake_up() is already done */ break; case SCST_CONTEXT_THREAD: goto out_thread_unlock_flags; - case SCST_CONTEXT_TASKLET: - scst_schedule_tasklet(); - goto out_unlock_flags; - default: - PRINT_ERROR_PR("Context %x is undefined, using thread one", - pref_context); + PRINT_ERROR_PR("Context %x is undefined, using the thread one", + pref_context); goto out_thread_unlock_flags; } @@ -270,6 +294,7 @@ struct scst_device *dev = cmd->dev; struct scst_info_cdb cdb_info; int atomic = scst_cmd_atomic(cmd); + int orig_bufflen = cmd->bufflen; int set_dir = 1; TRACE_ENTRY(); @@ -393,6 +418,13 @@ if (cmd->data_len == -1) cmd->data_len = cmd->bufflen; + if (cmd->data_buf_alloced && (orig_bufflen < cmd->bufflen)) { + PRINT_ERROR_PR("Target driver supplied data buffer (size %d), " + "is less, than required (size %d)", orig_bufflen, + cmd->bufflen); + goto out_error; + } + #ifdef EXTRACHECKS if (state != SCST_CMD_STATE_NEED_THREAD_CTX) { if (((cmd->data_direction == SCST_DATA_UNKNOWN) && @@ -427,12 +459,6 @@ res = SCST_CMD_STATE_RES_CONT_SAME; break; - case SCST_CMD_STATE_REINIT: - cmd->tgt_dev_saved = tgt_dev_saved; - cmd->state = state; - res = SCST_CMD_STATE_RES_RESTART; - set_dir = 0; - break; case SCST_CMD_STATE_NEED_THREAD_CTX: TRACE_DBG("Dev handler %s parse() requested thread " @@ -441,6 +467,13 @@ set_dir = 0; break; + case SCST_CMD_STATE_REINIT: + cmd->tgt_dev_saved = tgt_dev_saved; + cmd->state = state; + res = SCST_CMD_STATE_RES_RESTART; + set_dir = 0; + break; + default: if (state >= 0) { PRINT_ERROR_PR("Dev handler %s parse() returned " @@ -574,19 +607,34 @@ TRACE_ENTRY(); - if (cmd->data_direction == SCST_DATA_NONE) { - cmd->state = SCST_CMD_STATE_SEND_TO_MIDLEV; - goto out; - } + if (cmd->data_direction == SCST_DATA_NONE) + goto prep_done; r = scst_check_mem(cmd); if (unlikely(r != 0)) goto out; if (cmd->data_buf_tgt_alloc) { + int orig_bufflen = cmd->bufflen; TRACE_MEM("%s", "Custom tgt data buf allocation requested"); r = cmd->tgtt->alloc_data_buf(cmd); - cmd->data_buf_alloced = (r == 0); + if (r > 0) + r = scst_alloc_space(cmd); + else if (r == 0) { + cmd->data_buf_alloced = 1; + if (cmd->data_buf_alloced && + unlikely(orig_bufflen < cmd->bufflen)) { + PRINT_ERROR_PR("Target driver allocated data " + "buffer (size %d), is less, than " + "required (size %d)", orig_bufflen, + cmd->bufflen); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + cmd->state = SCST_CMD_STATE_DEV_DONE; + res = SCST_CMD_STATE_RES_CONT_SAME; + goto out; + } + } } else r = scst_alloc_space(cmd); @@ -600,6 +648,27 @@ goto out_no_space; } +prep_done: + if (cmd->preprocessing_only) { + if (scst_cmd_atomic(cmd) && + !cmd->tgtt->preprocessing_done_atomic) { + TRACE_DBG("%s", "preprocessing_done() can not be " + "called in atomic context, rescheduling to " + "the thread"); + res = SCST_CMD_STATE_RES_NEED_THREAD; + goto out; + } + + res = SCST_CMD_STATE_RES_CONT_NEXT; + cmd->state = SCST_CMD_STATE_PREPROCESS_DONE; + + TRACE_DBG("Calling preprocessing_done(cmd %p)", cmd); + cmd->tgtt->preprocessing_done(cmd); + TRACE_DBG("%s", "preprocessing_done() returned"); + goto out; + + } + switch (cmd->data_direction) { case SCST_DATA_WRITE: cmd->state = SCST_CMD_STATE_RDY_TO_XFER; @@ -624,6 +693,81 @@ goto out; } +void scst_restart_cmd(struct scst_cmd *cmd, int status, int pref_context) +{ + TRACE_ENTRY(); + + TRACE_DBG("Preferred context: %d", pref_context); + TRACE_DBG("tag=%d, status=%#x", scst_cmd_get_tag(cmd), status); + cmd->non_atomic_only = 0; + +#ifdef EXTRACHECKS + if (in_irq() && ((pref_context == SCST_CONTEXT_DIRECT) || + (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) + { + PRINT_ERROR_PR("Wrong context %d in IRQ from target %s, use " + "SCST_CONTEXT_TASKLET instead\n", pref_context, + cmd->tgtt->name); + pref_context = SCST_CONTEXT_TASKLET; + } +#endif + + switch (status) { + case SCST_PREPROCESS_STATUS_SUCCESS: + switch (cmd->data_direction) { + case SCST_DATA_WRITE: + cmd->state = SCST_CMD_STATE_RDY_TO_XFER; + break; + default: + cmd->state = SCST_CMD_STATE_SEND_TO_MIDLEV; + break; + } + if (cmd->no_sn) { + unsigned long flags; + int rc; + spin_lock_irqsave(&scst_list_lock, flags); + /* Necessary to keep the command's order */ + rc = scst_do_job_init(); + if (unlikely(rc > 0)) { + TRACE_DBG("Adding cmd %p to init cmd list", + cmd); + list_add_tail(&cmd->cmd_list_entry, + &scst_init_cmd_list); + spin_unlock_irqrestore(&scst_list_lock, flags); + goto out; + } + scst_cmd_set_sn(cmd); + spin_unlock_irqrestore(&scst_list_lock, flags); + } + break; + + case SCST_PREPROCESS_STATUS_ERROR_SENSE_SET: + cmd->state = SCST_CMD_STATE_DEV_DONE; + break; + + case SCST_PREPROCESS_STATUS_ERROR_FATAL: + set_bit(SCST_CMD_NO_RESP, &cmd->cmd_flags); + /* go through */ + case SCST_PREPROCESS_STATUS_ERROR: + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); + cmd->state = SCST_CMD_STATE_DEV_DONE; + break; + + default: + PRINT_ERROR_PR("scst_rx_data() received unknown status %x", + status); + cmd->state = SCST_CMD_STATE_DEV_DONE; + break; + } + + scst_proccess_redirect_cmd(cmd, pref_context, 1); + +out: + TRACE_EXIT(); + return; +} + /* No locks */ static int scst_queue_retry_cmd(struct scst_cmd *cmd, int finished_cmds) { @@ -682,6 +826,12 @@ goto out_dev_done; } + if (cmd->tgtt->rdy_to_xfer == NULL) { + cmd->state = SCST_CMD_STATE_SEND_TO_MIDLEV; + res = SCST_CMD_STATE_RES_CONT_SAME; + goto out; + } + if (atomic && !cmd->tgtt->rdy_to_xfer_atomic) { TRACE_DBG("%s", "rdy_to_xfer() can not be " "called in atomic context, rescheduling to the thread"); @@ -817,6 +967,7 @@ TRACE(TRACE_SCSI, "tag=%d status=%#x", scst_cmd_get_tag(cmd), status); cmd->non_atomic_only = 0; +#ifdef EXTRACHECKS if (in_irq() && ((pref_context == SCST_CONTEXT_DIRECT) || (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) { @@ -825,6 +976,7 @@ cmd->tgtt->name); pref_context = SCST_CONTEXT_TASKLET; } +#endif switch (status) { case SCST_RX_STATUS_SUCCESS: @@ -886,12 +1038,13 @@ if (rq_sense != NULL) { sense_valid = SCST_SENSE_VALID(rq_sense); if (sense_valid) { - memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); /* * We checked that rq_sense_len < sizeof(cmd->sense_buffer) * in init_scst() */ memcpy(cmd->sense_buffer, rq_sense, rq_sense_len); + memset(&cmd->sense_buffer[rq_sense_len], 0, + sizeof(cmd->sense_buffer) - rq_sense_len); } } else sense_valid = SCST_SENSE_VALID(cmd->sense_buffer); @@ -1164,7 +1317,7 @@ { TRACE_ENTRY(); - BUG_ON(in_irq()); + sBUG_ON(in_irq()); scst_dec_on_dev_cmd(cmd); @@ -1773,11 +1926,13 @@ scst_dec_on_dev_cmd(cmd); goto out_dec_cmd_count; } else { - BUG_ON(rc != SCST_EXEC_COMPLETED); + sBUG_ON(rc != SCST_EXEC_COMPLETED); goto out_unplug; } } + EXTRACHECKS_BUG_ON(cmd->no_sn); + expected_sn = tgt_dev->expected_sn; if (cmd->sn != expected_sn) { spin_lock_bh(&tgt_dev->sn_lock); @@ -1815,7 +1970,7 @@ else goto out_dec_cmd_count; } - BUG_ON(rc != SCST_EXEC_COMPLETED); + sBUG_ON(rc != SCST_EXEC_COMPLETED); /* !! At this point cmd can be already freed !! */ count++; expected_sn = __scst_inc_expected_sn(tgt_dev); @@ -2189,7 +2344,7 @@ { TRACE_ENTRY(); - BUG_ON(cmd->state != SCST_CMD_STATE_XMIT_WAIT); + sBUG_ON(cmd->state != SCST_CMD_STATE_XMIT_WAIT); cmd->state = SCST_CMD_STATE_FINISHED; scst_proccess_redirect_cmd(cmd, scst_get_context(), 1); @@ -2243,7 +2398,7 @@ static int scst_translate_lun(struct scst_cmd *cmd) { struct scst_tgt_dev *tgt_dev = NULL; - int res = 0; + int res; TRACE_ENTRY(); @@ -2279,15 +2434,6 @@ tgt_dev->cmd_count++; cmd->dev = tgt_dev->acg_dev->dev; - /* ToDo: cmd->queue_type */ - - /* scst_list_lock is enough to protect that */ - cmd->sn = tgt_dev->next_sn; - tgt_dev->next_sn++; - - TRACE(TRACE_DEBUG/*TRACE_SCSI_SERIALIZING*/, - "cmd->sn: %d", cmd->sn); - res = 0; break; } @@ -2320,6 +2466,11 @@ TRACE_ENTRY(); + if (unlikely(cmd->tgt_dev)) { + scst_cmd_set_sn(cmd); + goto out_move; + } + res = scst_translate_lun(cmd); if (likely(res == 0)) { cmd->state = SCST_CMD_STATE_DEV_PARSE; @@ -2330,18 +2481,21 @@ "Anonymous" : cmd->sess->initiator_name); scst_set_busy(cmd); cmd->state = SCST_CMD_STATE_XMIT_RESP; - } - TRACE_DBG("Moving cmd %p to active cmd list", cmd); - list_move_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); + } else if (!cmd->no_sn) + scst_cmd_set_sn(cmd); } else if (res < 0) { TRACE_DBG("Finishing cmd %p", cmd); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_lun_not_supported)); cmd->state = SCST_CMD_STATE_XMIT_RESP; - TRACE_DBG("Moving cmd %p to active cmd list", cmd); - list_move_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); - } + } else + goto out; +out_move: + TRACE_DBG("Moving cmd %p to active cmd list", cmd); + list_move_tail(&cmd->cmd_list_entry, &scst_active_cmd_list); + +out: TRACE_EXIT_RES(res); return res; } @@ -2352,22 +2506,24 @@ * have to be serialized, i.e. commands must be executed in order * of their arrival, and we set this order inside scst_translate_lun(). */ -static int scst_do_job_init(struct list_head *init_cmd_list) +static int scst_do_job_init(void) { - int res = 1; + int res = 0; TRACE_ENTRY(); - if (!test_bit(SCST_FLAG_SUSPENDED, &scst_flags)) { - while (!list_empty(init_cmd_list)) { - struct scst_cmd *cmd = list_entry(init_cmd_list->next, - typeof(*cmd), + if (likely(!test_bit(SCST_FLAG_SUSPENDED, &scst_flags))) { + while (!list_empty(&scst_init_cmd_list)) { + struct scst_cmd *cmd = list_entry( + scst_init_cmd_list.next, typeof(*cmd), cmd_list_entry); res = scst_process_init_cmd(cmd); if (res > 0) break; + /* For DIRECT context the cmd is always the last */ } - } + } else + res = 1; TRACE_EXIT_RES(res); return res; @@ -2381,9 +2537,7 @@ TRACE_ENTRY(); -#ifdef EXTRACHECKS - BUG_ON(in_irq()); -#endif + EXTRACHECKS_BUG_ON(in_irq()); cmd->atomic = ((context & ~SCST_PROCESSIBLE_ENV) == SCST_CONTEXT_DIRECT_ATOMIC); @@ -2421,9 +2575,9 @@ break; default: - PRINT_ERROR("cmd (%p) in state %d, but shouldn't be", + PRINT_ERROR_PR("cmd (%p) in state %d, but shouldn't be", cmd, cmd->state); - BUG(); + sBUG(); res = SCST_CMD_STATE_RES_CONT_NEXT; break; } @@ -2454,7 +2608,7 @@ "useful list (left on scst cmd list)", cmd, cmd->state); spin_unlock_irq(&scst_list_lock); - BUG(); + sBUG(); spin_lock_irq(&scst_list_lock); break; #endif @@ -2473,16 +2627,16 @@ if (!left_locked) spin_unlock_irq(&scst_list_lock); } else - BUG(); + sBUG(); } else - BUG(); + sBUG(); TRACE_EXIT_RES(res); return res; } /* Called under scst_list_lock and IRQs disabled */ -static void scst_do_job_active(struct list_head *active_cmd_list, int context) +static void scst_do_job_active(int context) { int res; struct scst_cmd *cmd; @@ -2502,7 +2656,7 @@ tm_dbg_check_released_cmds(); restart: - list_for_each_entry(cmd, active_cmd_list, cmd_list_entry) { + list_for_each_entry(cmd, &scst_active_cmd_list, cmd_list_entry) { if (atomic && cmd->non_atomic_only) { TRACE(TRACE_DEBUG, "Skipping non-atomic cmd %p", cmd); continue; @@ -2517,7 +2671,7 @@ } else if (res == SCST_CMD_STATE_RES_RESTART) { break; } else - BUG(); + sBUG(); } TRACE_EXIT(); @@ -2569,9 +2723,8 @@ remove_wait_queue(&scst_list_waitQ, &wait); } - scst_do_job_init(&scst_init_cmd_list); - scst_do_job_active(&scst_active_cmd_list, - SCST_CONTEXT_DIRECT|SCST_PROCESSIBLE_ENV); + scst_do_job_init(); + scst_do_job_active(SCST_CONTEXT_DIRECT|SCST_PROCESSIBLE_ENV); if (unlikely(test_bit(SCST_FLAG_SHUTDOWN, &scst_flags)) && list_empty(&scst_cmd_list) && @@ -2603,9 +2756,8 @@ spin_lock_irq(&scst_list_lock); - scst_do_job_init(&scst_init_cmd_list); - scst_do_job_active(&scst_active_cmd_list, - SCST_CONTEXT_DIRECT_ATOMIC|SCST_PROCESSIBLE_ENV); + scst_do_job_init(); + scst_do_job_active(SCST_CONTEXT_DIRECT_ATOMIC|SCST_PROCESSIBLE_ENV); spin_unlock_irq(&scst_list_lock); @@ -2705,9 +2857,7 @@ int irq = irqs_disabled(); TRACE_MGMT_DBG("Calling dev handler %s task_mgmt_fn(fn=%d)", tgt_dev->acg_dev->dev->handler->name, mcmd->fn); -#ifdef EXTRACHECKS - BUG_ON(in_irq()); -#endif + EXTRACHECKS_BUG_ON(in_irq()); if (!irq) local_bh_disable(); res = tgt_dev->acg_dev->dev->handler->task_mgmt_fn(mcmd, @@ -2716,11 +2866,8 @@ local_bh_enable(); TRACE_MGMT_DBG("Dev handler %s task_mgmt_fn() returned %d", tgt_dev->acg_dev->dev->handler->name, res); - if (set_status && (res != SCST_DEV_TM_NOT_COMPLETED)) { - mcmd->status = (res == SCST_DEV_TM_COMPLETED_SUCCESS) ? - SCST_MGMT_STATUS_SUCCESS : - SCST_MGMT_STATUS_FAILED; - } + if (set_status && (res != SCST_DEV_TM_NOT_COMPLETED)) + mcmd->status = res; } return res; } @@ -2757,7 +2904,7 @@ smp_mb__after_set_bit(); if (call_dev_task_mgmt_fn && cmd->tgt_dev) - scst_call_dev_task_mgmt_fn(mcmd, cmd->tgt_dev, 0); + scst_call_dev_task_mgmt_fn(mcmd, cmd->tgt_dev, 1); if (mcmd) { int defer; @@ -2790,7 +2937,7 @@ cmd->mgmt_cmnd, mcmd); } #endif - BUG_ON(cmd->mgmt_cmnd); + sBUG_ON(cmd->mgmt_cmnd); mcmd->cmd_wait_count++; cmd->mgmt_cmnd = mcmd; } @@ -2956,7 +3103,7 @@ if (cmd == NULL) { TRACE(TRACE_MGMT, "ABORT TASK failed: command for " "tag %d not found", mcmd->tag); - mcmd->status = SCST_MGMT_STATUS_FAILED; + mcmd->status = SCST_MGMT_STATUS_TASK_NOT_EXIST; mcmd->state = SCST_MGMT_CMD_STATE_DONE; } else { TRACE(TRACE_MGMT, "Cmd %p for tag %d (sn %d) found, " @@ -2974,7 +3121,7 @@ if (rc < 0) { PRINT_ERROR_PR("Corresponding device for lun %Ld not " "found", (uint64_t)mcmd->lun); - mcmd->status = SCST_MGMT_STATUS_FAILED; + mcmd->status = SCST_MGMT_STATUS_LUN_NOT_EXIST; mcmd->state = SCST_MGMT_CMD_STATE_DONE; } else if (rc == 0) mcmd->state = SCST_MGMT_CMD_STATE_READY; @@ -3020,8 +3167,9 @@ rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev, 0); if (rc == SCST_DEV_TM_NOT_COMPLETED) c = 1; - else if (rc == SCST_DEV_TM_COMPLETED_FAILED) - mcmd->status = SCST_MGMT_STATUS_FAILED; + else if ((rc < 0) && + (mcmd->status == SCST_MGMT_STATUS_SUCCESS)) + mcmd->status = rc; } if (cont && !c) continue; @@ -3054,7 +3202,8 @@ TRACE(TRACE_MGMT, "Result of host %d bus reset: %s", dev->scsi_dev->host->host_no, (rc == SUCCESS) ? "SUCCESS" : "FAILED"); - if (rc != SUCCESS) { + if ((rc != SUCCESS) && + (mcmd->status == SCST_MGMT_STATUS_SUCCESS)) { /* SCSI_TRY_RESET_BUS is also done by scsi_reset_provider() */ mcmd->status = SCST_MGMT_STATUS_FAILED; } @@ -3101,7 +3250,7 @@ TRACE(TRACE_MGMT, "Resetting host %d bus ", dev->scsi_dev->host->host_no); rc = scsi_reset_provider(dev->scsi_dev, SCSI_TRY_RESET_DEVICE); - if (rc != SUCCESS) + if ((rc != SUCCESS) && (mcmd->status == SCST_MGMT_STATUS_SUCCESS)) mcmd->status = SCST_MGMT_STATUS_FAILED; dev->scsi_dev->was_reset = 0; } @@ -3146,8 +3295,8 @@ spin_unlock_bh(&dev->dev_lock); rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev, 0); - if (rc == SCST_DEV_TM_COMPLETED_FAILED) - mcmd->status = SCST_MGMT_STATUS_FAILED; + if ((rc < 0) && (mcmd->status == SCST_MGMT_STATUS_SUCCESS)) + mcmd->status = rc; __scst_abort_task_set(mcmd, tgt_dev, !nexus_loss, 1); if (nexus_loss) @@ -3198,8 +3347,9 @@ int rc; rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev, 0); - if (rc == SCST_DEV_TM_COMPLETED_FAILED) - mcmd->status = SCST_MGMT_STATUS_FAILED; + if ((rc < 0) &... [truncated message content] |
From: <vl...@us...> - 2006-12-14 17:08:54
|
Revision: 57 http://svn.sourceforge.net/scst/?rev=57&view=rev Author: vlnb Date: 2006-12-14 09:08:46 -0800 (Thu, 14 Dec 2006) Log Message: ----------- /proc implementation moved to seq_*() library. Mostly done by Ming Zhang. Modified Paths: -------------- trunk/mpt/mpt_scst.c trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/scst/include/scsi_tgt.h trunk/scst/src/dev_handlers/scst_dev_handler.h trunk/scst/src/dev_handlers/scst_fileio.c trunk/scst/src/scst.c trunk/scst/src/scst_proc.c Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/mpt/mpt_scst.c 2006-12-14 17:08:46 UTC (rev 57) @@ -287,7 +287,7 @@ .rdy_to_xfer = mpt_rdy_to_xfer, .on_free_cmd = mpt_on_free_cmd, .task_mgmt_fn_done = mpt_task_mgmt_fn_done, - .proc_info = mpt_proc_info, +//ToDo: .proc_info = mpt_proc_info, }; static inline void Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-14 17:08:46 UTC (rev 57) @@ -28,7 +28,7 @@ #include <scsi/scsi_host.h> #include <linux/pci.h> #include <linux/delay.h> - +#include <linux/seq_file.h> #include <linux/list.h> #include <scsi_tgt.h> @@ -2054,36 +2054,40 @@ #include <linux/proc_fs.h> -static int qla2x00t_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) +static int q2t_log_info_show(struct seq_file *seq, void *v) { int res = 0; TRACE_ENTRY(); - res = scst_proc_log_entry_read(buffer, start, offset, length, eof, - data, trace_flag, NULL); + res = scst_proc_log_entry_read(seq, trace_flag, NULL); + TRACE_EXIT_RES(res); return res; } -static int qla2x00t_proc_log_entry_write(struct file *file, const char *buf, - unsigned long length, void *data) +static int q2t_proc_log_entry_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { int res = 0; TRACE_ENTRY(); - res = scst_proc_log_entry_write(file, buf, length, data, - &trace_flag, SCST_DEFAULT_QLA_LOG_FLAGS, NULL); + res = scst_proc_log_entry_write(file, buf, length, &trace_flag, + SCST_DEFAULT_QLA_LOG_FLAGS, NULL); TRACE_EXIT_RES(res); return res; } + + +static struct scst_proc_data q2t_log_proc_data = { + SCST_DEF_RW_SEQ_OP(q2t_proc_log_entry_write) + .show = q2t_log_info_show, +}; #endif -static int qla2x00t_proc_log_entry_build(struct scst_tgt_template *templ) +static int q2t_proc_log_entry_build(struct scst_tgt_template *templ) { int res = 0; #if defined(DEBUG) || defined(TRACING) @@ -2094,10 +2098,9 @@ if (root) { /* create the proc file entry for the device */ - p = create_proc_read_entry(Q2T_PROC_LOG_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, root, - qla2x00t_proc_log_entry_read, - (void *)templ->name); + q2t_log_proc_data.data = (void *)templ->name; + p = scst_create_proc_entry(root, Q2T_PROC_LOG_ENTRY_NAME, + &q2t_log_proc_data); if (p == NULL) { PRINT_ERROR("Not enough memory to register " "target driver %s entry %s in /proc", @@ -2105,7 +2108,6 @@ res = -ENOMEM; goto out; } - p->write_proc = qla2x00t_proc_log_entry_write; } out: @@ -2115,7 +2117,7 @@ return res; } -static void qla2x00t_proc_log_entry_clean(struct scst_tgt_template *templ) +static void q2t_proc_log_entry_clean(struct scst_tgt_template *templ) { #if defined(DEBUG) || defined(TRACING) struct proc_dir_entry *root; @@ -2131,7 +2133,7 @@ #endif } -static int __init qla2x00t_init(void) +static int __init q2t_init(void) { int res = 0; @@ -2154,7 +2156,7 @@ * called via scst_register_target_template() */ - res = qla2x00t_proc_log_entry_build(&tgt_template); + res = q2t_proc_log_entry_build(&tgt_template); if (res < 0) { goto out_unreg_target; } @@ -2169,11 +2171,11 @@ goto out; } -static void __exit qla2x00t_exit(void) +static void __exit q2t_exit(void) { TRACE_ENTRY(); - qla2x00t_proc_log_entry_clean(&tgt_template); + q2t_proc_log_entry_clean(&tgt_template); scst_unregister_target_template(&tgt_template); @@ -2185,8 +2187,8 @@ return; } -module_init(qla2x00t_init); -module_exit(qla2x00t_exit); +module_init(q2t_init); +module_exit(q2t_exit); MODULE_AUTHOR("Vladislav Bolkhovitin & Leonid Stoljar & Nathaniel Clark"); MODULE_DESCRIPTION("Target mode logic for qla2xxx"); Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/scst/include/scsi_tgt.h 2006-12-14 17:08:46 UTC (rev 57) @@ -24,10 +24,15 @@ #include <linux/version.h> #include <linux/blkdev.h> #include <linux/interrupt.h> +#include <linux/proc_fs.h> + #ifdef SCST_HIGHMEM #include <asm/kmap_types.h> #endif -#include <../drivers/scsi/scsi.h> +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> +#include <scsi/scsi_eh.h> +#include <scsi/scsi.h> /* Version numbers, the same as for the kernel */ #define SCST_VERSION_CODE 0x000906 @@ -694,14 +699,15 @@ */ int (*report_aen) (int mgmt_fn, const uint8_t *lun, int lun_len); - /* - * This function can be used to export the driver's statistics and - * other infos to the world outside the kernel. + /* + * Those functions can be used to export the driver's statistics and + * other infos to the world outside the kernel. * * OPTIONAL */ - int (*proc_info) (char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_tgt *tgt, int inout); + int (*read_proc) (struct seq_file *seq, struct scst_tgt *tgt); + int (*write_proc) (char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_tgt *tgt); /* * Name of the template. Must be unique to identify @@ -836,15 +842,15 @@ int (*task_mgmt_fn) (struct scst_mgmt_cmd *mgmt_cmd, struct scst_tgt_dev *tgt_dev); - /* - * This function can be used to export the handler's statistics and - * other infos to the world outside the kernel. + /* + * Those functions can be used to export the handler's statistics and + * other infos to the world outside the kernel. * * OPTIONAL */ - int (*proc_info) (char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_dev_type *dev_type, - int inout); + int (*read_proc) (struct seq_file *seq, struct scst_dev_type *dev_type); + int (*write_proc) (char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_dev_type *dev_type); struct module *module; @@ -2149,15 +2155,38 @@ const char *token; }; -int scst_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, void *data, - unsigned long log_level, const struct scst_proc_log *tbl); +int scst_proc_log_entry_read(struct seq_file *seq, unsigned long log_level, + const struct scst_proc_log *tbl); int scst_proc_log_entry_write(struct file *file, const char *buf, - unsigned long length, void *data, unsigned long *log_level, + unsigned long length, unsigned long *log_level, unsigned long default_level, const struct scst_proc_log *tbl); /* + * helper data structure and function to create proc entry. + */ +struct scst_proc_data { + struct file_operations seq_op; + int (*show)(struct seq_file *, void *); + void *data; +}; + +int scst_single_seq_open(struct inode *inode, struct file *file); + +struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry * root, + const char *name, struct scst_proc_data *pdata); + +#define SCST_DEF_RW_SEQ_OP(x) \ + .seq_op = { \ + .owner = THIS_MODULE, \ + .open = scst_single_seq_open,\ + .read = seq_read, \ + .write = x, \ + .llseek = seq_lseek, \ + .release = single_release, \ + }, + +/* * Adds and deletes (stops) num SCST's threads. Returns 0 on success, * error code otherwise. */ Modified: trunk/scst/src/dev_handlers/scst_dev_handler.h =================================================================== --- trunk/scst/src/dev_handlers/scst_dev_handler.h 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/scst/src/dev_handlers/scst_dev_handler.h 2006-12-14 17:08:46 UTC (rev 57) @@ -8,6 +8,7 @@ #include <linux/module.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #ifdef DEBUG #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_PID | \ @@ -17,28 +18,28 @@ #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR) #endif -static int scst_dev_handler_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, void *data) +static struct scst_proc_data dev_handler_log_proc_data; + +static int dev_handler_log_info_show(struct seq_file *seq, void *v) { int res = 0; TRACE_ENTRY(); - res = scst_proc_log_entry_read(buffer, start, offset, length, eof, - data, trace_flag, NULL); + res = scst_proc_log_entry_read(seq, trace_flag, NULL); TRACE_EXIT_RES(res); return res; } -static int scst_dev_handler_proc_log_entry_write(struct file *file, - const char *buf, unsigned long length, void *data) +static int scst_dev_handler_proc_log_entry_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { int res = 0; TRACE_ENTRY(); - res = scst_proc_log_entry_write(file, buf, length, data, - &trace_flag, SCST_DEFAULT_DEV_LOG_FLAGS, NULL); + res = scst_proc_log_entry_write(file, buf, length, &trace_flag, + SCST_DEFAULT_DEV_LOG_FLAGS, NULL); TRACE_EXIT_RES(res); return res; @@ -57,10 +58,9 @@ if (root) { /* create the proc file entry for the device */ - p = create_proc_read_entry(DEV_HANDLER_LOG_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, root, - scst_dev_handler_proc_log_entry_read, - (void *)dev_type->name); + dev_handler_log_proc_data.data = (void *)dev_type->name; + p = scst_create_proc_entry(root, DEV_HANDLER_LOG_ENTRY_NAME, + &dev_handler_log_proc_data); if (p == NULL) { PRINT_ERROR_PR("Not enough memory to register dev " "handler %s entry %s in /proc", @@ -68,7 +68,6 @@ res = -ENOMEM; goto out; } - p->write_proc = scst_dev_handler_proc_log_entry_write; } out: @@ -93,3 +92,9 @@ #endif } +#if defined(DEBUG) || defined(TRACING) +static struct scst_proc_data dev_handler_log_proc_data = { + SCST_DEF_RW_SEQ_OP(scst_dev_handler_proc_log_entry_write) + .show = dev_handler_log_info_show, +}; +#endif Modified: trunk/scst/src/dev_handlers/scst_fileio.c =================================================================== --- trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 17:08:46 UTC (rev 57) @@ -141,12 +141,12 @@ static void fileio_exec_prevent_allow_medium_removal(struct scst_cmd *cmd); static int fileio_fsync(struct scst_fileio_tgt_dev *ftgt_dev, loff_t loff, loff_t len, struct scst_cmd *cmd); -static int disk_fileio_proc(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_dev_type *dev_type, int inout); -static int cdrom_fileio_proc(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_dev_type *dev_type, int inout); -static int fileio_proc_help_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data); +static int disk_fileio_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type); +static int disk_fileio_write_proc(char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_dev_type *dev_type); +static int cdrom_fileio_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type); +static int cdrom_fileio_write_proc(char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_dev_type *dev_type); #define DISK_TYPE_FILEIO { \ name: DISK_FILEIO_NAME, \ @@ -161,7 +161,8 @@ parse: disk_fileio_parse, \ exec: disk_fileio_exec, \ task_mgmt_fn: fileio_task_mgmt_fn, \ - proc_info: disk_fileio_proc, \ + read_proc: disk_fileio_read_proc, \ + write_proc: disk_fileio_write_proc, \ } #define CDROM_TYPE_FILEIO { \ @@ -177,7 +178,8 @@ parse: cdrom_fileio_parse, \ exec: cdrom_fileio_exec, \ task_mgmt_fn: fileio_task_mgmt_fn, \ - proc_info: cdrom_fileio_proc, \ + read_proc: cdrom_fileio_read_proc, \ + write_proc: cdrom_fileio_write_proc,\ } DECLARE_MUTEX(scst_fileio_mutex); @@ -2262,349 +2264,285 @@ return dev; } -struct fileio_proc_update_struct { - int len, plen, pplen; - off_t begin, pbegin, ppbegin; - off_t pos; -}; - -static int fileio_proc_update_size(int size, off_t offset, int length, - struct fileio_proc_update_struct *p, int is_start) +/* + * Called when a file in the /proc/DISK_FILEIO_NAME/DISK_FILEIO_NAME is read + */ +static int disk_fileio_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type) { int res = 0; - if (size > 0) { - p->len += size; - p->pos = p->begin + p->len; - if (p->pos <= offset) { - p->len = 0; - p->begin = p->pos; - } else if (p->pos >= offset + length) { - res = 1; - goto out; - } else - res = 0; - } else { - p->begin = p->ppbegin; - p->len = p->pplen; - res = 1; + struct scst_fileio_dev *virt_dev; + + TRACE_ENTRY(); + + if (down_interruptible(&scst_fileio_mutex) != 0) { + res = -EINTR; goto out; } - if (is_start) { - p->ppbegin = p->pbegin; - p->pplen = p->plen; - p->pbegin = p->begin; - p->plen = p->len; + + seq_printf(seq, "%-17s %-11s %-11s %-15s %s\n", + "Name", "Size(MB)", "Block size", "Options", "File name"); + + list_for_each_entry(virt_dev, &disk_fileio_dev_list, fileio_dev_list_entry) { + int c; + seq_printf(seq, "%-17s %-11d %-12d", virt_dev->name, + (uint32_t)(virt_dev->file_size >> 20), + virt_dev->block_size); + c = 0; + if (virt_dev->wt_flag) { + seq_printf(seq, "WT "); + c += 3; + } + if (virt_dev->nv_cache) { + seq_printf(seq, "NV "); + c += 3; + } + if (virt_dev->rd_only_flag) { + seq_printf(seq, "RO "); + c += 3; + } + if (virt_dev->o_direct_flag) { + seq_printf(seq, "DR "); + c += 3; + } + if (virt_dev->nullio) { + seq_printf(seq, "NIO "); + c += 4; + } + while (c < 16) { + seq_printf(seq, " "); + c++; + } + seq_printf(seq, "%s\n", virt_dev->file_name); } + up(&scst_fileio_mutex); out: + TRACE_EXIT_RES(res); return res; } /* - * Called when a file in the /proc/DISK_FILEIO_NAME/DISK_FILEIO_NAME is read - * or written + * Called when a file in the /proc/DISK_FILEIO_NAME/DISK_FILEIO_NAME is written */ -static int disk_fileio_proc(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_dev_type *dev_type, int inout) +static int disk_fileio_write_proc(char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_dev_type *dev_type) { int res = 0, action; char *p, *name, *file_name; struct scst_fileio_dev *virt_dev, *vv; - int size; - struct fileio_proc_update_struct pu; + uint32_t block_size = DEF_DISK_BLOCKSIZE; + int block_shift = DEF_DISK_BLOCKSIZE_SHIFT; + size_t len; TRACE_ENTRY(); - - memset(&pu, 0, sizeof(pu)); /* VERY UGLY code. You can rewrite it if you want */ + + if (buffer[0] == '\0') + goto out; if (down_interruptible(&scst_fileio_mutex) != 0) { res = -EINTR; goto out; } - - if (inout == 0) { /* read */ - size = scnprintf(buffer, length, "%-17s %-11s %-11s %-15s %s\n", - "Name", "Size(MB)", "Block size", "Options", "File name"); - if (fileio_proc_update_size(size, offset, length, &pu, 1)) - goto stop_output; - list_for_each_entry(virt_dev, &disk_fileio_dev_list, - fileio_dev_list_entry) + p = buffer; + if (p[strlen(p) - 1] == '\n') { + p[strlen(p) - 1] = '\0'; + } + if (!strncmp("close ", p, 6)) { + p += 6; + action = 0; + } else if (!strncmp("open ", p, 5)) { + p += 5; + action = 2; + } else { + PRINT_ERROR_PR("Unknown action \"%s\"", p); + res = -EINVAL; + goto out_up; + } + + while (isspace(*p) && *p != '\0') + p++; + name = p; + while (!isspace(*p) && *p != '\0') + p++; + *p++ = '\0'; + if (*name == '\0') { + PRINT_ERROR_PR("%s", "Name required"); + res = -EINVAL; + goto out_up; + } else if (strlen(name) >= sizeof(virt_dev->name)) { + PRINT_ERROR_PR("Name is too long (max %zd " + "characters)", sizeof(virt_dev->name)-1); + res = -EINVAL; + goto out_up; + } + + if (action) { /* open */ + virt_dev = NULL; + list_for_each_entry(vv, &disk_fileio_dev_list, + fileio_dev_list_entry) { - int c; - size = scnprintf(buffer + pu.len, length - pu.len, - "%-17s %-11d %-12d", virt_dev->name, - (uint32_t)(virt_dev->file_size >> 20), - virt_dev->block_size); - if (fileio_proc_update_size(size, offset, length, &pu, - 1)) { - goto stop_output; + if (strcmp(vv->name, name) == 0) { + virt_dev = vv; + break; } - c = 0; - if (virt_dev->wt_flag) { - size = scnprintf(buffer + pu.len, length - pu.len, "WT"); - c += size; - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - } - if (virt_dev->nv_cache) { - size = scnprintf(buffer + pu.len, length - pu.len, - c ? ",NV" : "NV"); - c += size; - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - } - if (virt_dev->rd_only_flag) { - size = scnprintf(buffer + pu.len, length - pu.len, - c ? ",RO" : "RO"); - c += size; - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - } - if (virt_dev->o_direct_flag) { - size = scnprintf(buffer + pu.len, length - pu.len, - c ? ",DR" : "DR"); - c += size; - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - } - if (virt_dev->nullio) { - size = scnprintf(buffer + pu.len, length - pu.len, - c ? ",NIO" : "NIO"); - c += size; - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - } - while (c < 16) { - size = scnprintf(buffer + pu.len, length - pu.len, " "); - if (fileio_proc_update_size(size, offset, - length, &pu, 0)) { - goto stop_output; - } - c++; - } - size = scnprintf(buffer + pu.len, length - pu.len, "%s\n", - virt_dev->file_name); - if (fileio_proc_update_size(size, offset, length, &pu, - 0)) { - goto stop_output; - } } - *eof = 1; - goto stop_output; - } else { /* write */ - uint32_t block_size = DEF_DISK_BLOCKSIZE; - int block_shift = DEF_DISK_BLOCKSIZE_SHIFT; - p = buffer; - if (p[strlen(p) - 1] == '\n') { - p[strlen(p) - 1] = '\0'; - } - if (!strncmp("close ", p, 6)) { - p += 6; - action = 0; - } else if (!strncmp("open ", p, 5)) { - p += 5; - action = 2; - } else { - PRINT_ERROR_PR("Unknown action \"%s\"", p); + if (virt_dev) { + PRINT_ERROR_PR("Virtual device with name " + "%s already exist", name); res = -EINVAL; goto out_up; } while (isspace(*p) && *p != '\0') p++; - name = p; + file_name = p; while (!isspace(*p) && *p != '\0') p++; *p++ = '\0'; - if (*name == '\0') { - PRINT_ERROR_PR("%s", "Name required"); + if (*file_name == '\0') { + PRINT_ERROR_PR("%s", "File name required"); res = -EINVAL; goto out_up; - } else if (strlen(name) >= sizeof(virt_dev->name)) { - PRINT_ERROR_PR("Name is too long (max %zd " - "characters)", sizeof(virt_dev->name)-1); + } else if (*file_name != '/') { + PRINT_ERROR_PR("File path \"%s\" is not " + "absolute", file_name); res = -EINVAL; goto out_up; } - if (action) { /* open */ - virt_dev = NULL; - list_for_each_entry(vv, &disk_fileio_dev_list, - fileio_dev_list_entry) - { - if (strcmp(vv->name, name) == 0) { - virt_dev = vv; - break; - } - } - if (virt_dev) { - PRINT_ERROR_PR("Virtual device with name " - "%s already exist", name); + virt_dev = fileio_alloc_dev(); + if (virt_dev == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", + "Allocation of virt_dev failed"); + res = -ENOMEM; + goto out_up; + } + + while (isspace(*p) && *p != '\0') + p++; + + if (isdigit(*p)) { + char *pp; + uint32_t t; + block_size = simple_strtoul(p, &pp, 0); + p = pp; + if ((*p != '\0') && !isspace(*p)) { + PRINT_ERROR_PR("Parse error: \"%s\"", p); res = -EINVAL; - goto out_up; + goto out_free_vdev; } - while (isspace(*p) && *p != '\0') p++; - file_name = p; - while (!isspace(*p) && *p != '\0') - p++; - *p++ = '\0'; - if (*file_name == '\0') { - PRINT_ERROR_PR("%s", "File name required"); + + t = block_size; + block_shift = 0; + while(1) { + if ((t & 1) != 0) + break; + t >>= 1; + block_shift++; + } + if (block_shift < 9) { + PRINT_ERROR_PR("Wrong block size %d", + block_size); res = -EINVAL; - goto out_up; - } else if (*file_name != '/') { - PRINT_ERROR_PR("File path \"%s\" is not " - "absolute", file_name); + goto out_free_vdev; + } + } + virt_dev->block_size = block_size; + virt_dev->block_shift = block_shift; + + while (*p != '\0') { + if (!strncmp("WRITE_THROUGH", p, 13)) { + p += 13; + virt_dev->wt_flag = 1; + TRACE_DBG("%s", "WRITE_THROUGH"); + } else if (!strncmp("NV_CACHE", p, 8)) { + p += 8; + virt_dev->nv_cache = 1; + TRACE_DBG("%s", "NON-VOLATILE CACHE"); + } else if (!strncmp("READ_ONLY", p, 9)) { + p += 9; + virt_dev->rd_only_flag = 1; + TRACE_DBG("%s", "READ_ONLY"); + } else if (!strncmp("O_DIRECT", p, 8)) { + p += 8; + #if 0 + + virt_dev->o_direct_flag = 1; + TRACE_DBG("%s", "O_DIRECT"); + #else + PRINT_INFO_PR("%s flag doesn't currently" + " work, ignoring it", "O_DIRECT"); + #endif + } else if (!strncmp("NULLIO", p, 6)) { + p += 6; + virt_dev->nullio = 1; + TRACE_DBG("%s", "NULLIO"); + } else { + PRINT_ERROR_PR("Unknown flag \"%s\"", p); res = -EINVAL; - goto out_up; + goto out_free_vdev; } - - virt_dev = fileio_alloc_dev(); - if (virt_dev == NULL) { - TRACE(TRACE_OUT_OF_MEM, "%s", - "Allocation of virt_dev failed"); - res = -ENOMEM; - goto out_up; - } - while (isspace(*p) && *p != '\0') p++; + } + + strcpy(virt_dev->name, name); - if (isdigit(*p)) { - char *pp; - uint32_t t; - block_size = simple_strtoul(p, &pp, 0); - p = pp; - if ((*p != '\0') && !isspace(*p)) { - PRINT_ERROR_PR("Parse error: \"%s\"", p); - res = -EINVAL; - goto out_free_vdev; - } - while (isspace(*p) && *p != '\0') - p++; + len = strlen(file_name) + 1; + virt_dev->file_name = kmalloc(len, GFP_KERNEL); + if (virt_dev->file_name == NULL) { + TRACE(TRACE_OUT_OF_MEM, "%s", + "Allocation of file_name failed"); + res = -ENOMEM; + goto out_free_vdev; + } + strncpy(virt_dev->file_name, file_name, len); - t = block_size; - block_shift = 0; - while(1) { - if ((t & 1) != 0) - break; - t >>= 1; - block_shift++; - } - if (block_shift < 9) { - PRINT_ERROR_PR("Wrong block size %d", - block_size); - res = -EINVAL; - goto out_free_vdev; - } - } - virt_dev->block_size = block_size; - virt_dev->block_shift = block_shift; - - while (*p != '\0') { - if (!strncmp("WRITE_THROUGH", p, 13)) { - p += 13; - virt_dev->wt_flag = 1; - TRACE_DBG("%s", "WRITE_THROUGH"); - } else if (!strncmp("NV_CACHE", p, 8)) { - p += 8; - virt_dev->nv_cache = 1; - TRACE_DBG("%s", "NON-VOLATILE CACHE"); - } else if (!strncmp("READ_ONLY", p, 9)) { - p += 9; - virt_dev->rd_only_flag = 1; - TRACE_DBG("%s", "READ_ONLY"); - } else if (!strncmp("O_DIRECT", p, 8)) { - p += 8; - #if 0 - - virt_dev->o_direct_flag = 1; - TRACE_DBG("%s", "O_DIRECT"); - #else - PRINT_INFO_PR("%s flag doesn't currently" - " work, ignoring it", "O_DIRECT"); - #endif - } else if (!strncmp("NULLIO", p, 6)) { - p += 6; - virt_dev->nullio = 1; - TRACE_DBG("%s", "NULLIO"); - } else { - PRINT_ERROR_PR("Unknown flag \"%s\"", p); - res = -EINVAL; - goto out_free_vdev; - } - while (isspace(*p) && *p != '\0') - p++; - } - - strcpy(virt_dev->name, name); + list_add_tail(&virt_dev->fileio_dev_list_entry, + &disk_fileio_dev_list); - pu.len = strlen(file_name) + 1; - virt_dev->file_name = kmalloc(pu.len, GFP_KERNEL); - if (virt_dev->file_name == NULL) { - TRACE(TRACE_OUT_OF_MEM, "%s", - "Allocation of file_name failed"); - res = -ENOMEM; - goto out_free_vdev; + virt_dev->virt_id = + scst_register_virtual_device(&disk_devtype_fileio, + virt_dev->name); + if (virt_dev->virt_id < 0) { + res = virt_dev->virt_id; + goto out_free_vpath; + } + TRACE_DBG("Added virt_dev (name %s, file name %s, " + "id %d, block size %d) to " + "disk_fileio_dev_list", virt_dev->name, + virt_dev->file_name, virt_dev->virt_id, + virt_dev->block_size); + } else { /* close */ + virt_dev = NULL; + list_for_each_entry(vv, &disk_fileio_dev_list, + fileio_dev_list_entry) + { + if (strcmp(vv->name, name) == 0) { + virt_dev = vv; + break; } - strncpy(virt_dev->file_name, file_name, pu.len); + } + if (virt_dev == NULL) { + PRINT_ERROR_PR("Device %s not found", name); + res = -EINVAL; + goto out_up; + } + scst_unregister_virtual_device(virt_dev->virt_id); + PRINT_INFO_PR("Virtual device %s unregistered", + virt_dev->name); + TRACE_DBG("virt_id %d unregister", virt_dev->virt_id); - list_add_tail(&virt_dev->fileio_dev_list_entry, - &disk_fileio_dev_list); + list_del(&virt_dev->fileio_dev_list_entry); - virt_dev->virt_id = - scst_register_virtual_device(&disk_devtype_fileio, - virt_dev->name); - if (virt_dev->virt_id < 0) { - res = virt_dev->virt_id; - goto out_free_vpath; - } - TRACE_DBG("Added virt_dev (name %s, file name %s, " - "id %d, block size %d) to " - "disk_fileio_dev_list", virt_dev->name, - virt_dev->file_name, virt_dev->virt_id, - virt_dev->block_size); - } else { /* close */ - virt_dev = NULL; - list_for_each_entry(vv, &disk_fileio_dev_list, - fileio_dev_list_entry) - { - if (strcmp(vv->name, name) == 0) { - virt_dev = vv; - break; - } - } - if (virt_dev == NULL) { - PRINT_ERROR_PR("Device %s not found", name); - res = -EINVAL; - goto out_up; - } - scst_unregister_virtual_device(virt_dev->virt_id); - PRINT_INFO_PR("Virtual device %s unregistered", - virt_dev->name); - TRACE_DBG("virt_id %d unregister", virt_dev->virt_id); - - list_del(&virt_dev->fileio_dev_list_entry); - - kfree(virt_dev->file_name); - kfree(virt_dev); - } - res = length; + kfree(virt_dev->file_name); + kfree(virt_dev); } + res = length; out_up: up(&scst_fileio_mutex); @@ -2613,14 +2551,6 @@ TRACE_EXIT_RES(res); return res; -stop_output: - *start = buffer + (offset - pu.begin); - pu.len -= (offset - pu.begin); - if (pu.len > length) - pu.len = length; - res = max(0, pu.len); - goto out_up; - out_free_vpath: list_del(&virt_dev->fileio_dev_list_entry); kfree(virt_dev->file_name); @@ -2630,6 +2560,7 @@ goto out_up; } + /* scst_fileio_mutex supposed to be held */ static int cdrom_fileio_open(char *p, char *name) { @@ -2640,8 +2571,7 @@ int cdrom_empty; virt_dev = NULL; - list_for_each_entry(vv, &cdrom_fileio_dev_list, - fileio_dev_list_entry) + list_for_each_entry(vv, &cdrom_fileio_dev_list, fileio_dev_list_entry) { if (strcmp(vv->name, name) == 0) { virt_dev = vv; @@ -2932,98 +2862,102 @@ /* * Called when a file in the /proc/CDROM_FILEIO_NAME/CDROM_FILEIO_NAME is read - * or written */ -static int cdrom_fileio_proc(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_dev_type *dev_type, int inout) +static int cdrom_fileio_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type) { + int res = 0; + struct scst_fileio_dev *virt_dev; + + TRACE_ENTRY(); + + if (down_interruptible(&scst_fileio_mutex) != 0) { + res = -EINTR; + goto out; + } + + seq_printf(seq, "%-17s %-9s %s\n", "Name", "Size(MB)", "File name"); + + list_for_each_entry(virt_dev, &cdrom_fileio_dev_list, + fileio_dev_list_entry) { + seq_printf(seq, "%-17s %-9d %s\n", virt_dev->name, + (uint32_t)(virt_dev->file_size >> 20), + virt_dev->file_name); + } + + up(&scst_fileio_mutex); + +out: + TRACE_EXIT_RES(res); + return res; +} + +/* + * Called when a file in the /proc/CDROM_FILEIO_NAME/CDROM_FILEIO_NAME is written + */ +static int cdrom_fileio_write_proc(char *buffer, char **start, off_t offset, + int length, int *eof, struct scst_dev_type *dev_type) +{ int res = 0, action; char *p, *name; struct scst_fileio_dev *virt_dev; - int size; - struct fileio_proc_update_struct pu; TRACE_ENTRY(); - memset(&pu, 0, sizeof(pu)); - if (down_interruptible(&scst_fileio_mutex) != 0) { res = -EINTR; goto out; } - if (inout == 0) { /* read */ - size = scnprintf(buffer, length, "%-17s %-9s %s\n", - "Name", "Size(MB)", "File name"); - if (fileio_proc_update_size(size, offset, length, &pu, 1)) - goto stop_output; + p = buffer; + if (p[strlen(p) - 1] == '\n') { + p[strlen(p) - 1] = '\0'; + } + if (!strncmp("close ", p, 6)) { + p += 6; + action = 0; + } else if (!strncmp("change ", p, 5)) { + p += 7; + action = 1; + } else if (!strncmp("open ", p, 5)) { + p += 5; + action = 2; + } else { + PRINT_ERROR_PR("Unknown action \"%s\"", p); + res = -EINVAL; + goto out_up; + } - list_for_each_entry(virt_dev, &cdrom_fileio_dev_list, - fileio_dev_list_entry) - { - size = scnprintf(buffer + pu.len, length - pu.len, - "%-17s %-9d %s\n", virt_dev->name, - (uint32_t)(virt_dev->file_size >> 20), - virt_dev->file_name); - if (fileio_proc_update_size(size, offset, length, &pu, - 1)) { - goto stop_output; - } - } - *eof = 1; - goto stop_output; - } else { /* write */ - p = buffer; - if (p[strlen(p) - 1] == '\n') { - p[strlen(p) - 1] = '\0'; - } - if (!strncmp("close ", p, 6)) { - p += 6; - action = 0; - } else if (!strncmp("change ", p, 5)) { - p += 7; - action = 1; - } else if (!strncmp("open ", p, 5)) { - p += 5; - action = 2; - } else { - PRINT_ERROR_PR("Unknown action \"%s\"", p); - res = -EINVAL; - goto out_up; - } + while (isspace(*p) && *p != '\0') + p++; + name = p; + while (!isspace(*p) && *p != '\0') + p++; + *p++ = '\0'; + if (*name == '\0') { + PRINT_ERROR_PR("%s", "Name required"); + res = -EINVAL; + goto out_up; + } else if (strlen(name) >= sizeof(virt_dev->name)) { + PRINT_ERROR_PR("Name is too long (max %zd " + "characters)", sizeof(virt_dev->name)-1); + res = -EINVAL; + goto out_up; + } - while (isspace(*p) && *p != '\0') - p++; - name = p; - while (!isspace(*p) && *p != '\0') - p++; - *p++ = '\0'; - if (*name == '\0') { - PRINT_ERROR_PR("%s", "Name required"); - res = -EINVAL; + if (action == 2) { /* open */ + res = cdrom_fileio_open(p, name); + if (res != 0) goto out_up; - } else if (strlen(name) >= sizeof(virt_dev->name)) { - PRINT_ERROR_PR("Name is too long (max %zd " - "characters)", sizeof(virt_dev->name)-1); - res = -EINVAL; + } else if (action == 1) { /* change */ + res = cdrom_fileio_change(p, name); + if (res != 0) goto out_up; - } - - if (action == 2) { /* open */ - res = cdrom_fileio_open(p, name); - if (res != 0) - goto out_up; - } else if (action == 1) { /* change */ - res = cdrom_fileio_change(p, name); - if (res != 0) - goto out_up; - } else { /* close */ - res = cdrom_fileio_close(name); - if (res != 0) - goto out_up; - } - res = length; + } else { /* close */ + res = cdrom_fileio_close(name); + if (res != 0) + goto out_up; } + res = length; out_up: up(&scst_fileio_mutex); @@ -3031,16 +2965,25 @@ out: TRACE_EXIT_RES(res); return res; +} -stop_output: - *start = buffer + (offset - pu.begin); - pu.len -= (offset - pu.begin); - if (pu.len > length) - pu.len = length; - res = pu.len; - goto out_up; +static int fileio_help_info_show(struct seq_file *seq, void *v) +{ + char *s = (char*)seq->private; + + TRACE_ENTRY(); + + seq_printf(seq, "%s", s); + + TRACE_EXIT(); + return 0; } +static struct scst_proc_data fileio_help_proc_data = { + SCST_DEF_RW_SEQ_OP(NULL) + .show = fileio_help_info_show, +}; + static int fileio_proc_help_build(struct scst_dev_type *dev_type) { int res = 0; @@ -3049,23 +2992,17 @@ TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { - p = create_proc_read_entry(FILEIO_PROC_HELP, - S_IFREG | S_IRUGO, root, - fileio_proc_help_read, - (dev_type->type == TYPE_DISK) ? - disk_fileio_proc_help_string : - cdrom_fileio_proc_help_string); - if (p == NULL) { - PRINT_ERROR_PR("Not enough memory to register dev " - "handler %s entry %s in /proc", - dev_type->name, FILEIO_PROC_HELP); - res = -ENOMEM; - goto out; - } + fileio_help_proc_data.data = (dev_type->type == TYPE_DISK) ? + disk_fileio_proc_help_string : + cdrom_fileio_proc_help_string; + p = scst_create_proc_entry(root, FILEIO_PROC_HELP, &fileio_help_proc_data); + if (p == NULL) { + PRINT_ERROR_PR("Not enough memory to register dev " + "handler %s entry %s in /proc", + dev_type->name, FILEIO_PROC_HELP); + res = -ENOMEM; } -out: TRACE_EXIT_RES(res); return res; } @@ -3083,21 +3020,6 @@ TRACE_EXIT(); } -static int fileio_proc_help_read(char *buffer, char **start, off_t offset, - int length, int *eof, void *data) -{ - int res = 0; - char *s = (char*)data; - - TRACE_ENTRY(); - - if (offset < strlen(s)) - res = scnprintf(buffer, length, "%s", &s[offset]); - - TRACE_EXIT_RES(res); - return res; -} - static int __init init_scst_fileio(struct scst_dev_type *devtype) { int res = 0; Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/scst/src/scst.c 2006-12-14 17:08:46 UTC (rev 57) @@ -1254,6 +1254,9 @@ EXPORT_SYMBOL(scst_proc_log_entry_write); #endif +EXPORT_SYMBOL(scst_create_proc_entry); +EXPORT_SYMBOL(scst_single_seq_open); + EXPORT_SYMBOL(__scst_get_buf); EXPORT_SYMBOL(scst_check_mem); EXPORT_SYMBOL(scst_get); Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2006-12-14 16:22:29 UTC (rev 56) +++ trunk/scst/src/scst_proc.c 2006-12-14 17:08:46 UTC (rev 57) @@ -28,56 +28,32 @@ #include <asm/string.h> #include <asm/uaccess.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include "scst_debug.h" #include "scsi_tgt.h" #include "scst_mem.h" #include "scst_priv.h" -static int scst_scsi_tgt_proc_info(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data); -static int scst_proc_scsi_tgt_gen_write(struct file *file, - const char *buf, - unsigned long length, void *data); -static int scst_proc_version_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data); -static int scst_proc_sessions_read(char *buffer, char **start, off_t offset, - int length, int *eof, void *data); -static int scst_proc_help_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data); -static int scst_proc_threads_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data); -static int scst_proc_threads_write(struct file *file, const char *buf, - unsigned long length, void *data); -static int scst_proc_scsi_tgt_read(char *buffer, char **start, off_t offset, - int length, int *eof, void *data); -static int scst_proc_scsi_tgt_write(struct file *file, const char *buf, - unsigned long count, void *data); -static int scst_proc_scsi_dev_handler_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data); -static int scst_proc_scsi_dev_handler_write(struct file *file, const char *buf, - unsigned long count, void *data); -static int scst_proc_scsi_dev_handler_type_read(char *buffer, char **start, - off_t offset, int length, - int *eof, void *data); static int scst_proc_init_groups(void); static void scst_proc_cleanup_groups(void); static int scst_proc_assign_handler(char *buf); static int scst_proc_group_add(const char *p); -static int scst_proc_groups_devices_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data); -static int scst_proc_groups_devices_write(struct file *file, const char *buf, - unsigned long length, void *data); -static int scst_proc_groups_names_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data); -static int scst_proc_groups_names_write(struct file *file, const char *buf, - unsigned long length, void *data); static int scst_proc_del_free_acg(struct scst_acg *acg, int remove_proc); +static struct scst_proc_data scst_version_proc_data; +static struct scst_proc_data scst_help_proc_data; +static struct scst_proc_data scst_sgv_proc_data; +static struct scst_proc_data scst_groups_names_proc_data; +static struct scst_proc_data scst_groups_devices_proc_data; +static struct scst_proc_data scst_sessions_proc_data; +static struct scst_proc_data scst_dev_handler_type_proc_data; +static struct scst_proc_data scst_log_proc_data; +static struct scst_proc_data scst_tgt_proc_data; +static struct scst_proc_data scst_threads_proc_data; +static struct scst_proc_data scst_scsi_tgt_proc_data; +static struct scst_proc_data scst_dev_handler_proc_data; + /* * Must be less than 4K page size, since our output routines * use some slack for overruns @@ -217,90 +193,10 @@ #endif /* CONFIG_PPC */ -int scst_proc_read_tlb(const struct scst_proc_log *tbl, char *buffer, - int length, off_t offset, unsigned long log_level, int *first, - int *size, int *len, off_t *begin, off_t *pos) -{ - const struct scst_proc_log *t = tbl; - int res = 0; - - while (t->token) { - if (log_level & t->val) { - *size = scnprintf(buffer + *len, length - *len, - "%s%s", *first ? "" : " | ", t->token); - *first = 0; - if (*size > 0) { - *len += *size; - *pos = *begin + *len; - if (*pos <= offset) { - *len = 0; - *begin = *pos; - } else if (*pos >= offset + length) - goto out_end; - } else - goto out_end; - } - t++; - } -out: - return res; - -out_end: - res = 1; - goto out; -} - #if defined(DEBUG) || defined(TRACING) -int scst_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, void *data, - unsigned long log_level, - const struct scst_proc_log *tbl) -{ - int res = 0, first = 1; - int size, len = 0; - off_t begin = 0, pos = 0; - - TRACE_ENTRY(); - - TRACE_DBG("offset: %d, length %d", (int) offset, length); - - if (scst_proc_read_tlb(scst_proc_trace_tbl, buffer, length, offset, - log_level, &first, &size, &len, &begin, &pos)) - goto stop_output; - - if (tbl) { - TRACE_DBG("Reading private tlb, offset: %d, length %d", - (int) offset, length); - if (scst_proc_read_tlb(tbl, buffer, length, offset, - log_level, &first, &size, &len, &begin, &pos)) - goto stop_output; - } - - size = scnprintf(buffer + len, length - len, "%s\n", first ? "none" : ""); - if (size > 0) { - len += size; - pos = begin + len; - if (pos <= offset) { - len = 0; - begin = pos; - } else if (pos >= offset + length) - goto stop_output; - } else - goto stop_output; - -stop_output: - *start = buffer + (offset - begin); - len -= (offset - begin); - if (len > length) - len = length; - res = max(0, len); - TRACE_EXIT_RES(res); - return res; -} - int scst_proc_log_entry_write(struct file *file, const char *buf, - unsigned long length, void *data, unsigned long *log_level, + unsigned long length, unsigned long *log_level, unsigned long default_level, const struct scst_proc_log *tbl) { int res = length; @@ -308,6 +204,7 @@ unsigned long level = 0, oldlevel; char *buffer, *p, *e; const struct scst_proc_log *t; + char *data = (char *)PDE(file->f_dentry->d_inode)->data; TRACE_ENTRY(); @@ -452,44 +349,19 @@ return res; } -static int scst_scsi_tgt_proc_info_log(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) +static int scst_proc_scsi_tgt_gen_write_log(struct file *file, const char __user *buf, + size_t length, loff_t *off) { int res; TRACE_ENTRY(); - if (down_interruptible(&scst_proc_mutex) != 0) { res = -EINTR; goto out; } - res = scst_proc_log_entry_read(buffer, start, offset, length, eof, - data, trace_flag, scst_proc_local_trace_tbl); - - up(&scst_proc_mutex); - -out: - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_scsi_tgt_gen_write_log(struct file *file, - const char *buf, - unsigned long length, void *data) -{ - int res; - - TRACE_ENTRY(); - - if (down_interruptible(&scst_proc_mutex) != 0) { - res = -EINTR; - goto out; - } - - res = scst_proc_log_entry_write(file, buf, length, data, + res = scst_proc_log_entry_write(file, buf, length, &trace_flag, SCST_DEFAULT_LOG_FLAGS, scst_proc_local_trace_tbl); up(&scst_proc_mutex); @@ -501,7 +373,7 @@ #endif /* defined(DEBUG) || defined(TRACING) */ -static int scst_proc_init_module_log(void) +static int __init scst_proc_init_module_log(void) { int res = 0; #if defined(DEBUG) || defined(TRACING) @@ -509,14 +381,10 @@ TRACE_ENTRY(); - generic = create_proc_read_entry(SCST_PROC_LOG_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, - scst_proc_scsi_tgt, - scst_scsi_tgt_proc_info_log, - (void *)"scsi_tgt"); - if (generic) { - generic->write_proc = scst_proc_scsi_tgt_gen_write_log; - } else { + generic = scst_create_proc_entry(scst_proc_scsi_tgt, + SCST_PROC_LOG_ENTRY_NAME, + &scst_log_proc_data); + if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_LOG_ENTRY_NAME); res = -ENOMEM; @@ -527,7 +395,7 @@ return res; } -static void scst_proc_cleanup_module_log(void) +static void __exit scst_proc_cleanup_module_log(void) { #if defined(DEBUG) || defined(TRACING) TRACE_ENTRY(); @@ -553,14 +421,11 @@ goto out; } - generic = create_proc_read_entry(SCST_PROC_GROUPS_DEVICES_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, - acg->acg_proc_root, - scst_proc_groups_devices_read, - (void *)acg); - if (generic) { - generic->write_proc = scst_proc_groups_devices_write; - } else { + scst_groups_devices_proc_data.data = acg; + generic = scst_create_proc_entry(acg->acg_proc_root, + SCST_PROC_GROUPS_DEVICES_ENTRY_NAME, + &scst_groups_devices_proc_data); + if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_GROUPS_ENTRY_NAME, @@ -569,14 +434,11 @@ goto out_remove; } - generic = create_proc_read_entry(SCST_PROC_GROUPS_USERS_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, - acg->acg_proc_root, - scst_proc_groups_names_read, - (void *)acg); - if (generic) { - generic->write_proc = scst_proc_groups_names_write; - } else { + scst_groups_names_proc_data.data = acg; + generic = scst_create_proc_entry(acg->acg_proc_root, + SCST_PROC_GROUPS_USERS_ENTRY_NAME, + &scst_groups_names_proc_data); + if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_GROUPS_ENTRY_NAME, @@ -674,7 +536,7 @@ return res; } -static int scst_proc_init_groups(void) +static int __init scst_proc_init_groups(void) { int res = 0; @@ -707,7 +569,7 @@ goto out; } -static void scst_proc_cleanup_groups(void) +static void __exit scst_proc_cleanup_groups(void) { struct scst_acg *acg_tmp, *acg; @@ -728,133 +590,14 @@ TRACE_EXIT(); } -struct scst_proc_update_struct { - int len, plen, pplen; - off_t begin, pbegin, ppbegin; - off_t pos; -}; - -static int scst_proc_update_size(int size, off_t offset, int length, - struct scst_proc_update_struct *p) +static int __init scst_proc_init_sgv(void) { int res = 0; - if (size > 0) { - p->len += size; - p->pos = p->begin + p->len; - if (p->pos <= offset) { - p->len = 0; - p->begin = p->pos; - } else if (p->pos >= offset + length) { - res = 1; - goto out; - } else - res = 0; - } else { - p->begin = p->ppbegin; - p->len = p->pplen; - res = 1; - goto out; - } - p->ppbegin = p->pbegin; - p->pplen = p->plen; - p->pbegin = p->begin; - p->plen = p->len; -out: - return res; -} - -static int scst_proc_sgv_read_1(char *buffer, off_t offset, int length, - struct scst_proc_update_struct *p, - const struct sgv_pool *pool, const char *name) -{ - int i, size; - - size = scnprintf(buffer + p->len, length - p->len, "\n%-20s %-11d %-11d\n", - name, atomic_read(&pool->acc.hit_alloc), - atomic_read(&pool->acc.total_alloc)); - if (scst_proc_update_size(size, offset, length, p)) - return 1; - - for(i = 0; i < SGV_POOL_ELEMENTS; i++) { - size = scnprintf(buffer + p->len, length - p->len, - " %-18s %-11d %-11d\n", pool->cache_names[i], - atomic_read(&pool->cache_acc[i].hit_alloc), - atomic_read(&pool->cache_acc[i].total_alloc)); - if (scst_proc_update_size(size, offset, length, p)) - return 1; - } - return 0; -} - -static int scst_proc_sgv_read(char *buffer, char **start, - off_t offset, int length, int *eof, void *data) -{ - int res = 0; - int size; - struct scst_proc_update_struct st; - - TRACE_ENTRY(); - - TRACE_DBG("offset: %d, length %d", (int) offset, length); - - memset(&st, 0, sizeof(st)); - - size = scnprintf(buffer + st.len, length - st.len, "%-20s %-11s %-11s", - "Name", "Hit", "Total"); - if (scst_proc_update_size(size, offset, length, &st)) - goto stop_output; - - if (scst_proc_sgv_read_1(buffer, offset, length, &st, &scst_sgv.norm, - "sgv")) - goto stop_output; - - if (scst_proc_sgv_read_1(buffer, offset, length, &st, - &scst_sgv.norm_clust, "sgv-clust")) - goto stop_output; - - if (scst_proc_sgv_read_1(buffer, offset, length, &st, - &scst_sgv.dma, "sgv-dma")) - goto stop_output; - -#ifdef SCST_HIGHMEM - if (scst_proc_sgv_read_1(buffer, offset, length, &st, - &scst_sgv.highmem, "sgv-highmem")) - goto stop_output; - -#endif - - size = scnprintf(buffer + st.len, length - st.len, "\n%-32s %-11d\n", - "big", atomic_read(&sgv_big_total_alloc)); - if (scst_proc_update_size(size, offset, length, &st)) - goto stop_output; - - size = scnprintf(buffer + st.len, length - st.len, "\n%-32s %-11d\n", - "other", atomic_read(&sgv_other_total_alloc)); - if (scst_proc_update_size(size, offset, length, &st)) - goto stop_output; - - *eof = 1; - -stop_output: - *start = buffer + (offset - st.begin); - st.len -= (offset - st.begin); - if (st.len > length) - st.len = length; - res = max(0, st.len); - - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_init_sgv(void) -{ - int res = 0; struct proc_dir_entry *pr; TRACE_ENTRY(); - pr = create_proc_read_entry("sgv", S_IFREG | S_IRUGO, - scst_proc_scsi_tgt, scst_proc_sgv_read, NULL); + pr = scst_create_proc_entry(scst_proc_scsi_tgt, "sgv", &scst_sgv_proc_data); if (pr == NULL) { PRINT_ERROR_PR("%s", "cannot create sgv /proc entry"); res = -ENOMEM; @@ -864,14 +607,14 @@ return res; } -static void scst_proc_cleanup_sgv(void) +static void __exit scst_proc_cleanup_sgv(void) { TRACE_ENTRY(); remove_proc_entry("sgv", scst_proc_scsi_tgt); TRACE_EXIT(); } -int scst_proc_init_module(void) +int __init scst_proc_init_module(void) { int res = 0; struct proc_dir_entry *generic; @@ -884,57 +627,47 @@ goto out_nomem; } - generic = create_proc_read_entry(SCST_PROC_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, - scst_proc_scsi_tgt, - scst_scsi_tgt_proc_info, NULL); + generic = scst_create_proc_entry(scst_proc_scsi_tgt, + SCST_PROC_ENTRY_NAME, + &scst_tgt_proc_data); if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_ENTRY_NAME); goto out_remove; } - generic->write_proc = scst_proc_scsi_tgt_gen_write; - generic = create_proc_read_entry(SCST_PROC_VERSION_NAME, - S_IFREG | S_IRUGO, - scst_proc_scsi_tgt, - scst_proc_version_read, NULL); + generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_VERSION_NAME, + &scst_version_proc_data); if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_VERSION_NAME); goto out_remove1; } - generic = create_proc_read_entry(SCST_PROC_SESSIONS_NAME, - S_IFREG | S_IRUGO, - scst_proc_scsi_tgt, - scst_proc_sessions_read, NULL); + generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_SESSIONS_NAME, + &scst_sessions_proc_data); if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_SESSIONS_NAME); goto out_remove2; } - generic = create_proc_read_entry(SCST_PROC_HELP_NAME, - S_IFREG | S_IRUGO, - scst_proc_scsi_tgt, - scst_proc_help_read, NULL); + generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_HELP_NAME, + &scst_help_proc_data); if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_HELP_NAME); goto out_remove3; } - generic = create_proc_read_entry(SCST_PROC_THREADS_NAME, - S_IFREG | S_IRUGO | S_IWUSR, - scst_proc_scsi_tgt, - scst_proc_threads_read, NULL); + generic = scst_create_proc_entry(scst_proc_scsi_tgt, + SCST_PROC_THREADS_NAME, + &scst_threads_proc_data); if (!generic) { PRINT_ERROR_PR("cannot init /proc/%s/%s", SCST_PROC_ENTRY_NAME, SCST_PROC_THREADS_NAME); goto out_remove4; } - generic->write_proc = scst_proc_threads_write; if (scst_proc_init_module_log() < 0) { goto out_remove5; @@ -981,7 +714,7 @@ goto out; } -void scst_proc_cleanup_module(void) +void __exit scst_proc_cleanup_module(void) { TRACE_ENTRY(); @@ -999,188 +732,12 @@ TRACE_EXIT(); } -static int scst_scsi_tgt_proc_info(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) +static int scst_proc_threads_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { - int res = 0; - int size, len = 0, plen, pplen; - off_t begin = 0, pos = 0, pbegin, ppbegin; - struct scst_device *dev; - - TRACE_ENTRY(); - -//TRACE(TRACE_SPECIAL, "offset=%ld, length=%d", offset, length); - - if (down_interruptible(&scst_mutex) != 0) { - res = -EINTR; - goto out; - } - - size = scnprintf(buffer + len, length - len, "%-60s%s\n", - "Device (host:ch:id:lun or name)", - "Device handler"); - -//TRACE(TRACE_SPECIAL, "size=%d, pos=%ld, begin=%ld, len=%d, buf %s", -// size, pos, begin, len, buffer+len); - - if (size > 0) { - len += size; - pos = begin + len; - if (pos <= offset) { - len = 0; - begin = pos; - } else if (pos >= offset + length) - goto stop_output; - } else - goto stop_output; - - ppbegin = pbegin = begin; - pplen = plen = len; - list_for_each_entry(dev, &scst_dev_list, dev_list_entry) { - if (dev->virt_id == 0) { - char conv[12]; - size = scnprintf(buffer + len, length - len, - "%d:%d:%d:", - dev->scsi_dev->host->host_no, - dev->scsi_dev->channel, - dev->scsi_dev->id); - sprintf(conv, "%%-%dd%%s\n", 60-size); - size += scnprintf(buffer + len + size, length - len - size, - conv, dev->scsi_dev->lun, - dev->handler ? dev->handler->name : "-"); - } else { - size = scnprintf(buffer + len, length - len, - "%-60s%s\n", - dev->virt_name, dev->handler->name); - } - -//printk("size=%d, pbegin=%ld, plen=%d, ppbegin=%ld, pplen=%d, buf %s", -// size, pbegin, plen, ppbegin, pplen, buffer+len); - - if (size > 0) { - len += size; - pos = begin + len; - if (pos <= offset) { - len = 0; - begin = pos; - } -//TRACE(TRACE_SPECIAL, "pos=%ld, begin=%ld, len=%d", pos, begin, len); - if (pos >= offset + length) - goto stop_output; - } else { - begin = ppbegin; - len = pplen; - goto stop_output; - } - ppbegin = pbegin; - pplen = plen; - pbegin = begin; - plen = len; - } - - *eof = 1; - -stop_output: - *start = buffer + (offset - begin); - len -= (offset - begin); - if (len > length) - len = length; - res = max(0, len); - -//TRACE(TRACE_SPECIAL, "res=%d, start=%ld, len=%d, begin=%ld, eof=%d", res, offset-begin, len, begin, *eof); - - up(&scst_mutex); - -out: - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_version_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data) -{ - int res; - - TRACE_ENTRY(); - - res = scnprintf(buffer, length, "%s\n", SCST_VERSION_STRING); - -#ifdef STRICT_SERIALIZING - if (res < length) - res += scnprintf(&buffer[res], length-res, "Strict " - "serializing enabled\n"); -#endif - -#ifdef EXTRACHECKS - if (res < length) - res += scnprintf(&buffer[res], length-res, "EXTRACHECKS\n"); -#endif - -#ifdef TRACING - if (res < length) - res += scnprintf(&buffer[res], length-res, "TRACING\n"); -#endif - -#ifdef DEBUG - if (res < length) - res += scnprintf(&buffer[res], length-res, "DEBUG\n"); -#endif - -#ifdef DEBUG_TM - if (res < length) - res += scnprintf(&buffer[res], length-res, "DEBUG_TM\n"); -#endif - -#ifdef DEBUG_RETRY - if (res < length) - res += scnprintf(&buffer[res], length-res, "DEBUG_RETRY\n"); -#endif - -#ifdef DEBUG_OOM - if (res < length) - res += scnprintf(&buffer[res], length-res, "DEBUG_OOM\n"); -#endif - - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_help_read(char *buffer, char **start, off_t offset, - int length, int *eof, void *data) -{ - int res; - - TRACE_ENTRY(); - - res = scnprintf(buffer, length, "%s", scst_proc_help_string); - - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_threads_read(char *buffer, char **start,off_t offset, - int length, int *eof, void *data) -{ - int res; - - TRACE_ENTRY(); - - /* 2 mgmt threads */ - res = scnprintf(buffer, length, "%d\n", - atomic_read(&scst_threads_count) - 2); - - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_threads_write(struct file *file, const char *buf, - unsigned long length, void *data) -{ int res = length; int oldtn, newtn, delta; char *buffer; - TRACE_ENTRY(); @@ -1282,13 +839,13 @@ TRACE_ENTRY(); - if (vtt->tgtt->proc_info) { + if (vtt->tgtt->read_proc || vtt->tgtt->write_proc) { /* create the proc file entry for the device */ scnprintf(name, sizeof(name), "%d", vtt->tgtt->proc_dev_num); - p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, - vtt->tgtt->proc_tgt_root, - scst_proc_scsi_tgt_read, - (void *)vtt); + scst_scsi_tgt_proc_data.data = (void*)vtt; + p = scst_create_proc_entry(vtt->tgtt->proc_tgt_root, + name, + &scst_scsi_tgt_proc_data); if (p == NULL) { PRINT_ERROR_PR("Not enough memory to register SCSI " "target entry %s in /proc/%s/%s", name, @@ -1296,7 +853,6 @@ res = -ENOMEM; goto out; } - p->write_proc = scst_proc_scsi_tgt_write; vtt->proc_num = vtt->tgtt->proc_dev_num; vtt->tgtt->proc_dev_num++; } @@ -1312,7 +868,7 @@ TRACE_ENTRY(); - if (vtt->tgtt->proc_info) { + if (vtt->tgtt->read_proc || vtt->tgtt->write_proc) { scnprintf(name, sizeof(name), "%d", vtt->proc_num); remove_proc_entry(name, vtt->tgtt->proc_tgt_root); } @@ -1321,39 +877,10 @@ return; } -static int scst_proc_scsi_tgt_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) +static int scst_proc_scsi_tgt_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { - struct scst_tgt *vtt = data; - int res = 0; - - TRACE_ENTRY(); - - TRACE_DBG("offset: %d, length %d, id: %d", - (int) offset, length, vtt->proc_num); - - if (down_interruptible(&scst_proc_mutex) != 0) { - res = -EINTR; - goto out; - } - - if (vtt->tgtt->proc_info) { - res = vtt->tgtt->proc_info(buffer, start, offset, length, eof, - vtt, 0); - } - - up(&scst_proc_mutex); - -out: - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_scsi_tgt_write(struct file *file, const char *buf, - unsigned long length, void *data) -{ - struct scst_tgt *vtt = data; + struct scst_tgt *vtt = (struct scst_tgt *)PDE(file->f_dentry->d_inode)->data; ssize_t res = 0; char *buffer; char *start; @@ -1361,7 +888,7 @@ TRACE_ENTRY(); - if (vtt->tgtt->proc_info == NULL) { + if (vtt->tgtt->write_proc == NULL) { res = -ENOSYS; goto out; } @@ -1397,7 +924,7 @@ goto out_free; } - res = vtt->tgtt->proc_info(buffer, &start, 0, length, &eof, vtt, 1); + res = vtt->tgtt->write_proc(buffer, &start, 0, length, &eof, vtt); up(&scst_proc_mutex); @@ -1427,11 +954,10 @@ goto out_nomem; } - p = create_proc_read_entry(SCST_PROC_DEV_HANDLER_TYPE_ENTRY_NAME, - S_IFREG | S_IRUGO, - dev_type->proc_dev_type_root, - scst_proc_scsi_dev_handler_type_read, - (void *)dev_type); + scst_dev_handler_type_proc_data.data = dev_type; + p = scst_create_proc_entry(dev_type->proc_dev_type_root, + SCST_PROC_DEV_HANDLER_TYPE_ENTRY_NAME, + &scst_dev_handler_type_proc_data); if (p == NULL) { PRINT_ERROR_PR("Not enough memory to register dev " "handler entry %s in /proc/%s/%s", @@ -1440,20 +966,18 @@ goto out_remove; } - if (dev_type->proc_info) { + if (dev_type->read_proc || dev_type->write_proc) { /* create the proc file entry for the dev type handler */ - p = create_proc_read_entry(dev_type->name, - S_IFREG | S_IRUGO | S_IWUSR, - dev_type->proc_dev_type_root, - scst_proc_scsi_dev_handler_read, - (void *)dev_type); + scst_dev_handler_proc_data.data = (void *)dev_type; + p = scst_create_proc_entry(dev_type->proc_dev_type_root, + dev_type->name, + &scst_dev_handler_proc_data); if (p == NULL) { PRINT_ERROR_PR("Not enough memory to register dev " "handler entry %s in /proc/%s/%s", dev_type->name, SCST_PROC_ENTRY_NAME, dev_type->name); goto out_remove1; } - p->write_proc = scst_proc_scsi_dev_handler_write; } out: @@ -1479,7 +1003,7 @@ if (dev_type->proc_dev_type_root) { remove_proc_entry(SCST_PROC_DEV_HANDLER_TYPE_ENTRY_NAME, dev_type->proc_dev_type_root); - if (dev_type->proc_info) { + if (dev_type->read_proc || dev_type->write_proc) { remove_proc_entry(dev_type->name, dev_type->proc_dev_type_root); } @@ -1491,56 +1015,10 @@ return; } -static int scst_proc_scsi_dev_handler_type_read(char *buffer, char **start, - off_t offset, int length, - int *eof, void *data) +static int scst_proc_scsi_dev_handler_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { - struct scst_dev_type *dev_type = data; - int n = 0; - - TRACE_ENTRY(); - - n = scnprintf(buffer, length, "%d - %s\n", dev_type->type, - dev_type->type > 0x0f ? - "unknown" : scst_proc_dev_handler_type[dev_type->type]); - - TRACE_EXIT_RES(n); - return n; -} - -static int scst_proc_scsi_dev_handler_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) -{ - struct scst_dev_type *dev_type = data; - int res = 0; - - TRACE_ENTRY(); - - TRACE_DBG("offset: %d, length %d, name: %s", - (int) offset, length, dev_type->name); - - if (down_interruptible(&scst_proc_mutex) != 0) { - res = -EINTR; - goto out; - } - - if (dev_type->proc_info) { - res = dev_type->proc_info(buffer, start, offset, length, eof, - dev_type, 0); - } - - up(&scst_proc_mutex); - -out: - TRACE_EXIT_RES(res); - return res; -} - -static int scst_proc_scsi_dev_handler_write(struct file *file, const char *buf, - unsig... [truncated message content] |
From: <vl...@us...> - 2006-12-14 18:10:46
|
Revision: 60 http://svn.sourceforge.net/scst/?rev=60&view=rev Author: vlnb Date: 2006-12-14 10:10:39 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Update to work on 2.6.19. Mostly done by Ming Zhang. Modified Paths: -------------- trunk/qla2x00t/qla_attr.c trunk/qla2x00t/qla_def.h trunk/qla2x00t/qla_gbl.h trunk/qla2x00t/qla_inline.h trunk/qla2x00t/qla_isr.c trunk/scst/include/scst_debug.h trunk/scst/src/dev_handlers/scst_fileio.c trunk/scst/src/scst.c Modified: trunk/qla2x00t/qla_attr.c =================================================================== --- trunk/qla2x00t/qla_attr.c 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/qla2x00t/qla_attr.c 2006-12-14 18:10:39 UTC (rev 60) @@ -681,13 +681,29 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) { struct Scsi_Host *host = ha->host; + int ret; - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_ctl_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); } void Modified: trunk/qla2x00t/qla_def.h =================================================================== --- trunk/qla2x00t/qla_def.h 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/qla2x00t/qla_def.h 2006-12-14 18:10:39 UTC (rev 60) @@ -24,6 +24,7 @@ #include <linux/workqueue.h> #include <linux/firmware.h> #include <asm/semaphore.h> +#include <linux/version.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> @@ -2116,7 +2117,11 @@ char * (*pci_info_str) (struct scsi_qla_host *, char *); char * (*fw_version_str) (struct scsi_qla_host *, char *); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t (*intr_handler) (int, void *, struct pt_regs *); +#else + irq_handler_t intr_handler; +#endif void (*enable_intrs) (struct scsi_qla_host *); void (*disable_intrs) (struct scsi_qla_host *); Modified: trunk/qla2x00t/qla_gbl.h =================================================================== --- trunk/qla2x00t/qla_gbl.h 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/qla2x00t/qla_gbl.h 2006-12-14 18:10:39 UTC (rev 60) @@ -213,9 +213,15 @@ /* * Global Function Prototypes in qla_isr.c source file. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) extern irqreturn_t qla2100_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla2300_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla24xx_intr_handler(int, void *, struct pt_regs *); +#else +extern irqreturn_t qla2100_intr_handler(int, void *); +extern irqreturn_t qla2300_intr_handler(int, void *); +extern irqreturn_t qla24xx_intr_handler(int, void *); +#endif extern void qla2x00_process_response_queue(struct scsi_qla_host *); extern void qla24xx_process_response_queue(struct scsi_qla_host *); Modified: trunk/qla2x00t/qla_inline.h =================================================================== --- trunk/qla2x00t/qla_inline.h 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/qla2x00t/qla_inline.h 2006-12-14 18:10:39 UTC (rev 60) @@ -104,7 +104,11 @@ static inline void qla2x00_poll(scsi_qla_host_t *ha) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) ha->isp_ops.intr_handler(0, ha, NULL); +#else + ha->isp_ops.intr_handler(0, ha); +#endif } static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *); Modified: trunk/qla2x00t/qla_isr.c =================================================================== --- trunk/qla2x00t/qla_isr.c 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/qla2x00t/qla_isr.c 2006-12-14 18:10:39 UTC (rev 60) @@ -32,8 +32,13 @@ * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla2100_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_2xxx __iomem *reg; @@ -112,8 +117,13 @@ * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla2300_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_2xxx __iomem *reg; @@ -1571,8 +1581,13 @@ * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla24xx_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_24xx __iomem *reg; Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/scst/include/scst_debug.h 2006-12-14 18:10:39 UTC (rev 60) @@ -20,7 +20,7 @@ #ifndef __SCST_DEBUG_H #define __SCST_DEBUG_H -#include <linux/config.h> /* for CONFIG_* */ +#include <linux/autoconf.h> /* for CONFIG_* */ #if !defined(EXTRACHECKS) && defined(CONFIG_SCSI_TARGET_EXTRACHECKS) #define EXTRACHECKS Modified: trunk/scst/src/dev_handlers/scst_fileio.c =================================================================== --- trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-14 18:10:39 UTC (rev 60) @@ -293,15 +293,20 @@ goto out; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if ((fd->f_op == NULL) || (fd->f_op->readv == NULL) || (fd->f_op->writev == NULL)) +#else + if ((fd->f_op == NULL) || (fd->f_op->aio_read == NULL) || + (fd->f_op->aio_write == NULL)) +#endif { PRINT_ERROR_PR("%s", "Wrong f_op or FS doesn't have " "required capabilities"); res = -EINVAL; goto out_close_file; } - + /* seek to end */ old_fs = get_fs(); set_fs(get_ds()); @@ -1194,7 +1199,7 @@ } len = scnprintf(dev_id_str, 6, "%d", dev_id_num); TRACE_DBG("num %d, str <%s>, len %d", - dev_id_num,dev_id_str, len); + dev_id_num, dev_id_str, len); if (0 == cmd->cdb[2]) { /* supported vital product data pages */ buf[3] = 3; buf[4] = 0x0; /* this page */ @@ -1928,6 +1933,48 @@ return ftgt_dev->iv; } +/* + * copied from <ksrc>/fs/read_write.* + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) +static void wait_on_retry_sync_kiocb(struct kiocb *iocb) +{ + set_current_state(TASK_UNINTERRUPTIBLE); + if (!kiocbIsKicked(iocb)) + schedule(); + else + kiocbClearKicked(iocb); + __set_current_state(TASK_RUNNING); +} + +typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *, + unsigned long, loff_t); + +ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, + unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn) +{ + struct kiocb kiocb; + ssize_t ret; + + init_sync_kiocb(&kiocb, filp); + kiocb.ki_pos = *ppos; + kiocb.ki_left = len; + kiocb.ki_nbytes = len; + + for (;;) { + ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); + if (ret != -EIOCBRETRY) + break; + wait_on_retry_sync_kiocb(&kiocb); + } + + if (ret == -EIOCBQUEUED) + ret = wait_on_sync_kiocb(&kiocb); + *ppos = kiocb.ki_pos; + return ret; +} +#endif + static void fileio_exec_read(struct scst_cmd *cmd, loff_t loff) { mm_segment_t old_fs; @@ -1988,7 +2035,12 @@ if (virt_dev->nullio) err = full_len; else +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) err = fd->f_op->readv(fd, iv, iv_count, &fd->f_pos); +#else + err = do_sync_readv_writev(fd, iv, iv_count, full_len, &fd->f_pos, fd->f_op->aio_read); +#endif + if ((err < 0) || (err < full_len)) { PRINT_ERROR_PR("readv() returned %Ld from %zd", (uint64_t)err, full_len); @@ -2076,7 +2128,13 @@ if (virt_dev->nullio) err = full_len; else +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) err = fd->f_op->writev(fd, eiv, eiv_count, &fd->f_pos); +#else + err = do_sync_readv_writev(fd, iv, iv_count, full_len, &fd->f_pos, + fd->f_op->aio_write); +#endif + if (err < 0) { PRINT_ERROR_PR("write() returned %Ld from %zd", (uint64_t)err, full_len); @@ -2778,14 +2836,17 @@ virt_dev->file_name, res); goto out_free; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if ((fd->f_op == NULL) || (fd->f_op->readv == NULL)) { +#else + if ((fd->f_op == NULL) || (fd->f_op->aio_read == NULL)) { +#endif PRINT_ERROR_PR("%s", "Wrong f_op or FS doesn't " "have required capabilities"); res = -EINVAL; filp_close(fd, NULL); goto out_free; } - /* seek to end */ old_fs = get_fs(); set_fs(get_ds()); Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-12-14 17:53:01 UTC (rev 59) +++ trunk/scst/src/scst.c 2006-12-14 18:10:39 UTC (rev 60) @@ -1249,6 +1249,7 @@ scst_sgv_pools_deinit(&scst_sgv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) #define DEINIT_CACHEP(p, s) do { \ if (kmem_cache_destroy(p)) { \ PRINT_INFO_PR("kmem_cache_destroy of %s returned an "\ @@ -1256,6 +1257,12 @@ } \ p = NULL; \ } while (0) +#else +#define DEINIT_CACHEP(p, s) do { \ + kmem_cache_destroy(p); \ + p = NULL; \ + } while (0) +#endif mempool_destroy(scst_mgmt_mempool); mempool_destroy(scst_ua_mempool); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |