Commit Graph

291 Commits

Author SHA1 Message Date
Darek Stojaczyk
bcb9d9361a scsi: fail invalid MODE_SELECT requests
For MODE_SELECT request we didn't verify the parameter
list length field from CDB and could complete an invalid
I/O without reporting any error. Fix it by adding an
additional check. Just to clarify: the I/O did not do
any harm, we just completed it with success while we
should have completed it with some error status.

Change-Id: I473e321da37259ee6318ca7dadab2726851d2b68
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463065
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-08-05 23:15:08 +00:00
Darek Stojaczyk
f89166c089 scsi: remove bdev_scsi_mode_select_page()
The function didn't do anything.

Change-Id: Id44a7d0c129ab60751eda382911935d677730ec9
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463066
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: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-07-26 04:14:59 +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
Changpeng Liu
bdb90726ee scsi: fix error break when checking SCSI reservation
We should return for the registrant case when the reservation holder
exists.

Change-Id: Ie3cf31554eafdad03294aef2eeb6eaef1536b8c3
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460305
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Liang Yan <liang.z.yan@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-07-04 08:15:44 +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
73204fe2e5 dif: Add data offset to DIF context separately from start block address
Data offset are intended to correspond to DATAO in NVMe/TCP and
Buffer Offset in iSCSI.

Previously for iSCSI, buffer offset had been merged to start block
address, but passing buffer offset separately from start block address
clarifies the logic more.

On the other hand, for NVMe/TCP, passing DATAO separately from start
block address will be critically important because DATAO will bave any
alignment and will be necessary to use for not only reference tag
but also guard computation.

This patch adds data_offset to struct spdk_dif_ctx and adds it to the
parameters of spdk_dif_ctx_init(). ref_tag_offset is also added to struct
spdk_dif_ctx and it is computed by dividing data_offset by data_block_size
and is used to compute reference tag.

The next patch will use this change when getting DIF context in SCSI.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id0e12ca9b1dc75d0589787520feb0c2ee0f844a5
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457540
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
Changpeng Liu
14f6d724ac scsi: add additional check for initiator port
Vhost-scsi target will not set task's initiator port parameter,
so reservation commands sent from Guest will cause segment fault.

Change-Id: Ifc175effded5371eca08d5bfe7e4aa977dd4b1c6
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457550
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-11 18:05:55 +00:00
Changpeng Liu
4f95ec427c scsi: add a helper function to check the LUN holds a reservation or not
Change-Id: I8cf71783ad4af4f7bdef823018f907933b793c9d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455765
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-03 23:59:49 +00:00
Changpeng Liu
8c0c8e5333 scsi: add persistent reservation SCSI commands check
All the SCSI commands have two states: allowed and conflict,
based on different reservation types and I_T nexus, the SCSI
module will check each commands before sending to the backend
device.

Change-Id: Ib05cece1c237873360f85c68d139362200d2d47e
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436097
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-30 21:42:36 +00:00
Changpeng Liu
94e9f0ab8b scsi: add persistent reserve in command with read full status support
Change-Id: I9093397ec674de55473e61af1c54009bf60878aa
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436096
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-30 21:42:36 +00:00
Changpeng Liu
c25e9b2437 scsi: add persistent reserve in command with report capabilities support
Change-Id: I676c385ffd51c0ad2c606f948f21beb031ef4c95
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436095
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-30 21:42:36 +00:00
Changpeng Liu
fecac0d871 scsi: fix SCSI reservation typos
Change-Id: Ibbc5c95fddc3d39b7d9222fa203bc29e1cf44cf6
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456285
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-30 21:42:36 +00:00
Changpeng Liu
2b09903c2c scsi: add persistent reservation in with read reservations support
Change-Id: I5345207a6331889182324ae3231bb62c84b69d69
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436094
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-05-29 20:57:37 +00:00
Changpeng Liu
4e9e220e7c scsi: add persistent reservation in command with read keys action support
Change-Id: Ia8e4ad31e84a1a97c83d4f49680bb7090ee4e041
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436093
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-29 20:57:37 +00:00
Darek Stojaczyk
7a1c568598 Revert "SCSI: Stop I/O flooding to hot-removing LUN from iSCSI target"
Hotremoving a bdev exposed as a vhost-scsi LUN which
has an allocated io_channel is broken now. By detaching
LUNs from their SCSI devices at the start of LUN
hotremoval, we can end up with the LUN's descriptor
completely leaked.

Upon hotremove, each LUN fires a hotremove_cb to the
upper layer (iscsi/vhost) and starts a poller to
periodically check if lun->io_channel has been closed
already. While iSCSI allocates and frees io_channels
for particular LUNs separately using
spdk_scsi_lun_allocate_io_channel(), vhost allocates
and frees io_channels for the entire SCSI device using
spdk_scsi_dev_free_io_channels(), as it knows there's
only one LUN per SCSI device.

Since LUNs are removed from SCSI devices at the start
of LUN hotremoval, the spdk_scsi_dev_free_io_channels()
is not able to close the io_channel of the child LUN.
That LUN is no longer referenced there, and the function
returns immediately without any error.

By reverting this patch, we practically defer removing
LUN from SCSI device until the bdev descriptor is closed,
that is, until that spdk_scsi_dev_free_io_channels()
and the subsequent spdk_scsi_dev_destruct() in vhost
is called.

Historically, spdk_scsi_lun_free_io_channel() was
introduced after vhost-scsi already supported hotremove,
so before we can introduce a change like this one we
have to refactor vhost to use the new APIs first.

This reverts commit 497997bc60.

Change-Id: I58a9988a22694f5b5b927173098ac8218270462e
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455371
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-24 23:46:53 +00:00
Changpeng Liu
8f2a85362b scsi: add persistent reservation out command with preempt service action support
A PERSISTENT RESERVE OUT command with PREEMPT service action action is used to:
a) preempt (i.e., replace) the persistent reservation and remove registrations; or
b) remove registrations.

Change-Id: I906b09057e5ddef0ea2fe180bb5fff6e9e0a04f6
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436092
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-05-24 23:04:03 +00:00
Changpeng Liu
8d79b4109f scsi: add persistent reservation out command with clear service action support
Any application client can release the persistent reservation and remove all
registrations from a device server by issuing a PERSISTENT RESERVE OUT command
with CLEAR service action through a registered I_T nexus.

Change-Id: Ie21885f7f9632b9da77e877fbce7c51b2e0b47a7
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436091
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-24 23:04:03 +00:00
Changpeng Liu
e8e791f7b5 scsi: add persistent reservation out with release service action support
An application client releases the persistent reservation by issuing a
PERSISTENT RESERVE OUT command with RELEASE service action through an
I_T nexus that is a persistent reservation holder.  The RELEASE service
action will release the persistent reservation and do noting to
existing registrants.  Unit Attention isn't supported by SPDK so here
we will not establish any unit attention condition.

Change-Id: If0df3b3fc4e89ffa78d827e2b31cf5c61aa149db
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436090
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-05-24 23:04:03 +00:00
Changpeng Liu
601fbbf969 scsi: add persistent reservation out with reserve service action support
An application client creates a persistent reservation by issuing a
PERSISTENT RESERVE OUT command with RESERVE service action through
a registered I_T nexus with RESERVATION KEY and TYPE, and persistent
reservation has a scope of LUN, only one persistent reservation is
allowed at a time per LUN.

Change-Id: I052d0ddd439dd9994c0793218dd5c5d6ed176d2c
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436089
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-24 23:04:03 +00:00
Changpeng Liu
d0d19eb82e scsi: add persistent reservation out with register feature support
To establish a persistent reservation the application client shall first
register an I_T nexus with the device server. An application client registers
with a logical unit by issuing a PERSISTENT RESERVE OUT command with REGISTER
service action or REGISTER AND IGNORE EXISTING KEY service action.

Specify Initiator Ports (SPEC_I_PT) bit and All Target Ports (ALL_TG_PT) bit
are not supported for now, the registrants belong to the I_T nexus who sends
the command.

Also Activate Persist Through Power Loss (APTPL) bit will be supported in
following patches.

Change-Id: If057a764a4bfa73017f98048c94b697dbfa4b4a1
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/436088
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-05-24 23:04:03 +00:00
Darek Stojaczyk
122cc72cd9 Revert "scsi: Simplify removing LUN when no connection is for it"
The new, simplified scsi lun hotremove path doesn't call
lun->hotremove_cb if there's no io_channel allocated for
that lun. Vhost still depends on that callback and currently,
when the underlying bdev is removed, vhost is left completely
unnotified. It keeps a dangling pointer to a scsi lun and
will eventually crash. The vhost scsi controller also can't
be removed in this case.

This reverts commit 19182431c8.

Change-Id: I330330fdd7d6941db070d972192481f535f62977
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-05-20 16:56:06 +00:00
Shuhei Matsumoto
19182431c8 scsi: Simplify removing LUN when no connection is for it
Both for vhost SCSI and iSCSI target, IO channel is allocated to
LUN before using it. Hence LUN is not used by anyone if IO channel
is not allocated to it. So we can call scsi_lun_remove in this
case.

Change-Id: I6881a5e075ed6ef11802e1b166dfb3f35531d100
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453968
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-05-13 15:38:56 +00:00
Shuhei Matsumoto
497997bc60 SCSI: Stop I/O flooding to hot-removing LUN from iSCSI target
We have observed unexpcted timeout when we remove LUNs from the
active iSCSI target dynamically during FIO workload.

By making destroy_raid_bdev RPC wait for its completion, we could know
the destroy_raid_bdev RPC caused timeout because LUN hot removal didn't
complete.

By investigating the log, incoming I/Os from the host had not stopped
even after hot removal process was started.

The reason was that iSCSI target had continued to accept incoming I/Os
from the host.

By removing LUN from the SCSI device at the start of the LUN hot removal
process, iSCSI target will be able to stop incoming I/Os and LUN hot removal
will complete in finite time.

LUN itself can be accessible even after it is removed from the SCSI device.

LUN hot removal is for not I_T nexus but I_T_L nexus and so we cannot
start connection exiting in this case because connection can have multiple
LUNs. So this fix requires few changes and will be practical.

  Fixes #715

Change-Id: I17d7a1f6c6557297289c3bd148a62db46da48ec5
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453959
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-05-13 15:38:56 +00:00
Jim Harris
617184be3b trace: remove short_name
This was not used by any of the trace register descriptions.
Let's remove it rather keeping it around if we don't need it.

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

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452734
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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-05-02 08:41:56 +00:00
Darek Stojaczyk
07689e948c scsi: alloc temporary data buffer with regular calloc
spdk_dma_malloc() is not required here, as the buffer
is neither DMA-able nor shared between processes.

The buffer is used to store the scsi response as it's
prepared. At the end it's always memcopied to possibly
multiple DMA-able buffers in the scatter-gatter list
provided by the upper layer.

Change-Id: I92fcede67dc24c532b13399f6364b071b2aeeb56
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451555
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-05-01 17:59:34 +00:00
Shuhei Matsumoto
56d8b78576 lib/scsi: Make spdk_scsi_dev_destruct asynchronous
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>
2019-04-22 18:22:59 +00:00
Shuhei Matsumoto
9470d65e8d lib/scsi: Add lun to the names of descriptors and callback for LUN
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>
2019-04-22 16:00:42 +00:00
Jim Harris
07ec3d4789 scsi: don't zero entire vpd_ext_inquiry structure
This case was zeroing the entire structure - overwriting
the peripheral and page_code data already set.  Don't
bother zeroing the alloc_len either - we'll set that
later in this case statement.

Fixes issue #750.

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

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450922
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-04-18 16:09:57 +00:00
Shuhei Matsumoto
12ab86e24d scsi: Add helper functions to convert LUN ID between structure and integer
SPDK iSCSI target didn't convert LUN ID from integer to structure
when it sends R2T PDUs. The next patch will fix the issue. Introducing
helper functions into SCSI library and using them will be clean. Hence
this patch adds two helper functions to convert LUN ID between structure
and integer.

The logic of helper functions is derived simply from the current
implementation in SPDK.

Change-Id: I114b546cfcb44109d6cd131a1fa972f4d6bfea38
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449962
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-04-04 04:40:28 +00:00
Shuhei Matsumoto
0ed66e7ef6 scsi: Remove the prefix spdk_ from names of private functions
This patch doesn't change any behavior too.

Change-Id: I67be498bfd4f1ae42e6239de4539e5e99f158279
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449397
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-04-01 00:52:56 +00:00
Shuhei Matsumoto
8697bce7af scsi: Add an API to return DIF context of bdev and CDB
This patch adds an API spdk_scsi_bdev_get_dif_ctx().

spdk_scsi_bdev_get_dif_ctx() decodes opcode in CDB, and if opcode
is read or write block commands, it gets LBA and use the lower
32bits of LBA as Reference Tag. It gets DIF information from
specified bdev next. Then it sets all to DIF context and return.

spdk_scsi_bdev_get_dif_ctx() is exported to iSCSI through
spdk_scsi_lun_get_dif_ctx().

Change-Id: Id8aac164c48e9e9d4ff7cfc9fa81bb5090f3e187
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446224
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-03-08 01:21:26 +00:00
Shuhei Matsumoto
adc8da4aac scsi: Use data block size not including metadata instead of block size
SPDK iSCSI and SCSI target don't expose any metadata and DIF settings
to the corresponding iSCSI and SCSI initiator.

Even when SPDK iSCSI and SCSI target allocate any bdev formatted
with DIF,  SCSI commands sent from iSCSI and SCSI initiator don't
have any metadata and DIF information.

For that case, iSCSI target inserts and strips DIF on behalf of
iSCSI and SCSI initiator.

Hence SPDK SCSI target has to use data block size not including
metadata to process SCSI commands correctly.

This patch replaces spdk_bdev_get_block_size by
spdk_bdev_get_data_block_size in necessary places.

Change-Id: I264c8e532d1d1b016f6d8774c8ec03389528044f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/445083
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>
2019-03-07 07:03:27 +00:00
Shuhei Matsumoto
e7dc23696b scsi: Inline spdk_bdev_scsi_read/write into spdk_bdev_scsi_read_write
In this patch series, spdk_bdev_scsi_read and spdk_bdev_scsi_write
became almost identical. Hence squash them into spdk_bdev_scsi_read_write.

Change-Id: Ibbaddf74c1bf2dac37a0133eac27086af650a061
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444780
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-20 20:17:56 +00:00
Shuhei Matsumoto
07e9a00b60 scsi: Use spdk_bdev_writev_blocks instead of spdk_bdev_writev
This is in a effort to consolidate SCSI read and write I/O
for the upcoming transparent DIF support.

Previously conversion of bytes and blocks are done both in
SCSI layer and BDEV layer. After the patch series, conversion is
consolidated into SCSI layer.

Change-Id: Ib964a41ec22757f2a09cea22f398903f78d0781f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444779
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-20 20:17:56 +00:00
Shuhei Matsumoto
56e12b0071 scsi: Use spdk_bdev_readv_blocks instead of spdk_bdev_readv
This is in a effort to consolidate SCSI read and write I/O
for the upcoming transparent DIF support.

Previously conversion of bytes and blocks are done both in
SCSI layer and BDEV layer. After the patch series, conversion is
consolidated into SCSI layer.

About conversion from bytes to blocks, we don't expose bdev API
spdk_bdev_bytes_to_blocks and but create private helper function
_bytes_to_blocks because we will use not block size but data
block size when we support transparent DIF feature.

Change-Id: I37169c673479c92e027e2507a0e54a1e414b43e1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444778
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-20 20:17:56 +00:00
Shuhei Matsumoto
05f30ca396 scsi: Remove the param xfer_len and refactor spdk_bdev_scsi_read/write
The last parameter xfer_len of spdk_bdev_scsi_read is not used,
and of spdk_bdev_scsi_write is used only to check task->transfer_len.

Hence remove the last parameter xfer_len from spdk_bdev_scsi_read/write
and extract the check operation from spdk_bdev_scsi_write and insert
it into spdk_bdev_scsi_read_write.

Additionally, remove a debug log because xfer_len is not passed to
spdk_bdev_scsi_write anymore. Hopufully, this will not degrade any
maintainability.

On top of this, factoring out the operation to convert byte to
block in spdk_bdev_scsi_read/write be done.

Change-Id: I35faca269a9c4a7f15d27e8e61b6a1b809a36b3f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/444776
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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
2019-02-20 20:17:56 +00:00
Shuhei Matsumoto
ed8b4f5bae scsi: Use spdk_json_write_named_* APIs throughout
Change-Id: I536190f12022abc2c914b47cac8d831297bee247
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/442944
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-02-04 07:08:04 +00:00
Jim Harris
fbb1fc41f3 scsi: squash errlog for THIN_PROVISION INQUIRY page
It is perfectly valid for a bdev to not support the
unmap command - there's no need to print an ERRLOG
when a SCSI INQUIRY 0xB2 (LOGICAL BLOCK PROVISIONING)
command is sent to query if the LUN supports it.

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

Reviewed-on: https://review.gerrithub.io/c/442104
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>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2019-01-28 02:33:50 +00:00
Shuhei Matsumoto
728972cdf3 scsi: Set TMF code prior to calling spdk_scsi_dev_queue_mgmt_task
By subsequent patches for iSCSI, spdk_scsi_dev_queue_mgmt_task()
will not be called directly from the function that knows TMF code,
and currently setting TMF code to SCSI task is done in
spdk_scsi_dev_queue_mgmt_task().

Hence after subsequent patches for iSCSI, to hand off TMF code to
SCSI task, any dynamic context will be required.

To avoid the dynamic context, extract setting TMF code from
spdk_scsi_dev_queue_mgmt_task() and put appropriate place for
each call of spdk_scsi_dev_queue_mgmt_task().

Additionally, in spdk_abort_transfer_task_in_task_mgmt_resp(),
ref_task_tag is got from PDU but getting it from SCSI task is
much easier. Hence get ref_task_tag from SCSI task in the callback.

Change-Id: I7add9290598d2df7cfcf1506ec75d74c70c0f236
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/436643
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-12-10 20:34:11 +00:00
Shuhei Matsumoto
ba1811556b scsi: Add scsi_task_process_abort for aborted SCSI tasks.
Subsequent patches will have to abort SCSI tasks in the iSCSI
layer. But spdk_scsi_task_set_status() API is not public API.

spdk_scsi_task_process_null_lun() is existing public API but
LUN NOT SUPPORTED is not appropriate for those cases.

Hence add an new public API spdk_scsi_task_process_abort().

Change-Id: I5b488e902ccd790ace2936b3e6ebfeb124fa429a
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/436080
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-12-10 20:34:11 +00:00
Shuhei Matsumoto
5a365f3643 scsi: Move scsi_task_process_null_lun from lun.c to task.c
The next patch will add scsi_task_process_abort to task.c for
proper task management functions. scsi_task_process_null_lun
doesn't use struct spdk_scsi_lun and having both in the same
file will improve maintainability.

Change-Id: I6fd91aad84e62d14ecb7b44794db391a82cb4b12
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/436079
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-12-10 20:34:11 +00:00
Shuhei Matsumoto
d0e3f624f0 scsi: LUN reset waits for completion of all prior tasks
IO submissions to backends have to complete first in LUN reset.
Previous patch makes the waiting time limited.

LUN reset don't use timeout for now because even if LUN reset reports
timeout, error handling of the initiator will be escalated and the
initiator will issue stronger command and will wait eventually
until all outstanding tasks completed.

Besides, not using timeout in LUN reset will make implementation simple.

If timeout becomes necessary, I'll do it in the separate patch later.

Change-Id: Ie9e4502068c19b1727ea65dc773ddf08cedec7c4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434766
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-12-10 20:34:11 +00:00
Shuhei Matsumoto
b409bf4080 scsi: Revert submission queue and suspend submission during LUN reset
Submission queue deleted by https://review.gerrithub.io/393911
is necessary to support proper LUN reset.

Hence revert the removal in this patch.

And using the submission queue, suspend IO task submission during
LUN reset to limit completion time of LUN reset.

Change-Id: I3cdc4f0165fe845637112c2900407d6b4a09df79
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434765
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-12-10 20:34:11 +00:00
Shuhei Matsumoto
6dd09113e5 scsi: Serialize LUN reset execution
Task management functions don't require performance. Serializing
execution of task managment functions will sipmlify and stabilize
the logic and will be helpful for upcoming patches to support
other task management functions.

This patch introduces two queues, pending and submitted queue,
and serializes LUN reset exection and makes LUN hot removal
wait for LUN reset.

Besides, checking if LUN is NULL is moved to the upper layer as
same as IO task submission.

Change-Id: Ia0cf3f437a745ee70fc9b17744cc63c833690dda
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434764
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-12-10 20:34:11 +00:00
Shuhei Matsumoto
b7adc8fe83 scsi: Differentiate callback function about LUN reset from other TMFs
Current SPDK SCSI supports only LUN RESET in task management function.
Upcoming patches will support other functions too but differentiate
the callback function about LUN reset from other task management
functions for now to avoid misunderstanding.

Change-Id: If8f00ce413fbcc54b12dd885cbf01597f83a2af9
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434763
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@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>
2018-12-06 22:35:40 +00:00
Shuhei Matsumoto
b60923191d scsi: Remove the TMF code parameter because it is already set in task struct
This is a preparation to the next patch.

Change-Id: Ia7af66ba129a4666730f94be64d3699cded65e09
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/434762
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>
2018-12-06 22:35:40 +00:00
Changpeng Liu
38dfce0428 scsi: add iSCSI initiator port TransportID
SCSI persistent reservation feature need to get the TransportID
for the I_T nexus, so when creating initiator port we also
set the TransportID according to the specification, while here,
we use the format code 0x1 for the TransportID.

Change-Id: Ib45bec04bf0e33e2b0f611dd3846597f4176d069
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/435212
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>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-12-05 16:04:06 +00:00
Jim Harris
72f8c6a1f3 log: remove "trace" from internal API
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I8b1c0d4b00d5d41aae89d3b33f18d1ae957567dc

Reviewed-on: https://review.gerrithub.io/435344
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-12-03 19:50:15 +00:00
Liu Xiaodong
0e7ca66922 lib/trace: show specific usage of trace mask
Previously, if want to know which mask bit is used for specific
trace group, the only way is to check source code. Now list
each trace group with its trace tpoint group mask bit in
usage message

Change-Id: I7a85fe9c0885f1919f6ffbdc97dab81f1986fb07
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/435448
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-30 14:52:28 +00:00
Changpeng Liu
b2fb55192c scsi: fix possible memory leak for unmap command
Althrough it has very small chance to be executed, it's nice
to have it fixed.

Change-Id: I899681ccc13ed59c7fdd343ef7791df4e69e490f
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/433976
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 23:38:55 +00:00
Shuhei Matsumoto
65e5bbdc05 scsi: Use not C++ style comments // but C-style comments /* */
Change-Id: I44c1b5c68ddb56aca2ad46471753d6835dd744a5
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/431079
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>
Reviewed-by: Seth Howell <seth.howell5141@gmail.com>
2018-10-31 22:01:47 +00:00
Jim Harris
82c3c30f44 trace: remove alias concept
This was added a long time back for tracking an rte_mbuf
whose buffer was a different rte_mbuf - all related to
a userspace TCP stack that is no longer in development.
The concept isn't useful now, so remove it to reduce
the complexity of the tracing code.

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

Reviewed-on: https://review.gerrithub.io/424565
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-09-05 18:03:43 +00:00
Liang Yan
927ebdcc90 trace: update iscsi and scsi trace description
To be consistent with nvmf, use underscore.

Change-Id: I5f2ae60518367ab439db9b893ab8ba975e82bed9
Signed-off-by: Liang Yan <liang.z.yan@intel.com>
Reviewed-on: https://review.gerrithub.io/424179
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-31 19:21:29 +00:00
Shuhei Matsumoto
cefab5d647 iscsi: Support hot removal of LUN based on LUN open/close
When hot removal of a LUN is started, callback is called for each
iSCSI connection which accesses the LUN. Callback checks all transfer
tasks complete and then close the LUN.

If the connection clears all transfer tasks before getting all responses
to them from the initiator, the initiator continues to retry data write.
Hence the connection have to wait until all transfer tasks complete.

Change-Id: Iad9063673cfedbd78758890d55a4254512e4fca4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/417199
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-07-17 17:43:28 +00:00
Shuhei Matsumoto
fec7c88e45 scsi: Enforce to open LUN and then alloc IO channel by using descriptor
Use a descriptor got by opening the LUN to allocate IO channel of the LUN.
This requires opening the LUN is done before allocating IO channel of the
LUN.

Use the descriptor to free IO channel of the LUN too.

Additionally, assert is added to the close LUN function to check if
IO channel is freed before the last close LUN function is called.

Change-Id: Iafb2f9ce790fff25801ea45b3286f3e26943807b
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/417807
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@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>
2018-07-17 17:43:28 +00:00
Shuhei Matsumoto
c740e56928 scsi: Open/close a LUN to remove it safely for iSCSI multi connections
To remove a LUN safely for iSCSI multiple connections, each connection
must return I/O channel after checking completion of all tasks.

Open/close mechanism provides a way to register callback to do it.

Registered callback will be called after checking completion of
outstanding tasks.

Making the close LUN function public is necessary to support hot removal.

Change-Id: I06d50d016b0b7aba0d081da226f5b2e0c911629e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/417198
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-07-17 17:43:28 +00:00
Tomasz Zawadzki
f0ec7bc6e7 scsi/bdev: use spdk_bdev_queue_io_wait()
New function was added in bdev layer to allow
handling spdk_bdev_io buffer exhaustion.

This patch adds that functionality to scsi bdev.

Change-Id: Ia6a5be871ae09a4d1166991925f0a44f3b355bdd
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/417032
Tested-by: 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-07-10 21:17:38 +00:00
Tomasz Zawadzki
d7a7ef613c scsi: spdk_bdev_scsi_reset() now returns void
SCSI reset function return code is not used,
so there is no need for it to have return code.

Change-Id: Ib647109c75b1546675d2601fa00004e1ef186024
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/418615
Tested-by: 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-07-10 21:17:38 +00:00
Tomasz Zawadzki
bcfd6d0fb4 scsi: only set SPDK_SCSI_STATUS_GOOD on bdev callback
Previously when IO was sent to bdev, even without callback yet,
status for task was set to SPDK_SCSI_STATUS_GOOD.

This patch changes it so that it is only set when callback actually
comesback from bdev via spdk_bdev_io_get_scsi_status().

Change-Id: I4a36ec345608257123e1036d31540f5f1090a23b
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/417708
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Seth Howell <seth.howell5141@gmail.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-07-06 21:22:43 +00:00
Shuhei Matsumoto
1e5705ee6f scsi: Make scsi_lun_free_io_channel public
IO channel for LUN is used for hot removal as it is emphasized in the
previous patches.

In iSCSI, a SCSI device has multiple LUNs. So freeing only the IO channel
of a LUN must be possible.

Change-Id: I5b355200b4e173512a5aa4b7351534faf8839eef
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/417197
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-07-02 21:29:50 +00:00
Shuhei Matsumoto
c645cc69ab scsi: Reorder LUN hot removal to check outstanding tasks and then IO channel
Reorder operations of LUN hot removal so that following are satisfied.

Wait for completion of all outstanding tasks first. (After turning lun->removed
on, there will be no new outstanding task.)

Then wait for IO channel being freed. (For VHOST SCSI, IO channel is freed
in the callback handler of hot removal. For iSCSI, IO channel is freed when
the final connection exits. IO channel of LUN is freed only by the allocator.)

Then free LUN finally.

For VHOST SCSI, the callback handler of hot removal will
call spdk_scsi_lun_destruct() in spdk_scsi_dev_destruct(). But lun->removed is
already turned on and spdk_scsi_lun_hot_remove() will be NOP. Hence LUN is
freed safely by the first caller of spdk_scsi_lun_hot_remove().

Change-Id: I276dfed1d4a7767e382003bd9bb389aaff920115
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/417196
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-07-02 21:29:50 +00:00
Shuhei Matsumoto
322e50468c scsi: Use not pthread_self but spdk_get_thread for LUN affinity
spdk_thread is recommended to be used in SPDK library.

Change-Id: I5b75f390ddb2069e1266a3fc4f28732b281df725
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/416482
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-06-26 23:31:17 +00:00
Shuhei Matsumoto
1e1e0dd70c scsi: Don't free IO channel at LUN removal not by allocator
IO channel is freed unexpectedly at LUN removal. This hides
error due to uncorrect implementation of LUN hot removal.

IO channel of LUN must be freed only by its allocator.

Change-Id: Id3721180422364dfc4d9309f3a22ce0a3f766f82
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/416318
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-06-26 23:31:17 +00:00
Shuhei Matsumoto
3e9f06281e scsi: Unregister the poller of LUN hot-removal when it is registered
Change-Id: I48e831c235aab825c427892637ca1b4faafef152
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/416317
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
2018-06-26 23:31:17 +00:00
Ben Walker
a83f91c29a thread: Replace #include of io_channel.h with thread.h
Change-Id: I6babd4cf990bf19b510db88bdfb0ca81e29d9252
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/414700
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Madhu Pai <mpai@netapp.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-06-12 15:24:07 +00:00
Shuhei Matsumoto
03a52d0d32 iscsi: Factor out copy scsi status when it is not good
Change-Id: I5042df8c25a2d2f6591a2a922e22407904b04bab
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/414561
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-06-11 22:23:55 +00:00
Shuhei Matsumoto
edf924824e scsi: Unify the name of functions and variables about hot remove
Change the name of hot plug to hot remove not to confuse.

Change-Id: Ifc8de3452de72a08eba0e9ea942217e5342b2ef4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/414352
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-06-11 22:23:55 +00:00
Shuhei Matsumoto
f2554ee973 scsi: Change spdk_scsi_task_alloc/free_data() from public to private
This patch does a little cleanup of SPDK SCSI layer APIs.

spdk_scsi_task_alloc_data() is only used in spdk_scsi_task_scatter_data().
spck_scsi_task_free_data() is only used in spdk_scsi_task_put().

The latter was called in UT code but this can be removed without any
degradation.

SPDK SCSI layer is relatively matured and these will not be used
out of lib/scsi/task.c.

Additionally memory leak detected by ASAN is fixed in this patch.

Change-Id: I8eff7b4dbfc307c211087734649a9b9b10555f8d
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/413872
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-06-06 17:09:22 +00:00
Ben Walker
bcff4c89b8 bdev: Rename spdk_internal/bdev.h to spdk/bdev_module.h
This will become the public interface for implementing
bdev modules. Right now the file exposes too much of
the guts of the bdev layer to modules, so it needs
to be stripped down.

Change-Id: Ie8b8c3271d51fdb8d0c24a80244b3f3e510c8790
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/412297
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-05-25 16:02:22 +00:00
Shuhei Matsumoto
e008db08e7 rpc: Add state_mask to each RPC method to make sets of RPCs
Add state_mask to each RPC method and state to RPC server, respectively.
State mask of RPC method is set at registration. State of RPC server
is changed according to the state of the SPDK.

When any RPC method is recieved, if the bit of the RPC server is on in
the state mask of the RPC method, it is allowed. Otherwise, it is
rejected.

When any RPC is rejected by state_mask control, the new error code
is returned to describe the error clearly.

Change-Id: I84e52b8725a286e9329d61c56f498aa2c8664ec1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/407397
Reviewed-by: Daniel Verkamp <daniel.verkamp@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>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-05-03 19:48:15 +00:00
Daniel Verkamp
af9c9a415a scsi: validate dev name length
Instead of silently truncating overly-long SCSI dev names, add an
explicit check and return an error if the name is too long.

Since we now calculate the length of name up front, this also allows
simplification of the copy into dev->name.

This also ensures that dev->name will always be zero-terminated, so we
can simplify the strnlen() in spdk_bdev_scsi_pad_scsi_name() to a
strlen() and remove the invalid unit test case for padding names longer
than SPDK_SCSI_DEV_MAX_NAME.

Change-Id: I54de00bac062a142a10c41cfa2aec19d7969dff0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/406990
Tested-by: 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-04-10 15:43:03 -04:00
Roman Sudarikov
c3bc40a6ef io_channel: add return value to pollers
This will be used to track time used in pollers - each poller can now
indicate if it found any work to do or not.

For cases where it was obvious and the infrastructure was already in
place, existing pollers have been modified to return 0 or a positive
value to indicate whether work was done.  Other pollers have been
modified to return -1 by default, indicating that the poller isn't
indicating anything about whether work was performed.  This will allow
us to find un-annotated pollers easily in the future and fix them
incrementally.

Change-Id: Ifebfa56604a38434fac5c76ba7263267574ff199
Signed-off-by: Roman Sudarikov <roman.sudarikov@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/391042
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-03-13 11:16:20 -04:00
Daniel Verkamp
8a6ba58cb4 scripts/check_format: check for spaces before tabs
Automatically detect more whitespace errors.

All existing cases are fixed; only whitespace change (verify with
diff -w) except for one comment style fixup in include/spdk/nvme.h.

Change-Id: If750e54b9c8e3421ea6feda5f20184a31431631e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/402360
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-03-05 11:09:13 -05:00
Daniel Verkamp
88da45bfd0 scsi: ensure bdlen is initialized before use
This fixes a false positive warning when building on GCC 7.2.1 with
CONFIG_COVERAGE=y.

bdlen is always initialized on the path where it can be used, but the
compiler seems to get confused when coverage is enabled, so zero out the
value at the top of the function.

Change-Id: Ifc13abff80124cad3d26286ffebf84f967141d13
Reported-by: John Meneghini <johnm@netapp.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/396244
Tested-by: 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-01-24 16:45:49 -05:00
Shuhei Matsumoto
3b3c6002c9 iscsi: Add LUN to an existing target (not runtime)
Removing an LUN from an existing iSCSI target is possible by
removing the corresponding BDEV. However adding an LUN to an
existing iSCSI target is not possible yet.

Add a new function spdk_iscsi_tgt_node_add_lun() and related
functions first toward supporting this function.

JSON-RPC for this operation will be submitted an another patch.

Informing the newly added LUN to the initiator is not included
in this patch. Hence this operation is possible only for any
inactive target.

Change-Id: I3a28f4d75a17126e49c9d12ce64c3ad68f231840
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/385180
Tested-by: 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-01-17 12:41:29 -05:00
Pawel Wodkowski
85a61ea6f0 scsi: fix LUN removal/hotremoval path
bdev hotremove event is send directly to hotremove callback given
during spdk_scsi_dev_construct() call. So any bdev hotremove might be
promoted to whole SCSI device removal (like in vhost) wich will trigger
LUN removal. But after returning from hotremove callback LUN and device
might be still referenced (eg to register poller or by outstanding IO).

Even worse: spdk_scsi_dev object is not dynamicaly allocated but
returned from static array which mean there is no way to detect
use-after-free error on spdk_scsi_dev by any tool. This might lead to
using SCSI device that is freed or assigned to different device.

To fix this:
- always delete LUN using hotremove path
- defer spdk_scsi_dev delete/removal after all LUNS are really
deleted.

Change-Id: I65598bf42cd507f620095dff5d32509a0424d060
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/393674
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-01-16 19:14:00 -05:00
Shuhei Matsumoto
583e969922 scsi: remove lun name
There is no need to keep a lun name anymore - we always
use the bdev name as the lun name so it is not providing any
additional value. This also keeps us from associating
the same bdev with different LUNs on different iSCSI target
nodes or vhost-scsi controllers.

Side effect of this change is:

1) Use "bdev_name" across the APIs to make it more clear
   what these names refer to.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3d42fde22087352ce1d5dc80178bd8c5cac8cb7c
Reviewed-on: https://review.gerrithub.io/390843
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-01-11 18:37:34 -05:00
Dariusz Stojaczyk
3ef8dc1074 scsi/lun: simplify task submission path
Removed task `pending` queue. All tasks were
temporarily put in this queue just to be moved
out of it yet within the same reactor cycle.

Change-Id: I32d402f7abd3cfa21c263f41149425abdc71992f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393911
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-11 11:47:08 -05:00
Dariusz Stojaczyk
9014e913d9 scsi/dev: print an error when cannot find bdev with specified name
When trying to create a scsi dev with inexistent
lun (bdev name), the scsi_dev_construct would
just return a NULL without printing any error.
We should probably return an error code of some
kind, but for now let's just print an extra
message.

Change-Id: I28823c2cb83204c11207d3e7011fecbf725a691c
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393918
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-01-10 16:19:20 -05:00
Pawel Wodkowski
a862d1cdd6 scsi: remove lun_db
Change-Id: Icc40b66cd0c6f63242bc3d3f26b34f323450c570
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/393501
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-01-09 13:56:00 -05:00
Dariusz Stojaczyk
fce8466477 scsi/lun: fix segfault on sending mgmt task to inexistent lun
spdk_scsi_lun_complete_mgmt_task can't be called with
lun == NULL, as it deliberately dereferences it.

Change-Id: Idf9b100b66cdc7fdfe2011fb7f9b2477651f1e8c
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393912
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-09 13:21:16 -05:00
Daniel Verkamp
d57306d8eb scsi: pass only task to SCSI exec functions
Retrieve LUN data directly from struct spdk_scsi_lun rather than copying
them into struct spdk_scsi_task, and access the LUN via the task->lun
pointer.

Change-Id: Id8745f116bc559fb2f9e58811c2b9781c8cbdae8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393709
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-01-05 13:49:05 -05:00
Daniel Verkamp
683eeb59b8 scsi: annotate unlikely checks in read/write
The normal execution path for read/write commands is that none of the
checks fail; annotate all of the checks in spdk_bdev_scsi_readwrite()
with spdk_unlikely to encourage the compiler to generate the happy path
as straight-line code and move the error handling out of line.

Change-Id: Id0e606c78f0b99662e5c27e3bfa32535de20aa13
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393700
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Daniel Verkamp
a06daa1bfa scsi: inline LBA check into readwrite function
spdk_bdev_scsi_read_write_lba_check() was only called from one spot, and
moving its code directly into the caller makes the code simpler to read
and more consistent, since now all of the sense code setup is directly
in spdk_bdev_scsi_readwrite() rather than being split across two
functions.

No functional change.

Change-Id: Ic6ee21b06c721a949579817f0339a4b047ffb2cc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393699
Tested-by: 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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Daniel Verkamp
9c47ef85ed scsi: simplify LBA bounds check
Only two comparisons are necessary to ensure the I/O is in range.

Change-Id: I66e93abbf9b25949b3c783a47d26918362f00b93
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393698
Tested-by: 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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Daniel Verkamp
e45437aba7 scsi, iscsi: move task->parent to iSCSI task
The SCSI layer no longer needs to know about the parent/subtask
relationship maintained by iSCSI.

Change-Id: Ia6f7c5367c5b656bd7521ed1abb6d0f713a0500b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393697
Tested-by: 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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Daniel Verkamp
5e0ac51043 scsi: check read/write LBA even for subtasks
Simplify the logic in spdk_bdev_scsi_read_write_lba_check() to do the
LBA bounds check for both parent tasks and subtasks.

This will allow the parent/subtask relationship to be fully moved to
iSCSI in a follow-up patch.

Change-Id: Ic66466f7d77270c303c94b7002196398a34e4814
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393696
Tested-by: 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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2018-01-05 00:01:37 -05:00
Shuhei Matsumoto
c013db36fc scsi: SCSI string name format
it appears that scsi name string designator
format in SPDK is not correct. The name strings
are not null terminated (which causees garbage
to appear in scsi_inq -p 0x83). Further, they
are not padded correctly.

SCSI port name and device name strings must be null
terminated. Further, the length must be a multiple
of 4 bytes, and must be padded with 0s.

See SPC-5 Section 7.7.6.11.

Change-Id: Id7c4ad27e5c3a17ad68e5e466142801c0d03b1f2
Signed-off-by: Karandeep Chahal <devilsgrotto@gmail.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/393027
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-04 15:48:28 -05:00
Daniel Verkamp
380b3fc878 scsi, iscsi: accumulate data_transferred in iSCSI
Each SCSI task should only report its data_transferred; the
parent/subtask relationship should be handled in iSCSI.

Change-Id: Ibece110fd8cca4e94648942fe6b5e004a4fd8a80
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393212
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-04 15:01:30 -05:00
Dariusz Stojaczyk
fc03485b9d scsi/lun: fix hotremove with no io_channels open
When LUN with no io_channels is being hotremoved,
the hotremove poller was being started on the core
pointed by lun->lcore. However, this field is only
valid when there are io_channels open. For example,
when user tries to delete a bdev that's attached to
an unused vhost controller (no io_channels ever opened)
the scsi layer could start a hotremove poller on
lun->lcore == 0. If SPDK runs on a different cpuset -
not containing CPU0 - SPDK could even segfault.

Change-Id: I31a363352875d944f220b0296d5cfe570319023d
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/371863
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-01-03 14:38:11 -05:00
Daniel Verkamp
543cb17248 build: remove $(ENV_CFLAGS) where not necessary
Only Makefiles for libraries that directly depend on DPDK (rather than
the SPDK env abstraction) should add $(ENV_CFLAGS).

Change-Id: Ifdf44d3ef8c42bbf7f20edd524b330d00658235b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/392818
Tested-by: 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-01-03 12:05:59 -05:00
Daniel Verkamp
97f145c8b8 scsi: convert unmap command to bdev blocks API
Use spdk_bdev_unmap_blocks() in place of spdk_bdev_unmap(), since the
SCSI UNMAP descriptor already natively operates in blocks rather than
bytes.

Change-Id: I16a0c38d203cf5f60484229e7872783b11d8de6e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393202
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2017-12-29 13:43:29 -05:00
Daniel Verkamp
a520198dba scsi: convert sync command to bdev blocks API
Use spdk_bdev_flush_blocks() in place of spdk_bdev_flush(), since the
SCSI SYNCHRONIZE CACHE command already natively operates in blocks
rather than bytes.

Change-Id: I11810948fb8d0b6b911d48620e2a363f767cc7f7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393201
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
2017-12-29 13:43:29 -05:00
Daniel Verkamp
c2009e9e85 scsi: remove spdk_scsi_dev_print() function
Replace the single call to spdk_scsi_dev_print() with a reimplementation
using public SCSI API functions, and also using the SPDK logging
framework instead of printf().

Change-Id: Ifa455f9e6a4a07a35d5dec311a61e9a8afaa0227
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/391320
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-12-12 18:04:20 -05:00
Daniel Verkamp
59970a89be astyle: enforce braces around single-line statements
Require braces around all conditional statements, e.g.:

    if (cond)
        statement();

becomes:

    if (cond) {
        statement();
    }

This is the style used through most of the SPDK code, but several
exceptions crept in over time.  Add the astyle option to make sure we
are consistent.

Change-Id: I5a71980147fe8dfb471ff42e8bc06db2124a1a7f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/390914
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@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>
2017-12-11 11:19:32 -05:00
Jim Harris
0fd9bba256 scsi: use lun instead of its name as spdk_scsi_lun_delete param
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7cf52d4d27ee3433da94a034ef320ad811ca6758

Reviewed-on: https://review.gerrithub.io/390842
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-12-08 09:26:47 -05:00
Ziye Yang
f8dcdfa99e scsi: Make the pending tasks handling logic correct for reset
In principle, we should not have active tasks, which means
that lun->tasks should be empty. But for the exceptional case,
we may still need to handle those active tasks, to make
the scsi related application continue running instead of quit.

We should not directly call spdk_scsi_lun_complete_task since
those tasks are already sent to bdev layer. And finally, those
tasks will be return (even aborted) by call backs. So we only need to
set task status to condition, but
not call spdk_scsi_lun_complete_task directly.

Change-Id: I6af2bda0f0b1de7b0c655d2ac2980ddca48c1162
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/386817
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-12-07 13:43:52 -05:00
Shuhei Matsumoto
e44731d659 scsi: Remove the claimed flag from LUN
Struct spdk_scsi_lun has the claimed flag as a member.

However the claimed flag is no longer required.

Moreover the claimed flag itself is not used but
spdk_scsi_lun_claim() and _unclaim() functions are used in the
UT code by hard to understand manner. Moving the logic into
spdk_scsi_lun_construct() and _destruct() in the UT code will
be more natural.

Hence remove the claimed flag from LUN and do a little refactoring
in the UT code.

Change-Id: Ica9680b49bbdb5be7c5c4161210fb3a6dcb35229
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/390566
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-12-07 12:30:19 -05:00
Daniel Verkamp
ea1c15791f log: rename SPDK_TRACE_* to SPDK_LOG_*
Disambiguate the log components from the trace functionality
(include/spdk/trace.h).

The internal spdk_trace_flag structure and related functions will be
renamed in a later commit - this is just a find and replace on
SPDK_TRACE_* and SPDK_LOG_REGISTER_TRACE_FLAG().

Change-Id: I617bd5a9fbe35ffb44ae6020b292658c094a0ad6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376421
Tested-by: 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>
2017-12-07 12:23:19 -05:00
Ben Walker
9c35e39c54 event: Move spdk_poller_register to io_channel
Make this generic and not directly dependent on
the event framework. That way our libraries can
register pollers without adding a dependency.

Change-Id: I7ad7a7ddc131596ca1791a7b0f43dabfda050f5f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387690
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-28 12:30:37 -05:00