Add better helpers to allow creating multiple LUNs for the tests and to
set the size of the luns.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Add ULL to all the large integer literals. Without this they can be
treated as being signed by the compiler (at least on 32 bit machines)
leading to underflow problems and strange output when calculating the
elapsed time.
7c6a3e4a0b wound up always forcing the
usage of gettimeofday (even when the more accurate CLOCK_MONOTONIC was
available) because the define to indicate its availability is in
config.h which wasn't included.
Fix this by including config.h, correct the misnamed variable in the
CLOCK_MONOTONIC branch and rename VERSION to PERF_VERSION to avoid the
naming conflict.
Move the scsi_free_scsi_task() call from receive_copy_results() to the
callers of this function to avoid that accessing the unmarshalled data
triggers a use-after-free.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
This patch avoids that Valgrind reports that an uninitialized buffer
is passed to writev():
Syscall param writev(vector[...]) points to uninitialised byte(s)
at 0x5557D07: writev (in /lib64/libc-2.19.so)
by 0x5269BFD: iscsi_iovector_readv_writev (socket.c:509)
by 0x526A7A9: iscsi_write_to_socket (socket.c:727)
by 0x526AE47: iscsi_service (socket.c:888)
by 0x526B632: event_loop (sync.c:67)
by 0x526D925: iscsi_scsi_command_sync (sync.c:1223)
by 0x405970: send_scsi_command (iscsi-support.c:276)
by 0x40B190: extendedcopy (iscsi-support.c:2673)
by 0x40E9FE: test_extendedcopy_param (test_extendedcopy_param.c:63)
by 0x503E260: ??? (in /usr/lib64/libcunit.so.1.0.1)
by 0x503E56E: ??? (in /usr/lib64/libcunit.so.1.0.1)
by 0x503E8A5: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1)
Address 0xffefff864 is on thread 1's stack
in frame #8, created by test_extendedcopy_param (test_extendedcopy_param.c:31)
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
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>
The test tool is simplistic and uses the synchronous API. In this API
we will only poll() the socket and process events during the lifetime of any
iscsi_*_sync() calls.
A problem with this approach arises with multipath tests. When iscsi-test-cu
is used with multiple devices we will first open a session for each
multipath leg, but then as most tests are only using the first device we end
up with creating secondary sessions we don't do any iscsi_*_sync() calls on
for very long times. If a target is set up to send NOPs on these
secondary paths it will not get any responses and eventually tear down the
connection.
To avoid this, try to make sure we service any secondary paths we have
created by calling iscsi_service(POLLIN|POLLOUT) every few seconds
to make sure we do service and respond to any NOPs.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.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>
We unified ISCSI and SCSI status codes a long long time ago
and got rid of the actual ISCSI_STATUS_* codes.
Update iscsi.h and remove references to these obsolete symbols
and replace with SCSI_STATUS_*
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>
If a previous run of the test tool had been interrupted one or
more persistent reservation keys can still be registered. This
can cause tests in the new run to fail. Avoid this by clearing
these keys before running any tests. Do this only if --dataloss
has been specified.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Avoid that running the regression tests against a LUN with size zero triggers
the following assertion failure:
lt-iscsi-test-cu: iscsi-support.c:1666: read6: Assertion `task != ((void *)0)' failed.
Aborted
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
This patch does not change any functionality but removes the number
of casts in the test tool source code.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Check that the Persistent Reserve Out PREEMT request removes the
registration referenced by the service action key.
Signed-off-by: David Disseldorp <ddiss@suse.de>
test_iscsi_tur_until_good() dispatches TUR requests until the target has
cleared all UAs for the given sd, or the maximum number of retries is
reached.
This helper function is useful for any test that needs to deal with UAs
(e.g. PRs), so should be moved out into common code.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Issue a Persistent Reservation Out PREEMPT request, with keys and type
provided.
PREEMPT allows for the removal of registrations, and replacement of
reservations.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Check that the Persistent Reserve In REPORT CAPABILITIES response
carries valid LENGTH, ALLOW COMMANDS, and PERSISTENT RESERVATION TYPE
MASK fields.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Issue a Persistent Reservation In REPORT CAPABILITIES request and parse
the response. Callers can obtain the unmarshalled response data via the
_rcaps parameter.
Signed-off-by: David Disseldorp <ddiss@suse.de>
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>
This test currently reconnects to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.
Signed-off-by: David Disseldorp <ddiss@suse.de>
These tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.
Signed-off-by: David Disseldorp <ddiss@suse.de>
These tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Many tests currently reconnect to the base sd for multi-initiator
testing. Use the secondary multipath device instead, if available.
Signed-off-by: David Disseldorp <ddiss@suse.de>
A number of existing tests create a secondary iSCSI session by logging
into the target specified in the base sd during the test.
With multipath sessions now connected during iscsi-test-cu startup
(when launched with multiple URIs), secondary sessions can be
provided via multipath when available, rather than reconnecting.
This change adds a helper that conditionally returns the secondary
multipath device if available, or falls back to creating a new session
via the base sd target details.
Signed-off-by: David Disseldorp <ddiss@suse.de>