target mode

Scott Long scottl at samsco.org
Fri Jun 13 01:14:07 UTC 2008


Derek VerLee wrote:
> 
> Hello
> I'm curious about what is and isn't possible using scsi target mode in 
> FreeBSD, both in principle and given the current state of the 
> architecture.  In particular I am curious if it is possible to use a 
> scsi card in target mode, to "export" drives, such as a geom array, to 
> be accessed by another computer over a physical scsi connect.  I believe 
> this is what iscsi support aims at, however i'm interested in other scsi 
> interfaces, such as parrellel or perhaps SAS.  Searching the archives 
> and web somewhat, I have seen other people ask this a couple times but 
> haven't found a definite answer.
> 
> This would be to perhaps re-purpose an older computer, or an inexpensive 
> one, to act much like an external raid (but perhaps potentially more 
> flexible).
> 
> Is is possible now?  If not, could it be done with some hacking and 
> coding?   How crazy would you have to be to try?
> 

Short answer is yes, it's possible to export logical disks with what is 
in the tree and a minimal amount of setup and configuration.

The target mode support is split into 2 layers.  There is the kernel
driver that handles the basic parallel scsi wire protocol (i.e.
selection, reconnection, etc) in conjunction with the HBA driver, and
acts as a conduit for the command protocol.  Above that is the userland
driver that talks to the kernel target driver and handles the scsi
command protocol, i.e. inquiries, read/write, etc.

There is a skeletal but fully functional upper layer in
/usr/share/examples/scsi_target.  It can generate suitable responses
to inquiry and TUR commands, and can be pointed at a file to use as the
backing store for a virtual disk.  I'd suggest reading the man page in
there and playing with it; it's simple but it works and is a good
demonstration of the possibilities that exist.

Not all HBA drivers support target mode, however.  For parallel SCSI,
the AHC driver is probably the best choice since it was the reference
platform for all of the target mode code.

Scott


More information about the freebsd-scsi mailing list