Commit Graph

1460 Commits

Author SHA1 Message Date
Ronnie Sahlberg
2170f656bc Merge branch 'master' of github.com:sahlberg/libiscsi 2015-05-09 15:40:22 -07:00
Ronnie Sahlberg
86ce6a0ccd TESTS: tgtd now had TGT_IPC_SOCKET so lets use it
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-09 15:39:45 -07:00
Ronnie Sahlberg
64ead1c3df Merge pull request #164 from plieven/for_upstream
pdu: add known exceptions to target serial processing
2015-05-08 07:32:29 -07:00
Peter Lieven
6aa47691ce pdu: add known execptions to target serial processing
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-08 12:47:34 +02:00
Ronnie Sahlberg
9c58bf64f4 Merge pull request #163 from rodrigc/fix1
Skip unsupported tests instead of failing
2015-05-07 06:32:14 -07:00
Craig Rodrigues
3aec1a37a9 Skip unsupported tests instead of failing
* SCSI_REPORT_SUPPORTING_OPCODE
* SCSI_REPORT_SUPPORTING_SERVICEACTION
2015-05-07 07:09:13 -04:00
Ronnie Sahlberg
6b51466048 Merge pull request #162 from plieven/for_upstream
For upstream
2015-05-05 06:19:17 -07:00
Peter Lieven
a027931a2c init: simplify the case that the freelist is full in iscsi_sfree
if the freelist gets full we are likely in a low load situation so
we do not need to make all the work copying the pointers.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 14:14:26 +02:00
Peter Lieven
b4098c535e init: make LIBISCSI_CACHE_ALLOCATIONS a public environment variable
this variable was introduced for iscsi-test-cu only. This patch
makes it a generic environment variable that can be set per context.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 14:10:44 +02:00
Peter Lieven
724f44c31b socket: change the order of POLLIN and POLLOUT in iscsi_service
the original idea of writing to the socket before reading was to put data
on the wire as early as possible and avoid potential latency increase due
to long taking callbacks invoked in iscsi_read_from_socket.

Benchmarking with libiscsi userland tools have shown that changing the
order increases throughput by about 5%.
The reason is that during POLLIN we might receive an updated MaxCmdSN
which might us allow to send new data out during POLLOUT.

For Qemu the change doesn't matter since POLLIN and POLLOUT are processed
independently.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 13:57:10 +02:00
Peter Lieven
e9d67540e1 add LIBISCSI_IGNORE_NOP_OUT_ON_STUCK_WAITPDU_QUEUE environment variable
this variable is a helper to tell libiscsi to not reset the nops_in_flight
on receival of a NOP-Out if the oldest element in the waitpdu queue is
not changed since the last NOP-Out.

The idea is that we can detect a command that the target silently dropped
by this mechanism and run into a NOP timeout forcing a reconnect.

This environment variable is not suitable if a command is send that is taking more than
the allowed timeout for a NOP-Out as a reply to a initiator generated NOP-In
(or several NOP-Outs if more than 1 in flight is allowed).

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 13:54:22 +02:00
Peter Lieven
efcf602476 nop: print a warning if the oldest element in iscsi->waitpdu queue is stuck
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-05-05 13:54:15 +02:00
Bart Van Assche
e7a90f7ecb test_sanitize_overwrite: Fix three log messages
check_lun_is_wiped() verifies whether the 256 blocks following LBA
'lba' contain byte value 'c'. Modify the log messages such that these
refer to byte value 'c' instead of to zero. Change the argument type
of 'c' from char into unsigned char to avoid that 'c' is sign
extended in the log statements.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:19:30 -07:00
Bart Van Assche
52a57d26f2 test-tool: Improve reliability of status_is_invalid_opcode()
The test_report_supported_opcodes_one_command() sends SCSI commands
to the target for which the target has to reply with ILLEGAL REQUEST
/ INVALID FIELD IN CDB. Avoid that such a reply is misinterpret as
"command not supported" by checking the field offset in the sense
descriptor. See also patch "test tool: Detect unsupported opcodes
correctly" (commit ID fe9620092c).

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:18:41 -07:00
Bart Van Assche
8435f9722e lib: Parse sense specific descriptor
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:17:51 -07:00
Bart Van Assche
fbc87ab12f test_compareandwrite_dpofua: Fix this test
Initialize the buffer with data from the medium to avoid to
trigger a miscompare and double the compareandwrite() xferlen
argument.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:15:54 -07:00
Ronnie Sahlberg
39c4322c99 Merge pull request #161 from czankel/master
Fix '0block' write same and unmap tests and 'out-of-tree' builds
2015-04-26 09:30:18 -07:00
Chris Zankel
a4bde6adfd test_writesame16_unmap_until_end: pass 0 blocks instead of 0-length block
The test:
  "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting
number-of-blocks==0"
was passing 0 for the data length instead of the block count.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:40:02 -07:00
Chris Zankel
de512a5888 test_unmap_0blocks: skip multi-descriptor test if unsupported
Some targets only support a single descriptor for unmap operations,
so skip (CU_PASS) the test cases that use multiple descriptors in
those cases. Only run the tests if maximum_unmap_block_descriptor_count
is less than 2.

Also the test
  "Test UNMAP of 0 blocks at LBA:0-255  with one descriptor per block")
was passing one less descriptor.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:39:49 -07:00
Chris Zankel
fff67ba7dd test_writesame*_0blocks: skip 0-block test if unsupported
Skip 0-block WRITE SAME tests for targets that don't support these
operations, ie. they have write_same_no_zero (WSNZ) set in the
block limits vpd.

Also, fix the test:
  "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting
number-of-blocks==0"
to actually pass 0 blocks instead of the number of remaining blocks to the end.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-23 17:36:38 -07:00
Ronnie Sahlberg
85c531e44e Merge pull request #160 from plieven/for_upstream
For upstream
2015-04-23 06:27:37 -07:00
Peter Lieven
cd0f4a30d6 connect: fir off by one error in iscsi->reconnect_max_retries
Before b152d26 it was possible to set iscsi->reconnect_max_retries to 0.
This allowed reconnects, but aborted as soon as the reconnect failed.
The same behaviour is currenltly only possible by setting iscsi->reconnect_max_retries
to 1. iscsi->reconnect_max_retries == 0 forbids reconnecting completly.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-23 14:16:17 +02:00
Peter Lieven
52a6bdb774 Revert "lib: Make iscsi_realloc() update the freed pointer list"
iscsi_realloc MUST NOT be called with a pointer that is in the freelist
of small allocations. First they are free and secondly a realloc
will change the size of the small allocation to an unknown size.

This reverts commit d8de6531f8.
2015-04-23 14:12:57 +02:00
Chris Zankel
9068f23f95 test-tool: print (logging) the actual sense code if mismatch
Print (log) the actual sense code that was returned if it doesn't match the
expected value.

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:27 -07:00
Chris Zankel
e186169064 build: fix 'out-of-tree' build
Prefix include paths with '${srcdir}' to allow 'out-of-tree' builds:

  cd $BUILD
  $LIBISCSI/configure
  make

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:14 -07:00
Chris Zankel
ff61508aa7 gitignore: exclude test/Makefile and test/Makefile.in
Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:13:54 -07:00
Bart Van Assche
cf4076dba9 test-tool: Make it possible to disable memory caching
Disable memory caching in libiscsi if the environment variable
LIBISCSI_CACHE_ALLOCATIONS has been set to zero. This makes
Valgrind reports more meaningful.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-20 07:01:17 -07:00
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