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>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455454 (master)
(cherry picked from commit 59a1fbe937)
Change-Id: Ia01cf96e8eb6e08ddcaaeff449386e78de7c5bc5
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457271
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: GangCao <gang.cao@intel.com>
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>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455460 (master)
(cherry picked from commit 462c12d9e9)
Change-Id: I8d27f0c7a79ae91cb6504e5ff6ffc8e346c9e54c
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457270
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>
When iSCSI target failed to start due to insuccificent resource like PDU pool,
one memory is double freed.
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453981 (master)
(cherry picked from commit e358eaeeea)
Change-Id: I1b68d4f0f130b024be9f8406c8d1611e92a27787
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457225
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: GangCao <gang.cao@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
spdk_dma_malloc() is not required here, as the session
array is nether DMA-able nor shared between processes.
Change-Id: Ia9218d00eea8a3207abf07c1d78eaa585ffcad2c
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450552
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: Changpeng Liu <changpeng.liu@intel.com>
All error paths must free opts->nodebase and opts->authfile.
Change-Id: I655f112dd36bbd0dca6050bc5cc3ade1a5b05b7d
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451770
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>
This is the end of the patch series. After this patch,
delete_target_node RPC will wait for the completion of
removal of the SCSI device and then free the iSCSI target.
SCSI device holds passed callback and calls it in free_dev().
free_dev() is ensured to be called after all iSCSI sessions
are closed. So iSCSI target resource can be freed safely
after that.
Change-Id: I25921b4014207092b7b3845dfeae58bcdffa2edc
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450607
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>
We did this a while ago for login notifications - do
it for logout as well.
While here, just use SPDK_DEBUGLOG instead of printing
to a buffer first.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I77f566d139cd818428371ec887efeca6eee08898
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451062
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
The next patch will add the function ponter typedef
spdk_scsi_dev_destruct_cb for SCSI device destruction.
Hence add lun to the names of descriptors and callback for SCSI
LUN for clarification.
This patch doesn't change any behavior.
Change-Id: I73f2bce9129f7a6f16770ab6ed18428b16589108
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450883
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>
This patch changes iscsi_tgt_node_destruct to be asynchronous.
spdk_iscsi_shutdown_tgt_node_by_name() uses the callback
provided by iscsi_tgt_node_destruct(), but
spdk_iscsi_shutdown_tgt_nodes() doesn't use it.
The reason is that during shutdown all sessions are terminated
already, and spdk_iscsi_shutdown_tgt_nodes() doesn't need to
wait for the completion of iscsi_tgt_node_destruct() by using
the callback. iscsi_tgt_node_destruct() will complete immediately
in this case.
spdk_scsi_dev_destruct() is not asynchronized yet and so
iscsi_tgt_node_destruct() calls its callback directly in this patch.
The next patch will replace the call.
Change-Id: I86911c5297a93560551e0404d6ea85f49d647c22
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450606
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>
This patch changes spdk_rpc_delete_target_node() to pass
rpc_delete_target_node_done() and its context to
spdk_iscsi_shutdown_tgt_node_by_name().
iscsi_tgt_node_destruct() is not asynchronized yet and so
spdk_iscsi_shutdown_tgt_node_by_name() calls the callback
passed from the caller directly for now.
The next patch will replace the call.
Change-Id: Ide2d9fcc6738e02de19f91249c21ac2d0d37138a
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450605
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>
delete_target_node RPC had not waited for completion of
spdk_iscsi_shutdown_tgt_node_by_name. This implementation
is not the direct cause of the deadlock issue in
spdk_iscsi_conn_stop() but changing delete_target_node RPC
to wait for completion of spdk_iscsi_shutdown_tgt_node_by_name
will prevent future errors.
spdk_iscsi_shutdown_tgt_node_by_name() is not asynchronized yet
and so rpc_delete_target_node calls rpc_delete_target_node_done
directly in this patch.
The next patch will replace the call.
Change-Id: I6a042028b93c36ca9f68e3b212141e101b33d394
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450604
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>
When any iSCSI target is destructed, if the target exits all corresponding
connections first, destructing SCSI device will be easier.
Hence, iscsi_tgt_node_destruct() starts exiting all corresponding
connections. Then it destructs SCSI device immediately if no active
active connections, or waits for the completion if there is any
active connection for the target.
Change-Id: Ibd4a29789faecfefccefa1153a519c43d040a00d
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450737
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>
In iscsi_conns_cleanup(), g_conns_array was unmapped but was not
invalidated by setting MAP_FAILED.
So, find_iscsi_connection_by_id() caused segmentation fault if
it is called after iscsi_conns_cleanup().
Change-Id: Ib91c9240c62c2aaa32713dd4aa382d31e5ea2eed
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450901
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>
Add the flag destructed to struct spdk_iscsi_tgt_node and
iscsi_op_login_check_target() refers it and returns
ISCSI_LOGIN_TARGET_REMOVED if it is true.
When destructing iSCSI target node, it will be nice if iSCSI library
can stop further connections are created but, connections are not
associated with any target node until processing login. Hence stop
creating sessions instead.
Additionally, when destructing iSCSI target node, if the flag destructed
is already set, return immediately, and the flag destructed does not
affect discovery session.
Change-Id: Ic73bdd93f2ca7d5ca1d2f897d5046cbc51650d5f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450881
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>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
These change will be used in the next patch.
Change-Id: Ifdb4ccf20049b46e850122a4021cbbe7441e1270
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450736
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>
Subsequent patches will exit only connections belonging to the
specific target node. So add target to get_active_conns() as
an argument.
Change-Id: If0d9cad46614310e0fe17e69e75c1185146730f4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450735
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>
When target is specified, the function starts exiting any
connection that belongs to the target. When target is not
specified, the function starts exiting all connections.
Change-Id: I0dfb56ceac5ee36d10547a9ab9a0f768ca8e02ec
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450734
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>
Factor out the operation to start exiting connections into a
function. This patch doesn't change any behavior.
Change-Id: I8f48961bcc95c480636e0e0d8fbb8ef029818d9e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450733
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>
target had been set to the created session after returning from
create_iscsi_sess(). But create_iscsi_sess() has been used only in
a place and target has been already included in the arguments in
it. So set target to the created session in create_iscsi_sess().
Change-Id: Id65e6c5a1f76b995a7d0e9939ff3a2fce5daeb3f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450732
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>
iSCSI mutex had guarded both unregister operation and destruct
operation in a single critical region in spdk_iscsi_shutdown_tgt_nodes
and spdk_iscsi_shutdown_tgt_node_by_name.
Subsequent patches will separate unregister operation and
destruct operation, and so this patch separates critical region of
unregister operation and destruct operation.
Change-Id: I847915f8277c4475c034ca64fd07ccdd47659590
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450583
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>
Subsequent patches will make iSCSI target possible to wait for
completion of SCSI device destruction by using callback.
This patch moves spdk_scsi_dev_destruct() before starting to
free iSCSI target node resource as a preparation.
Change-Id: I9cfe7662a05b1211292a5cc448bbba60a929f356
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450582
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>
It's possible that we get a request to abort I/O just after
a queued_datain_task has completed, but before we've had a
chance to remove it from the queued_datain_tasks TAILQ.
_iscsi_conn_abort_queued_datain_task wasn't accounting for
that which would result in an infinite loop.
Fixes issue #725.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Tested-by: Jane Lusby
Change-Id: I494ee78763d527d83dcb65f46563ee69bb975576
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450301
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
LUN ID is not converted from integer to structure and integer is
set to R2T PDUs.
Popular iSCSI initiators don't check this value and work correctly.
This patch uses the public helper function of the SCSI library
to fix the issue.
Additionally, private helper function to convert structure to
integer for LUN ID is replaced to the public helper function
of the SCSI library.
Change-Id: I9218c5ef7a8bfec43326c6584db7c6929fdd11a8
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449963
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>
Right now they can only use memory from the socket
that performed iSCSI static initialization, which
doesn't make sense. Those mempools can be used from
a different socket as well, so don't restrict them
to any specific one.
Change-Id: I0def1c554ed6227ab0f0a7be107c4c1c61f40c96
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450055
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>
My iSCSI target reported segment fault after memory allocation
failure, and add the addtional check here can fix the issue.
Change-Id: Iee3e497d7028fbface6d110c78e73965ef0f178b
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449717
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
A few private functions had still the prefix spdk_ in their names.
This patch completes the effort to remove the prefix spdk_ from
private functions in iSCSI library.
Change-Id: Ic1a1e85220edb72296ca4881bdf7b550c4f6b6b8
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449716
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>
iSCSI library had used the prefix spdk_ for most functions regardless
of private or public. Using the prefix spdk_ only for public functions
will be helpful to distinguish private and public functions, and
will be helpful to investigate issues or do further improvement.
Besides in iscsi.c static variable spdk_arc4random_initialized had
the prefix spdk_, and change it to g_arc4random_initialized according
to the SPDK's good practice.
iSCSI library still have some issues but is more stable than before
and now will be the good time to adjust the naming rule to other
libraries.
This patch doesn't change any behavior.
Change-Id: Ia0b8585a7ce6662cabc0e6f57b7ccb8a40342297
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449396
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>
These function declarations are not used.
Change-Id: If525f4157e3fa9e5d718e6c7aa77db8584edd14c
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449395
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
spdk_iscsi_conn_read_data was changed to use sock_readv
instead of sock_recv as a refactoring effort.
However this change caused about 3% performance degradation
for write I/O.
Hence this patch changes spdk_iscsi_conn_read_data to use
sock_recv and changes spdk_iscsi_conn_readv_data to call
spdk_iscsi_conn_read_data if iovcnt is 1.
Change-Id: I5fcad03ff23dee4e9954eee879225d3c493be52e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448021
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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
spdk_iscsi_get_dif_ctx() didn't work correctly for Data In PDU
because we had to get iSCSI task from PDU directly for Data In PDU,
and lun_id was not copied in spdk_iscsi_task_get().
This patch fixes these bugs and the DIF strip feature was verified
after applying this patch.
Change-Id: I74d404b82c4a9502a9a8e166748f817d3c2e4368
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447884
Reviewed-by: Ziye Yang <ziye.yang@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>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Generate and insert DIF for write I/O by stream fashion in
spdk_iscsi_read_pdu().
Verify DIF for read I/O in spdk_iscsi_conn_write_pdu().
Verification can be done in spdk_iscsi_build_iovs(), but how many
writes to socket is not known beforehand, and same range may be
verified multiple times. So verify DIF before starting to write to
socket.
Change-Id: I860637758164b7d518c38fe92356562cbbe3d8f8
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446406
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: Ziye Yang <ziye.yang@intel.com>
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>
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>
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>
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>
This patch adds spdk_iscsi_conn_readv_data() to read PDU data
from network socket by using spdk_sock_readv().
Additionally, this patch changes the existing spdk_iscsi_conn_read_data()
to call spdk_iscsi_conn_readv_data() by creating a single struct
iovec.
Change-Id: Ied487bb71bd4261ad53c9f3744ae272e65f98d7a
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446377
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>
The operation to read data segment of PDU will be enhanced to
support DIF insert operation ofr write I/O.
This patch factors out check data segment length operation into a
function to make the enhancement easier.
Change-Id: I4fbc3bd440192b3723435c9acf3b6b46d3ce4939
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446342
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>
spdk_iscsi_build_iovs() has the common pattern among segments, and
introduce a temporal context to factor out the common pattern into
a helper function. This will make subsequent patches easier to add
code about DIF strip in spdk_iscsi_build_iovs().
Change-Id: I307d8d0501910071b23a8c0d8eb5e19a4d1684c4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446573
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>
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>
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>
Building iovecs had been done in spdk_iscsi_build_iovs() and
fast-forwarding iovecs for the partially written first PDU had
been done in-line separately.
This patch unifies these two operations into spdk_iscsi_build_iovs().
Fast-forwarding iovecs is necessary only for the first PDU, but the
operation is applied to all PDUs after this patch.
Extra overhead will be negligible because usually at most two
iovecs are consumed, one is for the base header segment and another
is for the data segment.
Change-Id: I8feafac6d280439eb7cf73136107adbac820ae09
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446174
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>
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>
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>
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>
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>
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>
The physical addresses in iSCSI are completely unused
as iSCSI does not perform any DMA on its own.
Change-Id: I350037b708a9f36f423e6ca6f7c822d8b6b95116
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443482
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>