Just ignore any iSCSI AsyncMsg / SCSI Async Events we receive instead of
reconnecting. We can't pass the data back to the application anyway
with the current API.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
RFC3720 10.13.4. states that the statsn should explicitly set with
the first Login Repsonse. In theory the target could choose a StatSN
that is not greater than iscsi->statsn (zero at start) in Serial32
arithmetic.
Signed-off-by: Peter Lieven <pl@kamp.de>
RFC3720 10.19. NOP-In
NOP-In is either sent by a target as a response to a NOP-Out, as a
"ping" to an initiator, or as a means to carry a changed ExpCmdSN
and/or MaxCmdSN if another PDU will not be available for a long time
(as determined by the target).
...
Signed-off-by: Peter Lieven <pl@kamp.de>
originally NOPs where used to detect failures in the transport
layer. This is e.g. implemented in qemu since a few years now.
Recently I found a few vServers with hanging I/O where
the NOP mechanism could not detect the error.
The reason is most likely due to a bug in the target,
however if NOPs increase the CmdSN this could help
to detect such failures. If there are requests hanging
and the OS stops I/O before CmdSN > MaxCmdSN we can currently
send NOPs forever and they might still be answered. If
a NOP increases the CmdSN we will enter a point where CmdSN
is greater than MaxCmdSN. This is, of course, not the ideal check,
but it might detect some types of errors. Ideally we would
send out a Test-Unit-Ready command with attr=ordered, but
that requires a new API and/or modification of the tool
that uses libiscsi. This here comes with no modification for
the userspace.
Signed-off-by: Peter Lieven <pl@kamp.de>
iscsi-ls show luns command does not work when the target redirects at login.
to avoid redundant code allow iscsi_full_connect_async to skip the testunit ready
part.
Signed-off-by: Peter Lieven <pl@kamp.de>
We allowed iscsi to be NULL in iscsi_parse_url. Especially
qemu does this and currently segfaults at start. Change the
usage guidelines for target username/password to be the same
as for chap username/password.
Signed-off-by: Peter Lieven <pl@kamp.de>
Don't reset nalloc when resetting an iovector during reconnect.
Resetting offset/consumed should be sufficient.
Also, don't reset the iovectors when we detect an error condition in
iscsi_iovector_readv_writev. If there is a bug feeding an invalid
pos into this function, where pos suddently points before the amount
of data we have already read/written, then singlan this as an error
and return -EINVAL.
Previosly we did not reset the iovectors correctly when we re-queued
PDUs after a reconnect and thus relied on the iovectors being automatically
reset if/when we detected this type of error in readv_writev.
Now we do reset the iovectors properly so we do nt need to atuo reset them
here anymore and we can change this check to test for and abort the transfer
if an error is detected.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
The only PDU type that does not have ISCSI_PDU_DROP_ON_RECONNECT is the
SCSI COMMAND PDU. Thsi is the only PDU that we re-queue on reconnect.
All other, including DATA-OUT, NOP, task management, PDUs are simply
dropped.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This is a bug that has been there a long time.
When we reconnect and requeue a PDU we must reset the iovectors
for the task. Otherwise, any partially sent/received data when the
command is reconnected would end up containing garbage.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Rework the reconnect logic so we just call iscsi_scsi_command_async()
for the scsi commands we are re-quining instead of poking into the
private fields of the structures themself.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
We no longer need to modify pdu->flags directly any more from
iscsi_logout_async_internal. We can just pass these as extra flags to
iscsi_allocate_pdu().
We also always set ISCSI_PDU_DROP_ON_RECONNECT unconditionally so there is
no need to pass this flag in from the callers in pdu.c .
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Remove iscsi_allocate_pdu() which is just a wrapper.
Rename iscsi_allocate_pdu_with_itt_flags() to iscsi_allocate_pdu()
and update all callers.
This only removes a wrapper function and contains no logic changes.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
the recent implementation allows to send
iscsi->first_burst_length + iscsi->target_max_recv_data_segment_length
bytes if immediate and unsolicited data-out is send and
iscsi->target_max_recv_data_segment_length < iscsi->first_burst_length.
RFC3720 defines the length as:
Length=(min(FirstBurstLength, Expected Data
Transfer Length) - Received Immediate Data Length).
so that immediate data and unsolicited data-out are together
FirstBurstLength at maximum.
Signed-off-by: Peter Lieven <pl@kamp.de>
We write unsolicited data-out PDUs from two places;
when we originally write the command in iscsi_scsi_command_async()
but also when we re-queue the PDUs during a session reconnect.
The re-queuing during the session re-connect was recently (almost) fixed
but was still buggy in that it did not correctly clamp the amount of written
data as per first burst length restriction.
This attempts to fix that.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Both are the same value at this point but it is better to
do the computation only based on pdy-> fields.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
If we have writes that do not have the Final bit set during reconnect
we must send out any missing data-out PDU.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
If we have send unsolicited immediate data and are ALSO sending
unsilocoted data-out, then we have to exclude the length of data we have already sent.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
From Adam Endrodi <adam.endrodi@nsn.com>
Fix a bug and clear is_corked during socket disconnect so that we
can re-use the context for a new connection.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
set_tcp_sockopt in particular conflicts with libnfs's function of the same
name and prevents a a program from statically linking against both libnfs and
libiscsi.
Similar fix should also go into libnfs.
- Fix UNMAP tests
- Build updates
- Check residuals also when status != GOOD
- Add WSNZ bit to the tests
- Various test updates
- Fix bug in scsi_create_task so it sets cdb_len correctly
- Add a getter function for scsi task status and sense
- Fixes and workarounds for Dell Equallogic issues
- Be more flexible when allowing for unit attentions during connect time
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
We forgot to set task->cdb_size which means all tasks we create with this
function becomes test unit ready :-(
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>