Commit Graph

52 Commits

Author SHA1 Message Date
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