Commit Graph

208 Commits

Author SHA1 Message Date
Ronnie Sahlberg
09df905d30 Add unmarshalling ot REPORT_CAPABILITIES 2012-12-18 21:19:25 -08:00
Ronnie Sahlberg
4522658254 Add unmarshalling og READ_RESERVATION data 2012-12-18 21:10:26 -08:00
Ronnie Sahlberg
0338e4edd0 TEST: Change the last test to be a more simple REGISTER/UNREGISTER test for persisntet registrations. 2012-12-18 20:30:03 -08:00
Ronnie Sahlberg
2a74fc00bc Initial support for PERSISTENT_RESERVER_OUT and add a simple test to show the api 2012-12-17 21:25:46 -08:00
Ronnie Sahlberg
2b46e4adfa Add unmarshalling of PERSISTENT_RESERVE_IN/READ_KEYS DATA-IN blob 2012-12-17 19:26:43 -08:00
Ronnie Sahlberg
c60093eafe Add support for PERSISTENT_RESERVE_IN and add a simple test for READ_KEYS 2012-12-17 19:01:50 -08:00
Peter Lieven
446b1829c8 SOCKET use readv/writev to write directly into iovectors
This patch adds support for read/writev to directly read and write
from/to iovectors. Before this patch on read and write from/to socket
the operation was limited by the iovec boundaries. If there is enough
data in the buffer or enough buffer space available its now possible
to transfer the whole data in one atomic operaion.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-10 19:24:28 +01:00
Peter Lieven
5f18c72706 RECONNCT fix broken reconnect for iov out vectors
We where modifying out_offset and out_len in iscsi_write_to_socket().
If the packet that was being sent before reconnect was a write command
the was a significant change that out_offset and out_len where already
touched. When requeing the packet after reconnect we where
sending garbage!

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:16 +01:00
Peter Lieven
237729545a NOP count in flight of client generated NOP-Outs
This patch adds the abilitiy to libiscsi to count the number
of consecutive outstanding NOPs.

With this ability its fairly easy to implement a keepalive
check with NOPs in your application.

Periodically (e.g. every 5 secs) create a NOP-Out with:

iscsi_nop_out_async(iscsi, NULL, NULL, 0, NULL);

At that time check the number of consecutive missing NOP-Ins
with

iscsi_get_nops_in_flight(iscsi) > N.

Where N is the number of missing NOP-Ins you will allow.
Please note that it is legitime for the Target to ignore
a NOP if the load is very high as those packet are mark
as IMMEDIATE.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-06 10:42:09 +01:00
Ronnie Sahlberg
d1344a666b Merge pull request #53 from plieven/reconnect_on_login_error
RECONNECT add option to limit the number of reconnect retries
2012-12-04 19:16:44 -08:00
Ronnie Sahlberg
22797e0f67 NOPs should not be requeued when reconnecting a session.
Just like DATA_OUT we should just discard NOPs instead of requeueing them
on session reconnect.
Add new flag that to indicate this behaviour on reconnect and set it for
both data out and nops
2012-12-04 19:07:49 -08:00
Peter Lieven
ee83c7ce75 RECONNECT add option to limit the number of reconnect retries
In specific situation it might be useful to give up if a reconnect
is not successful or after a given number reconnect retries.
This patch adds the ability to change that. The default remains
the same: retry forever.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-04 13:38:50 +01:00
Peter Lieven
dbe9a1e73a SOCKET queue cmd PDUs directly in waitpdu queue
A storage might sent an R2T response for a WRITE command while
we still sending out the WRITE command PDU. This is especially
the case when the command PDU carries immediata data.

Without this patch the R2T response will get lost as
the cmdpdu for the R2T cannot be found in iscsi_process_pdu()
leading to a deadlock.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-12-03 11:05:21 +01:00
Ronnie Sahlberg
04970ef95e TESTS: Add a new test that does a one block write using unsilicited immediate data
As part of the test also validate the PDU that libiscsi generates and verify that
1, the PDU we send has the F flag set
2, that datasegmentlength for the PDU is one block
2012-12-01 10:45:42 -08:00
Ronnie Sahlberg
276f600181 Add functions to control how IMMEDIATE_DATA and INITIAL_R2T is negotiated 2012-12-01 09:19:50 -08:00
Ronnie Sahlberg
6661f290a0 Remove next/prev pointers from the scsi_cbdata structure 2012-12-01 08:14:49 -08:00
Ronnie Sahlberg
3ae7cec51d Revert "ISCSI fix broken send logic in iscsi_scsi_async_command"
This reverts commit 548bd22f51.

Revert for now. Will check it later today.
Causes 0130 and other tests to fail/hang when sending a solicited data-out
2012-11-30 06:49:53 -08:00
Peter Lieven
58e5ef5cbc SCSI_IOVECTOR remove size field
Remove the size field as it is not used. If we would keep it
we would have to calculate it in scsi_task_set_iov_in/out which
would add unneccassry wals to the iovec array.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-30 08:44:33 +01:00
Peter Lieven
548bd22f51 ISCSI fix broken send logic in iscsi_scsi_async_command
The send logic was completely broken for any cases except
ISCSI_INITIAL_R2T_NO and ISCSI_IMMEDIATE_DATA_YES.
The final flag was set wrong or no data was sent.

It was also broken if the data did not fit into the cmd_pdu as
the consecutive pdus did not have the scsi_cbdata set which
lead to a segfault in iscsi_get_user_out_buffer().

Unfortunately we need to include scsi-lowlevel.h again in iscsi-private.h.
This should be fixed asap by introduction of an iscsi_task struct
to avoid to store iscsi relevant data in the scsi_task.

Signed-off-by: Peter Lieven <pl@kamp.de>

Conflicts:

	lib/iscsi-command.c

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-30 08:43:34 +01:00
Ronnie Sahlberg
b1da7311c4 change u_int to uint 2012-11-29 19:14:26 -08:00
Ronnie Sahlberg
9449753a5d Remove iscsi_scsi_free_cbdata from the headers 2012-11-29 18:49:06 -08:00
Ronnie Sahlberg
5ffb58c55f Merge branch 'zero_copy_write-3' into resolve-conflicts
Conflicts:
	lib/iscsi-command.c
	lib/pdu.c
	lib/socket.c
2012-11-29 18:46:51 -08:00
Ronnie Sahlberg
6eb523af64 Merge pull request #45 from plieven/nest-scsi_cbdata
ISCSI_PDU nest iscsi_scsi_cbdata
2012-11-29 06:36:06 -08:00
Peter Lieven
562dd46833 PDU avoid incrementing itt to 0xffffffff
This patch avoid incrementing itt to 0xffffffff which is
a reserved value for immediate pdus. Avoid incrementing
it to 0xfffffff to avoid unexpected behaviour.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-28 10:58:33 +01:00
Peter Lieven
cd09c0f17d PDU use serial32 arithmetic for cmdsn, maxcmdsn and expcmdsn.
RFC3720 says that cmdsn comparison must be done using
serial32 arithmetic. This will definetly avoid a deadlock
if cmdsn wraps from 2^32-1 to 0.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-28 10:37:28 +01:00
Ronnie Sahlberg
700d363a88 Create a wrapper function for when we add pdus to the out queue
so that we can add them so that they are send in increasing itt order.
2012-11-27 20:26:13 -08:00
Peter Lieven
d9f0464232 ISCSI_PDU nest iscsi_scsi_cbdata
We can simply next the iscsi_scsi_cbdata in the iscsi_pdu struct
since it is only used inside the iscsi_pdu.

This saves one malloc for each pdu.

Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-27 11:48:53 +01:00
Ronnie Sahlberg
9f741ad2e3 Remove the iscsi data alloc_size field.
Avoiding to realloc data over and over should rather be handled with something
similar to iovectors instead.
2012-11-25 19:22:37 -08:00
Ronnie Sahlberg
bb755104e5 Remove iscsi_allocate_pdu_with_itt_flags_size()
We dont need this anymore.
2012-11-25 19:11:51 -08:00
Ronnie Sahlberg
7b1c0a19bb Remove iscsi_allocate_pdu_size. This is not use any more. 2012-11-25 19:02:34 -08:00
Ronnie Sahlberg
4237d8c257 Remove 'nidata' from the iscsi pdu structure. We dont use it any more. 2012-11-25 19:01:26 -08:00
Ronnie Sahlberg
cbfb086d40 Update the documentation for read/write iovectors 2012-11-25 18:56:33 -08:00
Ronnie Sahlberg
3ac9fdcbff Change iscsi_scsi_command_async() to use iovectors for writes.
Change iscsi_scsi_command_async() to write data-out using iovectors
attached to the scsi task structure instead of copying the data into
the buffer holding the header.
Still allow passing the data via an argument to the funtcion so that the
ABI does not change but then just conver the data to an iovector.

Update the write_to_socket functions to know about the iovectors and write them
as part of the pdu.

Convert write10_task to use iovectors.

This will allow 'zero-copy' writes through libiscsi.
However, as 'zero-copy writes does mean that we do more send() calls into
the kernel this may degrade performance for very small i/o.

A scsi write will not take at least 2 send() calls.
One send call for the iscsi header structure and a second send call for the
payload data.
This will be more expensive than the old memcpy() of payload data plus one send() call since the send() will be a lot more expensive than memcpy() of a small amount of data.
2012-11-25 18:17:51 -08:00
Ronnie Sahlberg
beed0809a5 Fix indentation 2012-11-25 14:12:33 -08:00
Bernhard Kohl
7e4b33dd31 scsi-lowlevel: make scsi_get_uint16/32() global and add scsi_set_uint16/32()
This is a preparation to use the (un)marshalling functions anywhere
in the library.

Signed-off-by: Bernhard Kohl <bernhard.kohl@gmx.net>
2012-11-23 16:46:03 -08:00
Peter Lieven
e7cc6dc1ca SCSI add support for POSIX compatible iovectos
This patch defines an scsi_iovec struct which is guaranteed
to be POSIX compatible. It furthermore adds support for
in+out iovectors for bi-directional operations
Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-23 15:43:00 +01:00
Peter Lieven
55f76cfb0c SCSI add support for iovectors
If an application passes buffers to libiscsi for reading they are
currently added to a linked list one by one. This leads to a malloc
for each buffer object plus O(n) walks trough the list to add
the buffer to then end of the list. Additionally the buffer read
routine takes up to O(n) iterations to find the right buffer
for a request.

This patch introduces an scsi_iovector struct to pass buffers to
an scsi task. Adding a new buffer is in O(1) and finding the
right buffer to also. Malloc requirements are in O(log(n)).

Additionally the scsi_iovector struct is itended to be binary
compatible to an QEMUIOVector allowing to pass this structure
directly to the library.

Initial tests have been made booting an Ubuntu LTS 12.04.1
Desktop server up to the login prompt. The following observations
have been made with regards to scsi_malloc calls:

original implementation:	~11.500 mallocs
using iovector instead of list:	~ 7.500 mallocs
passing the iovector directly:        0 mallocs

To enable this feature in qemu for testing the following patch might
be used:

diff --git a/block/iscsi.c b/block/iscsi.c
index a6a819d..2809c15 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -390,11 +390,16 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
         return NULL;
     }

+#if defined(LIBISCSI_FEATURE_IOVECTOR)
+    assert(sizeof(struct QEMUIOVector) == sizeof(struct scsi_iovector));
+    scsi_iovector_assign(acb->task, (struct scsi_iovector*) acb->qiov);
+#else
     for (i = 0; i < acb->qiov->niov; i++) {
         scsi_task_add_data_in_buffer(acb->task,
                 acb->qiov->iov[i].iov_len,
                 acb->qiov->iov[i].iov_base);
     }
+#endif

     iscsi_set_events(iscsilun);

---
Signed-off-by: Peter Lieven <pl@kamp.de>
2012-11-21 17:02:59 +01:00
Ronnie Sahlberg
4a973e9a4e SCSI: Pass the expected opcode to scsi_cdb_unmarshall()
Pass the opcode we expect to the unmarshalling function so it can do a basic
check that we are trying to unmarshalling the right kind of cdb.
2012-11-20 19:16:42 -08:00
Ronnie Sahlberg
890471c8cc Add support to unmarshall a CDB into a structure and update iscsi-dd
Add two new helper functions scsi_get_uint32() and scsi_get_uint16()
2012-11-20 19:00:55 -08:00
Arne Redlich
5194d13e73 scsi-lowlevel: remove scsi_maintenancein_params and finally scsi_task->params too
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 23:28:32 +01:00
Arne Redlich
8baa843d73 scsi-lowlevel: remove scsi_readtoc_params and fix READ TOC format field
Set the format field in the READ TOC CDB (lower nibble of byte 2).

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 23:16:45 +01:00
Arne Redlich
551298adfb scsi-lowlevel: remove scsi_serviceactionin_params and plug potential memleaks
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 22:57:59 +01:00
Arne Redlich
fa158865d2 scsi-lowlevel: remove scsi_modesense6_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 22:47:14 +01:00
Arne Redlich
5f414317dc scsi-lowlevel: remove scsi_inquiry_params and refactor INQUIRY data-in unmarshalling
Split the INQUIRY data-in unmarshalling into smaller chunks, fixing some
potential memory leaks along the way.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 22:46:04 +01:00
Arne Redlich
b5a9ba6159 scsi-lowlevel: remove scsi_readcapacity10_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 22:04:57 +01:00
Arne Redlich
188505a72d scsi-lowlevel: remove scsi_verify16_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 21:59:42 +01:00
Arne Redlich
de67d86e64 scsi-lowlevel: remove scsi_verify12_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 21:58:30 +01:00
Arne Redlich
10fd2f560b scsi-lowlevel: remove scsi_verify10_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 21:57:00 +01:00
Arne Redlich
1dbdd04795 scsi-lowlevel: remove scsi_writeverify16_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 21:55:01 +01:00
Arne Redlich
a262d07c4b scsi-lowlevel: remove scsi_writeverify12_params
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-11-18 21:53:44 +01:00