Commit Graph

2061 Commits

Author SHA1 Message Date
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
Peter Lieven
153e6ba07c pdu: set pdu->cmdsn when the pdu structure is updated
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-30 12:32:03 +02:00
Peter Lieven
395ca12746 login: implicitly set statsn
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>
2015-03-30 11:50:04 +02:00
Peter Lieven
79246def9d login: randomize cmdsn and itt
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-30 11:43:07 +02:00
Peter Lieven
74c2869b54 nop: a NOP-Out Reply may also update the statsn
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-30 09:03:18 +02:00
Peter Lieven
7e97763155 nop: add even more SN debugging
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-30 09:02:42 +02:00
Peter Lieven
37f908bb8a socket: set expstatsn when we put the PDU on the wire
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-30 08:44:50 +02:00
Peter Lieven
47e2b8918e socket: Data-Out PDUs may carry a CmdSN < ExpCmdSN
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 22:21:51 +01:00
Peter Lieven
7fd58eca21 pdu: a target NOP-In may indiciate a changes MaxCmdSN or ExpCmdSN
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>
2015-03-27 13:16:42 +01:00
Peter Lieven
b9dc3749c9 iscsi-perf: add a switch to send requests of random size
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 12:18:58 +01:00
Peter Lieven
9d6f0690f8 iscsi-perf: add NOPs to the perf stream and account for timeouts
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 11:08:37 +01:00
Peter Lieven
cc54f4938b nop: add some more SN debugging
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 10:38:33 +01:00
Peter Lieven
5c4bd85b80 nop: clear immediate flag in iscsi_nop_out_async
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>
2015-03-27 09:53:23 +01:00
Peter Lieven
cb6667a5dc drop ISCSI_PDU_URGENT_DELIVERY
its not needed anymore

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 17:00:20 +01:00
Peter Lieven
ff67986b55 login: drop iscsi_logout_async_internal
now that immediate PDUs are queued at the head of outqueue we do no
longer need the immediate delivery hack.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 16:56:50 +01:00
Peter Lieven
2a57cea180 socket: queue immediate PDUs at front of outqueue
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 16:51:18 +01:00
Peter Lieven
b76c8a703e socket: honour ISCSI_PDU_IMMEDIATE in iscsi_which_events
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 16:45:03 +01:00
Peter Lieven
0962150193 nop: increase logging if more than one NOP is in flight
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 16:34:35 +01:00
Ronnie Sahlberg
38cc03f709 Merge pull request #149 from plieven/for_upstream
init: fix segfaul in iscsi_parse_url
2015-03-26 06:29:35 -07:00
Peter Lieven
33c301335b socket: check if expcmdsn is not greater than pdus cmdsn
this is just another sanity check.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 12:27:48 +01:00
Peter Lieven
21cb9a9014 debug: add NOP Out and stalled outqueue debug messages
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 12:18:29 +01:00
Peter Lieven
4ce740f737 socket: fix bounds check in iscsi_iovector_readv_writev
if we received too little iovectors niov++ may also
make iov2 point to uninitialized memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 11:42:53 +01:00
Peter Lieven
44b1a2e1e0 iscsi-perf: use a common iovec for all requests
this avoids a lot of unnecessary mallocs and frees.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 11:08:31 +01:00