Commit Graph

1392 Commits

Author SHA1 Message Date
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
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
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
Peter Lieven
fe265aef9c connect: allow to avoid the testunit ready call in iscsi_full_connect_async
iscsi-ls show luns command does not work when the target redirects at login.
to avoid redundant code allow iscsi_full_connect_async to skip the testunit ready
part.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:48:01 +01:00
Peter Lieven
2955b2c616 init: apply settings to context in iscsi_parse_url
if iscsi_context is not NULL we apply the parsed settings
to the context.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:37:39 +01:00
Peter Lieven
a45094b7a7 init: fix segfaul in iscsi_parse_url
We allowed iscsi to be NULL in iscsi_parse_url. Especially
qemu does this and currently segfaults at start. Change the
usage guidelines for target username/password to be the same
as for chap username/password.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:07:52 +01:00
Ronnie Sahlberg
15490a4c3e Merge pull request #148 from plieven/for_upstream
For upstream
2015-03-24 19:05:13 -07:00
Peter Lieven
b55ce5cc09 reconnect: do not leak free small allocations
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-24 15:22:37 +01:00
Peter Lieven
3b6f796a1b reconnect: do not leak immediate PDUs
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-24 14:33:06 +01:00
Peter Lieven
2fc538c8be iscsi-perf: add SCSI_STATUS_BUSY and SCSI_STATUS_CHECK_CONDITION handling.
this also fixes abort on errors and time output.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-24 14:32:00 +01:00
Ronnie Sahlberg
33c7dd51b9 Merge branch 'master' of github.com:sahlberg/libiscsi 2015-03-22 08:26:28 -07:00
Ronnie Sahlberg
2f94f16d02 iovectors: don't reset nalloc when resetting an iovector
Don't reset nalloc when resetting an iovector during reconnect.
Resetting offset/consumed should be sufficient.

Also, don't reset the iovectors when we detect an error condition in
iscsi_iovector_readv_writev. If there is a bug feeding an invalid
pos into this function, where pos suddently points before the amount
of data we have already read/written, then singlan this as an error
and return -EINVAL.

Previosly we did not reset the iovectors correctly when we re-queued
PDUs after a reconnect and thus relied on the iovectors being automatically
reset if/when we detected this type of error in readv_writev.
Now we do reset the iovectors properly so we do nt need to atuo reset them
here anymore and we can change this check to test for and abort the transfer
if an error is detected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-22 08:20:29 -07:00
Ronnie Sahlberg
d33e41c9d4 Merge pull request #147 from plieven/destroy_segfault2
init: fix segfault in iscsi_destroy_context
2015-03-19 06:18:43 -07:00
Peter Lieven
ea2bcfd308 init: fix segfault in iscsi_destroy_context
observed when iscsi_destroy_context is called while a iscsi NOP out is in flight.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-19 12:40:37 +01:00
Sebastian Herbszt
373d5883d4 update .gitignore
Add test-tool/iscsi-test-cu to .gitignore.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
2015-03-14 11:11:21 -07:00
Ronnie Sahlberg
b1d0ac45f1 Add support for bidirectional CHAP
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-14 10:43:03 -07:00
Ronnie Sahlberg
b03959dbb5 Merge pull request #146 from stweil/master
Fix wrong checks for username
2015-03-07 07:38:04 -08:00
Stefan Weil
dd1ee0f51c Add more entries to .gitignore
When building on a host with installed libtool, some files are generated
which should be ignored by git:

	examples/iscsi-dd
	examples/iscsiclient
	examples/ld_iscsi.so
	utils/iscsi-inq
	utils/iscsi-ls
	utils/iscsi-perf
	utils/iscsi-readcapacity16
	utils/iscsi-swp

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Stefan Weil
86adf5847c Fix wrong checks for username
The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.

When libscsi is built using clang instead of gcc, those errors are reported:

iscsi-perf.c:256:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]

Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Stefan Weil
d7a8ab0f1e Remove trailing blanks
The files touched here need a bug fix which is applied with the
following patch.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Ronnie Sahlberg
54e32122d3 Merge branch 'requeue-pdu' 2015-03-02 19:47:23 -08:00
Ronnie Sahlberg
7ffce43dc9 iscsi-util.c: use PRIu64 instead of llu
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-02 19:46:46 -08:00