Commit Graph

88 Commits

Author SHA1 Message Date
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
Felipe Franciosi
3c4925e8da pdu: Introduce iscsi_cancel_pdus()
Introduce a helper exported from lib/pdu.c which cancels all pdus for a
given context. This patch eliminates repeated code from various other
files which have the same purpose. The only functional difference is
that the cancellation done from iscsi-command.c was (incorrectly) not
checking for iscsi->is_loggedin before issuing callbacks.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2017-11-25 17:03:01 +00:00
Tim Crawford
aba0f7da1a Replace WIN32 with _WIN32
Using WIN32 depends on the build environment defining the variable.
_WIN32 is a predefined MSVC macro and is always available.

Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
2017-11-29 10:07:44 -05:00
David Disseldorp
4bc5f962e2 Libiscsi: add support for EXTENDED COPY
Build on existing scsi_cdb_extended_copy() functionality. This operation
can be used to offload inter and intra LU copies to the target.

The API is rather primitive, in that the caller needs to construct the
parameter buffer, including CSCD and segment descriptor lists, etc.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2017-01-04 19:33:00 +01:00
David Disseldorp
f475436c5a Libiscsi: add support for RECEIVE COPY RESULTS
Build on existing scsi_cdb_receive_copy_results() functionality. This
request is most commonly used to determine target-side EXTENDED COPY
operational parameters.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2017-01-04 19:33:00 +01:00
Ronnie Sahlberg
39001203b7 TESTS: simple support for READDEFECTDATA10/12
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-22 22:43:16 -07:00
Peter Lieven
fa123fc397 abstract transport to static driver functions and opaque driver specific information.
This splits a transport into static driver specific functions for the common
iscsi commands. Optionally, a driver specific opaque memory is introduced
which is currently only used by iSER transport.
Last a lot of functions changed to static.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-08-05 11:28:43 +02:00
Ronnie Sahlberg
37507c994a Add back iscsi_queue_pdu
We need a public symbol for iscsi_queue_pdu. This is now just a
simple wrapper around iscsi->t->queue_pdu

https://github.com/sahlberg/libiscsi/issues/212

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-11 18:37:25 -07:00
Peter Lieven
765d492aa0 pdu: dump PDU header on ILLEGAL REQUEST sense
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 11:38:21 +02: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
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
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
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
99a5f99527 Add some emacs defaults. Tabs are 8 spaces.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:34:43 -08:00
Ronnie Sahlberg
02fd6217cb Add support for WRITE_ATOMIC_16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-08 10:16:57 -07:00
Ronnie Sahlberg
0630aa5ef0 Timeouts: Fix bugs in scsi task timeout code
Add a test to verify the pdu timeout handling.
Fix numerous bugs in the timeout handling. It was really broken.

Add test for non-SCSI task PDUs too and verify they works.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 14:34:06 -07:00
Ronnie Sahlberg
cb4ad5f774 Connect: Don't use the TUR checks on re-connects
Only use TUR to eat any pending unit attentions on the initial connect
but not during reconnect.

From Peter Lieven <pl@kamp.de>

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-19 19:21:26 -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
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
63fd8679fa reconnect: do not queue TESTUNIT_READY cdbs
those are part of the login process to consume UNIT_ATTENTIONS.

Its questionable if we should consume them at all, but iff we change
that behaviour we should do it for the initial login as well as
for a reconnect.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:06:32 +02:00
Peter Lieven
b152d26eb9 connect: make the reconnect async
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 16:21:00 +02: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
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
Ronnie Sahlberg
76f8296dbb reconnect logic and pdu handling
Rework the reconnect logic so we just call iscsi_scsi_command_async()
for the scsi commands we are re-quining instead of poking into the
private fields of the structures themself.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:46:57 -08:00
Ronnie Sahlberg
511c2fdbd1 pdu.c: remove iscsi_allocate_pdu_with_itt_flags()
Remove iscsi_allocate_pdu() which is just a wrapper.
Rename iscsi_allocate_pdu_with_itt_flags() to iscsi_allocate_pdu()
and update all callers.

This only removes a wrapper function and contains no logic changes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-23 20:26:22 -08:00
Peter Lieven
de7b38d9a0 use MIN and MAX macros at some places
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-02-23 08:03:27 +01:00
Peter Lieven
dd6831a50f iscsi-command: fix unsolicited data-out length
the recent implementation allows to send
iscsi->first_burst_length + iscsi->target_max_recv_data_segment_length
bytes if immediate and unsolicited data-out is send and
iscsi->target_max_recv_data_segment_length < iscsi->first_burst_length.

RFC3720 defines the length as:

Length=(min(FirstBurstLength, Expected Data
   Transfer Length) - Received Immediate Data Length).

so that immediate data and unsolicited data-out are together
FirstBurstLength at maximum.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-02-23 07:53:41 +01:00
Ronnie Sahlberg
2f5d21b09c iscsi-command.c: Use common function to write unsolicited data-out pdus.
We write unsolicited data-out PDUs from two places;
when we originally write the command in iscsi_scsi_command_async()
but also when we re-queue the PDUs during a session reconnect.

The re-queuing during the session re-connect was recently (almost) fixed
but was still buggy in that it did not correctly clamp the amount of written
data as per first burst length restriction.
This attempts to fix that.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-20 20:51:14 -08:00
Ronnie Sahlberg
831ecb3656 iscsi-command.c: use pdu->expxferlen instead of pdu->expxferlen
Both are the same value at this point but it is better to
do the computation only based on pdy-> fields.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-20 20:39:51 -08:00
Ronnie Sahlberg
b001d980ef reconnect: we must re-queue any missing data-outs during reconnect
If we have writes that do not have the Final bit set during reconnect
we must send out any missing data-out PDU.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-17 06:46:58 -08:00
Ronnie Sahlberg
8ae706630e iscsi-command.c: Better fix for the length bug for immediatedata
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 17:36:58 -08:00
Ronnie Sahlberg
db7924fc90 iscsi_command: fix length bug when sending unsolicited data.
If we have send unsolicited immediate data and are ALSO sending
unsilocoted data-out, then we have to exclude the length of data we have already sent.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-16 17:27:56 -08: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
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
Peter Lieven
4e129d385c pdu: fix statsn and factor out sn comparision
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-17 14:58:38 +02:00
Peter Lieven
e6894fd73a iscsi-command: do not fail commands while reconnect is pending
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-17 14:56:57 +02:00
Ronnie Sahlberg
717b95cb8a slist.h: rename SLIST_ to ISCSI_LIST_ to avoid clash on *BSD
Rename the macros for managing the linked lists from SLIST_* to ISCSI_LIST_*
to avoid a clash on *BSD which already have other macros SLIST_*

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-05-07 06:44:19 -07:00
Michael Tokarev
120b308741 Spelling fixes: Dont => Don't
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-12-16 18:19:24 -08:00
Paolo Bonzini
dbaa0b4ea6 exit after malloc failure when allocating sense data blob
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-11-05 14:24:56 +01:00
Ronnie Sahlberg
286df50244 Add more status codes : CONDITIONS_MET/TASK_SET_FULL/ACA_ACTIVE/TASK_ABORTED 2013-09-25 20:26:00 -07:00
Sitsofe Wheeler
0b6b12ba53 TESTS: Fix COMPAREANDWRITE tests to send write data
Previously COMPAREANDWRITE was only sending verify instance data which
can cause targets to generate COMMAND ABORTED/NOT ENOUGH UNSOLICITED
DATA errors due to the buffer being obviously too small to contain
verify AND write instance data.

The buffer size check has been modified and compareandwrite tests
updated to pass a larger buffer with interesting write instance data.
2013-09-09 17:48:13 +01:00
Ronnie Sahlberg
daac72a8f9 TESTS more writesame1* test fixes 2013-08-25 16:39:38 -07:00
Ronnie Sahlberg
dc981c93ef Cleanup: rename to payload_* the PDU variables used to track writing to socket 2013-08-04 17:34:15 -07:00
Ronnie Sahlberg
804c5b0211 Dont reference *pdu after it has been freed 2013-07-21 13:29:43 -07:00
Ronnie Sahlberg
fd38ff4bfc Add MODESENSE6/10 and MODESELECT6/10 support 2013-07-20 14:05:20 -07:00
Ronnie Sahlberg
7895fb700c Add MODESELECT6 support
Add support for MODESELECT6 and add marshalling functions for the
mode pages we support so far.
2013-07-06 16:11:17 -07:00
Ronnie Sahlberg
92b987de52 Add helpers for the SANITIZE service actions 2013-05-26 10:51:19 -07:00