So I tried to play a little with target but did not know where to start. The documentation I've found in the wiki was not always clear to me. A few things here and there seem to be missing. So here something I come up with after reading the code and fixing something here and there. Please note that I might got a few things wrong here in terms of proper explanation or usage in scsi terms as I am new to this. This is however what I used for my new /dev/sda testing :) Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- Documentation/target/QuickTestingSetup.txt | 71 ++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 Documentation/target/QuickTestingSetup.txt diff --git a/Documentation/target/QuickTestingSetup.txt b/Documentation/target/QuickTestingSetup.txt new file mode 100644 index 0000000..a4bbc47 --- /dev/null +++ b/Documentation/target/QuickTestingSetup.txt @@ -0,0 +1,71 @@ +Quick Target Setup +~~~~~~~~~~~~~~~~~~ + +This document tries to describe a minimal testing environment for the +target framework using the loopback fabrics. This means it can be used +locally without any additional setup. + +0. Environment +~~~~~~~~~~~~~~ +The configuration is configfs driven. The document that you have the +target module loaded and setup a few environment variables i.e. this +setup: + +modprobe target_core_mod; mount a -t configfs /sys/kernel/config +CONFIGFS=/sys/kernel/config/; TARGET=$CONFIGFS/target/core/ +FABRIC=$CONFIGFS/target/loopback/ + +1. Storage +~~~~~~~~~~ +You can chose between block, file or ramdisk storage for your new scsi +device: + +1.1 block + # create a new block target + mkdir -p $TARGET/iblock_0/iblock + # assign /dev/vdc for read/write access + echo /dev/vdc >$TARGET/iblock_0/iblock/udev_path + # enable it + echo 1 > $TARGET/iblock_0/iblock/enable + +1.2 file + # create a new file target + mkdir -p $TARGET/fileio_0/fileio + # assign file /root/file.bin with a size of 31457280 bytes. + echo fd_dev_name=/root/file.bin,fd_dev_size=31457280 > \ + $TARGET/fileio_0/fileio/control + # enable it + echo 1 > $TARGET/fileio_0/fileio/enable + +1.3 ramdisk + # create a new ramdisk target + mkdir -p $TARGET/rd_mcp_0/ramdisk + # assign 32768 pages (with 4KiB/page this is 128MiB of memory) + echo rd_pages=32768 > $TARGET/rd_mcp_0/ramdisk/control + # enable it + echo 1 > $TARGET/rd_mcp_0/ramdisk/enable + +2. Assign storage to device +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The fabric needs to know the protocol and it needs a nexus. The "naa." +prefix says that SAS protocol will be used. 0 and 1 are the unique nexus +which are used for the two devices. + + # create the fabric device + mkdir -p $FABRIC/naa.0/tpgt_0/lun/lun_0 + echo naa.0 > $FABRIC/naa.1/tpgt_0/nexus + + # assign a storage backend. For the file backend this would be: + ln -sv /sys/kernel/config/target/core/fileio_0/fileio \ + $FABRIC/naa.0/tpgt_0/lun/lun_0/file_0 + +3. Remove +~~~~~~~~~ + # remove storage and fabric + unlink $FABRIC/naa.0/tpgt_0/lun/lun_0/fileio_0 + rmdir $FABRIC/naa.0/tpgt_0/lun/lun_0 + rmdir $FABRIC/naa.0/tpgt_0 + rmdir $FABRIC/naa.0 + # remove storage, here the file + rmdir $TARGET/fileio_0/fileio + rmdir $TARGET/fileio_0 -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html