Commit Graph

375 Commits

Author SHA1 Message Date
Ronnie Sahlberg
e640fa3cde missing , broke compile 2013-04-22 18:28:20 -07:00
Ronnie Sahlberg
45f5fc2105 Add SSC to the version descriptors.
I actually have a usb-stick that claims it supports SSC. I stongly doubt it.
2013-04-22 17:44:13 -07:00
Ronnie Sahlberg
91a98d6b92 Add handling of inquiry version descriptors 2013-04-21 14:04:30 -07:00
Ronnie Sahlberg
402653b9f3 portability updates
add check if ipv6/sockaddr_in6 is availavble or not
add check for poll.h and only include when available
add includes for AROS
2013-04-18 19:43:36 -07:00
Ronnie Sahlberg
fbf58ead9f TESTS: When task management functions fail, print the reason why it failed. 2013-03-27 17:25:47 -07:00
Ronnie Sahlberg
aac7ed29b8 SYNC Task mgmt functions. Return !0 status if the command completed successfully
but the target responded with non-zero response code.
2013-03-26 17:38:47 -07:00
Ronnie Sahlberg
d5c5fb83af We should still be able to login even if the device is reserved.
TESTUNITREADY returning reservation conflict is no reason to fail the login
2013-03-21 19:26:55 -07:00
Ronnie Sahlberg
f8901ea18e Merge pull request #61 from plieven/ascq
Add ASCQ codes related to thin-provisioning
2013-03-11 06:46:20 -07:00
Peter Lieven
80ef1807ef Add ASCQ codes related to thin-provisioning
Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 12:13:42 +01:00
Peter Lieven
5a94d5d73a fix leak of iscsi_context in iscsi_reconnect
in case the maximum number of reconnects is limited with
iscsi_set_reconnect_max_retries() the an iscsi_context
is leaked if the limit is exhausted.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 08:51:18 +01:00
Peter Lieven
327b51ed5b do not reconnect if reconnect is already defered
If the amount of reconnects is limited with iscsi_set_reconnect_max_retries()
it might happen that iscsi_reconnect is called while there is already a deferred
reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-03-11 08:44:11 +01:00
Ronnie Sahlberg
3e28133a9a Add unmarshallers for READ*/VERIFY*/WRITE* cdb 2013-03-10 09:19:23 -07:00
Ronnie Sahlberg
0d5c8a4f11 TESTS: Add test for PREVENTALLOWMEDIUMREMOVAL are cleared on lun/target reset 2013-03-03 13:37:52 -08:00
Ronnie Sahlberg
100fcd796d Add ASCQ code for CAPACITY_DATA_HAS_CHANGED 2013-02-19 17:59:45 -08:00
Peter Lieven
8bc0046f51 changed iscsi_data.size from int to size_t
iscsi_data.size is used as parameter to memory
operation functions (such as malloc) which except
size_t rather than int.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-01-28 09:36:00 +01:00
Peter Lieven
7e46a5a337 RECONNECT fix lost allocation on reconnect.
Signed-off-by: Peter Lieven <pl@kamp.de>
2013-01-28 09:31:13 +01:00
Ronnie Sahlberg
0f73f062d2 SCSI: remove LBDATA/PBDATA from the WriteSame10/16 signatures
Make LBA the third argument to the iscsi writesame functions
2013-01-21 21:15:37 -08:00
Ronnie Sahlberg
72598c0b46 UNMAP: Fix marshalling of DATA when more than one unmap descriptor is sent. 2013-01-21 20:06:11 -08:00
Ronnie Sahlberg
065319f996 SCSI Add support for STATUS_BUSY
Add support for BUSY status coide from the target and just pass this
back to the application as is (instead of converting it to _ERROR).

This allows the application to trap task->status==SCSI_STATUS_BUSY and
decide what/how to proceed.
2013-01-01 10:15:56 -08:00
Lee Duncan
d72e6b3717 Removed custom struct for tracking Persistent Resvn type. 2012-12-23 21:36:46 -08:00
Lee Duncan
474cec5556 Added new 1130* test file for PGR simple reserve testing.
Added infrastructure to support reading, setting, and
clearing reservations.
2012-12-22 13:50:55 -08:00
Ronnie Sahlberg
09df905d30 Add unmarshalling ot REPORT_CAPABILITIES 2012-12-18 21:19:25 -08:00
Ronnie Sahlberg
4522658254 Add unmarshalling og READ_RESERVATION data 2012-12-18 21:10:26 -08:00
Ronnie Sahlberg
2a74fc00bc Initial support for PERSISTENT_RESERVER_OUT and add a simple test to show the api 2012-12-17 21:25:46 -08:00
Ronnie Sahlberg
2b46e4adfa Add unmarshalling of PERSISTENT_RESERVE_IN/READ_KEYS DATA-IN blob 2012-12-17 19:26:43 -08:00
Ronnie Sahlberg
c60093eafe Add support for PERSISTENT_RESERVE_IN and add a simple test for READ_KEYS 2012-12-17 19:01:50 -08:00
Peter Lieven
4cbbc0e1e9 SOCKET order packets in outqueue by CmdSN
Ordering by itt adds the special case of handling
itt == 0xffffffff. Order by CmdSN instead as described
by RFC3720.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-16 12:36:34 +01:00
Peter Lieven
2f9fda19d2 SOCKET do not queue PDUs with itt==0xffffffff head of queue
Queing packets with itt = 0xffffffff (e.g. NOP-Out replies) ahead
of queue because they might have a higher CmdSN than following
packets. This again could lead to a deadlock AND its a protocol
violotion:

RFC3720 Section 3.2.2.1 second last paragraph on Page 21:
"On any connection, the iSCSI initiator MUST send the commands in
increasing order of CmdSN, except for commands that are retransmitted
due to digest error recovery and connection recovery."

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-15 13:27:52 +01:00
Peter Lieven
735e3063ad PDU log header of rejected PDUs
Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-15 13:27:41 +01:00
Peter Lieven
446b1829c8 SOCKET use readv/writev to write directly into iovectors
This patch adds support for read/writev to directly read and write
from/to iovectors. Before this patch on read and write from/to socket
the operation was limited by the iovec boundaries. If there is enough
data in the buffer or enough buffer space available its now possible
to transfer the whole data in one atomic operaion.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-10 19:24:28 +01:00
Peter Lieven
752c0ad396 SOCKET set TCP_NODELAY on iscsi->fd
This will set TCP_NODELAY on the socket connection
to the target. This is the first step to improve latency.
For systems supporting TCP_CORK we plan to add a cork
around certain PDUs e.g. DATA-Out, but this needs further
testing.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-07 15:01:19 +01:00
Peter Lieven
36be387547 SOCKET remove useless code
At this point in iscsi_write_to_socket() pdu->written can only be
equal to total.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:30 +01:00
Peter Lieven
154760a00e RECONNECT remove redundant requeue code
We first merge waitpdu and outqueue queues and then requeue
the elements. iscsi_add_to_outqueue() will sort them accordingly
so this is no problem.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:23 +01:00
Peter Lieven
5f18c72706 RECONNCT fix broken reconnect for iov out vectors
We where modifying out_offset and out_len in iscsi_write_to_socket().
If the packet that was being sent before reconnect was a write command
the was a significant change that out_offset and out_len where already
touched. When requeing the packet after reconnect we where
sending garbage!

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:16 +01:00
Peter Lieven
237729545a NOP count in flight of client generated NOP-Outs
This patch adds the abilitiy to libiscsi to count the number
of consecutive outstanding NOPs.

With this ability its fairly easy to implement a keepalive
check with NOPs in your application.

Periodically (e.g. every 5 secs) create a NOP-Out with:

iscsi_nop_out_async(iscsi, NULL, NULL, 0, NULL);

At that time check the number of consecutive missing NOP-Ins
with

iscsi_get_nops_in_flight(iscsi) > N.

Where N is the number of missing NOP-Ins you will allow.
Please note that it is legitime for the Target to ignore
a NOP if the load is very high as those packet are mark
as IMMEDIATE.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:09 +01:00
Ronnie Sahlberg
d1344a666b Merge pull request #53 from plieven/reconnect_on_login_error
RECONNECT add option to limit the number of reconnect retries
2012-12-04 19:16:44 -08:00
Ronnie Sahlberg
22797e0f67 NOPs should not be requeued when reconnecting a session.
Just like DATA_OUT we should just discard NOPs instead of requeueing them
on session reconnect.
Add new flag that to indicate this behaviour on reconnect and set it for
both data out and nops
2012-12-04 19:07:49 -08:00
Peter Lieven
ee83c7ce75 RECONNECT add option to limit the number of reconnect retries
In specific situation it might be useful to give up if a reconnect
is not successful or after a given number reconnect retries.
This patch adds the ability to change that. The default remains
the same: retry forever.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-04 13:38:50 +01:00
Peter Lieven
be998cdaed DATA-IN fix broken read without iov
The preallocation logic was messing with size and offset of pdu->indata.
This was broken when we removed iscsi_data->alloc_size. Removing
entirely since reading without iovectors is deprecated.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-03 17:08:07 +01:00
Peter Lieven
dbe9a1e73a SOCKET queue cmd PDUs directly in waitpdu queue
A storage might sent an R2T response for a WRITE command while
we still sending out the WRITE command PDU. This is especially
the case when the command PDU carries immediata data.

Without this patch the R2T response will get lost as
the cmdpdu for the R2T cannot be found in iscsi_process_pdu()
leading to a deadlock.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-03 11:05:21 +01:00
Ronnie Sahlberg
39f42dbd2f Update comments explaining how we send unsolicited data.
Add comments to explain how/why we send unsolicited data.
This is a somewhat hairy area and it is easy to make mistakes here, so
extra comments on the how/why is useful.
2012-12-02 13:09:12 -08:00
Ronnie Sahlberg
023c7f855a Simplify the logic for when we need to send unsolicited DATA-OUT 2012-12-02 12:58:52 -08:00
Ronnie Sahlberg
338a8e26f5 When sending unsolicited data out, beginning of buffer to send is pdu->out_len, not pdu->offset.
We might have already sent pdu->out_len amount of data as immediate data.
2012-12-02 10:05:32 -08:00
Ronnie Sahlberg
a3ce92c93c Fix sending of unsolicited data in the first burst
When deciding if to generate a data out queue for the first sequence
the test was wrong.
We should not check if INITIAL_R2T is NO and IMMEDIATE_DATA=NO.
Immediate data does not matter here.

What we should check is IF we have more data we need to send and IF
INITIAL_R2T allows us to send more data, then we generate a train of DATA-OUT.

If MaxRecvDataSegmentLength is less than FirstBurstLength we will often have
to send unsolicited data as both ImmediateData and also as unsolicited
DATA-OUT PDUs.

Example:
Assume Target has responded :
MaxRecvDataSegmentLength = 8k
FirstBurstLength = 64k
ImmediateData=YES
InitialR2T=NO

Then this should generate the following sequence :
I->T   ISCSI_COMMAND + 8K of immediate data. F-Bit is not set.
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K
I->T   DATA-OUT 8K. Final PDU in sequence   so F-bit is set.
T->I   R2T
...
2012-12-02 09:55:07 -08:00
Ronnie Sahlberg
564fc9963a Max immediate data we can send is MIN(maxrecvdatasegmentlength, firstburstlength)
Also, we can send unsolicited DATA-OUT if we need to regardless of whether we also sent immediate data.
2012-12-02 09:37:18 -08:00
Ronnie Sahlberg
56707bcdf9 Fix how we negotiate IMMEDIATE_DATA. It defaults to YES and is negotiated
unless one side said NO
2012-12-01 11:21:24 -08:00
Ronnie Sahlberg
edb0df07d6 INITIAL_R2T defaults to YES 2012-12-01 09:43:49 -08:00
Ronnie Sahlberg
276f600181 Add functions to control how IMMEDIATE_DATA and INITIAL_R2T is negotiated 2012-12-01 09:19:50 -08:00
Ronnie Sahlberg
9a570e0b37 Dont clear the F-flag when we we have more data to send later as solicited data.
If we do a write that spans more than first-burst-length amount of data
and we can use immediate data.

This will lead to a sequence
I->T  SCSI_COMMAND + furst_burst_length of immediate data
T->I  R2T
I->T  DATA-OUT with the remainder of the data.
T->I  SCSI_RESPONSE

In this situation we still have to set the F-bit in the flags for the ISCSI_COMMAND.

The F-bit indicates that the PDU is the final PDU in the current sequence
and is what will trigger the target to process what it has currently received
after which the target will either respond with a SCSI-RESULT or DATA-IN if this
was the final sequence of the command,
Or in the case this was not the last sequence, then the target will send a R2T
to request the next sequence for this command.

In this scenario above we have two sequences.
the first sequence is the SCSI_COMMAND with immediate data and since it has filled the full amount of immediate data and can not send any more data until an R2T, this means this pdu ends the sequence and thus has the F-bit set.

Once we receive the R2T the second sequence starts, which also will have the F-bit set in the PDU.
2012-12-01 08:28:47 -08:00
Peter Lieven
92114f5d7a ISCSI fix broken send logic in iscsi_scsi_async_command [v2]
This fixes the IMMEDIATE_DATA_YES case if the paylaod did
not fit into the first PDU and fixes no unsolicited data
sent out iff IMMEDIATE_DATA_NO and INITIAL_R2T_NO.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-30 21:06:39 +01:00