Commit Graph

76 Commits

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