Commit Graph

1587 Commits

Author SHA1 Message Date
Ronnie Sahlberg
bd29dab95b Tests: Create helper macros for the WriteVerify* commands
By creating a helper macros for WriteVerify we can save a lot of boilerplate
code.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-21 15:04:36 -08:00
Ronnie Sahlberg
72cfdbb5f1 Tests: Make null pointer asserts abort the test
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-21 14:55:54 -08:00
Ronnie Sahlberg
0f886b7d3a TaskMgmt: Remove null pointer check
We do not need to check the pointer for null here since it is guaranteed
to never be.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-20 14:36:32 -08:00
Ronnie Sahlberg
b240bf1a2c Don't free() things allicated through scsi_malloc()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-20 14:27:52 -08:00
Ronnie Sahlberg
0629d44e83 Remove C99 style variable declarations
Make it slightly more portable and move the declarations to the start of the
function.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:50:35 -08:00
Ronnie Sahlberg
99a5f99527 Add some emacs defaults. Tabs are 8 spaces.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:34:43 -08:00
Ronnie Sahlberg
da4496a232 Add create/remove lun helpers to the test suite
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>
2016-02-18 21:33:33 -08:00
Ronnie Sahlberg
e805db8793 Merge pull request #188 from sitsofe/socket-perf-fixes
Socket and iscsi-perf fixes
2016-02-11 06:53:49 -08:00
Sitsofe Wheeler
403ec4493a iscsi-perf: Add ULL suffix to large integer literals
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.
2016-01-30 09:44:45 +00:00
Sitsofe Wheeler
831b222917 iscsi-perf: Allow a better clock to be used
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.
2016-01-30 09:44:34 +00:00
Sitsofe Wheeler
6ea30f9fb2 socket: Simplify SOL_TCP check
Rather than checking for the names of OSes that don't implement it
just check whether the define is available directly.
2016-01-30 08:12:28 +00:00
Sitsofe Wheeler
4714e12e8f socket: Use alternatives if MSG_NOSIGNAL is unavailable
Only Linux has MSG_NOSIGNAL as a socket flag (see
http://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly
) which makes compilation fail on other OSes. The BSDs and OS X have
SO_NOSIGPIPE which implements the same thing but others like
Solaris don't even have that (see
http://stackoverflow.com/questions/2205455/detecting-broken-pipe-in-solaris-send-call
)...

Work around this by checking using MSG_NOSIGNAL or SO_NOSIGPIPE if
available otherwise don't set anything at all so we at least continue
to compile.
2016-01-30 07:50:50 +00:00
Bart Van Assche
be9b803334 test-tool: Avoid that using receive_copy_results() triggers a use-after-free
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>
2015-12-24 10:38:38 -08:00
Bart Van Assche
cacc144a29 test-tool: Initialize parameter buffers
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>
2015-12-24 10:36:55 -08:00
Ronnie Sahlberg
7b8363827b libiscsi: Fix RECEIVE COPY RESULTS response unmarshalling
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>
2015-12-24 10:36:04 -08:00
Bart Van Assche
9ab1cc8baa test-tool/*_dpofua: Fix memory leaks in error paths
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 08:55:25 -08:00
Bart Van Assche
e9536d3333 test-tool: Avoid that login failure causes a segmentation fault
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 08:54:40 -08:00
Ronnie Sahlberg
5532325042 Test-tool: call iscsi_service on MP devices once every second so we respond to NOP
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>
2015-12-15 21:55:03 -08:00
Ronnie Sahlberg
0407cf6aed Fail pending LOGOUT commands on session reconnect
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>
2015-12-15 21:17:50 -08:00
Ronnie Sahlberg
8e1332d70a Change ISCSI_STATUS_* to SCSI_STATUS_*
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_*
2015-12-15 21:09:42 -08:00
Ronnie Sahlberg
70391b6449 Typo
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-15 19:09:08 -08:00
Ronnie Sahlberg
916fef6c03 Allow sending TUR to consume all UAs during reconnect
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>
2015-12-15 19:05:55 -08:00
Ronnie Sahlberg
cda985167d Merge branch 'master' of github.com:sahlberg/libiscsi 2015-12-13 14:34:19 -08:00
Ronnie Sahlberg
3c44092635 Add a feature to request transparent reconnects without any UA
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>
2015-12-13 14:29:32 -08:00
Ronnie Sahlberg
a48710c9db Merge pull request #186 from ddiss/prout_preempt
test/pr: fix key deregistration in PRout PREEMPT test
2015-12-10 06:31:58 -08:00
David Disseldorp
086f1d1903 test/pr: fix key deregistration in PRout PREEMPT test
Remove duplicate k2 deregistration.

Reported-by: Chris Zankel <czankel@purestorage.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-12-10 12:02:03 +01:00
Ronnie Sahlberg
74fc637eeb Use MSG_NOSIGNAL with send()
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>
2015-12-06 12:12:49 -08:00
Bart Van Assche
0e0073e818 test-tool: Clear persistent reservation keys before tests are run
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>
2015-10-07 07:45:32 -07:00
Bart Van Assche
0bddefca95 test_report_supported_opcodes_one_command: Make reporting more detailed
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:44:59 -07:00
Bart Van Assche
2d412530c1 test-tool: Move all_zeroes() helper function to iscsi-support.c
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:44:18 -07:00
Bart Van Assche
5231923bc8 test_read6_beyond_eol: Fix an assertion failure
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>
2015-10-07 07:43:41 -07:00
Bart Van Assche
393165d66a test-tool: Remove three casts
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>
2015-10-07 07:43:00 -07:00
Bart Van Assche
608dbcba12 scsi-lowlevel.c: Use sizeof() instead of a hardcoded constant
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:42:30 -07:00
Ronnie Sahlberg
c26710345f Merge pull request #184 from ddiss/pr_report_caps_and_preempt_tests
Persistent Reservation REPORT CAPS and PREEMPT tests
2015-10-07 07:41:16 -07:00
David Disseldorp
b9b414981c test/pr: PRout PREEMPT remove registration test
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>
2015-09-30 11:00:25 +02:00
David Disseldorp
a1d11eb0f9 test: move UA drain helper function into iscsi-support
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>
2015-09-30 11:00:25 +02:00
David Disseldorp
760ae95d9c test: add prout_preempt() helper function
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>
2015-09-30 11:00:25 +02:00
David Disseldorp
9aa5b55b41 test/pr: simple PRin REPORT CAPABILITIES test
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>
2015-09-30 11:00:19 +02:00
David Disseldorp
9c524b37fa test: add prin_report_caps() helper function
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>
2015-09-30 11:00:19 +02:00
David Disseldorp
ef8e59a24d lib/scsi: fix PRin REPORT CAPS allow_cmds unmarshalling
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>
2015-09-30 11:00:13 +02:00
Ronnie Sahlberg
46e606f048 Merge pull request #182 from ddiss/mp_instead_of_reconnect
use multipath for secondary sessions (if available) instead of reconnecting
2015-09-28 19:24:43 -07:00
David Disseldorp
4f55a3f5c3 test/preventallow: use multipath session if available
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>
2015-09-21 15:53:31 +02:00
David Disseldorp
69d9a77f14 test/sanitize: use multipath session if available
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>
2015-09-21 15:52:40 +02:00
David Disseldorp
638d58dd57 test/prout: use multipath session if available
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>
2015-09-21 15:47:21 +02:00
David Disseldorp
89c1749ae7 test/reserve6: use multipath session if available
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>
2015-09-21 15:40:18 +02:00
David Disseldorp
0cfc593bbd test/multipath: add helper to obtain secondary sessions
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>
2015-09-21 15:11:37 +02:00
Ronnie Sahlberg
1540ab460d TESTS: remove extra assert
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:48:26 -07:00
Ronnie Sahlberg
fae0d70260 TESTS: Dont try to eject the media if preventallow is not supported
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:29:29 -07:00
Ronnie Sahlberg
e725788eeb TESTS: WriteAtomic fixes to handle devices that do not return BlockLimits VPD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:12:01 -07:00
Ronnie Sahlberg
fe1017fe2a TESTS: Don't test WriteSame10/16 if we do not have BlockLimits VPD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-19 16:06:05 -07:00