realisediscsicode
iscsi  

所属分类:Linux/Unix编程
开发工具:Unix_Linux
文件大小:94KB
下载次数:90
上传日期:2008-03-27 11:51:09
上 传 者257855
说明:  实现 iscsi 的 c 代码,需要的朋友可以参考实现的代码完成自己的设计
(ISCSI realize the c code, need to realize friends can refer to the code to complete their own design)

文件列表:
iscsi\COPYING (18007, 2001-04-25)
iscsi\iscsi.c (14235, 2001-04-24)
iscsi\iscsi.h (13854, 2001-04-25)
iscsi\iscsi_client.c (48103, 2001-04-24)
iscsi\iscsi_client.h (4003, 2001-04-21)
iscsi\issi\issi\issi.vcproj (5176, 2007-08-10)
iscsi\issi\issi\issi.vcproj.CHINAIP.jqg.user (1767, 2007-08-10)
iscsi\issi\issi.ncb (183296, 2007-08-10)
iscsi\issi\issi.sln (1307, 2007-08-10)
iscsi\issi\issi.suo (9728, 2007-08-10)
iscsi\Makefile (1539, 2001-04-25)
iscsi\usr_targ_x86.c (27281, 2001-04-21)
iscsi\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.vshost.exe (5632, 2005-12-08)
iscsi\WindowsApplication1\WindowsApplication1\Form1.cs (347, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Form1.Designer.cs (1169, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Program.cs (478, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Properties\AssemblyInfo.cs (1186, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Properties\Resources.Designer.cs (2892, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Properties\Resources.resx (5612, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Properties\Settings.Designer.cs (1102, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\Properties\Settings.settings (249, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\WindowsApplication1.csproj (3093, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1.sln (946, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1.suo (8704, 2007-08-20)
iscsi\WindowsApplication1\WindowsApplication1\obj\Debug\TempPE (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1\bin\Debug (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1\obj\Debug (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1\bin (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1\obj (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1\Properties (0, 2007-12-21)
iscsi\issi\issi (0, 2007-12-21)
iscsi\WindowsApplication1\WindowsApplication1 (0, 2007-12-21)
iscsi\issi (0, 2007-12-21)
iscsi\WindowsApplication1 (0, 2007-12-21)
iscsi (0, 2004-06-28)

The drivers included here are an initial implementation of iSCSI for linux. This is a quick HOWTO on how to get iSCSI up and running in your environment. Getting Started To use these modules you need to have 2 machines running linux 2.4.x connected together via some TCP/IP network. (using 1 machine and running both the target and client on localhost probably works but is untested). 1 machine should have a SCSI adapter installed with a SCSI device (disk) preferably using SCSI Id 0. This machine is henceforth referred to as the "target" machine. The other machine is henceforth reffered to as the "client" machine. *DO NOT USE A TARGET SCSI DEVICE CONTAINING IMPORTANT DATA* You have been warned. Installing -- Client Side -- On the client machine download the initiator source distribution from here: http://www.cs.uml.edu/~mbrown/iSCSI/iscsi-0.1.tar.gz Make sure /usr/src/linux contains the source to your running kernel and is version 2.4.x. Extract the sources: $ tar -zxvf iscsi-0.1.tar.gz $ cd iscsi Edit the file iscsi_client.c. Change line 488 to: u32 addr = ; where target_ip_address is the IP address of your target machine in hex format in network byte ordering. There are some examples included there to help. Build the iscsi and iscsi_client kernel modules: $ make -- Target Side -- On the target machine download the target source distribution from here: ftp://ftp.iol.unh.edu/pub/iscsi/kernel_emulator_10.tgz Like the client, make sure /usr/src/linux contains the source to your running kernel and is version 2.4.x. Extract the sources: $ tar -zxvf kernel_emulator_10.tgz $ cd kernel_emulator_10 Edit the file scsi_target.h. Comment line 47: //# define MEMORYIO Uncomment line 49: #define FILEIO For an explanation of what these modes of operations do, read Ashish Palekar's paper included with the distribution (tr0101.pdf). Currently the client distribution works with either MEMORYIO or FILEIO. (Ashish has said GENERICIO mode works, I have been unable to get it working. This is sill being investigated) Build the iscsi_target and scsi_target kernel modules: $ make Note this distribution also includes a qlogicfc driver and an sep_target driver. These are not needed for our purposes. Optionally instead of using the kernel target, you may use the user space target provided with the client distribution. This is currently undocumented but should be straightforward to use. It is intended to simplify debugging the client for those wishing to hack my client code. -- Kernel Configuration -- On both machines make sure your kernel has compiled in support or modules for scsi, sg, and sd. (st and sr too if the device you want to use over iscsi is a cdrom or tape). On the target machine make sure you have compiled in support or modules for your scsi adapter. -- Running -- Before executing these insmod lines make sure your have the appropriate scsi modules loaded if necesary. The target modules when running in FILEIO mode open up two files scsi_disk_file_0_0 and scsi_disk_file_0_1 in the current directory. It uses these files as virtual disks. Before loading the target kernel modules, on the target machine create a symbolic link from your scsi device to scsi_disk_file_0_0: (in my case, I have a 520MB scsi disk attached to the only scsi adapter in the machine) $ ln -s /dev/sda scsi_disk_file_0_0 1. On the target, execute: $ insmod ./scsi_target.o $ insmod ./iscsi_target.o 2. On the client, execute: $ insmod ./iscsi.o $ insmod ./iscsi_client.o Note the target should be up and running before the client modules are loaded, otherwise the client will cause a kernel panic() due to a bug in my code. Also note that rmmod'ing the iscsi_client module will cause a panic() due to a bug in my code. Suggest rebooting the client for each new instantiation. -- Using iSCSI -- All commands henceforth are to be executed on the client. No further work is required on the target. Assuming that my directions were accurate and everything went ok, by this point you should have a working iSCSI connection. To verify, machine execute: $ lsmod and verify iscsi and iscsi_client are loaded. $ cat /proc/scsi/scsi and verify you see a listing similar to: Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: UNH-IOL Model: Target Emulator Rev: 1.1 Type: Direct-Access ANSI SCSI revision: 01 .... $ cat /proc/scsi/iscsi_client/0 and verify you see a message similar to: This driver implements the IETF iSCSI draft (SCSI over TCP/IP) At this point hopefully you've verified that your iSCSI setup is up and running. If there are no other SCSI adapters on your system, the first device available should be /dev/sda. You may now use /dev/sda on the client like any other SCSI disk as if it were local to the client. Examples include: ( to view/modify the partition table ) $ fdisk /dev/sda ( to create an ext2 filesystem on the first partition ) $ mke2fs /dev/sda1 ( to mount the iscsi partition ) $ cd /mnt $ mkdir iscsi $ mount /dev/sda1 /mnt/iscsi -t ext2 ( to copy files to and from the mounted iscsi partition ) $ cp /etc/passwd /mnt/iscsi/ $ cp /boot/vmlinuz-2.4.3 /mnt/iscsi/ $ cp /mnt/iscsi/passwd /tmp/passwd $ cp /mnt/iscsi/vmlinuz-2.4.3 /tmp/vmlinuz-2.4.3 ( to verify the integrity of the files copied to and from the iscsi partition ) $ diff /tmp/passwd /etc/passwd $ diff /tmp/vmlinuz-2.4.3 /boot/vmlinuz-2.4.3 -- Final Notes -- When you are done playing with the iscsi mount you should unmount per usual via: $ umount /mnt/iscsi In addition, since the client's kernel thinks its the only entity to ever access that scsi disk it may have buffered mount state. You should run: $ sync to force the client to flush any and all outstanding kernel buffers. Performance is abysmal in my setup, 10 Mbit eth network. 100K/s according to hdparm. I have a number of theories I am investigating. -- Problems/Questions/Flames -- Any problems you encounter specifically with the client setup should be directed to me, Michael F. Brown, mbrown@cs.uml.edu. Feel free to also contact me with help with the target setup. If I can't answer your questions about the target, I will forward them to Ashish Palekar, the author of the target drivers.

近期下载者

相关文件


收藏者