Commit Graph

1672 Commits

Author SHA1 Message Date
Roy Shterman
a628264ef0 Libiscsi: iSER implementation
This commit includes all iSER implementation in libscsi
library and utilities.

Also, adding iser option in url.

Change-Id: I55ca8a9d4db802e72eb991061260dbb0bd0ef9ba
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:59:01 -07:00
Ronnie Sahlberg
0a1b96c383 Add configure checks for iSER support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-03 18:54:38 -07:00
Roy Shterman
47b6881b97 Libiscsi: Adding abstraction to async functions
future iSER implementation will include different implementations
for all socket relative function. in iSER we get event only when
there is new entry in completion queue opposed to TCP that we get event
when we can write to the socket.

1. iscsi_get_fd -
	TCP - returns socket fd.
	ISER - returns completion queue channel fd.
2. iscsi_service -
	TCP -   processing the event type got from the socket
		and handles it.
	ISER -  rearming the event mechanism in the completion queue
		and polling all available completion queue entries for
		process.
3. iscsi_which_events -
	TCP -   returns which type of event the library is waiting for
		(Read, Write or both).
	ISER -  in iSER we are waiting only for POLLIN event, hence this
		function always returns POLLIN.

Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:54:02 -07:00
Roy Shterman
c85042bacb Libiscsi: Introducing new functions for zero-copy write operations
iscsi-command:  Adding new functions for all write operations (WRITE10,
                WRITE12, WRITE16, WRITEOR, etc') for cases where the user wants
                to pass his own io vectors (prevent memcpy).

                new functions are called iscsi_write*_iov_task and looks
                very similar to the iscsi_write*_task, only they get
		scsi_iovec pointer and number of scsi_iovec as
		parameters.

Change-Id: I719552b4cbda4f937975b5df7e77b4844e48cd16
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:51:27 -07:00
Ronnie Sahlberg
2bba53d31d We need the new read functions in libiscsi.def too
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-03 18:50:46 -07:00
Roy Shterman
e00e47d28d Libiscsi: Introducing new functions for zero-copy read operations
iscsi-command:  Adding new functions for all write operations (READ6,
                READ10, READ12, READ16, etc') for cases where the
		user wants to pass his own io vectors (prevent memcpy).

                new functions are called iscsi_read*_iov_task and looks
                very similar to the iscsi_read*_task, only they get
                scsi_iovec pointer and number of scsi_iovec as
                parameters.

Change-Id: Ice6bdb9227d72b20f495927f17d6757c124e4c84
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:47:55 -07:00
Roy Shterman
6c1bdb4808 Libiscsi: Adding free_pdu function to transport abstraction
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:47:23 -07:00
Roy Shterman
dff69584e0 Libiscsi: Adding disconnect function to transport abstraction
all library: change disconnect to iscsi->t->disconnect

1. In TCP we need only to put -1 in fd and we don't
have more transport resources. In future iSER we will need to
clean resources and destroy the rdma connection.

Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:46:50 -07:00
Roy Shterman
bc64420bad Libiscsi: Changing header iscsi_in_pdu
socket: need to malloc hdr

include/iscsi-private: changing iscsi_in_pdu hdr to char*
		       instead of static array for more convinient iser
		       pdu creation.

To use iscsi_in_pdu in iSER without making a copy of it
we need to change hdr to pointer from static array,
Because of that, iscsi_tcp flow need to do szmalloc (small zero malloc)
hdr when creating new iscsi_in_pdu. iscsi_in_pdu is being malloced
once per each received pdu. This change is reducing iscsi_in_pdu struct
size but adding extra allocation of the same size we reduced
from the struct.

Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:46:18 -07:00
Roy Shterman
2671e10565 Libiscsi: Adding new_pdu function to transport abstraction
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:45:44 -07:00
Roy Shterman
e3df0bbf96 Libiscsi: Adding queue pdu function to transport abstraction
include/iscsi-private: adding queue_pdu in transport function pointers
                       struct
include/iscsi: declaration of tcp_queue_pdu function

socket: adding queue_pdu function to transport initialization

all_library: changing iscsi_queue_pdu into iscsi->t->queue_pdu

Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:44:51 -07:00
Roy Shterman
0d6362ffe6 Libiscsi: Adding connect function to transport abstraction
socket: adding tcp_connect function and implement it
	in the last common part of iSER and TCP in iscsi_connect_async

Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:43:46 -07:00
Roy Shterman
9378a39ddc Libiscsi: Adding transport layer into all library utilities
lib/init: initializing connection transport

lib/socket: Adding function to initialize tcp transport.
            future commits will include adding iSER transport layer,
            so each transport option will has it's own template of functions.

all_utils: All utils stay the same, in future iSER commits in case of
	   iSER transport we will override tcp_transport in
	   iscsi_context.

connect: adding transport initialization when creating context

include/iscsi-private: Adding iscsi_transport attribute in iscsi_context

Signed-off-by: Roy Shterman <roysh@mellanox.com>

Make iscsi_init_tcp_transport private

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-03 18:43:03 -07:00
Ronnie Sahlberg
e26f6fe51a Merge pull request #208 from sitsofe/ws-0blocks-fixes
Tests: WRITESAME 0-blocks fixes and improvements
2016-06-01 19:41:20 -07:00
Sitsofe Wheeler
b908bdeb99 Tests: WRITESAME 0-blocks fixes and improvements
The current WRITE SAME (WS) 0 blocks test at LBA 0 isn't always correct
because if:
- The target's WSNZ bit set is 0
- The target's MAXIMUM WRITE SAME LENGTH (MWSL) is greater than 0
- We are issuing a WS with a NUMBER OF LOGICAL BLOCKS of 0

then whether the command should return success or failure depends on
whether the starting LBA is within MWSL blocks of the end of the LUN
(see http://www.t10.org/pipermail/t10/2016-May/017988.html for details).

Replace the vestigial code which tried to handle this (but no longer
worked since commit 8585e4509b ) and add
some additional MAXIMUM WRITE SAME LENGTH tests.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2016-05-30 12:37:58 +01:00
Ronnie Sahlberg
99980b2437 TESTS: fix unsigned/signed warning in writesame tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-23 21:47:21 -07:00
Ronnie Sahlberg
66f55eb3e0 Merge pull request #207 from ddiss/test_writesame_check
tests: add WRITESAME data verification tests
2016-05-23 21:44:18 -07:00
David Disseldorp
3644504147 tests: add WRITESAME data verification tests
Based on the corresponding simple tests. Issue a WRITESAME request and
confirm that the data written matches the data read back.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-05-18 11:59:54 +02:00
Ronnie Sahlberg
a341c665d8 Merge pull request #206 from plieven/fix_gitignore
gitignore: really ignore autom4te.cache
2016-05-13 05:36:24 -07:00
Peter Lieven
dd218f0e6b gitignore: really ignore autom4te.cache
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-13 09:22:23 +02:00
Ronnie Sahlberg
8da7b8df3e New version 1.17.0
This release contains a bugfix for a rare condition where
if a DATA-OUT PDU has a callback registered, it can cause a crash
on reconnect/timeout.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-08 12:37:59 -07:00
Ronnie Sahlberg
a41f97ad09 Merge pull request #204 from plieven/fix_segv
Fix seg fault on reconnect/timeout
2016-05-08 12:28:37 -07:00
Ronnie Sahlberg
62a81b6a53 Merge pull request #205 from sitsofe/exit1_on_fail
Tests: Exit iscsi-test-cu with 1 if a test fails
2016-05-06 06:22:31 -07:00
Sitsofe Wheeler
f291c7f9c0 Tests: Exit iscsi-test-cu with 1 if a test fails
Make it easier for build systems to tell a test run had failures by
changing the exit code to 1.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2016-05-05 17:18:19 +01:00
Peter Lieven
423b82efa4 pdu: check callback for NULL everywhere
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-02 13:55:13 +02:00
Peter Lieven
cde2043891 pdu: drop ISCSI_PDU_NO_CALLBACK
we use the flag ISCSI_PDU_NO_CALLBACK and pdu->callback simultaneously, but
check only for one of them in various places. So drop ISCSI_PDU_NO_CALLBACK
and check for pdu->callback != NULL instead.

All PDUs that carried this flag have pdu->callback set to NULL.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-02 10:40:15 +02:00
Peter Lieven
03fe4d73f7 iscsi-command: DATA OUT PDUs must have no callback
otherwise we might invoke a cmd_pdu callback multiple times
on timeout or reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-02 10:08:01 +02:00
Ronnie Sahlberg
2b9cd64e7c New version 1.16.0
- Various test updates.
 - Add tests for ExtendedCopy and ReceiveCopyResults
 - Add support for WRITE_ATOMIC_16 and tests
 - Multipath tests added
 - Persistent Reservation test updates.
 - Make sure to process target NOPs in the tests
 - Fix broken CHAP has handling.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-01 15:55:58 -07:00
Ronnie Sahlberg
a6fc65b4ef Tests: remove the warning if a SSD supports SANITIZE/OVERWRITE
There is technically no reason why a SSD with (assumingly with thin
provisioning) can not support SANITIZE/OVERWRITE instead or or in addition
to the more expected SANITIZE/BLOCK-ERASE so remove the warning for this.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-01 12:35:29 -07:00
Ronnie Sahlberg
526039793e Merge pull request #203 from sitsofe/mpath-initiator
Tests: Ensure each path sends a different initiator when using multipath
2016-05-01 11:44:34 -07:00
Sitsofe Wheeler
190f5712fe Tests: Ensure each path sends a different initiator when using multipath
Tests such as ProutPreempt presume each path they have is sending a
different initiator name. When using multipath this did not happen and
initiatorname1 was used on all paths.

Fix this by creating and initializing an array (currently size 2) of
initiator names and iterating it in step with each new path we make
(hopefully the compiler will complain if iscsi-test-cu ever supports
more than two multipaths and there isn't a corresponding initiatorname).

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2016-04-05 09:13:15 +01:00
Ronnie Sahlberg
678d70eb68 Tests: writeatimic simple. Make sure that writes are aligned correctly
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-04-03 09:56:16 -07:00
Ronnie Sahlberg
3458c2dd97 Merge pull request #199 from sitsofe/clang-fixes
Silence clang missing-field-initializers warning
2016-04-03 09:31:26 -07:00
Sitsofe Wheeler
71879c913a Silence clang missing-field-initializers warning
When libiscsi is built with clang several spurious
missing-field-initializers warnings like the following are reported:

test_async_write.c:61:45: error: missing field 'completed' initializer
[-Werror,-Wmissing-field-initializers]
	struct tests_async_write_state state = { 0 };

These appear to be due to clang being overzealous in its checking
because the code is legal C (see
https://llvm.org/bugs/show_bug.cgi?id=21689 ) but it causes compilation
to be aborted. Workaround the problem by specifying a 0 or NULL for each
structure member.
2016-03-31 20:32:47 +01:00
Ronnie Sahlberg
2bba2fedf9 Merge pull request #197 from bonzini/libiscsi-20160330
Fix iscsi-ls for IPv6 link-local addresses, and bump ABI version again
2016-03-30 19:25:48 -07:00
Jakob van Kruijssen
7d2e9ec708 Fix sending to many headers after completing CHAP auth.
TODO: see if this breaks something else.
2016-03-30 19:21:25 -07:00
Jakob van Kruijssen
81a7610155 Fix CHAP challange not being fully read and hashed. 2016-03-30 19:21:12 -07:00
Paolo Bonzini
edc5a80857 bump ABI version again
Commit 80b81772e2 again broke
the libiscsi ABI.  Bump the soname of the library.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-30 18:07:29 +02:00
Paolo Bonzini
d84ee65eaa iscsi-ls: skip link-local IPv6 addresses
Some iSCSI targets provide a link-local IPv6 address as a portal, but that
is unusable without knowing the interface (aka scope-id) to use for the
connection.  This causes iscsi-ls to report an EINVAL and exit.  Just
skip the error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-30 17:55:03 +02:00
Ronnie Sahlberg
8afffbd506 Fix compiler warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-03-27 10:51:05 -07:00
Ronnie Sahlberg
6f702198e9 Merge pull request #195 from ddiss/abort_nocancel
Remove local cancellation from ABORT TASK path and add simple test
2016-03-27 10:47:12 -07:00
David Disseldorp
bf9c7cb277 test: simple ABORT TASK TMF test
Dispatch a write and subsequently abort it.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:27:25 +01:00
David Disseldorp
bfd614053e test-tool: add test_get_clock_sec() helper
Useful for test IO timeouts.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:19:59 +01:00
David Disseldorp
f117b6c96d socket: add iscsi_out_queue_length() function
This function allows the caller to determine the number of PDUs queued
for transmission for a given iscsi context.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:19:51 +01:00
David Disseldorp
c38a8c1d9a task_mgmt: don't cancel local PDUs on ABORT TASK
Currently the iscsi_task_mgmt_abort_task_[a]sync() functions cancel any
queued or dispatched (awaiting response) PDUs prior to transmitting the
ABORT TASK TMF request, which means that a TMF request may be sent which
references a PDU that the target never received.

Bug: https://github.com/sahlberg/libiscsi/issues/192

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:12:09 +01:00
David Disseldorp
4a3dcf0349 iscsi: add response values for Task Mgmt Func
These values are defined in rfc3720
10.6. Task Management Function Response
-> 10.6.1.  Response

The response field is a single byte value, and is already used within
libiscsi as a command_data parameter for iscsi_task_mgmt_async()
callbacks.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2016-03-22 21:06:39 +01:00
Ronnie Sahlberg
a370208b38 Merge pull request #194 from plieven/segfault_fix
Fix Qemu Segfault
2016-03-17 19:41:00 -07:00
Peter Lieven
a7c94a7af5 connect: invoke all callbacks for dropped PDUs
if we drop a PDU which has a callback we should invoke it otherwise
the caller may wait infinetely for a command completion.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-03-17 12:08:26 +01:00
Peter Lieven
97406c5b36 Revert "Fail pending LOGOUT commands on session reconnect"
This seriously breaks qemu NOP timeouts and probably other things.
The reason is that the

define ISCSI_PDU_ERROR_ON_RECONNECT	0x00000016

is masking bits 0x2 and 0x4 as well.

Correctly it should read:
define ISCSI_PDU_ERROR_ON_RECONNECT	0x00000010

However, the better solution for this approach is invoke all callbacks
of PDUs which carry the ISCSI_PDU_DROP_ON_RECONNECT flag. This will
make sure that callbacks of whatever sync tasks are invoked.

This reverts commit 0407cf6aed.
2016-03-17 12:08:20 +01:00
Ronnie Sahlberg
d6e76e8ba4 Merge pull request #191 from ddiss/test-async
Tests: Asynchronous iSCSI
2016-03-14 19:42:22 -07:00