Commit Graph

1243 Commits

Author SHA1 Message Date
Ronnie Sahlberg
fc601fd228 Merge pull request #140 from plieven/vc
pdu: add workaround for DELL Equallogic FW bugs 71409 & 73732
2014-10-29 12:59:27 -07:00
Peter Lieven
ac46262afa pdu: add workaround for DELL Equallogic FW bugs 71409 & 73732
Dell Equallogic storages may redirect connections from one member of a multi member storage
group to another. When the member that has the volume lead changes the storage issues
an async disconnect request message. The correct behaviour would be to either fail all I/O requests
with a check condition (waiting for logout) or fullfil requests until the time specified
in the disconnect request message has elapsed and then drop the connection. In firwamre 7.x
however the storage sometimes cancels requests with SENSE KEY:ILLEGAL_REQUEST(5)
ASCQ:LOGICAL_UNIT_NOT_SUPPORTED(0x2500). This leads to I/O errors propagated to the application.
This patch was reported in May 2014 to Dell and the initial bug 71409 has been fixed in 7.0.7.
However, the first fix did not entirely solve the problem and bug 73732 has been raised.

This patch adds an environment variable LIBISCSI_DROP_CONN_ON_ASYNC_EVENT1 which if set leads
to an immediate drop of the connection when such an async event is received. This is ugly, but
works around the I/O errors.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-10-28 09:20:05 +01:00
Ronnie Sahlberg
3d6c2be342 configure: only build the test tool and ld-iscsi iff we have shared libraries
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-22 17:44:03 -07:00
Ronnie Sahlberg
9e514fbf44 scsi-lowlevel.c: check that task/datain are valid before we unmarshalling
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 09:48:16 -07:00
Ronnie Sahlberg
f6d57ef3b0 connect.c: remove UA whitelist and just consume up to 10 UAs before failing
Lets not use a whitelist of UnitAttentions that we consume during the connect
phase. Instead we can just loop and fail after the 10th.
If there are more than 10 UAs then we have a problem, otherwise
just consume them all, forget them  and then pass control back to the caller.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-23 17:23:27 -07:00
Ronnie Sahlberg
900ce145ad libiscsi.def: add missing scsi_cdb_compareandwrite and scs_malloc symbols
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-18 12:11:50 -07:00
Ronnie Sahlberg
97177ec0e4 Merge branch 'master' of github.com:sahlberg/libiscsi 2014-09-18 11:57:32 -07:00
Bart Van Assche
161547d5b6 lib/socket.c: Fix a use-after-free
This issue was introduced via patch "pdu: introduce ISCSI_PDU_CORK_WHEN_SENT"
on June 13, 2014 (commit 99585b6996).

Valgrind reported this use-after-free as follows:

Invalid read of size 4
   at 0x5267606: iscsi_write_to_socket (socket.c:721)
   by 0x5267A72: iscsi_service (socket.c:823)
   by 0x526827C: event_loop (sync.c:67)
   by 0x52698A4: iscsi_compareandwrite_sync (sync.c:823)
   by 0x408111: compareandwrite (iscsi-support.c:1752)
   by 0x4139E2: test_compareandwrite_simple (test_compareandwrite_simple.c:88)
   by 0x503D260: ??? (in /usr/lib64/libcunit.so.1.0.1)
   by 0x503D578: ??? (in /usr/lib64/libcunit.so.1.0.1)
   by 0x503D8B5: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1)
   by 0x4046C6: main (iscsi-test-cu.c:1241)
 Address 0x639f258 is 8 bytes inside a block of size 256 free'd
   at 0x4C291E7: free (vg_replace_malloc.c:473)
   by 0x525321B: iscsi_free (init.c:68)
   by 0x52532F0: iscsi_sfree (init.c:110)
   by 0x5257AD9: iscsi_free_pdu (pdu.c:179)
   by 0x5267601: iscsi_write_to_socket (socket.c:719)
   by 0x5267A72: iscsi_service (socket.c:823)
   by 0x526827C: event_loop (sync.c:67)
   by 0x52698A4: iscsi_compareandwrite_sync (sync.c:823)
   by 0x408111: compareandwrite (iscsi-support.c:1752)
   by 0x4139E2: test_compareandwrite_simple (test_compareandwrite_simple.c:88)
   by 0x503D260: ??? (in /usr/lib64/libcunit.so.1.0.1)
   by 0x503D578: ??? (in /usr/lib64/libcunit.so.1.0.1)

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Peter Lieven <pl@kamp.de>
2014-09-18 11:57:05 -07:00
Ronnie Sahlberg
389facbdf1 Merge pull request #136 from tpetazzoni/build-fixes
Build fixes
2014-09-07 08:16:47 -07:00
Thomas Petazzoni
80b47741c4 ld_iscsi: fix largefile related issues
This commit fixes two related issues in the ld_iscsi example with
largefile support.

The first issue appears when building libiscsi against the glibc C
library, with the flags -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64:

{standard input}: Assembler messages:
{standard input}:2774: Error: symbol `__fxstat64' is already defined
{standard input}:2850: Error: symbol `__lxstat64' is already defined
{standard input}:2938: Error: symbol `__xstat64' is already defined

This is due to the fact that when _FILE_OFFSET_BITS=64 is passed, the
*64() functions are defined by the C library as aliases to the
non-64*() functions, because those ones directly support large files
(i.e 64 bits).

The second issue appears when building libiscsi against the uClibc C
library, in a configuration that doesn't have largefile support. In
this case, the ld_iscsi that tries to use stat64 or some other *64()
functions cannot build, because such functions are not provided by the
C library. Of course, ld_iscsi does not need to wrap the *64()
functions in such a situation, because they do not exist.

This commit fixes those problems by enclosing the *64() related code
of ld_iscsi in the following compile time conditional:

This ensures that the *64() function handling is here only if
largefile support is available and enabled (_LARGEFILE_SOURCE64) and
if non-*64() functions are not already 64 bits capable (in which case
the 64*() functions are just aliases for the non-64*() ones).

See also
http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
for more details about the meaning of those macros.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-09-07 14:40:02 +02:00
Thomas Petazzoni
474e88740a Fix CUnit test for cross-compilation
The current test in configure.ac for CUnit uses AC_TRY_RUN, which
doesn't work in a cross-compilation context, because we can't run on
the build machine the binaries that are built for the target. In
addition, the current logic assumes CUnit is available when the
AC_TRY_RUN test cannot be used (e.g in a cross-compilation case).

Since we actually don't care about *running* but only about testing
whether a simple program include the CUnit header file and linking
against the cunit library works, simply use AC_TRY_LINK() instead of
AC_TRY_RUN().

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-09-07 14:40:02 +02:00
Ronnie Sahlberg
2dccc96160 Merge pull request #134 from plieven/fix_inquiry
test-tool: fix Inquiry.AllocLength
2014-08-21 18:50:12 -07:00
Ronnie Sahlberg
4650f47d63 Merge pull request #132 from plieven/test_lbas_check_desc
Some improvements for the get_lba_status tests.
2014-08-21 18:49:56 -07:00
Ronnie Sahlberg
55707fc1e6 Merge pull request #135 from sitsofe/intlitfix32
Add ULL suffix to large integer literals
2014-08-21 18:48:59 -07:00
Sitsofe Wheeler
3bac2a0e17 Add ULL suffix to large integer literals
When trying to compile libiscsi on a 32 bit Ubuntu 10.04 with gcc 4.4.3
errors like the following are produced:

test_get_lba_status_beyond_eol.c:45: error: integer constant is too
large for ‘long’ type

This is because we don't specify that we are explictly compiling to the
c99 standard and as such gcc defaults to gnu90 standard. This in turn
means the maximum default type of integer literals is unsigned long int
which not big enough to hold the literal on a 32 bit architecture.

Fix this by adding the ULL suffix to all large integer literals.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2014-08-21 18:04:37 +01:00
Bart Van Assche
ad5872c1d5 Fix test_writesame1[06]_unmap_unaligned()
As far as I know SPC-4 does not allow unaligned unmap requests to
fail. The only phrase I found in SPC-4 about unaligned unmap
requests is the following: "An unmap request with a starting LBA
that is not optimal may result in unmap operations on fewer LBAs
than requested." Hence check that unaligned unmap requests succeed.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:43:40 -07:00
Bart Van Assche
ded75ae18a Fix WRITE SAME data buffer length handling
From the SPC-4 paragraph about WRITE SAME(10): "The WRITE SAME (10)
command requests that the device server transfer a single logical
block from the Data-Out Buffer [ ... ]". Hence always pass a data
buffer when sending a WRITE SAME(10) command.

Set the NDOB bit in the WRITE SAME(16) command if no data out buffer
is present.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:42:49 -07:00
Bart Van Assche
e8c4be8f62 test_writesame16_0blocks: Add support for WSNZ=1
Support for WRITE SAME with NUMBER OF LOGICAL BLOCKS = 0 is optional.
Hence set NUMBER OF LOGICAL BLOCKS to 0 if this value is supported
and set this parameter to 1 otherwise.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:40:51 -07:00
Bart Van Assche
d4ac9ef1b5 Skip test_writesame1[06]_unmap large len test for small disks
Only perform the test with 65536 blocks on block devices with at
least that number of blocks. Fix the 65536 block test log message.
Generalize the WRITE SAME(10) 256-block test log messages. Fix
interpretation of the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field.
A quote from SPC-4: "If there is no limit on the number of UNMAP
block descriptors contained in the parameter data, then the device
server shall set the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field to
FFFF_FFFFh."

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:40:21 -07:00
Ronnie Sahlberg
1deb4f8e4a configure: tell platforms that dont have AM_PROG_* to just ignore it
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-16 19:43:25 -07:00
Ronnie Sahlberg
ace7f200fb Revert "Revert "configure.ac: Avoid that automake complains that AM_PROG_AR is missing""
After checking several platforms, we do need this change in order to build.
If CentOS<old-version> does not manage we need to figure out why and how to fix it.

This reverts commit b9cf7e8cd2.
2014-08-16 18:23:34 -07:00
Peter Lieven
1f900054e1 test-tool: fix Inquiry.AllocLength
according to SBC-2 the alloc length should be at least 5 when
evpd is set to zero.

Also don't leak task if SPC-3 or later.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-08-13 18:53:52 +02:00
Peter Lieven
f3ce541463 test-tool: fix GetLBAStatus.Simple exit
if GetLBAStatus fails immediately exit the test.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-08-13 17:58:32 +02:00
Peter Lieven
a2592bff3a test-tool: improve GetLBAStatus.UnmapSingle
the test became nearly useless when reverting most
of its contents in commit 7d96336.

This patch adds some useful stuff back. While
we can't check that unmapped blocks are deallocated
we still can check that the blocks surrounding the
unmapped area don't get dealloaced.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-08-13 17:55:09 +02:00
Peter Lieven
8e4e03d85d test-tool: allow get_lba_status to return provisioning type
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-08-13 17:02:51 +02:00
Ronnie Sahlberg
b9cf7e8cd2 Revert "configure.ac: Avoid that automake complains that AM_PROG_AR is missing"
AM_PROG_AR is not available on some platforms. Revert while I investigate.

This reverts commit 6cdb47b9b4.
2014-08-11 05:59:17 -07:00
Bart Van Assche
b631a2146c SPC-2 RESERVE tests: Use MODE SENSE instead of TEST UNIT READY
Although SPC-2 specifies that a reservation conflict should be
reported when TEST UNIT READY is received from another initiator than
the registered initiator, it is an established practice that TEST
UNIT READY is accepted in this case. Hence use the MODE SENSE command
to test the effect of the RESERVE command instead of TEST UNIT READY.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:05:25 -07:00
Bart Van Assche
bb8d01e093 test_compareandwrite_simple: Make error messages more verbose
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:05:09 -07:00
Bart Van Assche
f6c4a82a22 test_writesame*_0blocks.c: Include WSNZ bit in test
From the SBC-4 section about the block limits VPD page: "A write
same non-zero (WSNZ) bit set to one indicates that the device
server does not support a value of zero in the NUMBER OF LOGICAL
BLOCKS field in the WRITE SAME command CDBs (see 5.45, 5.46, and
5.47). A WSNZ bit set to zero indicates that the device server may
or may not support a value of zero in the NUMBER OF LOGICAL BLOCKS
field of the WRITE SAME commands." Hence verify that WRITE SAME
with NUMBER OF LOGICAL BLOCKS set to zero fails if WSNZ = 0.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:04:43 -07:00
Bart Van Assche
cfce944b35 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).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:04:21 -07:00
Bart Van Assche
d77765548f libiscsi: Also parse residual if SCSI status != GOOD
This change is needed for the test_write*_residuals tests.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:03:49 -07:00
Bart Van Assche
370741f83d configure.ac: Enable the subdir-objects option
Avoid that automake >= 1.14 warns that some source files are in a
subdirectory but that the option subdir-objects is disabled. See also
http://www.gnu.org/software/automake/manual/html_node/List-of-Automake-options.html#index-Options_002c-subdir_002dobjects

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-02 08:29:56 -07:00
Bart Van Assche
6cdb47b9b4 configure.ac: Avoid that automake complains that AM_PROG_AR is missing
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-02 08:29:26 -07:00
Ronnie Sahlberg
85cbf3c10e iscsi-dd.c: Don't use %lu for 64 bit integers
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-02 08:19:17 -07:00
Ronnie Sahlberg
7d96336d52 TESTS: don't check that UNMAP actually unmapped the blocks
We can not test that UNMAP will actually unmap anything even if
it returned status GOOD from the device.
Devices are allowed to "do nothing and return status GOOD" whenever they
want to.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-23 17:22:16 -07:00
Ronnie Sahlberg
9d3d40ae14 Typo
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-21 11:26:45 -07:00
Ronnie Sahlberg
8c27635c5d New version 1.12.0
- Fix bug in statsn wrapping
- Add support for async events

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-21 07:36:03 -07:00
Ronnie Sahlberg
cefb6a6127 TESTS: update the get_lba_status + unmap test to account for lbppbe
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-16 05:37:34 -07:00
Ronnie Sahlberg
e09d5fcefc Typo
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-14 20:29:23 -07:00
Ronnie Sahlberg
a41ec1fe60 TESTS: Add tests that get_lba_status for a single range works
Add a test for unmapping a single range of blocks and that
get_lba_status returns correct data.

Test unmapping a single block at offsets 0-255

Test unmapping 1-255 blocks at offset 0 and verify that
get_lba_status at LBA 0 returns a descriptor of 1-255 blocks.
get_lba_status at the last block of the unmapped range returns
a descriptor for a single block.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-14 19:46:12 -07:00
Ronnie Sahlberg
f0ebbdc203 Merge pull request #128 from plieven/revert_iovector
socket: rename max_read parameter to count in iscsi_iovector_readv_write...
2014-07-14 06:24:05 -07:00
Peter Lieven
53e38dff7d socket: rename max_read parameter to count in iscsi_iovector_readv_writev
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-07-14 15:05:19 +02:00
Ronnie Sahlberg
a0d09ca9de Merge pull request #127 from plieven/revert_iovector
Revert "Rewrite and simplify iscsi_iovector_readv_writev"
2014-07-14 05:56:12 -07:00
Ronnie Sahlberg
6ea698eed0 Merge pull request #126 from plieven/async_avoid_busy_wait
iscsi_which_events: do not set POLLOUT if context is corked
2014-07-14 05:55:20 -07:00
Peter Lieven
59e4a07129 Revert "Rewrite and simplify iscsi_iovector_readv_writev"
Since writing headers and payload in a single iov has never been
implementend and after thinking about it several times seems to
be very hairy I would like to revert this change since
the original implementation is in O(1) while the changed one
is in O(n). This results in a complexity of O(n^2) instead of
O(n) for the whole send operation.

This reverts commit 06eab264f6.
2014-07-14 08:05:32 +02:00
Peter Lieven
4b3f4b5822 iscsi_which_events: do not set POLLOUT if context is corked
if the socket is corked we otherwise set POLLOUT and then
do not sent. Depending on the event loop implementation this
can result in a busy wait.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-07-14 08:02:24 +02:00
Ronnie Sahlberg
6285ba72b7 iscsi-swp: Check user[0]!=0 instead of user!=NULL. user is no longer a pointer.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-13 17:19:24 -07:00
Ronnie Sahlberg
062dc151aa Merge pull request #108 from bonzini/reconnect-dangling-pointer-fix
libiscsi: fix dangling pointer for outqueue_current
2014-07-13 16:47:11 -07:00
Ronnie Sahlberg
ada1fc2008 Merge pull request #123 from plieven/asyncv3
add support for async messages
2014-07-13 16:46:27 -07:00
Ronnie Sahlberg
8e6af982a4 Merge pull request #125 from plieven/iscsi-test
iscsi-test: check for invalid descriptors offsets in get_lba_status
2014-07-13 16:35:19 -07:00