Commit Graph

101 Commits

Author SHA1 Message Date
Ronnie Sahlberg
332ea04e8d TaskMgmt: Add a functionto set the Reference cmdsn for tm pdus 2011-02-15 21:44:16 +11:00
Ronnie Sahlberg
95db35e592 TaskMgmt: add a function to set the ritt for tm pdus 2011-02-15 21:42:23 +11:00
Ronnie Sahlberg
2c093d86a6 whitespace changes to the list of pdu types 2011-02-15 21:26:26 +11:00
Ronnie Sahlberg
704288169f Add task management pdu request and response constants to the list of pdu types 2011-02-15 21:24:24 +11:00
Ronnie Sahlberg
f73e42ec26 TaskManagement: Store the ITT and CMDSN in the scsi_task structure
These are required for some of the task management functions
2011-02-15 20:57:03 +11:00
Ronnie Sahlberg
b51807e65a README update 2011-02-13 08:09:08 +11:00
Ronnie Sahlberg
e3af8903ac README remove strace from example 2011-02-13 08:06:30 +11:00
Ronnie Sahlberg
52b7ae3152 LD_PRELOAD: add dup2 support so we can use it with dd 2011-02-13 07:36:26 +11:00
Ronnie Sahlberg
0c6025b01b Using two different structures, with the same first element, and casting
between them makes compilers complain about aliasing.

Merge the two and use one single structure bot both iscsi and scsi sync
commands so that gcc stops crying about strict-aliasing
2011-02-09 15:51:45 +11:00
Ronnie Sahlberg
7a454aa010 autogen.sh: we should create libiscsi.pc not ctdb.pc 2011-02-07 21:47:26 +11:00
Ronnie Sahlberg
947a1a7796 MAKEFILE: Add a distclean target 2011-02-07 21:46:57 +11:00
Ronnie Sahlberg
35821830d6 LD_ISCSI.SO LD_PRELOAD hack
ld_iscsi.so is a small LD_PRELOAD hack that can be used to make normal
unix utilities such as 'stat' and 'cat' become iSCSI 'aware' and fake
handling an iSCSI URL as a normal read-only file.

See README for examples.
2011-02-05 21:21:52 +11:00
Ronnie Sahlberg
eba0a2de81 SYNC READ10 : add a sync version for read10 2011-02-05 20:41:02 +11:00
Ronnie Sahlberg
c29b9a2aae Add a new "iscsi_queue_length()" which will tell us how many commands
are in flight at the moment.
Aside from commands, we also consider the "has not yet connected completely" as being an i/o.

When this command returns 0 it means we are connected ant the iscsi connection is idle, with no commands in flight.

KVM needs a function to detect idleness like this for its block layer io_flush
function.
2011-02-03 19:08:16 +11:00
Ronnie Sahlberg
d22a2aee3c When initializing a new session, default to set the
"random" ISID randomly.

Dont assume that users will never create multiple contexts
concurrently, in which case the previous getpid()^time(NULL)
would create duplicates.
2011-01-27 11:02:16 +11:00
Ronnie Sahlberg
ca1e152f2c New example file :
iscsi-dd can be used to copy the content of one iscsi lun onto a different
iscsi lun of the exact same sixe.

This example  illustrates how to "steal" a task structure from a callback
so we can use store it and have it remains valid after the read10 callback
has completed.
It also illustrates the async api of libiscsi for read10/write10.

Initially a number of read10 calls are made asynchronously until the
queue is full.
As each read10 completes and returns data, we issue a write10 to write
that data to the other lun.

As soon as a write10 completes, we "release" the initial read10 task corresponding to what we wrote and issue a new read10 to continue copying the next set of un-read data.

Using the async api, it should be easy to get very high performance and
throughput even from one single thread.
2011-01-23 18:35:58 +11:00
Ronnie Sahlberg
ec08fe7a45 Read10/Write10 parameters
LBA is uint32_t for read/write10

Also store the lba/numblocks arguments in the task structure for read10/write10
This makes it much easier to implement a fully async "read lots/write lots"
applications.
2011-01-23 18:34:16 +11:00
Ronnie Sahlberg
7b5ff1095c Improve help/usage strings for iscsi-ls and iscsi-inq
For help output, also print the syntax for the iscsi url required.
2011-01-09 10:36:53 +11:00
Ronnie Sahlberg
b2c4bdcd43 iscsi-ls: Destroy the iscsi_url when exiting. 2011-01-09 09:51:26 +11:00
Ronnie Sahlberg
f3f2031a8c Fix a compiler warning 2011-01-09 09:48:59 +11:00
Ronnie Sahlberg
b9ad4beb41 Replace rindex() with strrchr() 2011-01-09 09:47:39 +11:00
Ronnie Sahlberg
5e11bb17b1 Replace index() with strchr() 2011-01-09 09:46:42 +11:00
Ronnie Sahlberg
f1996d26a6 Check the return from asprintf() and report an error when it fails. 2011-01-09 09:43:33 +11:00
Ronnie Sahlberg
e312aa2ae0 ISID: Add helper functions to set any type of ISID value for the iscsi context.
Let default be to create a 'random' ISID during context creation.
2011-01-09 09:26:03 +11:00
Ronnie Sahlberg
b5d5370b8c TYPO, fix typo in iscsi.h 2011-01-09 09:04:13 +11:00
Ronnie Sahlberg
554670820b README: Add a blurb about HeaderDigest in libiscsi and what is the default 2011-01-09 08:58:32 +11:00
Ronnie Sahlberg
3b6176ad79 README: add a note about ipv6 support and ipv6 syntax 2011-01-09 08:54:58 +11:00
Ronnie Sahlberg
954e55148a TODO: expand on what we need to do to handle target-originated iscsi-nop. 2011-01-08 16:19:13 +11:00
Ronnie Sahlberg
acd459ad48 TOTO: ipv6 is done 2011-01-08 16:10:59 +11:00
Ronnie Sahlberg
aa916b7802 IPv6 Support. Add ipv6 support to the socket management.
IPv6 addresses are specified in [...] format.

iscsi://10.1.1.27/...
iscsi://10.1.1.27:3260/...
iscsi://[fec0::1]/...
iscsi://[fec0::1]:3260/...
2011-01-08 16:09:14 +11:00
Ronnie Sahlberg
7d702357d1 TODO: we need ipv6 at some stage 2011-01-06 20:03:23 +11:00
Ronnie Sahlberg
c877737b36 Add redirect support to TODO 2011-01-06 12:15:16 +11:00
Ronnie Sahlberg
827cf9af05 iscsi-ls --show-luns: We need to remember the username/password used
during the initial discovery login so we can use it again when we do
the normal logins to do inquiry/readcapacity for --show-luns
2011-01-03 18:16:40 +11:00
Ronnie Sahlberg
6f36a6ca2b Change HeaderDigest to default to None,CRC32C instead of None
This allows our default setting to work with any target configuration.
2011-01-03 15:54:38 +11:00
Ronnie Sahlberg
9ddce8dc24 Replace bzero() with memset() 2011-01-03 15:35:36 +11:00
Ronnie Sahlberg
77f1440b65 iscsi-ls: Use the helper function to parse the Portal URL
and add support for CHAP authentication during the discovery login.
2011-01-03 15:28:44 +11:00
Ronnie Sahlberg
7253a667ae Add a helper function to parse a Portal URL.
A Portal URL is of the form
   iscsi://[<username>[%<password>]@]<host>[:<port>]
and is used by command such as iscsi-ls during the discovery login phase.

During discovery we do not yet know the target iqn name, nor the lun of
any devices.
2011-01-03 15:22:01 +11:00
Ronnie Sahlberg
51662af5ba Document the iSCSI URL syntax and how to specify username/password 2011-01-03 15:10:15 +11:00
Ronnie Sahlberg
178f9c8751 Only set CHAP username/password if BOTH have been provided.
There is no point in setting the username if there is no password
and vice versa.

Also, if we only set username but not passwd this would lead to a segv.
2011-01-03 15:01:38 +11:00
Ronnie Sahlberg
5928575bac Allow setting the CHAP username/password via environment variables
so that the password will not be showing up in log where the application
logs the "filename/iscsi url" or in ps aux output.

LIBISCSI_CHAP_USERNAME and LIBISCSI_CHAP_PASSWORD environment variables are
available to set these outside of the url.
If hte username/password is ALSO set in the URL, the settings in the URL
will override the environment variables.
2011-01-03 14:58:52 +11:00
Ronnie Sahlberg
87072d5622 Dont use gethostbyname2() at all since it is non-portable,
use gethostbyname() instead.
2011-01-03 14:48:43 +11:00
Ronnie Sahlberg
71ec54603d Solaris install fixes, solaris needs to use ginstall, not install and it does not have ldconfig 2011-01-03 11:15:50 +11:00
Ronnie Sahlberg
adfb7326e3 Solaris needs -lsocket and -lnsl and does not support gethostbyname2()
With these changes we build and work on solaris
2011-01-03 10:57:35 +11:00
Ronnie Sahlberg
e7c24af75e Handle ImmediateData=Yes correctly when sending data to the target.
We should not handle any combination of
ImmediateData=Yes/No
InitialR2T=Yes/No
correctly
2011-01-02 19:51:08 +11:00
Ronnie Sahlberg
20eaf85dd4 Handle InitialR2T=Yes correctly when sendign data to a target and wait for a R2T before sending the first block of data.
We should now honour, and handle the case of
ImmediateData=No
InitialR2T=Yes
correctly for targets that are limited on receiveing data too fast.
2011-01-02 19:33:43 +11:00
Ronnie Sahlberg
74fadc9337 Add support for R2T PDUs.
Update the "send scsi command" fucntion to honour
"FirstBurstLength" so that we only send this many bytes as unsolicited data.

The wait for a train of R2T from the target to clock out additional
busrts of data until the full task data has been sent to the Target.

We should now honour, and handle the case of
ImmediateData=No
InitialR2T=No
correctly for targets that are limited on receiveing data too fast.
2011-01-02 19:27:32 +11:00
Ronnie Sahlberg
502843d64a Honour MaxRecvDataSegmentLength from the target and split DATAOUT into
chunks of this size.
2011-01-02 19:27:23 +11:00
Ronnie Sahlberg
d240e8b5aa Use an initiator specific and one target specific value for MaxRecvDataSegmentLength 2011-01-02 19:27:16 +11:00
Ronnie Sahlberg
5e5d6c05c0 Add a function to send DATAOUT PDUs.
Update the send pdu command to trap when we need to send data to the target
but we are not allowed to send using immediate data.
For this case, send the data as a separate DATAOUT pdu instead.

Twiddle the flags and other fields to now manage that we send the data
as two separate PDUs.
2011-01-02 18:01:21 +11:00
Ronnie Sahlberg
9a8fca8bea Add two new helpers iscsi_pdu_set_[datasn|bufferoffset]()
These two helpers can be used to set the corresponding fields in a
DATAOUT PDU
2011-01-02 18:01:08 +11:00