Commit Graph

105 Commits

Author SHA1 Message Date
Ziye Yang
098d32273a lib/iscsi: Add two parameters in spdk_iscsi_conn_write_pdu
This is prepared for the further call back usage.

Change-Id: Iccf304c87e67debfb4e7c330acc9cc233cc3ec48
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481917
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-01-23 02:29:58 +00:00
Ziye Yang
d648dde682 lib/iscsi: Use asychronized writev for sending data on sockets
This patch eliminates the flushing logic and simplies
the writev logic. And this patch can also improve the performance.

We support async write for PDUs other than login response, logout response,
and text response in this patch. We will support async write also for them
later in this patch series.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: I243f598f297d594da0bb18466bc47dab918ed3ee
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481686
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-23 02:29:58 +00:00
Ziye Yang
377a016f69 lib/iscsi: add the conn in spdk_iscsi_pdu
Purpose: Prepare for the async writev usage for spdk
iSCSI target application.

Change-Id: Iff0e932159b0ad80be32aed3fc543b67d8fb8f51
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481644
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-01-23 02:29:58 +00:00
Shuhei Matsumoto
3176d5ab14 lib/iscsi: Change iscsi_queue_task() from private to public
Subsequent patches will move a few functions which call
iscsi_queue_task() from iscsi.c to conn.c.  This patch is a
preparation to it.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id136b5d3bf76a9894162115dd0d57d997178c869
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477415
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-12-17 09:29:10 +00:00
Shuhei Matsumoto
492789cee1 lib/iscsi: Change spdk_iscsi_send_nopin() to private and rename it
spdk_iscsi_send_nopin() is called only in a single place of conn.c.
So change it to private in conn.c.  Additionally, iscsi_conn_send_nopin()
may be a little more meaningful and rename to it.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I1fe70e0468e1dd43468492b8b3d359c094130ed7
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477190
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-12-12 14:41:41 +00:00
Shuhei Matsumoto
4c577b1fce lib/iscsi: Change spdk_iscsi_is_deferred_free_pdu() to private and rename it
spdk_iscsi_is_deferred_free_pdu() is called only in a single
place of conn.c.  So change it to private in conn.c.  Additionally,
iscsi_is_free_pdu()_deferred() may be a little more meaningful
and rename to it.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic1e3d7ff435c454f40e81f9a4f90fe76589ec7b2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477189
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-12-12 14:41:41 +00:00
Shuhei Matsumoto
7ff4d22d4c lib/iscsi: Move declaration of spdk_iscsi_task_mgmt_cpl from iscsi.h to conn.h
spdk_iscsi_task_mgmt_cpl()'s function body is in conn.c, and so move
its declaration from iscsi.h to conn.h.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Idd22c360ce1d3d464bf782e21348425ae7debdd8
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477188
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-12-12 14:41:41 +00:00
Shuhei Matsumoto
3c78f68363 lib/iscsi: Move declaration of spdk_iscsi_task_cpl() from iscsi.h to conn.h
spdk_iscsi_task_cpl()'s function body is in conn.c, and so move
its declaration from iscsi.h to conn.h.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7bc6feecd5a2ff698c8e30e7aab547ada398c44f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477187
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-12-12 14:41:41 +00:00
Shuhei Matsumoto
e79a29b264 lib/iscsi: Make spdk_del_transfer_task() return success/failure
After recent refinement of LUN hotplug, it is possible that
for large write I/O, primary task is freed doubly as a github issue
is reported.

However we could not notice the case because spdk_del_transfer_task()
had not return success/failure, and to make matters worse,
the second call of TAILQ_REMOVE() to the same header and instance
caused no error if the first call succeeded.

This patch changes spdk_del_transfer_task() to return success/failure.

Besides, the next after patch expects the stub of spdk_del_transfer_task()
returns true in the unit test, and hence do that.

The next after patch will fix the issue of double free of primary task
by using this patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibc0b65723050362d5fafa913417b64393feb874e
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475042
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-11-21 08:01:29 +00:00
Shuhei Matsumoto
c5ef36742a lib/iscsi: Move function declaration to param.h to match function body
Four functions are defined in param.c and so moving their declaration
from iscsi.h to param.h is a little easier to read.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id16eab56d20d7ec99759e69525e791b091a93783
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472673
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
2019-11-19 09:10:14 +00:00
Shuhei Matsumoto
83271409c0 lib/iscsi: Simplify DIF insert/strip by doing at each PDU type handler
We have separated PDU header handler and payload handler, and have
PDU header handlers for each PDU type now.

By using this refinement, we can remove an aggregated helper function
spdk_iscsi_get_dif_ctx() and embed spdk_scsi_lun_get_dif_ctx() into
each PDU header handler.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ib4d9939b625858466224647c545cb67a04babf86
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471699
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-11-18 12:51:38 +00:00
Shuhei Matsumoto
bb61fabf26 lib/iscsi: Clarify only logout with reason "close the session" is acceptable on discovery session
Based on the following description in Chapter 4.3 "iSCSI Session Types in
iSCSI specification

      b) Discovery session - a session only opened for target discovery.
         The target MUST ONLY accept Text Requests with the SendTargets
         key and a Logout Request with reason "close the session".  All
         other requests MUST be rejected.

update the comment slightly, add macro constants for iSCSI logout
reason, and change the ordering of checks to be session type and then
logout reason.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifc2ecc5b6dde546700662d3cda59d8cc465fd83a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472672
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
2019-11-12 05:31:59 +00:00
Shuhei Matsumoto
8f3fa385b7 lib/iscsi: Add a flag to struct spdk_iscsi_pdu to know if it is rejected
The subsequent patches will separate PDU header handling and PDU
payload handling. But for the PDUs which have data segment,
if PDU header is correct, we have to read data segment even if any other
error is found and the PDU is rejected.

To do that, add a flag is_rejected to pass if the PDU is rejected or
not from PDU header handling to PDU payload handling.

If PDU payload handling sees the PDU is already relected, do nothing.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie3fe518fc0f452da9965a2fe3642568c86866480
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471005
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-10-17 16:27:27 +00:00
Shuhei Matsumoto
5b963d40fd lib/iscsi: Move PDU receive repetition into the same file as PDU receive state machine
To make the code clearer,
- make the spdk_iscsi_read_pdu() private in iscsi.c and named iscsi_read_pdu(), and
- make the iscsi_conn_handle_incoming_pdus() public and named
  spdk_iscsi_handle_incoming_pdus().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I967681b8e9b86681a906b18719e91e1d387450d7
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469969
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-17 16:27:27 +00:00
Shuhei Matsumoto
52e2b86b33 lib/iscsi: Move spdk_iscsi_execute() from iscsi_conn_handle_incoming_pdus() to spdk_iscsi_read_pdu()
Move spdk_iscsi_execute() from iscsi_conn_handle_incoming_pdus()
to spdk_iscsi_read_pdu() and then strip the prefix spdk_ from
spdk_iscsi_execute() and make it private.

This is to introduce state machine into receive incoming PDU processing.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I5d5b3e55ece0994532e924d3c75d898cb373875c
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470287
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-15 16:23:19 +00:00
Shuhei Matsumoto
4427cac695 lib/iscsi: Check data segment length separately for immediate data
We can move data segment length check from iscsi_check_data_segment_length()
to iscsi_op_text() and iscsi_op_scsi().

Task Management Function request, SNACK request, and Logout request
don't have data segment, and so any related check is not added.
Of course we can add check if data segment length is zero though.

This patch also changes the return type of spdk_get_max_immediate_data_size()
and a related variable spdk_iscsi_pdu::data_segment_len to uint32_t to
remove unnecessary casts. They are little to stand as an independent
patch.

The next patch will remove iscsi_check_data_segment_length().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I736ec234d2726de0c70bbae7e748a5b1b5134a32
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470725
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-12 01:20:09 +00:00
Shuhei Matsumoto
fe5611b79b lib/iscsi: Request logout to asynchronously to initiator
Request logout to the initiator asynchronously when exiting the
running connection from the target.

Based on this patch, the next patch will make flushing PDUs possible
only when the connection is RUNNING (or INVALID) and remove the
tight loop in iscsi_conn_flush_pdus().

Set timeout of logout request as 30 seconds. 30 seconds is as same as
NOP timeout and will be reasonable for now.

Add and use logout_request_timer to check the timeout.

When the connection gets internal a logout request, move the connection
to EXITING state if the connection is in INVALID state, request logout
to initiator and start 30 seconds timer if the connection is in RUNNING
state and logout is not requested yet, or do nothing otherwise.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I43192be9fd7112ad444152c0dd88f99a14aa8d30
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470705
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-09 02:45:17 +00:00
Shuhei Matsumoto
8703949c05 lib/iscsi: Replace ISCSI_CONN_STATE_LOGGED_OUT state by is_logged_out flag
The connection state is mainly for flushing PDUs. ISCSI_CONN_STATE_LOGGED_OUT
was as same as ISCSI_CONN_STATE_RUNNING for this point.

Replace ISCSI_CONN_STATE_LOGGED_OUT state by a is_logged_out flag
and use the latter to reject any incoming PDU after sending logout
response.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3426a3ecbd241db402b1a2f7b3914a18e3591591
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470703
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-09 02:45:17 +00:00
Changpeng Liu
8a857a3b30 iscsi: Deprecate MinConnectionsPerCore finally
Parameter 'MinConnectionsPerCore' was removed in last release and marked
as deprecated, now we will deprecate 'MinConnectionsPerCore' finally.

Change-Id: I613a371e8b5352dfb84f8e4293805b792020c643
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468789
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-09-20 02:03:37 +00:00
Seth Howell
72d06a99e1 Revert "iscsi: change the field bhs to pointer type."
This reverts commit 80cf038ced.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I95e2ddfbc9cd07e874a385b345dc401fc8076e88
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468778
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-19 05:04:00 +00:00
Ziye Yang
80cf038ced iscsi: change the field bhs to pointer type.
Purpose: Prepare for the further optimization work
to use one bigger buffer to read more data for
reducing system calls.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: Ie92603b09308bd3149263269fdec355b67251b37
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468538
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-09-18 18:14:53 +00:00
Shuhei Matsumoto
ff9d333171 iscsi: Move macros to define max port name from portal_grp.h to iscsi.h
This is a preparation to the next patch which will change portal_host
and portal_port from malloc to fixed size.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0f95d969edfd88efde41a43eaf0426fcd4b98987
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464135
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-08-12 21:31:44 +00:00
Ben Walker
fb641c4b54 iscsi: Assign connections to poll groups instead of lcores.
This patch binds poll groups to SPDK thread through IO channel and
assigns connections to poll groups instead of cores.

iSCSI subsystem registers iSCSI global object as an IO device, and create
poll groups as context of IO channels of the IO device.

Each portal get and hold portal group on which the corresponding acceptor is
running.

When a connection is constructed, iSCSI subsystem assigns a poll group
to the connection by getting it from the corresponding portal.

When a connection enters full-feature phase, iSCSI subsystem schedules
the connection to a poll group by round-robin.

Then, each connection can know its running SPDK thread directly and can
use SPDK message passing infrastructure instead of SPDK event framework.

By this change, iSCSI connections are binded to SPDK thread, and not
binded to processor core anymore.

Some other changes in this patch are
- core ID is removed from the output of get_iscsi_connections RPC. The
  upcoming patches will change the RPC to use spdk_for_each_channel and can
  access SPDK thread safely, and add SPDK thread ID instead.
- utilize UT multithread framework added by the last patch to test
  iSCSI poll groups by UT.

Change-Id: Iec73c778aa413bcabdb63141cc41d4160911ea0e
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463359
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-08-12 20:49:36 +00:00
Shuhei Matsumoto
1eba9812f2 iscsi: Simplify include relationships to avoid cyclic inclusion
Including tgt_node.h in iscsi.h will prevent us from including
iscsi.h in tgt_node.h. Subsequent patches will require tgt_node.h
to refer the macro constants in iscsi.h.

Hence
- remove inclusion of tgt_node.h from iscsi.h,
- add inclusion of spdk/scsi.h to iscsi.h, and
- remove inclusion of spdk/scsi.h from tgt_node.h

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I5ac808a83754c157e4140bcd2a83c4d210e30d91
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459704
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +00:00
Shuhei Matsumoto
2761079168 iscsi: Remove SPDK_SUCCESS and use 0 instead
SPDK_SUCCESS is a remnant and all other SPDK libraries have used
just 0. So this patch removes SPDK_SUCCESS from iSCSI library and
uses 0 instead.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie33fd26238411e994ea9ea0c898da1abb502cad6
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456928
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-06-06 02:08:15 +00:00
Shuhei Matsumoto
5ef1a15c6f lib/iscsi: Unify array size and used count in SGL operation
This patch adopts the good practice in DIF library, and unifies
array size and used count into unused count.

Change-Id: Ifde15d1fa66dbd2578da771b5500e45a84664f63
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455475
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-05-24 23:19:24 +00:00
Ben Walker
af8affd1a9 iscsi: Deprecate MinConnectionsPerCore
iSCSI is currently being adapted to SPDK's new threading model,
and this parameter doesn't make sense anymore. Remove it for
now until something functionally equivalent is added later.

Change-Id: Ia0e2f5aa81b72d99467c5a900619fbeeb42b2069
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452779
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Shuhei Matsumoto
daf2206ec4 iscsi: Skip metadata space in read or write data from network socket
This patch leaves metadata space in data buffer for read or write I/O
to generate and verify DIF.

For write I/O,
- in spdk_iscsi_read_pdu(), leave metadata space for every block
  by calling spdk_dif_set_md_interleave_iovs() and then
  spdk_iscsi_conn_readv_data(), and remember this in PDU.
- in spdk_iscsi_op_scsi() and spdk_iscsi_op_data(), set not data
  length but buffer length to length of an iovec. The reason is
  that the actual data length sent to SCSI layer will be larger
  than the data length set in PDU. SCSI task holds data length
  as an independent member and this change doesn't loose any
  information.

For read I/O, in spdk_iscsi_build_iovs(), leave metadata space for
every block by calling spdk_dif_set_md_interleave_iovs().

The reason why DIF context is saved in PDU is that DIF verification
will be done in spdk_iscsi_conn_write_pdu() and DIF context will be
used there first.

Change-Id: Iac5739211f26a91b00a4ecf2f306bbecec3d78dd
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446382
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-03-13 01:40:02 +00:00
Shuhei Matsumoto
c24f506993 iscsi: Increase the size of write buffers to store DIF
Increase the size of write (data out) buffers and immediate
data buffers in the iSCSI library to store DIF. Increase is the
amount necessary to store 16 byte metadata block to the block
formatted iwth 512 + 16. 512 + 16 is the current maximum ratio
of metadata per block.

Use the macro SPDK_BDEV_BUF_SIZE_WITH_MD defined in
include/spdk/bdev.h for this purpose.

Besides, change the name of a helper function from
spdk_get_immediate_data_buffer_size() to
spdk_get_max_immediate_data_size() to differentiate the maximum
data size and the buffer size, and then to use the macro.

Change-Id: I626f8045ff706e1a6d79fa298261769bc96b7d8b
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447011
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-03-13 01:40:02 +00:00
Shuhei Matsumoto
b8a51ff5b8 iscsi: Add an API to return DIF context of SCSI command
Ths patch adds an API spdk_iscsi_get_dif_ctx().

When opcode of BHS is SCSI command, spdk_iscsi_get_dif_ctx() extracts
CDB and LUN ID from BHS. When opcode of BHS is Data Out or Data In,
spdk_iscsi_get_dif_ctx() extracts TTT and get R2T task corresponding
to TTT, and gets CDB and LUN ID from the task.

Then spdk_iscsi_get_dif_ctx() gets LUN by using LUN ID and calls
spdk_scsi_lun_get_dif_ctx().

Additionally spdk_iscsi_get_dif_ctx() checks the state of the connection
and the type of the session is valid before starting decode operation
because contents of PDU is not reliable when the state of the connection
is invalid. The necessity of the check was found by the Calsoft test tool.
Checks and test cases are not matched yet but copying existing checks
from spdk_iscsi_conn_execute, spdk_iscsi_op_scsi, and spdk_iscsi_op_data
will be enough. The check added for Data Out is not necessary for Data In
but it will not be harmful for Data In.

Change-Id: Iba09e0ac3e760aa1c5b582a120596c49b9e9d51e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446231
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-03-08 01:21:26 +00:00
Shuhei Matsumoto
e17851314e iscsi: Hold size of buffer to store PDU data segment in struct spdk_iscsi_pdu
Upcoming patches will store larger data in the data buffer than
iSCSI Initiator transfers, and size of metadata is not known until
asking to SCSI layer. This addition will be used to avoid overflow
in them.

Change-Id: I43e15d0cfbfddcf01342325b134d90e3d7dae038
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446378
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-03-08 01:21:26 +00:00
Shuhei Matsumoto
fa7dd957ee iscsi: Reduce required free iovecs from 5 to 1 to flush PDUs
Upcoming patches will support DIF insert and strip feature in
iSCSI target and the feature will be implemented by utilizing
iovecs.

Even when we support the DIF feature, we want to keep current
batched PDU flush, and current requirement that there must be
enough free iovecs to map all segments of a PDU is too strict.

This patch alleviates the requirement by passing remaining
number of iovecs to spdk_iscsi_build_iovs().

Change-Id: I6206322839c363e0ff5abe84bfd524bdc09e23ca
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446176
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-03-01 22:47:21 +00:00
Shuhei Matsumoto
ca0022f9da iscsi: Unify calculate mapped length and build iovecs to flush PDUs
To know the mapped length by iovecs, pdu length was got first and
then the size of partial written was reduced separately.

This patch unifies these two operations into spdk_iscsi_build_iovs().

Change-Id: Ic6f5eecc902b8e209ef00c010915f476ca16c002
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446175
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
2019-03-01 22:47:21 +00:00
Shuhei Matsumoto
42596fb6b1 iscsi: Use iov instead of iovec for names of variabls and functions
iovec_cnt and iovec_array are very descriptive and good but iovcnt
and iovs are often seen in SPDK and will be enough.

Subsequent patches will add some changes on iovec operations and
simple and familiar names will be helpful to work and review them.

This patch doesn't change any behavior.

Change-Id: I89ff74809a0ddbb358e3fc8fdc353a47338cc3c5
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446173
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
2019-03-01 22:47:21 +00:00
Shuhei Matsumoto
95fc5d3581 iscsi: Remove SPDK_ISCSI_MAX_SEND_DATA_SEGMENT_LENGTH
In iSCSI, SPDK_ISCSI_MAX_SEND_DATA_SEGMENT_LENGTH was an alias
of SPDK_BDEV_LARGE_BUF_MAX_SIZE.

iSCSI had used both interchangeably.

SPDK_BDEV_LARGE_BUF_MAX_SIZE means the buffer size of the large
buffer pool in generic bdev layer, and will be changed to be
configurable.

SPDK_ISCSI_MAX_SEND_DATA_SEGMENT_LENGTH had been used to negotiate
MaxRecvDataSegmentLength with iSCSI initiator and to split large
read data, but both are determined by not iSCSI target but generic
bdev layer.

Hence this patch replaces SPDK_ISCSI_MAX_SEND_DATA_SEGMENT_LENGTH
by SPDK_BDEV_LARGE_BUF_MAX_SIZE.

Change-Id: I822a5203a5092fe8b2d1ca3f93423f1acbfc782e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444539
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-21 18:38:07 +00:00
Shuhei Matsumoto
d0efddd281 iscsi: Move macro constant DEFAULT_MAX_QUEUE_DEPTH to the appropriate location
This macro constant is not related with data size and should be moved
to the separate location.

Change-Id: I73b337f5750c39d1f87591c2e372664019e50b95
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444545
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-02-21 18:38:07 +00:00
Shuhei Matsumoto
97768b0773 iscsi: Replace helper function spdk_get_data_out_buffer_size() by macro constant
The helper function spdk_get_data_out_buffer_size() is a little
confusing because it does only returning macro constant
SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH.

The macro constant will be configurable and so the helper function
is not sustainable.

Replace the helper function simply by the macro constant.

Change-Id: I4ec300f61783da7bb712512603c2dd80987ec702
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444537
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-15 21:01:08 +00:00
Shuhei Matsumoto
80fd917004 iscsi: Rename macro constant MAX_FIRSTBURSTLENGTH by SPDK_ISCSI_MAX_FIRST_BURST_LENGTH
Change-Id: If3e2ded87dab5c6596ec499460f7d233bf63154e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444536
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-15 21:01:08 +00:00
Shuhei Matsumoto
d3526f523e iscsi: Replace duplicated macro constant DEFAULT_FIRSTBURSTLENGTH
Replace DEFAULT_FIRSTBURSTLENGTH by SPDK_ISCSI_FIRST_BURST_LENGTH.

Change-Id: Ia90ef714fab79dff4f9b9eb92ade8cfed3391450
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444535
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-15 21:01:08 +00:00
Shuhei Matsumoto
113db66a9a iscsi: Remove unused macro constant MAX_SESSIONS
Change-Id: I72fcb458d46f90b1036cfa346fbc675b8c21cf2f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444534
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-02-15 21:01:08 +00:00
Darek Stojaczyk
95200f5bac iscsi: remove unused mobj fields
The `len` field wasn't used at all and `reserved` is
no longer needed after we removed the paddr in the
previous patch.

This effectively cuts down spdk_mobj struct size by half.

Change-Id: Ica39f3a30e14ec1275a87d827dc41df5df9cf623
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443483
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-02-06 20:21:48 +00:00
Shuhei Matsumoto
308b62c6ba iscsi: Fix uncorrect LUN reset called when exiting connection.
This direct call of LUN reset has caused unexpected behavior
during heavy stress test.

Apply correct LUN reset handling for this case too.
Even if there are multiple LUNs, LUN resets are serialized in
the SCSI layer by previous patches and parallel calls of LUN resets
will not cause any issue.

Change-Id: I920e2864ef0fb41c6bd2b6153ef3caff6876e893
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/436115
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-12-11 16:37:55 +00:00
Shuhei Matsumoto
a115177b98 iscsi: Clear only R2T tasks prior to task management request
As described in RFC3720, task management request will act on all
the commands from the same session having a CmdSN lower than the
task management CmdSN.

Current implementation clears all R2T tasks without checking CmdSN.

This patch changes the implementation to clear only R2T tasks
whose CmdSN is smaller than the task management request.
Additionally this patch adds to UT code to verify the change works
as expected.

Change-Id: I0b368cb13741bc05259924d27793438e9250b951
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434761
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-06 22:35:40 +00:00
Changpeng Liu
e8b6523280 iscsi: check the length of initiator/target name
According to the RFC3720, the length of initiator name and
target name should not larger than 223 bytes, while here,
add a check for initiator/target name.

Change-Id: I1517a4c4e1b0a944b239665f38f5dfb46f0075d2
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/433797
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-21 00:55:55 +00:00
Ziye Yang
4621ba73fa iscsi: do not caculate the CRC in multiple times
Since a PDU can be sentout in many times, so this
function is called multiple times, so move the
caculation function in spdk_iscsi_conn_write_pdu

Change-Id: Ib4da4a74c17709d98e4b01c2e76428021afea947
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/429931
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-11-05 15:30:07 +00:00
Jim Harris
b6ee6f9241 iscsi, nvmf, vhost: remove default config file pathnames
Config file pathnames have been possible on the command line
for a very long time, and all of the SPDK testing infrastructure
uses it.  The default pathnames were added a very long time ago,
and now can cause weird issues like conflicting with --wait-for-rpc
when an INI config file is not passed on the command line but is
pulled in by the default pathname instead.

So remove the default pathnames.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia914ff1c9321235f79f8cc9a054ed7f099340151

Reviewed-on: https://review.gerrithub.io/424606
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-09-05 19:46:17 +00:00
Shuhei Matsumoto
3a08001dd4 iscsi&scripts/rpc: Add get_iscsi_auth_groups RPC to get current configuration
Add an new RPC to get current authentication group configuration.
This patch is utilized in the next patch to support JSON config dump
for authentication group configuration.

Change-Id: I34be9e196f8e7a484bcd316da54f05d0f6ee0300
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/421468
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-08-29 21:40:31 +00:00
Shuhei Matsumoto
ad323b8064 iscsi&scrpts/rpc: Require to specify CHAP secret file explicitly to load it
Previous patches enabled users to configure CHAP secrets dynamically
by RPCs. Subsequent patches will enable users to load CHAP secrets
from JSON config file.

Loading CHAP secret file is done by default and this will conflict to
JSON config file.

Hence the path to CHAP secret file is required to specify in the config
file or JSON RPC set_iscsi_options explicitly after this patch.

Users who have used CHAP secret file are expected to specify it explicitly
and this will be no harm for them.

Besides, CHAP secret file is not oly for discovery sessions but also for
login to iSCSI targets. However there were wrong description to make user
misunderstand. Hence remove these wrong description in this patch too.

Change-Id: Ic4093cabc0c14b87e26baef4bba6b0d292e40c06
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/421467
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-08-29 21:40:31 +00:00
Shuhei Matsumoto
750e5d25fb iscsi&scripts/rpc: Add add/delete_secret_to/from_iscsi_auth_group RPCs
Add RPCs to add/delete a secret to/from an existing authentication group
dynamically.

Use mutex to ensure exclusive access to CHAP secrets.

Tries to use descriptive message in RPCs when error occurs.

Change-Id: I59650ae11a2fe675d03b90bbd4d2dc5b9c0160ed
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/421465
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-08-27 21:13:49 +00:00
Shuhei Matsumoto
dcafd5b1ea iscsi&scripts/rpc: Add add/delete_iscsi_auth_group RPCs
This patch adds new RPCs add/delete_iscsi_auth_group to add and
delete authentication group dynamically.

Mutex is added to ensure exclusive access to CHAP secrets.

Additionally provide descriptive message in RPC when error occurs.

Change-Id: Iaddfbdd5688ca7907d2c7d859835faa056deecd1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/421464
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-08-27 21:13:49 +00:00