Commit Graph

1433 Commits

Author SHA1 Message Date
Bart Van Assche
d8de6531f8 lib: Make iscsi_realloc() update the freed pointer list
This patch improves the stability of libiscsi by avoiding that
stale pointers are passed to free().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-20 06:57:31 -07:00
Bart Van Assche
e3e4d8730c test_write*_residuals: Fix overflow tests
RFC 3720 is not clear about whether a target should return SUCCESS
or CHECK CONDITION if SPDTL > EDTL. Hence accept both. See also
Fred Knight, Re: [Ips] Data Out residual overflow/underflow handling,
IETF mailing list archive, 21 September 2012
(http://www.ietf.org/mail-archive/web/ips/current/msg02756.html).

This patch reworks the changes introduced via commit
cfce944b35 and applies similar changes
to the other WRITE and WRITE VERIFY tests.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-20 06:51:02 -07:00
Ronnie Sahlberg
6a7135a9dd Merge pull request #159 from plieven/for_upstream
For upstream
2015-04-20 06:01:16 -07:00
Peter Lieven
b3ad565783 pdu: move update of maxcmdsn, expcmdsn & statsn to iscsi_process_pdu
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-20 14:46:44 +02:00
Peter Lieven
1f6d901324 socket: fix disconnected message for pending logouts
the check was not quite correct. iscsi->pending_reconnect can be true but
we are still connected (and thus can disconnect). This is the case when
we receive an async logout request.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-20 14:26:11 +02:00
Peter Lieven
fe75c0f10c pdu: remove redundant logout message
the message is redundant since 1bb06b33

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-20 14:16:52 +02:00
Ronnie Sahlberg
b6fc366b5c TESTS: Add a test for D_SENSE in the CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-19 18:20:12 -07:00
Ronnie Sahlberg
669998e9d7 TESTS: the CONTROL mode page has SPF==0
When scanning for the CONTROL mode page we must also check that SPF==0
since otherwise we might pick up CONTROL EXTENSIONS or other subpages
that may be returned.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-19 17:27:20 -07:00
Christoph Hellwig
60a0289d74 iscsi-test-cu: set up vectored transfer length properly
I didn't set up the transfer length properly for the vectored SG_IO
support in the previous patch, which makes some implementations
of the ioctl unhappy.  Fix this up per the spec.
2015-04-18 12:06:14 -07:00
Ronnie Sahlberg
b745e28573 TESTS: remove some dead code
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:48:43 -07:00
Christoph Hellwig
b89f6592c4 iscsi-test-cu: fix implicit DATA OUT buffers with SG_IO
Command like PERSISTENT RESERVE OUT fill out DATA OUT data in their
CDB setup routine, but the SG_IO code doesn't look at that, leading
to a segfault when issueing such commands.  Fix this by copying over
some code from the iSCSI path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-04-18 08:44:24 -07:00
Christoph Hellwig
e2e401c50c iscsi-test-cu: support arbitrary device nodes
We support SG_IO on various block devices, including but not limited to:
SCSI disks, CDROMs and tapes, virtio-blk and nvmve.

Instead of checking a filename prefix just treat anything that isn't
an iscsi:// url as a device node.  The ioctl checks after open will weed
out devices (or files) that don't support SG_IO.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-04-18 08:43:00 -07:00
Ronnie Sahlberg
ba120e4347 TESTS: Add a test for the SWP flag in the CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:27:03 -07:00
Ronnie Sahlberg
4e174f5d7c TESTS: Add basic test for CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-18 08:03:15 -07:00
Ronnie Sahlberg
e978232447 Add a test that we reply to NOPs from the target
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-16 08:21:48 -07:00
Ronnie Sahlberg
ec4eb766c7 reconnect: improve error message is reconnect is disabled
if reconnect is disabled then a failure in iscsi_service_reconnect_if_loggedin
can leak back to the application by iscsi_service returning an error
but the error string is not being updated.
Thus the applucation will print the last prevous error message that was set.

Change iscsi_service_reconnect_if_loggedin to print a less confusing
error message.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-16 08:12:49 -07:00
Bart Van Assche
cfac4c5d55 configure.ac: Fix RHEL 5 build
Avoid that building libiscsi on a RHEL 5 system fails as follows:

configure.ac:7: error: possibly undefined macro: AM_SILENT_RULES

Avoid that the following warning is printed when building on a RHEL 5
system:

examples/Makefile.am:24: Libtool library used but `LIBTOOL' is undefined
examples/Makefile.am:24:
examples/Makefile.am:24: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
examples/Makefile.am:24: to `configure.ac' and run `aclocal' and `autoconf' again.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-16 06:39:04 -07:00
Bart Van Assche
d13a85cd39 configure.ac: Suppress an autoconf warning
Avoid that autoconf prints the following warning if AM_PROG_AR
is not defined:

configure.ac:9: warning: macro `AM_PROG_AR' not found in library

See also commits 1deb4f8e4a, ace7f200fb, b9cf7e8cd2 and
6cdb47b9b4.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-16 06:38:36 -07:00
Ronnie Sahlberg
d6858e08f4 Merge pull request #158 from plieven/for_upstream
For upstream
2015-04-16 06:05:07 -07:00
Peter Lieven
e4a448b115 init: don't close fd of iscsi->old_iscsi
its already closed at this point

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-16 11:58:39 +02:00
Peter Lieven
1bb06b337b login: log successful logout
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-16 11:58:33 +02:00
Peter Lieven
812d55d343 socket: do not show misleading disconnect message if we are not actually logged in
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-16 11:58:28 +02:00
Ronnie Sahlberg
f3a3854718 iscsi.h: document when iscsi_which_events return 0
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-15 08:25:16 -07:00
Ronnie Sahlberg
d9481ad488 Merge pull request #157 from plieven/for_upstream
pdu: fix Target NOP-In debug output
2015-04-14 06:08:26 -07:00
Peter Lieven
f455f2f760 pdu: fix Target NOP-In debug output
the lun parameter was missing.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-14 10:05:18 +02:00
Ronnie Sahlberg
e8a2296f94 Initial test branch for adding tests to libiscsi
These tests depends on not yet released version on TGTD to allow running
both TGTD and TGTADM as unprivileged users to set up and configure
targets to test against during make test.
Update TGTD to tip of master before running these tests.

See STGT mailinglist for patches.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-13 14:58:30 -07:00
Ronnie Sahlberg
fc6e06ce04 Merge pull request #155 from plieven/for_upstream
For upstream
2015-04-13 14:55:40 -07:00
Peter Lieven
2858cb5483 NOP: copy the LUN from target NOP-In to NOP-Out
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 14:34:23 +02:00
Peter Lieven
913b2ab708 reconnect: avoid deadlock if socker error is received during reconnect
If we are reconnecting and the connection is already established we
end up looping forever if there is a socket error before we finish
the login process. Fix this by invoking the reconnect callback if
there is an error and no new reconnect is scheduled.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 12:11:03 +02:00
Peter Lieven
e219f1bb97 utils/examples: avoid busy waiting on wait for reconnect
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:26:28 +02:00
Peter Lieven
a8b33cefac drop iscsi->is_reconnecting
iscsi->is_reconnecting != 0 is equal to iscsi->old_iscsi != NULL.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:13:36 +02:00
Peter Lieven
63fd8679fa reconnect: do not queue TESTUNIT_READY cdbs
those are part of the login process to consume UNIT_ATTENTIONS.

Its questionable if we should consume them at all, but iff we change
that behaviour we should do it for the initial login as well as
for a reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:06:32 +02:00
Bart Van Assche
b3783b961b test-tool: Avoid that Valgrind complains about uninitialized data
Avoid that Valgrind reports complaints similar to the following:

Syscall param writev(vector[...]) points to uninitialised byte(s)
   at 0x5567087: writev (writev.c:49)
   by 0x5265AE0: iscsi_iovector_readv_writev (socket.c:492)
   by 0x52666B5: iscsi_write_to_socket (socket.c:710)
   by 0x5266CCC: iscsi_service (socket.c:852)
   by 0x526751F: event_loop (sync.c:67)
   by 0x5269B41: iscsi_scsi_command_sync (sync.c:1153)
   by 0x4050F6: send_scsi_command (iscsi-support.c:245)
   by 0x408007: compareandwrite (iscsi-support.c:1512)
   by 0x40B6AD: test_compareandwrite_dpofua (test_compareandwrite_dpofua.c:69)
   by 0x503EC99: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503EF27: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503F2A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
 Address 0xffeffff10 is on thread 1's stack
 in frame #8, created by test_compareandwrite_dpofua (test_compareandwrite_dpofua.c:30)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-11 08:49:59 -07:00
Bart Van Assche
0995b0aa2b test_*_dpo*: Fix NULL pointer dereferences
Avoid that the DPO / DPOFUA tests triggers a NULL pointer dereference
if the MODE SENSE command in these tests fails.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-11 08:48:51 -07:00
Ronnie Sahlberg
35b8d6a45f Merge pull request #151 from plieven/reconnect_async
Reconnect async
2015-04-10 06:26:59 -07:00
Bart Van Assche
dbc4e33db2 test-tool: Fix a few sporadic crashes
Avoid that Valgrind reports complaints similar to the following:

Conditional jump or move depends on uninitialised value(s)
   at 0x405097: send_scsi_command (iscsi-support.c:240)
   by 0x40904B: reserve6_conflict (iscsi-support.c:1915)
   by 0x42231C: test_reserve6_logout (test_reserve6_logout.c:63)
   by 0x503EC99: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503EF27: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503F2A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x404B43: main (iscsi-test-cu.c:1292)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-09 19:56:19 -07:00
Ronnie Sahlberg
1a0897ae10 pdu.c: silently ignore any SCSI Async Events we receive
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>
2015-04-09 19:05:49 -07:00
Ronnie Sahlberg
ba3054151e Merge pull request #152 from plieven/for_upstream
discovery: set cmdsn in discovery pdu
2015-04-08 19:54:33 -07:00
Peter Lieven
47ea729d08 discovery: set cmdsn in discovery pdu
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-07 21:55:36 +02:00
Peter Lieven
d47b1ecec3 discovery: set cmdsn in discovery pdu
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-07 21:54:44 +02:00
Peter Lieven
a3e5c4d3c5 socket: allow iscsi_which_events to return 0
this is meant as a hint that there can be no event at the moment
and in this special case iscsi_service will return immediately.
We use this at the moment in the case of a wait for a reconnect
in which case we would enter a busy loop waiting for that
reconnect. The 0 means do not poll for the client application.
Do not poll, just wait a little (a few hundred ms) and call iscsi_which_events
again. The wait should be timer driven or at least non busy looping,
of course.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-02 08:34:52 +02:00
Peter Lieven
b7cb8fbf5a iscsi_service: dont return if a reconnect is pending but not yet reconnecting
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-02 08:31:53 +02:00
Peter Lieven
8398059635 sync: add iscsi_reconnect_sync
This function represents the old sync reconnect behaviour.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 16:33:36 +02:00
Peter Lieven
b152d26eb9 connect: make the reconnect async
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 16:21:00 +02:00
Bart Van Assche
12eea9756b test_writesame*_unmap: Optimize result buffer comparison
While running the test tool I noticed that a significant number
of CPU cycles was spent in test_writesame10_unmap(). Rewrite the
comparison loop such that it needs fewer CPU cycles. Use the same
comparison code in test_writesame16_unmap().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-03-31 06:52:09 -07:00
Bart Van Assche
52e45096df Do not pass NULL to access()
Avoid that Valgrind complains about passing a NULL pointer as first
argument to access().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-03-31 06:50:43 -07:00
Ronnie Sahlberg
7187353f5a Merge pull request #150 from plieven/for_upstream
For upstream
2015-03-31 06:48:47 -07:00
Peter Lieven
2c1b88e9e7 iscsi-perf: add a max reconnects switch and fix double CTRL-C
this adds a switch to define max_reconnects instead of just aborting
after a NOP timeout. It is now also possible to force an exit
if CTRL-C is pressed twice.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 15:44:46 +02:00
Ronnie Sahlberg
45360785e5 README: document how you can send patches to me
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-30 22:28:30 -07:00
Christoph Hellwig
c72edd514d test-tool: always use low-level SCSI APIs
This allows all tests to properly work on /dev/sg nodes instead
of segfaulting when a test is written the iSCSI-specific APIs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-03-30 22:24:41 -07:00