			 UNH-iSCSI DISKIO Mode
			      Ethan Burns

	DISKIO mode is mode for the UNH-iSCSI target in which a real
SCSI device will be sent the commands received from the iSCSI initiator.
In this mode of operation, a real disk device can be, directly, sent the
SCSI commands that were transported over an iSCSI session.

For a list of known issues, see the section ``DISKIO Gems'' below.

			  --------------------
			  Enabling DISKIO mode
			  --------------------

	In order to enable DISKIO mode, you must define the DISKIO
pre-processor macro.  This can be done by appending the -DDISKIO mode
flag to the list of C compiler flags in the Makefile, or by editing
target/scsi_target.h and selecting DISKIO mode as the uncommented macro
in the section of code which is selecting the target mode.

			 ----------------------
			 Selecting SCSI Devices
			 ----------------------

	DISKIO mode forwards SCSI commands received from iSCSI to real
SCSI devices on the target system.  In order to select which devices
will be available to the iSCSI initiator the proc filesystem can be
used.  The /proc/scsi_target/scsi_target file can be written to in order
to add SCSI devices to the list of those devices offered to an iSCSI
initiator.

	To add a new SCSI device to this list, use the ``adddevice''
command, which has the format:

# adddevice host=<hostid> chan=<channel> id=<id> lun=<lun>

	For example, to add SCSI device 1:2:3:4, you would do:

# echo "adddevice host=1 chan=2 id=3 lun=4" > /proc/scsi_target/scsi_target

	The /sys/bus/scsi/devices directory can be used in order to find
a list of all currently attached SCSI devices on the system.

	Additionally a script has been provided in the cmd/ directory of
this project which will search for all available SCSI devices (using the
sys/ file system), and will add all available devices to the list of
devices offered to the initiator.  This script is called
cmd/target_add_all_devices.sh.  The script, by default, will not offer
SCSI devices which correspond to mounted disk devices.  The optional -f
argument can be passed on the command-line, however, to force offering
of mounted disks.

			      -----------
			      DISKIO Gems
			      -----------

Issues with DISKIO mode are listed below:

-----------------------------------------------------------------------
	Each SCSI HBA on the system selects a maximum number of
sectors-per-command that it can accept when it registers with the SCSI
mid-level.  As of this writing, for example, the USB storage HBA (used
for USB flash sticks) accepts a maximum of 240 sectors (120KB) per SCSI
command.  If a command with a larger number of sectors is received, it
will be dropped.

	Since, in DISKIO mode, the target can be offering the initiator
devices from a wide range of actual HBAs, the initiator must explicitly
set the max sectors value of the iSCSI initiator HBA to the lowest max
sectors value of any driver offered by the target.  This is because the
target will be forwarding the commands passed to the iSCSI initiator's
HBA directly over to the HBA for the corresponding device on the target
system.  If the iSCSI initiator HBA allows larger commands than can be
accepted by the HBA of one of the offered devices, the command will be
dropped on the target side.  This causes I/O errors on the initiator and
is a disaster.

For example:

	In a situation where the target is offering USB stick (with max
sectors of 240) to the initiator, the initiator can *never* send more
than 240 sectors in a data transfer to/from the USB stick.  To guarantee
that this will never happen, the iSCSI initiator must set the
max_sectors parameter to 240:

# insmod unh_iscsi_initiator.ko max_sectors=240

-----------------------------------------------------------------------
