Commit Graph

292 Commits

Author SHA1 Message Date
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
Ben Walker
00b02039c5 event: Pollers must now be unregistered from the thread they run on.
Change-Id: I8ea8c59a0c67176c0c0c39abf807afad61ff3828
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387689
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-11-17 11:11:23 -05:00
Ben Walker
fcb4776fe7 event: Pollers must now be registered from the thread they run on.
Change-Id: I864cd8a6c206dfbe62fcb3f72275c1ae51aa4ed7
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387688
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-11-17 11:11:23 -05:00
Ben Walker
435138b76d scsi: Register all pollers to the current core
Register all pollers to the current core. If necessary, send
an event to the correct core before registering.

Change-Id: Ie34cc8b11143a58c0f621c87c409a3d09d929648
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387682
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-17 11:11:23 -05:00
Daniel Verkamp
5b9f0ddc53 scsi: use scsi_spec.h enums for VPD page numbers
Change-Id: I9783803a2f1ce5bb16d9336f7fecbd4f06dcdd52
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/384136
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>
2017-10-29 12:12:47 -04:00
Seth Howell
5f5edbcb8c scsi_bdev: increase max I/O size to 4 MiB
This is necessary to avoid failing very large write_zeroes operations.

This is the minimal workaround to get the current bdevio tests to pass -
the real fix will be implemented in the bdev layer later.

Change-Id: I4e49f1b4da5d4c7f9507757d6c71ba3880d22437
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/383306
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-10-23 11:50:16 -04:00
Daniel Verkamp
fc5f527c21 scsi: split Inquiry peripheral type and qualifier
The SCSI spec defines two separate fields within the first byte of
the Inquiry data.  Define them as bitfields and add enum values for the
peripheral qualifier field.

Change-Id: Ibbb158338da199fc1b67b04c52ec91633577c571
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/382713
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>
2017-10-17 11:32:45 -04:00
Shuhei Matsumoto
0e5b81b3d7 scsi: remove port from scsi_dev dynamically
Current implementation supports only adding port to scsi_dev.
This change is required to support dynamic remapping of portals.

Change-Id: Idce49aeae43c8861ebe2807df853694f7bacf884
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/379931
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-10-12 15:46:14 -04:00
Tomasz Zawadzki
b1ccfaca01 subsystem: remove fini return code
Closing the framework has to go through all subsystems
without failure, so return codes are unnecessary.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I53c9b4df12d2357e641130869f398b18637e6ff7
Reviewed-on: https://review.gerrithub.io/381681
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@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>
2017-10-10 10:56:34 -04:00
Daniel Verkamp
36a8f75006 scsi: fix LUN 0 check in scsi_dev_construct
When constructing a SCSI device, LUN 0 must be assigned to some LUN.
However, the current code was assuming that LUN 0 had to be in the first
array element of lun_id_list in spdk_scsi_dev_construct().  Combined
with the scripts/rpc.py implementation that uses a Python (unordered)
dictionary object to generate the lun_ids array, there could be cases
where LUN 0 exists in the list but isn't first.

Fix the check by allowing LUN 0 in any position of the lun_id_list
array.

Change-Id: I39f387ec238fcecca8d2d786d3d42c42a4790637
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/381611
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2017-10-06 16:37:27 -04:00
Daniel Verkamp
4affd37f2b Revert "scsi: remove LUN I/O channel ref counting"
This reverts commit d3828a23ec.

GitHub issue #202 reports that this causes a crash with two or more
iSCSI connections on the same LUN.

Change-Id: I9ffb85d393eb506aac9d176299a3b3bcf021a38c
Reviewed-on: https://review.gerrithub.io/379866
Tested-by: 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>
2017-09-26 18:44:55 -04:00
Daniel Verkamp
d3828a23ec scsi: remove LUN I/O channel ref counting
spdk_bdev_get_io_channel() already handles this.

Change-Id: I6b28fe10b86b00762ff15324fcd0a32aae94e012
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376267
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>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2017-09-01 12:46:43 -04:00
Daniel Verkamp
932a186b4c log: remove uses of SPDK_TRACE_DEBUG
Replace SPDK_TRACE_DEBUG with component-specific flags.

Change-Id: Iee7eafab5e6ac8713f247323a18552b5afb0e86a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375834
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>
2017-08-29 15:07:13 -04:00
Daniel Verkamp
d92f0f75ca log: rename SPDK_TRACELOG to SPDK_DEBUGLOG
This matches the name to the behavior and prepares for addition of a new
log macro for "info" log level.

Change-Id: I94ccd49face4309d3368e399528776ab140748c4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375833
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>
2017-08-29 13:25:58 -04:00
Dariusz Stojaczyk
2705f6f10d Fixed all SPDK_LOG() calls without newline char
Change-Id: Ib9a6b3e7584c5edd8f8c0f8cd20349d86651a5a2
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/374780
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-18 18:56:51 -04:00
Daniel Verkamp
0720ad357b scsi: allow zero-length read and write
The SCSI spec says that zero transfer length shouldn't be considered an
error.

Change-Id: I98958cc393e0e487e25fdbb0eb7fc8126aff9945
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/374320
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-08-15 15:26:37 -04:00
Daniel Verkamp
0b1bbb4532 scsi_bdev: add Maximum Transfer Length check
We report SPDK_WORK_BLOCK_SIZE (1 MiB) as the Maximum Transfer Length in
the Block Limits VPD.  The initiator should not submit a request larger
than this; if it does, fail the request.

Change-Id: I39575cdca4555ac1f78e055a48569be3f47e4781
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/373162
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>
2017-08-14 15:47:18 -04:00
Ben Walker
c0de8a8b0e scsi: Remove global unmap config parameters
None of these make sense as global parameters - they're
all only configurable per-disk. This is a large simplification
and removes the SCSI library's dependency on the config
file entirely.

Change-Id: I1236158a23fa49e437938c51022b13772e404561
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/371598
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>
2017-08-11 19:54:32 -04:00
Ben Walker
60c38d4022 bdev: Change unmap to use offset/len instead of descriptors
This is far simpler, although it does limit the bdev
layer to unmapped just one range per command. In practice,
all of our code reports limits of just one range per command
anyway.

Change-Id: I99247ab349fe85b9925769e965833b06708d0d70
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/370382
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-08-04 20:03:37 -04:00
Jim Harris
be9a3b9f69 bdev: pass descriptors for I/O operations
This enables checking permissions - for example,
spdk_bdev_write will fail if the descriptor was not
created with write permissions.

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

Reviewed-on: https://review.gerrithub.io/369493
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-14 13:31:30 -04:00
Jim Harris
dd06e98d4a bdev: rename blockdev instances to bdev
This includes file names, functions, #defines, etc.
There are still a few uses of "blockdev" outside of
include/ and lib/ - these can be handled later.

This preps for a future patch to consolidate vbdev
modules and bdev modules into just bdev modules.

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

Reviewed-on: https://review.gerrithub.io/369325
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-14 13:31:30 -04:00
Dariusz Stojaczyk
fa15dc611a scsi: removed dev->maxlun field
This variable was misleading and unnecessary. Replaced all it's
occurences with SPDK_SCSI_DEV_MAX_LUN.

Change-Id: Iaaf9ed5efb60f9a89585121d2fbec7b43c3723e9
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/368115
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-12 13:16:55 -04:00
Daniel Verkamp
f25f84b796 scsi: fix off-by-one error in spdk_scsi_dev_get_lun()
lun_id could potentially overflow the dev->lun array bounds if it was
equal to dev->maxlun, which is actually the maximum lun array index plus
one, not the maximum valid LUN index.

Change-Id: I5662c6f6fa634a7dd755c9bfc1a24d3c4cabe7ea
Reported-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/369074
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>
2017-07-12 13:16:55 -04:00
Daniel Verkamp
2bdec64fbf jsonrpc: modify API to pass request to handler
This will enable asynchronous request handling in a future patch, and it
also removes the need for the RPC handlers to know about request id and
the JSON-RPC rules about notification-only requests.

Change-Id: I25aaa8e48bff8d5594ffcccecb61842b1e31ec3c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/368225
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-07-06 13:48:12 -04:00
Jim Harris
57d174ff67 bdev: add spdk_bdev_open/close
Retire the old claim/unclaim semantics in favor of
open/close.  Clients must now open a bdev to get
an spdk_bdev_desc, then pass this desc to get an
I/O channel.

This allows multiple clients to open a bdev,
although only one may open a bdev with write
access.

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

Reviewed-on: https://review.gerrithub.io/367611
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-07-05 18:04:28 -04:00
Dariusz Stojaczyk
57f9221fab scsi: added spdk_scsi_dev_has_pending_tasks()
Added new function in preparation to implementing device hotremove.

Change-Id: I5b85f76f543b882acf3b0fe40c9e92125594b257
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/366725
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>
2017-07-05 17:11:55 -04:00
Dariusz Stojaczyk
72343bcf23 scsi: added lun hotremove callback
Added optional callback inside scsi lun hotremove, so that higher-level
abstraction can be notified about hotremove.

Change-Id: I5f1bd8160e3d770a484068dd73928bc2b64c876f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/367309
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-30 16:32:47 -04:00
Ben Walker
4185205540 scsi: Remove cb_event. It is no longer necessary.
This is an artifact from a past design. There is no longer
any reason to create an event here - the bdev layer will
correctly queue events and call completions on the correct
thread.

Change-Id: I145dab4046899834c0449ec7380dcbb28215b493
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364831
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-06-22 10:47:31 -04:00
Ben Walker
c9f8765a69 scsi: Move event subsystem initialization to event_scsi
This removes the event framework dependency from the
scsi library entirely.

Change-Id: I73546d06721487f86c4c6a3be24474a5677bdb41
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365728
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-06-20 16:58:35 -04:00
Ben Walker
5015ec9ce8 scsi: Add a separate subsystem library
This separates the scsi library from the event framework's
subsystem mechanism.

Change-Id: Iac2bbdb861e28ee9af0f13bc7187ac24279d0f5b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365284
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-16 13:10:26 -04:00
Pawel Wodkowski
4af745126b scsi: don't leak bdev_io on mgmt task complete
Change-Id: I90623a81e31176f08ac409d26a0c23f0af2231db
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/364773
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-06-09 13:49:42 -04:00
Ben Walker
aff7e226f7 bdev: spdk_bdev_[read|write|flush|unmap|reset] now return int
It is not actually useful to be immediately returned
a handle to the bdev_io. There isn't anything valid
that the user can do with it at that point. Instead,
return an integer error code.

Change-Id: Iffa9a8dc5b2eefab57e3cc1f68919985431d17d1
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/364137
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-08 16:35:49 -04:00
Ben Walker
ce8de311a4 vhost: Fix reset handling
Resets were not correctly aborting all I/O.

Change-Id: I03fd5f7094b3aa53f070eb731c30e5f9bfbfea16
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/363626
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-05 12:56:26 -04:00
Daniel Verkamp
aab3b1def3 scsi: add GCC 7 -Wimplicit-fallthrough annotations
Mark the intentional switch/case fallthrough locations with comments
recognized by -Wimplicit-fallthrough=4 in GCC 7.

Change-Id: Ibf2b077d9432e7f23a3833f98edd4768e5e8cfe9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/363490
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-06-02 19:48:49 -04:00
Ben Walker
4fe9536de0 bdev: Remove reset_type
There is now just one type of reset, which is equivalent
to a HARD reset previously.

Change-Id: I955b219cbc5c25793d97de1cc003b30ae99313ac
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362615
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-02 12:02:53 -04:00
Tomasz Zawadzki
5e132b6b7a scsi: Set proper transport protocol id
This patch adds property of transport protocol id to spdk_scsi_dev.
This allows to change it depending on which appliation is using
the device. Previously only iSCSI was used for all.

Setting protocol id is done at the time when device is added to
vhost controller (vhost) or target node (iSCSI).

Please note that for SPDK vhost SAS protocol id is used,
as that is what kernel vhost reports as well.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I455a856c5d7796a749b6650fee0218d526e094ed
Reviewed-on: https://review.gerrithub.io/362864
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>
2017-06-01 12:10:22 -04:00
Ziye Yang
6e0d1dcdfa subsystem: make subsystem init in async manner
The next patch will make bdev modules init
in the async manner.

Change-Id: I4909c80510d786daf54003b99a5925428cf37373
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/362110
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-31 15:30:58 -04:00
John Meneghini
8a44220b1a env: Rename spdk_malloc/zmalloc/realloc/free to spdk_dma_(func)
- rename spdk_malloc_socket to spdk_dma_malloc_socket
  - rename spdk_malloc to spdk_dma_malloc
  - rename spdk_zmalloc to spdk_dma_zmalloc
  - rename spdk_realloc to spdk_dma_realloc
  - rename spdk_free to spdk_dma_free

Change-Id: I52a11b7a4243281f9c56f503e826fd7c4a1fd883
Signed-off-by: John Meneghini <johnm@netapp.com>
Reviewed-on: https://review.gerrithub.io/362604
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-05-31 15:30:27 -04:00
Ben Walker
d969ac445a io_channel: Remove per-channel priority
This wasn't used anywhere and we currently believe there
are superior software-only techniques for controlling
quality of service.

Change-Id: Icdadd5870ed0629b338c307d2619bbc242c3e7a3
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362065
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-26 13:42:19 -04:00
Changpeng Liu
2e28ef9d02 scsi: fix scsi compliance issue for inquiry VPD NAA identifier
NAA locally assinged designator(3h) format was defined in SPC4,
as SPDK claimed can only support SPC3, so we used NAA IEEE
extended identifier format instead.

Change-Id: Ia4c153263c6b89ae8160488deaf16fd0e5cac8dc
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/361904
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-05-24 11:51:00 -04:00
Jim Harris
2e3f07ac40 bdev: add spdk_io_channel parameter to spdk_bdev_reset
This ensures that all spdk_bdev_io structures now have
an attached channel, simplifying some future work around
things like counting the number of outstanding IOs for
a given channel (which otherwise would have had to
account specially for resets).

Reset semantics are still that they affect the entire bdev
and not just the channel it was submitted on.

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

Reviewed-on: https://review.gerrithub.io/362251
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-05-24 11:42:15 -04:00
Jim Harris
1a2cd90c98 scsi: simplify lun task mgmt path
1) Consolidate the checks for a null LUN
2) Eliminate a bunch of static functions that are no
   longer needed due to #1

This prepares for some upcoming bdev reset changes.

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

Reviewed-on: https://review.gerrithub.io/362262
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2017-05-24 11:42:15 -04:00
Daniel Verkamp
b9bcc3531e bdev: make enum spdk_bdev_io_status private
The user should not see the bdev_io status directly; the NVMe and SCSI
error code wrappers provide the ability to translate to the desired
format regardless of what kind of error is stored inside the bdev_io.

Replace the spdk_bdev_io_completion_cb status parameter with a bool
simply indiciating whether the I/O completed successfully.

Change-Id: Iad18c2dac4374112c41b7a656154ed3ae1a68569
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/362047
Tested-by: <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-23 16:30:10 -04:00
Daniel Verkamp
f66a0c9e34 scsi: pass management function as a parameter
Specify the function as a parameter to spdk_scsi_dev_queue_mgmt_task.
This makes the API clearer by making it explicit that the management
function is required for management tasks.

Change-Id: I92d893aadb6faebea81dd79729894d2c2fddf088
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-18 13:47:42 -07:00
Daniel Verkamp
1e7e6a618b scsi: automatically set spdk_scsi_task::type field
The type of a task is known due to the function used to submit it:
- spdk_scsi_dev_queue_task() for normal SCSI command tasks
- spdk_scsi_dev_queue_mgmt_task() for management tasks

Change-Id: I183a1f89ab85f3fce1de2491e77d95d4b147fd72
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-18 13:47:42 -07:00
Daniel Verkamp
de5ffac4ec scsi: factor out read/write LBA range check
The SCSI read and write functions use the same LBA range check, so move
it up to spdk_bdev_scsi_readwrite().

spdk_bdev_scsi_read() previously passed task->transfer_len / blen rather
than xfer_len to the LBA range checking function, but this should
actually be using the transfer length field from the CDB (which is the
xfer_len parameter).

Change-Id: I8285abf936a18a0baf7cc25709945637e4e6b87d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-18 13:47:42 -07:00
Daniel Verkamp
9d1e05d2f2 bdev: add getter for write cache enable status
Change-Id: I93656deda8956c77e9565ee1f271795642e62ac9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-17 09:45:42 -07:00
Daniel Verkamp
0d56499d3a scsi_bdev: use max unmap descriptor getter
Change-Id: Id67b158c36b2b879849b18909bc9bb9a5273f8c7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-17 09:45:42 -07:00
Daniel Verkamp
7455910d1b scsi_bdev: simplify scsi_readwrite helper function
Factor out the common data direction Check Condition logic from read
and write.

Change-Id: Ia2fbd5f69eefd826ebb5ab2a8e99aeb380f1b7ea
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 13:35:18 -07:00
Daniel Verkamp
8e379851ab scsi_bdev: clarify block count variable names
What was previously called "maxlba" was actually the block count
of the device, which is the maximum LBA plus one.

Change-Id: I5e141a3eb0c79b2aa70006739c5586cb50744d3d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 13:35:18 -07:00
Daniel Verkamp
19a9871495 scsi: remove spdk_scsi_task::owner_task_ctr
The SCSI library already provides a callback when the task is released
(free_fn), so the user can update their own task counter.

Change-Id: I7fb13f6fff66dbba2315fd03fb06e49f793be123
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 10:12:42 -07:00
Daniel Verkamp
7145cf62c6 scsi: set free_fn in spdk_scsi_task_construct()
The task free callback function is required, so make its assignment part
of task construction.

Change-Id: I2f5fdf73b064653ee85b4e7961cb1653a0a4107d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 10:12:42 -07:00
Daniel Verkamp
1aea6c5b6f bdev: add getter for maximum unmap descriptors
Change-Id: Ifbdd29e2081600bf0d860582d80696546107cf1b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-15 10:11:23 -07:00
Daniel Verkamp
326786a943 bdev: add getters for block size and block count
Change-Id: I6fad28da43c163ea4e2c4a04ced356b67d63652f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-12 10:34:58 -07:00
Daniel Verkamp
1bcf22cde1 bdev: add getters for bdev name and product name
Change-Id: I6a75fada94fa845ecedd4cd8afc78f4259df14fe
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-12 09:36:30 -07:00
Changpeng Liu
6de5c05556 scsi/bdev: fix wrong condition check for inquiry VPD page
Change-Id: I435825dbd6a7f990d702db9e0965a489f452cdc3
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-05-11 15:01:03 +08:00
Daniel Verkamp
22b6098965 bdev: remove spdk_bdev thin_provisioning flag
Blockdevs already indicate support for unmap via
spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP).

Change-Id: I634f27a281fd900bb3a6da2e4ff8a74e43579578
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-09 08:42:10 -07:00
Ben Walker
b961d9cc12 include: Move the remainder of the code base to stdinc.h
Change-Id: I6a142feeaad3117bd3c75e7c5cb7231a1cfa78ae
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-08 13:20:36 -07:00
Daniel Verkamp
730a63d02b scsi: remove unreachable read iovec copy path
The SCSI layer always passes task->iovs to spdk_bdev_readv(), so there
is no way for task->iovs != bdev_io->u.read.iovs to be true.

Change-Id: I4c0a2075c6e50e4304d62707a29bededa37b4e5c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
15fcb1020c bdev: make struct spdk_bdev_io contents private
Change-Id: I24ff52a7375d54df06b9769bc53ddf84691e1cb1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
825379870b bdev: add accessor function to get an I/O's iovec
Change-Id: I09321abe93303d6225fbcce4065b0024dd541b19
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-05 09:39:49 -07:00
Daniel Verkamp
91b13bd105 scsi: don't change bdev_io status in spdk_scsi_task_put()
The SCSI task bdev I/O should never be pending when spdk_scsi_task_put()
is called, and just setting the status to failed is not correct (when
the bdev eventually completes the I/O, it will write into the now-freed
bdev_io, which may be reused by someone else).

Change-Id: Iaad6ce9ab41539652abc40147fed47c5012109dc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 14:59:12 -07:00
Daniel Verkamp
414b754579 scsi: remove SCSI task id and add iSCSI task tag
The SCSI layer was not using the task ID for anything; the iSCSI layer
was using it to store the task tag, so move it there and rename it to
"tag" to make its purpose clear.

Change-Id: Ibda4f4e215056116b9be4a3a0264f98bc4c29535
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 10:10:47 -07:00
Daniel Verkamp
dc9e11163e bdev: add API to translate to SCSI status
Move the scsi_nvme translation code from the SCSI library into bdev, and
provide a generic way to translate any bdev_io status into a SCSI
status.

Change-Id: Ib61a6209387c24543e31574e2b5ca249e2ac8b74
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 09:11:42 -07:00
Daniel Verkamp
2990f869a1 scsi: make spdk_scsi_port definition private
Change-Id: Ib2c17a4dd4ce680161be92f76b831df792f9ff4d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-04 09:05:53 -07:00
Daniel Verkamp
a3738d9031 scsi: make spdk_scsi_dev definition private
Change-Id: I62b36a22e11e845045f190886ae00aa644f96ec6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-03 12:34:57 -07:00
Daniel Verkamp
d0290b6525 scsi_internal.h: remove duplicated min/max macros
Use the ones from spdk/util.h instead.

Change-Id: Icd8416d1b3cb0cde35ac46ea8b1ba7a1ea8994c6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 09:41:43 -07:00
Daniel Verkamp
12965bb6ce scsi: make spdk_scsi_lun definition private
The contents of struct spdk_scsi_lun don't need to be part of the public
API.

Change-Id: I101b77871054557380610fd901ab38bada463202
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-02 09:41:43 -07:00
Daniel Verkamp
5639b965ac scripts/check_format.sh: catch misaligned comments
Fix up the existing comment blocks misaligned in the first column.

Also add line numbers to the comment checks.

Change-Id: I9d28c365271df36e7013d74cbb02d0023ab4f581
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-04-26 06:39:58 -07:00
Tomasz Zawadzki
9879b50769 scsi: fix page control page field in MODE SENSE
This patch assigns correct value to page control.
Now that page control value is correctly taken from CDB,
error via sense data is reported when processing "saved values".
"Changeable values" are not supported, so all parameters
are reported as not changeable when requested.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I41378c96b1e8c716b5d0ce4b72777065fb122228
2017-04-24 15:26:39 -07:00
Daniel Verkamp
6b91943209 scripts/check_format.sh: check spaces in comments
Fix up all existing spacing errors in comments and add an automated
check for patterns like /*comment*/.

Change-Id: I28f61c93612dc0f8aed66bd509da78e91ea9737e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-04-24 13:37:41 -07:00
Dariusz Stojaczyk
154323ab51 scsi: Include null terminator in Unit Serial Number VPD Page
According to the scsi standard, all ASCII data fields "may be
terminated with one or more ASCII null (00h) characters"
[7.6.10, 4.4.1]. Windows SCSI Compliance tests expect a null terminator
there, so let's include it.

Change-Id: I18fa35295233a163cea711a5c4ff8e3d3e80c4f1
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-04-21 08:12:04 -07:00
Ben Walker
16ae587966 env: Move lcore functions into env layer.
They were previously in the event library.

Change-Id: I24ffd8f771e895ccf5395c8120423cd114893139
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-04-04 09:19:01 -07:00
Daniel Verkamp
edbca2a676 conf: add Boolean value helper function
Change-Id: Ie86745fe397167416aee356dc773a1bf8387b492
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-04-03 11:17:47 -07:00
Piotr Pelplinski
425b902bc0 scsi: use SOFT reset when reseting bdev
This fixes multiple SCSI reset issue.
This patch does not remove sleep in iSCSI tests.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: I5e9f3705e5dc34004b9d1b9e40fbdcb04a3bee4e
2017-03-30 16:09:33 +02:00
Jim Harris
913257cba5 Revert "scsi: use SOFT reset when reseting bdev"
Some intermittent issues still observed with multiple
resets in quick succession.  Reverting for now while the
issue is more fully root caused.

This reverts commit 7fa7f91ee3.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I493b564e8a110bbfb7a6cc47107d53d6eca40053
2017-03-29 15:42:11 -07:00
Pawel Wodkowski
7fa7f91ee3 scsi: use SOFT reset when reseting bdev
This fixes multiple SCSI reset issue.

Change-Id: Ie62e0c1850faff17d383bcea00071d63d6bfa7f4
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-03-29 09:17:26 -07:00
Dariusz Stojaczyk
55d8cca428 scsi: Use parameter alloc_len instead of task->alloc_len in
spdk_bdev_scsi_inquiry

It was causing false-positive error checks.

Change-Id: I6145152abc65bb80cfdfc68ce3b32e6f41d69348
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-03-28 10:25:25 -07:00
Ziye Yang
ef91841763 (i)scsi: check strlen before copy
Make sure that we have space for termination char '\0'

Change-Id: Iaebdad3b4278ee322bd78247acc7f0997c3f4b44
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-03-27 11:37:15 -07:00
Changpeng Liu
fa9d3466aa scsi/bdev: assert on failed data buffer malloc
Change-Id: I4f698d7c35e3315c86a6dc15b930c349ba6b105f
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2017-03-27 10:08:12 -07:00
Daniel Verkamp
0d752e42f8 scsi: ensure LUN name is null terminated
Change-Id: I2c0d0d9dd4f4b852401f21b65142ee85c29f3c62
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-03-24 10:52:48 -07:00
Pawel Wodkowski
73c95f5476 scsi: remove delete_lun RPC call and move claimed flag
Move claimed flag to struct spdk_scsi_lun and remove RPC call that allow
SCSI LUN to be deleted by user.

Change-Id: I0fe57d33ab017816ab4799bce259807735e0c783
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-03-13 11:27:22 -07:00
Daniel Verkamp
b58a5d73ef util: add SPDK_COUNTOF() array size macro
SPDK_COUNTOF works like sizeof, except it returns the number of elements
in an array instead of the number of bytes.

Change-Id: I38ff4dd3485ed9b630cc5660ff84851d0031911f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-03-07 12:43:42 -07:00
Cunyin Chang
fca35b7b96 scsi: Add support for hotplug in scsi layer.
Change-Id: Ic779a79d41d60b6998f9bd05ca4a59c1301a10ac
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2017-03-03 08:16:48 +08:00
Cunyin Chang
b21fd06463 iscsi: finish the task if the lun is NULL immediately in iscsi layer.
This patch make the function spdk_scsi_task_process_null_lun() as public and
finish the task immediately once we get task in iscsi layer.

Change-Id: I4ada027d3a324dce8ef0d0f7706dbc14184ead96
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2017-03-02 00:54:34 -07:00
Cunyin Chang
77183f9722 bdev: Add support for hot plug in generic bdev layer.
Change-Id: Iac724518fb82b1b1bcafa7610210b0000c2063aa
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
2017-03-02 09:48:39 +08:00
Tsuyoshi Uchida
0521f34f4f scsi: do not unregister bdev during lun delete (#116)
The bdev was not created by the SCSI layer, so spdk_bdev_unregister
shouldn't be called here.
2017-02-24 13:32:51 -07:00
Pawel Wodkowski
e8e40b0c54 scsi: change rotation rate to 0x1
Change medium rotation rate type to 0x1 - non-rotating media.

Change-Id: I855d27851bb633c66d337d3f8a3447de3ad1c87b
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2017-02-21 11:20:56 -07:00
Tomasz Zawadzki
c210a81fd9 scsi: spdk_scsi_lun_construct should return only new objects
This patch makes spdk_scsi_lun_construct behave as documented.
spdk_scsi_lun_construct will return only newly created LUN.
If LUN with that name already exists, NULL will be returned.

Unit test relevant to this behaviour is now changed to show
this functionality is now working.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I002903d6f96555c638aba3fa99cc2c2504ced603
2017-02-16 11:03:59 +01:00
Tomasz Zawadzki
90b0873665 scsi: handle return status of spdk_scsi_lun_claim(lun)
This is necessary to prevent claiming the same LUN twice
and properly cleanup in case of an error during spdk_scsi_dev_construct.

This patch addresses three issues:
- spdk_scsi_lun_claim error is correctly handled in spdk_scsi_dev_add_lun
- on error when constructing scsi dev, it is now correctly removed along with attached luns
- spdk_scsi_dev_destruct not only unclaims, but calls spdk_scsi_lun_destruct on each lun in dev

Unit tests relevant to this behaviour are changed to show this functionality is now working.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I111c320f875e5003e3f1f7748a2630097301ce1b
2017-02-16 11:03:48 +01:00
Tomasz Zawadzki
86278ab90e unit_test: check for adding same lun twice to scsi device
This patch adds two new unit tests for scsi device:
- creating two different devices, each containing the same lun
- creating one device, with the same lun twice

As noted in code, three asserts are incorrectly set to show functionality
that is not working currently.
Next patch in series implements that functionality and changes asserts
in the unit tests.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I2645401fee4f2cd986458e0a4db108ce4e1bf9db
2017-02-16 10:11:20 +01:00
Ziye Yang
4133842d36 scsi: fix the scsi read write direction issue.
For iscsi read/write, expected_data_xfer_len
is 0, dxfer_dir is set to SPDK_SCSI_DIR_NONE.
But we can still have read/write op in SCSI layer.
This patch solves this issue.

Change-Id: I950e163fffb06fefaf8a913d1f6de29c96a52264
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-01-23 16:12:27 -07:00
Daniel Verkamp
6aabf494dc scsi: only generate sense data for Check Condition
Change-Id: Ia8bc43f045f367c12a8da818bd8496e45b8ac930
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-01-19 09:39:26 -07:00
Daniel Verkamp
249a68e92b bdev: add API to claim block devices
Claim the block devices used by iSCSI LUNs and NVMe-oF subsystems so
they can't accidentally be reused.

This will also be used by virtual block devices to allow layering of
bdevs.

Change-Id: I5384923fbf24f13f4ce720a797c5a628053d49f4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-01-11 16:49:39 -07:00
Ziye Yang
2a3154bd87 SCSI: Fix SCSI R/W error status when lba and its range is not valid
Change-Id: Ibdf3941991d552e67b69c28eacacd5384570145a
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-01-11 12:39:31 -07:00
Daniel Verkamp
a96dc2592e bdev: remove event dependency from I/O callback
Use a plain function pointer + callback context for the bdev I/O
completion callback.  This is possible now because each I/O channel will
be polled on the core that submitted the I/O.

Change-Id: I29ee8e4a3430df11c74845adab840395b9bc5010
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-01-09 12:09:36 -07:00
Jim Harris
292c9c42aa scsi: simplify lun task execution
An old prototype SPDK AHCI driver would return
TASK_SET_FULL if all NCQ slots were full on a given
disk.  This would kick the SCSI task back to the LUN
to be retried later.  Since then, we have pushed
responsibility onto the bdev modules themselves
to handle this kind of queueing/retry logic.

Removing this logic allows us to make some additional
changes that enable tasks to get completed inline without
an extra event callback to handle completion.  We also
no longer need to worry about checking if pending tasks
need to be executed in the complete_task() routine, since
the execute() routine will now always exhaust the pending_task
list.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: If2dc3ab017e0dbc225c8f627e1f87c5a8e9b1e3e
2017-01-09 11:37:25 -07:00
Ziye Yang
ae07bdf125 scsi: make the io channel of scsi lun free correct
Previously, we did not calculate the ref for the LUN.

Change-Id: If2b7bc7d129e7efd994a7987ae2c421048969acb
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2017-01-06 09:50:22 -07:00
Daniel Verkamp
44ef085bed event: pass arg1 and arg2 directly to event fn
This allows the elimination of the spdk_event_get_arg1() and
spdk_event_get_arg2() macros, which accessed the event structure
directly; this was preventing the event structure definition from being
moved out of the public API header.

Change-Id: I74eced799ad7df61ff0b1390c63fb533e3fae8eb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-01-05 11:57:18 -07:00
Daniel Verkamp
7b01af8fd2 event.h: split non-public API into spdk_internal
Change-Id: Ie783df6cf387286ab882107fb9d4ce12358602e2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-01-05 11:57:18 -07:00
Tsuyoshi Uchida
4838a081f8 scsi: use spdk_lun_db_get_lun in spdk_scsi_lun_delete (#93)
It's a little refactoring.
2017-01-03 14:22:34 -07:00
Ziye Yang
aeaa76a5f3 scsi: Change T10 vendor ID from Intel to INTEL
The vendor ID for Intel shoudl be "INTEL", according
to the following page:
http://www.t10.org/lists/vid-alph.htm#VID_V

Change-Id: Ib9611e5604c8b5e3eaec8101548aaf4a3c45597a
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-12-13 09:24:31 -07:00
Tsuyoshi Uchida
3560b00f20 scsi: no check lun->dev in spdk_scsi_lun_deletable (#82)
We don't need check lun->dev in spdk_scsi_lun_deletable.
Whichever dev is null or not null, spdk_scsi_lun_delete works
appropriately.
2016-12-08 18:41:03 -07:00
Pawel Wodkowski
a1948352a3 lib/scsi: handle scattered input/output buffers for non IO commands
Fix buffer overflow/underflow for commands with alloc length scattered
into multiple preallocated buffers (eg. INQUIRY)

Change-Id: If6f7cabc7a6a7fb384bb015e14dc38548f484d0f
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-21 10:52:35 -07:00
Daniel Verkamp
d27b24c94b log: split internal TRACELOG macro into new header
The SPDK_TRACELOG macro depends on a CONFIG setting (DEBUG), so it
should not be part of the public API.

Create a new include/spdk_internal directory for headers that should
only be used within SPDK, not exported for public use.

Change-Id: I39b90ce57da3270e735ba32210c4b3a3468c460b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 13:33:51 -07:00
Tsuyoshi Uchida
81d60e6f30 scsi: fix panic issue of spdk_scsi_dev_queue_task
When task->lun is NULL, spdk_scsi_dev_queue_task panics. This patch
fixes it.
2016-11-10 13:29:12 -07:00
Pawel Wodkowski
8b449060eb lib/scsi: allocate only requested amount of data
Remove 4k allocation size in spdk_scsi_task_alloc_data(). From now on
all commands must obay allocation length.

Change-Id: Ica9384c62d431483ae1d0bd2e6fdee18b570861f
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-09 12:33:15 -07:00
Pawel Wodkowski
4fdc493c8e scsi_bdev: respect allocation length in READ CAPACITY 10/16
Change-Id: Iedab4471edc8639fde32bb29acba9172b0f65734
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-09 11:50:23 -07:00
Pawel Wodkowski
0244b5d78d scsi_bdev: respect allocation length in MODE SENSE 6 and 10
This refactor MODE SENSE 6 and 10 related functions to respect buffer
size parameter.

Change-Id: I03bad456bac0554a8bf7b56f69d1f9cf5b1991f6
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-09 10:52:34 -07:00
Pawel Wodkowski
f30f0c76f1 scsi: refactor usage of iov from spdk_scsi_task
This patch is preparation for fixing alloc_len overrun in SENSE 6/10 and
READCAP 6/10. To simplify code forbid usage of iov outside of
scsi/task.c.

This also drop SPDK_SCSI_TASK_ALLOC_BUFFER flag that obfuscate code. As
a replacement assume that if field alloc_len is non zero it mean that
iov.buffer is internally allocated. Functions
spdk_scsi_task_free_data(), spdk_scsi_task_set_data() and
spdk_scsi_task_alloc_data() manage this field.

Change-Id: Ife357a5bc36121f93a4c5d259b9a5a01559e7708
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-11-09 10:19:53 -07:00
Tsuyoshi Uchida
6583441f54 bdev: add members for SCSI sense information in spdk_bdev_io (#59)
Custom bdev modules can return any SCSI status and SCSI sense
information to a host by this patch. This is usefull when a custome bdev
module detect an error in the module and need to return meaningful
information to a host.
2016-11-07 13:14:47 -07:00
Daniel Verkamp
cc1146a8b5 iscsi: move iSCSI-specific SenseLength into PDU
This removes the 2 bytes of SenseLength from the beginning of the SCSI
sense_data buffer, so now the offsets within sense.data match up to the
expected values from the SCSI spec.

Change-Id: I9188560096a9ec5a8fcf83bec95201521b127494
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-02 14:15:09 -07:00
Tsuyoshi Uchida
a5f0327897 scsi: translate nvme error to scsi error (#54)
This patch translates NVMe status code to SCSI sense according to NVM
Express: SCSI Translation Reference.

http://nvmexpress.org/wp-content/uploads/NVM_Express_-_SCSI_Translation_Reference-1_5_20150624_Gold.pdf
2016-10-28 13:06:45 -07:00
Piotr Pelplinski
a2d0fa5351 spdk: add support for readv and writev in scsi layer
This patch adds support for spdk_bdev_readv in scsi layer.
It also fixes write so that it uses multiple iov's instead of one.
Currently we should use only task->iov (for single vector operation)
or task->iovs (for multiple vector operations).

Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: Ia3b2f6d18fd212b11d7b63b11dc46ec5bbc74788
2016-10-26 04:24:08 -07:00
Piotr Pelplinski
074b6d2430 spdk: remove iobuf from spdk_scsi_task
This patch removes reduntant field in spdk_scsi_task and
fixes all logic to use iov.iov_base

Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: Ie2fa1e2357b6383c118d05aec9206d1c60537d40
2016-10-24 09:11:05 -07:00
Ziye Yang
51b9664203 scsi: Make scsi sense data build more clear
Change-Id: I072abaae2d00ab84d7322f3dadd8dd30608b1a1c
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-10-21 08:54:01 -07:00
Pawel Wodkowski
113f8e23a7 bdev: enable IO vector operations
This patch enables vector operation for bdev drivers aio, malloc and
nvme.
The rbd driver still handle only one vector.

Change-Id: Ie2c1f6853bfd54ebd8039df9a0305854ca3297b9
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-10-14 16:21:24 +02:00
Jim Harris
81b3d6c9fc Revert "bdev: enable IO vector operations"
This reverts commit 422eab7106.
2016-10-11 15:52:10 -07:00
Ben Walker
2224ff2162 env: Replace rte_malloc with spdk_zmalloc
Use the env library to perform all memory allocations
that previously called DPDK directly.

Change-Id: I6d33e85bde99796e0c85277d6d4880521c34f10d
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-10-11 13:34:09 -07:00
Pawel Wodkowski
422eab7106 bdev: enable IO vector operations
This patch enables vector operation for bdev drivers aio, malloc and
nvme.
The rbd driver still handle only one vector.

Change-Id: I5f401527c2717011ecc21116363bbb722e804112
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
2016-10-11 12:17:47 -07:00
Ben Walker
a4747c6048 env: Make the environment library configurable.
This allows users to swap out SPDK's third party
libraries for an implementation based on their own
framework.

Change-Id: Ia0b7384ce5e31acba5ad0d7002dec9e95b759c52
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-10-05 11:51:37 -07:00
Krzysztof Jakimiak
46b7d49af0 spdk: add iov buffers to struct spdk_scsi_task
Preparation for SGL support (readv/writev).

Change-Id: I14a116d764ebc582ea0a0077cc5a0d0bac638cb0
Signed-off-by: Krzysztof Jakimiak <krzysztof.jakimiak@intel.com>
2016-10-05 09:40:13 -07:00
Ziye Yang
6c4a07ecbe scsi: change spdk_put_task to spdk_scsi_task_put
Change-Id: I2598627523b2a78b68d7e7fdadbb7d8ef44592b9
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
2016-09-29 15:42:29 -07:00
Daniel Verkamp
19dff91a1b scsi: replace off_t with uint64_t
These offsets are passed to the bdev I/O functions, which take uint64_t
offsets.

Change-Id: I1d597d066dfb64b6c7658906e7ee8e6fb2f8e4db
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-09-29 13:32:34 -07:00
liupan1111
0bde77082d Fix some cppcheck errors on lib/iscsi & lib/scsi. (#41)
Fixed error types:
 1 nullPointerRedundantCheck;
 2 unsignedLessThanZero;
 4 invalidPrintfArgType_sint;
 5 arrayIndexThenCheck
2016-09-28 13:55:56 -07:00
Ben Walker
a17ad921e2 Replace RTE_VERIFY with assert
We already require the assert header from the C standard library,
so use that instead of RTE_VERIFY to further isolate DPDK
dependencies.

Change-Id: I4a718af858c88aff6080e33e6c3dd533c077b8f4
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-09-28 10:15:56 -07:00
Jim Harris
0babf8ce81 bdev, copy: move all I/O paths to use I/O channels
bdev and copy modules no longer have check_io functions
now - all polling is done via pollers registered when
I/O channels are created.

Other default resources are also removed - for example,
a qpair is no longer allocated and assigned per bdev
exposed by the nvme driver - the qpairs are only allocated
via I/O channels.  Similar principle also applies to the
aio driver.

ioat channels are no longer allocated and assigned to
lcores - they are dynamically allocated and assigned
to I/O channels when needed.  If no ioat channel is
available for an I/O channel, the copy engine framework
will revert to using memcpy/memset instead.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I99435a75fe792a2b91ab08f25962dfd407d6402f
2016-09-26 14:02:07 -07:00
Jim Harris
06ef766bc0 scsi: add spdk_io_channel support
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I189ea68c8550bbaeab79be36cb3c4faba7cd2f69
2016-09-26 14:02:07 -07:00
Jim Harris
f93bb8a32d Switch spdk_bdev_read/write arg order for length and offset.
This matches the general order (LBA start then LBA count) for
the NVMe API.

While here, fix a copy/paste error in a debug message (write
instead of writev).

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ice326af5d6025867dffed4d1f6c7b81fb9eba5eb
2016-09-14 10:51:25 -07:00
Jim Harris
72bb4b6171 scsi: always zero unused INQUIRY bytes up to 96 if allocated
Our SCSI translation layer only fills 4 version descriptors
meaning the last 30 bytes of the 96 byte standard inquiry
data format are not used.  Some compliance tests expect
the full 96 bytes to be returned, even if they are unused.
So zero the remaining bytes (up to 96) if those bytes were
allocated.

This fixes a regression introduced by recent commit d3b58c006.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id61614b904b5dff39f034b7ba4da624be1b25bae
2016-09-09 07:57:41 -07:00
Jim Harris
d3b58c006f scsi: do not fill out more than allocation length for standard inquiry
The translation code currently cheats a bit - it allocates a full 4KB
buffer for any DATA_IN command that is not a READ, and then the
different SCSI commands that fall into this category (INQUIRY,
READ_CAPACITY, MODE_SENSE, etc.) can write as much data as they
want without having to worry about a buffer overrun.  Code higher
up the stack makes sure we only send the correct amount of data back
to the iSCSI initiator.

This patch fixes this behavior for standard INQUIRY (EVPD = 0).
Future patches will fix the behavior for other non-READ DATA_IN
commands, at which point we can remove the 4KB allocation and
only allocate the amount of data specified in the CDB.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: If5e4a10eeba9851e2d91cab71228d2fc2d5baad0
2016-09-08 09:34:49 -07:00
Ben Walker
ecb6e49d09 scsi: Include spdk/bdev.h from scsi_bdev.c
This compilation unit depends on bdev.h definitions, but
was only getting them due to #include ordering elsewhere.

Change-Id: I4fcbdb2582a40836bcabc3539cc558614fbfacfd
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-26 09:40:01 -07:00
Daniel Verkamp
d2ea70cafd iscsi: use spdk/endian.h functions
Switch from the non-portable <sys/endian.h> functions (htobeXX/beXXtoh)
to the SPDK endian conversion functions.

Change-Id: Id49b87f2e536c68f0d5d567e78e1990c0a37ef14
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-08-25 13:29:56 -07:00
Daniel Verkamp
98c8867e5a scsi: move spdk_strcpy_pad() into util/string.c
This will be useful outside of the SCSI code, so put it in the common
string utility file.

Also reorder the parameters so they match the order used in strncpy().

Change-Id: I9e25a59b64e4bedf04e5a96de463b1d8aa0ddac3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-08-22 08:58:07 -07:00
Changpeng Liu
17dbcf58c1 scsi: fill BLOCK LIMITS VPD page filed with suitable value
Linux block layer driver will use the maximum transfer length field to
split IOs larger than this value. We should set the field according to
iSCSI target limitation.

Change-Id: I03ee35bb96f0949418bb976a6c8013f88622a324
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-08-11 09:23:22 -07:00
Changpeng Liu
3c5eac6bfb scsi: return correct data length of VPD page 0xB1 and 0xB2
For VPD page 0xB1 and 0xB2, the scsi target did not return correct
value to the initiator, so return the length with correct value.

Change-Id: Ic17d804ca00d490fd6a2f833db5c9b73ce8dc160
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
2016-08-11 09:56:36 +08:00
Ben Walker
26350acc0a scsi: Fix integer size mismatch when setting lba
Change-Id: I25ce88006dbd073fb795046b80086237246a6ff5
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-05 16:08:01 -07:00
Daniel Verkamp
040c0193f4 bdev: change blocklen from uint64_t to uint32_t
This is the size of a logical block in bytes; 4 GB is more than plenty.

Also allows cleaning up casts to uint32_t in the SCSI translation layer.

Change-Id: I3ec2e2f41fd378f1a83f31aac25c46ef780f63e9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-08-05 09:03:15 -07:00
Ben Walker
b91c6e0e4a scsi: Make OBJECT_SCSI_TASK public
Change-Id: Icb4a5532dffe671aaa8e2b1b619de17ead66d3b4
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-04 13:15:23 -07:00
Ben Walker
01d13145c9 scsi: Flesh out the public header file
The public header file was missing some required definitions.

Change-Id: Ic4f8028367b1e21ea00c02660ca36be28da54e37
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-03 09:47:28 -07:00
Ben Walker
e648950f89 bdev: Delete bdev_db
Combine the necessary functionality with the main bdev file.

Change-Id: I96d796bc87ac2a8688cdf1fd3c16d2a7c8aef730
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2016-08-02 09:08:51 -07:00
Daniel Verkamp
bd4ac74eaf scsi: import SCSI/blockdev translation layer
Change-Id: Ie96943f40ea8be4156d55bc5eeacc567743cf9d6
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-08-01 10:35:01 -07:00