include/iscsi-private: adding queue_pdu in transport function pointers
struct
include/iscsi: declaration of tcp_queue_pdu function
socket: adding queue_pdu function to transport initialization
all_library: changing iscsi_queue_pdu into iscsi->t->queue_pdu
Signed-off-by: Roy Shterman <roysh@mellanox.com>
socket: adding tcp_connect function and implement it
in the last common part of iSER and TCP in iscsi_connect_async
Signed-off-by: Roy Shterman <roysh@mellanox.com>
lib/init: initializing connection transport
lib/socket: Adding function to initialize tcp transport.
future commits will include adding iSER transport layer,
so each transport option will has it's own template of functions.
all_utils: All utils stay the same, in future iSER commits in case of
iSER transport we will override tcp_transport in
iscsi_context.
connect: adding transport initialization when creating context
include/iscsi-private: Adding iscsi_transport attribute in iscsi_context
Signed-off-by: Roy Shterman <roysh@mellanox.com>
Make iscsi_init_tcp_transport private
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This release contains a bugfix for a rare condition where
if a DATA-OUT PDU has a callback registered, it can cause a crash
on reconnect/timeout.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
we use the flag ISCSI_PDU_NO_CALLBACK and pdu->callback simultaneously, but
check only for one of them in various places. So drop ISCSI_PDU_NO_CALLBACK
and check for pdu->callback != NULL instead.
All PDUs that carried this flag have pdu->callback set to NULL.
Signed-off-by: Peter Lieven <pl@kamp.de>
There is technically no reason why a SSD with (assumingly with thin
provisioning) can not support SANITIZE/OVERWRITE instead or or in addition
to the more expected SANITIZE/BLOCK-ERASE so remove the warning for this.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This function allows the caller to determine the number of PDUs queued
for transmission for a given iscsi context.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Currently the iscsi_task_mgmt_abort_task_[a]sync() functions cancel any
queued or dispatched (awaiting response) PDUs prior to transmitting the
ABORT TASK TMF request, which means that a TMF request may be sent which
references a PDU that the target never received.
Bug: https://github.com/sahlberg/libiscsi/issues/192
Signed-off-by: David Disseldorp <ddiss@suse.de>
if we drop a PDU which has a callback we should invoke it otherwise
the caller may wait infinetely for a command completion.
Signed-off-by: Peter Lieven <pl@kamp.de>
This seriously breaks qemu NOP timeouts and probably other things.
The reason is that the
define ISCSI_PDU_ERROR_ON_RECONNECT 0x00000016
is masking bits 0x2 and 0x4 as well.
Correctly it should read:
define ISCSI_PDU_ERROR_ON_RECONNECT 0x00000010
However, the better solution for this approach is invoke all callbacks
of PDUs which carry the ISCSI_PDU_DROP_ON_RECONNECT flag. This will
make sure that callbacks of whatever sync tasks are invoked.
This reverts commit 0407cf6aed.
Allocate the correct amount of memory for the scsi_copy_results_copy_status
and scsi_copy_results_op_params structures.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Certain iSCSI commands such as NOP and LOGOUT commands are discarded instead
of re-queued when we have a session failure and reconnect.
Change the LOGOUT command to instead fail with SCSI_STATUS_ERROR when this
happens.
Otherwise, IF we are in iscsi_logout_sync() and we get a session failure
at the same-ish time we may end up automatically re-connecting the
session, but since we have discarded the logout command we will never
get a reply and will hang indefinitely in the event loop for synchronous
commands.
Arguably, we could also just return SCSI_STATUS_GOOD here since
when we perform a logout, we probably don't care too much about how we
disconnected from the server, only that we did disconnect from the server.
That is academic anyway since this only affects the sync API which is only
meant for trivial applications, which will likely not inspect the result
and just do a:
...
iscsi_logout_sync()
iscsi_destroy_context()
...
anyway.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
During reconnect we normally defer any SCSI commands that are issued
to be queued and sent later, once the re-connect has completed and we have
swapped the contexts.
This is what we want for almost all situations, except when we are
reconnecting very simple applications which request "no ua on reconnect".
For these applications we want to actually send the TURs that are used
during the login phase on the temporary context.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Normal applications want the current behaviour where we have the library
consume any/all of the UnitAttentions that the target may have queued on the
initial connection, but when we reconnect the session after a failure the
library will pass all the UAs back to the application to process.
Some applications, such as the test suite or really trivial applications
might not want to have to deal with handling of UAs and just "make it work".
Those applications can now request that upon any reconnection of the session
that libiscsi will automatically consume any and all UAs and hide them from
the application.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
If the server closes the TCP connection before we call send() in
iscsi_write_to_socket() we will get SIGPIPE unless we pass this
argument to send.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
The Persistent Reserve In REPORT CAPABILITIES response carries the
ALLOW COMMANDS field in bits 4-6 at byte offset 3.
Bit 7 (TMV) should be masked out during ALLOW COMMANDS unmarshalling.
Signed-off-by: David Disseldorp <ddiss@suse.de>
- Replace some u_int32_t with uint32_t
- Portability fixes to iscsi-perf
- Improved documentation for the tests in README
- Add/fix support for setting task/pdu timeouts and add unit tests for it.
- Add multipath helpers for the test suite and add a simple multipath test
- Skip sending TUR during reconnect, since it can cause the connection to
- hang.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Add a test to verify the pdu timeout handling.
Fix numerous bugs in the timeout handling. It was really broken.
Add test for non-SCSI task PDUs too and verify they works.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Only use TUR to eat any pending unit attentions on the initial connect
but not during reconnect.
From Peter Lieven <pl@kamp.de>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
- Add support to use /dev/* nodes instead of just iscsi devices.
- Create a dedicated test for the FUA/DPO flags
- Allow reusing the context after disconnect
- Fix non-randomness in rand_key()
- Add iscsi-perf tool
- Fix length bug when sending unsolicited data in iscsi_command
- Reqrite the reconnect logic to begome fully async
- Fix wrong checks for username in CHAP
- Support Bidirectional CHAP
- Improve handling of IMMEDIATE bit
- Cmdsn, statsn fixes+
- iscsi_which_events can return 0, which means that there are no events right
now but try again in a second or so.
- Ignore any ASYNC EVENTS we receive since we can not yet pass them back to
the application.
- Add initial make test support
- Various minor fixes to libiscsi and the test suite
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
if the freelist gets full we are likely in a low load situation so
we do not need to make all the work copying the pointers.
Signed-off-by: Peter Lieven <pl@kamp.de>
this variable was introduced for iscsi-test-cu only. This patch
makes it a generic environment variable that can be set per context.
Signed-off-by: Peter Lieven <pl@kamp.de>
the original idea of writing to the socket before reading was to put data
on the wire as early as possible and avoid potential latency increase due
to long taking callbacks invoked in iscsi_read_from_socket.
Benchmarking with libiscsi userland tools have shown that changing the
order increases throughput by about 5%.
The reason is that during POLLIN we might receive an updated MaxCmdSN
which might us allow to send new data out during POLLOUT.
For Qemu the change doesn't matter since POLLIN and POLLOUT are processed
independently.
Signed-off-by: Peter Lieven <pl@kamp.de>
this variable is a helper to tell libiscsi to not reset the nops_in_flight
on receival of a NOP-Out if the oldest element in the waitpdu queue is
not changed since the last NOP-Out.
The idea is that we can detect a command that the target silently dropped
by this mechanism and run into a NOP timeout forcing a reconnect.
This environment variable is not suitable if a command is send that is taking more than
the allowed timeout for a NOP-Out as a reply to a initiator generated NOP-In
(or several NOP-Outs if more than 1 in flight is allowed).
Signed-off-by: Peter Lieven <pl@kamp.de>
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>