Commit Graph

521 Commits

Author SHA1 Message Date
Seth Howell
d899c6db20 mk: add a lib deps file.
By adding this file and modifying the way we define a couple of
variables in the makefiles, we can actually avoid having to redefine
the library dependencies on a per file basis.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466063 (master)

(cherry picked from commit 9d14641dd5)
Change-Id: Ieab4aa1021b0341fc21e3b65677a9ad7f70559c2
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466980
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-06 02:19:41 +00:00
Seth Howell
0cef5d5b76 lib: combine event/iscsi_rpc with lib/iscsi/iscsi_rpc.c
Part of a larger series simplifying the library directory.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465212 (master)

(cherry picked from commit ff69b368b8)
Change-Id: Ib9c9dc9a0c92ac35a9f0260451f97fc126d10031
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466972
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-06 02:19:41 +00:00
Pawel Kaminski
de1d0f8fe9 jsonrpc: don't check returned value from spdk_jsonrpc_begin_result()
As spdk_jsonrpc_begin_result() is not allowed to return NULL we can
remove these checks. We didn't have any tests cases that goes this path
anyway.

Change-Id: I0894e76c0162591e550e70b172566b9060a6dd5f
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459199
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-22 05:13:30 +00:00
Ziye Yang
b09bd95ad3 sock: update spdk_sock_group_add_sock
And also add spdk_sock_group_get_ctx function

Change-Id: I2a2a58b0588ff7d99d3538ea0a633a3b8c7a234b
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454538
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
2019-07-04 08:21:05 +00:00
Shuhei Matsumoto
666a0b5cb4 iscsi: Assign not pointer but instance of spdk_cpuset in struct spdk_iscsi_portal_grp
This will reduce pontential malloc failures.

Change-Id: I9b1965e0be95af4c0496dfbae80c86b25c460c94
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459718
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-07-04 00:30:22 +00:00
Changpeng Liu
77c1f90e98 iscsi: change ERRLOG to DEBUGLOG for read socket error
Since spdk_iscsi_conn_read_data() can print error log, so we
don't need to print again in the caller, existing code will
print error log for LOGOUT and DISCOVERY cases.

Fix issue #845.

Change-Id: I547d3d667b6412ab6a59c9b401d0f28c5026307d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460110
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-02 22:56:01 +00:00
Shuhei Matsumoto
f341e69a50 iscsi: Use not malloc'ed but fixed size string for portal porta number
Using malloc'ed string for string in iSCSI target has caused
scan-build error.

Define maximum port number of portal to be 32 and use fixed size string
whose size is 33 for spdk_iscsi_portal_grp::port.

This change will reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie1fcdbd45ce000a9c1c53761195697555b8d030a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459709
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +00:00
Shuhei Matsumoto
8f64724e86 iscsi: Use not malloc'ed but fixed size string for portal IP address
Using malloc'ed string for string in iSCSI target has caused
scan-build error.

Define maximum IP address of portal to be 256 and use fixed size string
whose size is 257 for spdk_iscsi_portal_grp::host.

This change will reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iceeae94e250ea426f72ff72355a213606308da51
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459708
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +00:00
Shuhei Matsumoto
d1961b5e41 iscsi: Use not malloc'ed but fixed size string for target name and alias
Using malloc'ed string for string in iSCSI target has caused
scan-build error.

Maximum size of target name is already defined to be MAX_TARGET_NAME,
and hence use fixed size string whose size is MAX_TARGET_NAME + 1 for
spdk_iscsi_tgt_node::name.

Change psdk_iscsi_tgt_node::alias together.

This change will reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iac4cd6e9d60173ddeb68ca21ce712126c13bc3c4
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459707
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +00:00
Shuhei Matsumoto
975e48ae8a iscsi: Use not malloc'ed but fixed size string for initiator address
Using malloc'ed string for string in iSCSI target has caused
scan-build error.

Maximum size of initiator address is already defined to be
MAX_INITIATOR_ADDR, and hence use fixed size string whose size
is MAX_INITIATOR_ADDR + 1 for spdk_iscsi_initiator_mask::mask.

This change will reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic39e08986c9377800ce58a1cb5b8401c6b71cf96
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459706
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +00:00
Shuhei Matsumoto
4a3ad8371c iscsi: Use not malloc'ed but fixed size for initiator name
Using malloc'ed string for string in iSCSI target has caused
scan-build error.

Maximum size of initiator name is already defined to be
MAX_INITIATOR_NAME, and hence use fixed size string whose size
is MAX_INITIATOR_NAME + 1 for spdk_iscsi_initiator_name::name.

This will also reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic6bc172125fc6c9c0896499704d2a9b522106da0
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459705
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-01 05:03:07 +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
beefcd1ae5 iscsi: Fix the bug to add wrong size in _iscsi_sgl_append_with_md
This bug was found by code inspection. When PDU read restarts
after data segment, iov_offset must be reduced by data length.
However iov_offset had been reduced by buffer length by mistake.

Lack of UT code was the main reason of this bug. Hence add UT
code to test the fix of the bug together in this patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I74f2f6ae8dca2e78a64bfdef8080c8031dfabb87
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458530
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-06-19 07:38:46 +00:00
GangCao
c3d1e498d5 iscsi: update the error message for the login init
Change-Id: Ic6baf284753c625d9f1d3110149f67ce4b48c0e7
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458406
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>
2019-06-19 03:43:45 +00:00
Shuhei Matsumoto
94f67dd5ae dif: Change data_len of spdk_dif_set_md_interleave_iovs to be remaining length
This patch changes the meaning of the data_len parameter of
spdk_dif_set_md_interleave_iovs from `Expected data length of the payload`
to `Expected length of the newly read data in the extended LBA payload`.

This change will align the parameters of spdk_dif_set_md_intereleave_iovs
to of spdk_dif_generate_stream.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7f9c45e78be977625713acb79d2ae82d4375f419
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457543
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-06-18 04:25:33 +00:00
GangCao
f874737792 iscsi: set the rsph with correct error information
In several error cases, the status_class and status_detail
is not properly set.

Change-Id: Ie9cf8ec13b971d7295862872e8c7e834d08e7f14
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457932
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>
2019-06-17 04:56:31 +00:00
Ziye Yang
ba3adc4367 iscsi: return the correct error code in spdk_iscsi_read_pdu
We shoud not always return SPDK_ISCSI_CONNECTION_FATAL
in spdk_iscsi_read_pdu function.

Reason: In iscsi_conn_handle_incoming_pdus, the loop
directly return only rc==SPDK_ISCSI_CONNECTION_FATAL.
But it masks all the necessary information. So we would like
to keep some information of the return value for spdk_iscsi_read_pdu,
and we can use error log to track those information.

Then we can return SPDK_ISCSI_CONNECTION_FATAL as the error
return value for iscsi_conn_handle_incoming_pdus function.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: I4c40fcb27052b55cb92e06273701a881def18e12
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457078
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-06-13 06:04:31 +00:00
Shuhei Matsumoto
37bdd0e87f scsi: Add data offset to DIF context separately from start block address
This patch uses the change by the last patch to initialize DIF
context in SCSI layer. Besides this patch changes the name of a
parameter from offset to data_offset to clarify the meaning.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I54bf1168ec5959432aa15dae0360c0640138b033
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457541
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-06-11 18:53:58 +00:00
Shuhei Matsumoto
3cfb1fe8dd iscsi: Schedule the connection only after completing login processing
Previously the connection was scheduled to another core just
after setting conn->full_feature to 1, but conn->state was still
ISCSI_CONN_STATE_INVALID. The connection started to run on another
core but could not run normally until conn->state became
ISCSI_CONN_STATE_RUNNING. conn->state was changed late to
ISCSI_CONN_STATE_RUNNING after sending the first login reponse.

This gap window had caused intermittent critical failures.

Based on this analysis, this patch changes to call
spdk_iscsi_conn_schedule() just after sending the final login response.
Whether any login response is final or not can be known by checking
conn->full_feature is not zero.

    Fixes #785

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I8ea55fef27e2f332fcd789d32daf479a24c0588d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457414
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-06-10 09:43:09 +00:00
Shuhei Matsumoto
6d156d5b7d iscsi: Dump PDU contents to know what PDU was sent in illegal state
In some test cases, unknown iSCSI PDU other than the login request
has been sent to the iSCSI target when the iSCSI target is not in
runnable state, and it has caused failure in iSCSI target.

To know what PDU was received by the iSCSI target, this patch changes
the iSCSI taget to collect dump of the PDU.

SPDK has already the SPDK_LOGDUMP macro but the SPDK_ERRLOGDUMP macro
will be appropriate in this use case and added. Then the SPDK_ERRLOGDUMP
is used in iSCSI library.

We can decode PDU and output any format easy to read by human, but
creating good format is not easy task and error prone. So this patch
uses simple dump.

Dump outputs like:

PDU
00000000  40 80 00 00 00 00 00 00  00 00 00 00 00 00 00 00  @...............
00000010  0b 06 00 10 ff ff ff ff  00 00 00 5a 00 00 00 03  ...........Z....
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3ed2fca7fec24ccff17b89ba749a58c397b72c13
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456952
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>
2019-06-07 05:11:00 +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
872d8d8ea7 iscsi: correct data digest computation for extended LBA payload
This patch uses the newly added API spdk_dif_update_crc32c() when
DIF insert/strip is enabled.

Change-Id: Icf32a0ddef6cf92b0887b38495457e7fcac30987
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456172
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@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
a7d832f28c iscsi: Correct iovec increment when data digest is enabled
iscsi_sgl_append_with_md had not increment _iscsi_sgl::iov
by appended count of iovecs. Hence if data digest is enabled,
data segment will be overwritten by data digest.

This patch fixes the bug.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibcdacb883b2b97ad86cfc39a035c76264090401d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456451
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-06-06 02:08:15 +00:00
Shuhei Matsumoto
85e6f154b8 iscsi: Get DIF context once when allocating data buffer
DIF context had been got for every read of data segment but
DIF context is not changed and so getting DIF context once
when allocating data buffer is enough and is done in this
patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0f386ab594a0d9076fa0206d5fc240f5c790181d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456772
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-06-06 02:08:15 +00:00
Shuhei Matsumoto
1204ff34e0 iscsi: Update _pdu only when completing read in spdk_iscsi_read_pdu
The only caller iscsi_conn_handle_incoming_pdus accesses the returned
pdu only when the return code is 1. So we can remove update of
_pdu for other cases in spdk_iscsi_read_pdu.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I54b9f050c3b45c87f4797a90d7606638d6c821ad
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456771
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
GangCao
2882b9895a iscsi: return the proper error to append the connection
Instead of just return "-1", the proper error detail will be
returned and reported out.

Change-Id: Ief900494081ddc9ae6329ee7a56723d9cb5efe13
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456937
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: Changpeng Liu <changpeng.liu@intel.com>
2019-06-06 01:44:33 +00:00
GangCao
9aed5fa5b6 iscsi: update the version error message
Change-Id: I3a2488cdd81812f1fce136b97e49eee18b49fbc1
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456915
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: Changpeng Liu <changpeng.liu@intel.com>
2019-06-06 00:59:57 +00:00
Li Feng
02363ccb3b lib/iscsi: fix iscsi connection schedule
If the qualified core wasn't found, then we should compare
spdk_env_get_core_count() with i, instead of lcore.

Signed-off-by: Li Feng <fengli@smartx.com>
Change-Id: Ie92f56712b7f0e51636008fe12fff5584b6be8ab
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456415
Reviewed-by: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
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-06-05 17:39:12 +00:00
GangCao
3a0886c408 iscsi: correct the error detail
According to https://tools.ietf.org/html/rfc3720#page-196,

Error detail of "Authorization failure" is for the case that
the initiator is not allowed to the given target.

Change-Id: Ie628c4c857e965aa6694399a9832ce0501e50745
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456826
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>
2019-06-05 16:48:48 +00:00
Shuhei Matsumoto
57fe0394a3 iscsi: Use 0 instead of SPDK_SUCCESS in spdk_iscsi_read_pdu to match caller
spdk_iscsi_read_pdu has been used only in a place,
iscsi_conn_handle_incoming_pdus. iscsi_conn_handle_incoming_pdus
classifies return code of spdk_iscsi_read_pdu to
SPDK_ISCSI_CONNECTION_FATAL, 0, or 1.

Using 0 instead of SPDK_SUCCESS in spdk_iscsi_read_pdu matches
iscsi_conn_handle_incoming_pdus and is done in this patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I231c2e70a094c26af2c8eb60d77b92d880674901
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456770
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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-06-05 05:31:22 +00:00
Shuhei Matsumoto
0f5314eb05 iscsi: Consolidate error paths in spdk_iscsi_read_pdu
spdk_iscsi_read_pdu() returns three return values,
SPDK_ISCSI_CONNECTION_FATAL, 0, or 1.

Consolidating error paths clarifies the logic.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I66a734f37bfd3bbd0ae0974813086b24cb3cd432
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456769
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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-06-05 05:31:22 +00:00
GangCao
9a73633190 iscsi: add a cleanup utility function
Added a utility function for the cleanup related operations.

Change-Id: I4e49dd9c2da899a5bda289bc36778b636af9c5df
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456599
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-04 23:51:15 +00:00
Shuhei Matsumoto
f089b07af4 lib/iscsi: Rename _iov_ctx to _iscsi_sgl to match DIF library
Recently DIF library refined _iov_ctx to support multiple iovecs
for DIF insert and strip operations. iSCSI library is the first
user of DIF insert and strip, and so rename _iov_ctx to _iscsi_sgl
to match DIF library. Names of related helper functions and
a member variable are changed together.

This change will be helpful to extract common part into a specific
helper library if necessary in future.

Change-Id: I3be3b6c3c476b0309ffafdecf3181fb2bb19abc6
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455620
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-05-24 23:19:24 +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
Jim Harris
59a1fbe937 iscsi: fix hang on high QD large reads
We throttle the number of data_in operations per
connection.  Currently after a read is completed,
we try to send more data_in operations since one
has just been completed.

But we are trying to send more too early.  The data_in_cnt
doesn't actually get decremented until after the PDU is
written on the socket.  So this results in a case
where data_in_cnt == 64, and all 64 read operations
complete before any of those 64 are actually transmitted
onto the TCP socket.  There are no more read operations
waiting, so we won't try to handle the data_in list
again, and if none of these 64 resulted in a SCSI
command completing, then the initiator may not send us
any more read I/O which would have also kicked the data_in
list.

So the solution is to kick the data_in list after the
PDU has been written - not after a read I/O is completed
back from the SCSI layer.

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

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455454
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-24 04:19:03 +00:00
Jim Harris
462c12d9e9 iscsi: free pdus in hot remove path with no lun
The datain handling code path will set the LUN to
NULL if it finds a task's LUN has been hotremoved.
This could happen before the iscsi hotplug routine
actually gets a chance to run.  If this happens,
one of these tasks doesn't actually get freed, and
then will be freed after the lun is closed -
causing a segfault in the bdev layer since it may
have a bdev_io associated with it.

Found by running the iscsi_tgt/fio test after
applying the next patch in this series.

There's more work needed in this hot remove clean up
path - currently we are just freeing a lot of PDUs
rather than completing them with error status when
a LUN is hot removed.  But let's tackle that
separately.

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

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455460
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-24 04:19:03 +00:00
Ben Walker
3f81bcaf12 iscsi: Move acceptor into portal_grp
It's 3 functions that are only called from this compilation
unit.

Change-Id: I033ced4c19ee2a33b9537c347532ea5706d02d6a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454493
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-16 23:23:45 +00:00
Shuhei Matsumoto
17b2f5e931 dif: Support a single iovec for data buffer in spdk_dif_generate_stream
As a subsequent effort, this patch changes the interface of
spdk_dif_generate_stream to accept SGL data buffer.

This patch allows only a single iove. The next patch will allow
multiple iovecs.

Change-Id: I56f901d73ca3b9da4b56c213ebafcd7706b1fef8
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453755
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-05-16 20:17:44 +00:00
Shuhei Matsumoto
2821762a60 dif: Support a single iovec for data buffer in spdk_dif_set_md_interleave_iovs
Currently iSCSI target have used a single contiguous data buffer
both for read and write I/O. Hence spdk_dif_set_md_interleave_iovs
accepts a single contiguous data buffer and its size as arguments.

On the other hand, NVMe-TCP target recently has changed to use
SGL data buffer instead.

DIF strip and insert will be supported in NVMe-TCP target next,
and updating spdk_dif_set_md_interleave_iovs to accept SGL data
buffer will be helpful.

This patch changes the interface of spdk_dif_set_md_interleave_iovs,
but allows only a single iovec. The next patch will allow multiple
iovecs.

Change-Id: I31b09814f8ec920e463a5b1be8fb88cad7d277fb
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453735
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-05-16 20:17:44 +00:00
Ben Walker
bdb595cfb3 iscsi: spdk_iscsi_poll_group_add_conn now takes a poll group argument
Make this explicit instead of implicit.

Change-Id: Iab1b856648e1f11722e1f76602f1eee4bc4ed0b5
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454381
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>
2019-05-15 18:45:46 +00:00
GangCao
e358eaeeea iscsi: fix double free when failed to start target
When iSCSI target failed to start due to insuccificent resource like PDU pool,
one memory is double freed.

Change-Id: I1b68d4f0f130b024be9f8406c8d1611e92a27787
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453981
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-13 07:55:40 +00:00
Ben Walker
1c8a1064b0 iscsi: Rename iscsi_unregister_poll_group to iscsi_poll_group_destroy
Follow our typical subject_verb pattern.

Change-Id: I21b0f78dba0a7d019a85e922fadff0f0399d2fc3
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453021
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Ben Walker
814f1503fe iscsi: Rename iscsi_create_poll_group to iscsi_poll_group_create
Follow our usual subject_verb format.

Change-Id: I6384e049d812e0df84ad7a2b35ed2d77349c7255
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453020
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Ben Walker
c6f43b89bc iscsi: Always schedule discovery sessions on the acceptor thread
Change-Id: I0b8aee43f8b4cc380c91a7bb69fb33b307edb412
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453019
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Ben Walker
fc35f1ae3e iscsi: inline spdk_iscsi_conn_allocate_reactor
This function was only called from a single place, so just
move the code there.

Change-Id: I78c05ef41ca0d5684385e80cb75d699453c90792
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453018
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Ben Walker
1224a5a049 iscsi: Remove out-dated comment above spdk_iscsi_conn_construct
This went stale and the code is currently in flux.

Change-Id: Ib0b2171f253db0f54d41573c07668eb3b2bd83b4
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452781
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
Ben Walker
07c9541082 iscsi: Assign connections to cores using round robin
Previously, this searched the list of cores for the one
with the fewest connections and scheduled there. iSCSI
is being migrated to a new threading model where the
threads themselves will float, so simplify this part
of the code while that's implemented.

Change-Id: I05a1ff51a45df9c176c0e57d7f1ae9e97928adcd
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452780
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +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
Ben Walker
1f41fb365b iscsi: Simplify iscsi_poll_group_add/remove conn operations
We don't need to have operations to remove just the socket.

Change-Id: I00e0c7fb81af98d1c072ba126ce22b41954e313b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452728
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00
Ben Walker
d6d5f870c4 iscsi: Only call iscsi_conn_stop in exit path
For migrating a connection, don't stop it entirely.

Change-Id: I0e09698e03127c04257485a0a2af262ed1a7761a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453017
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: Jim Harris <james.r.harris@intel.com>
2019-05-06 17:10:48 +00:00