Commit Graph

270 Commits

Author SHA1 Message Date
Seth Howell
d18e63206a mk/lib: add a check that major and minor version is set for libs.
Also, while we are here, consolidate setting SO_SUFFIX to one spot.

Previously, it was possible for a library to slip through
without an SO version.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I4db5fa5839502d266c6259892e5719b05134518c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2361
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-21 09:19:00 +00:00
Shuhei Matsumoto
e99aa89108 lib/scsi: add map file
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I019ad7147e4e9bc223d1a772e9284d18d5591ace
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1897
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-04-24 07:06:52 +00:00
Shuhei Matsumoto
33a2974768 lib/scsi: Remove spdk prefix from private functions
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I89aa5dc10150cff74a420ccf8c3842bd12e84f3c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1825
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>
2020-04-16 08:09:14 +00:00
Shuhei Matsumoto
18dec40111 lib/scsi: Remove spdk_ prefix from internal APIs
Remove spdk_ prefix from the name of internal APIs.

Add single underscore as the prefix of the function name to the
private functions if we see any conflict as a result of this change.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: If0eabffbdb750db02866c1aa2b29b0c89fab1040
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1824
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>
2020-04-16 08:09:14 +00:00
Shuhei Matsumoto
1fbc628e7a lib/scsi: Delete unused struct spdk_lun_db_entry
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I95f1b7445e55efe2aec5ab819eaef1d3e25b2507
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1821
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>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2020-04-15 07:40:06 +00:00
Shuhei Matsumoto
799e0a84af lib/scsi: Merge append and execute SCSI task into a single function
Both for SCSI IO task and management task, append and execute
operations bad bbeen separated into different functions.

Append operation was for LUN reset, and separating into two different
functions was for clarification and readability.

LUN reset is sufficiently stable now.

Merging append and execute SCSI task into a single function is good
as API and enables us to do optimization.

For SCSI management task, merge spdk_scsi_lun_append_mgmt_task into
spdk_scsi_lun_execute_mgmt_task() simply.

For SCSI IO task, merge spdk_scsi_lun_append_task into
spdk_scsi_lun_execute_task() and do a small optimization.
The refined spdk_scsi_lun_execute_task() adds the IO task to the
pending list if there is any pending management task, executes all
existing penging IO tasks first and then the IO task if there is any
pending IO task, or executes the IO task directly otherwise.

Update unit test accordingly.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I26ffc4f4f62747d8cdecb90690f26cd58a9c17f7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1817
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-04-15 07:40:06 +00:00
Shuhei Matsumoto
2aa74d8ba9 lib/scsi: Inline _scsi_lun_execute_mgmt_task() into the caller function
Inline _scsi_lun_execute_mgmt_task() into the caller function
spdk_scsi_lun_execute_mgmt_task() as another preparation to the following
patches to avoid using double underscores as the prefix of the
function name.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3c282fff133dfe7afc70c374a2186c14d1eb766c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1829
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>
2020-04-15 07:40:06 +00:00
Shuhei Matsumoto
2144f0b4c3 lib/scsi: Separate pending task and outstanding (submitted) task into different functions
This is a preparation to the following patches to optimize task
submission and remove the spdk_prefix from internal or private
functions.

To avoid using double underscores as the prefix of the function name,
separate pending task check and outstanding task check into
different functions.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ieda54507bf4c781b60fa05d03cd32ca25948e430
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1826
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>
2020-04-15 07:40:06 +00:00
Shuhei Matsumoto
ab0bc5c254 lib/thread: Use function name as poller name by using macro SPDK_POLLER_REGISTER
We will be create fine name for each poller but it will need large
effort. Replacing spdk_poller_register by the macro SPDK_POLLER_REGISTER
will provide better name than function address with minimum effort.

Following patches may improve function name for clarification.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: If862a274c5879065c3f7cb04dcb5ca7844523e68
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1781
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: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Community-CI: Broadcom CI
2020-04-15 07:23:09 +00:00
Seth Howell
193927830d make: rev SO versions individually for libraries.
This will allow us to keep track of compatibility issues on a
per-library basis.

Change-Id: Ib0c796adb1efe1570212a503ed660bef6f142b6e
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1067
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>
2020-03-18 08:02:30 +00:00
Shuhei Matsumoto
6383602952 lib/scsi: Remove workaround for astyle format check about break-after-return-type
To avoid the starnge formatting, typedef has been used. But this comment
is hard to get the meaning. So stop breaking after return type for this case.

The strange formating is

struct spdk_scsi_dev *
       spdk_scsi_dev_construct(const char *name, const char *bdev_name_list[],
                        int *lun_id_list, int num_luns, uint8_t protocol_id,
                        void (*hotremove_cb)(const struct spdk_scsi_lun *, void *),
                        void *hotremove_ctx)

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I20c30b225b3b96fa9207b4a89e3210c8a97fb1d8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1050
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-03-04 10:04:26 +00:00
Shuhei Matsumoto
fa2dd2722d lib/scsi: Move scsi_task_free_data() in a file to remove function declaration
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I9c98ded51bf88cd199bace7b3703b86ed4a9c25b
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472519
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-11-21 08:01:29 +00:00
Shuhei Matsumoto
16dbc19508 lib/scsi: Consolidate error paths in bdev_scsi_readwrite()
This simplifies the code a little.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Idf53616bda21c82b82f9e9438f4dcb87ffaa59a6
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472518
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2019-11-21 08:01:29 +00:00
Shuhei Matsumoto
ca0972d3b8 lib/scsi: Match parameters of bdev_scsi_readwrite() with bdev_scsi_sync/unmap()
We can pass bdev, lun->bdev_desc, and lun->io_channel to
bdev_scsi_readwrite() as same as bdev_scsi_sync/unmap().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ib8b368da4da54b057ae09a91ab60a50388a5c684
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472517
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-11-21 08:01:29 +00:00
Shuhei Matsumoto
84e64cc9d7 lib/scsi: Pass SCSI task to SCSI layer to get DIF context
By the recent refactoring, SCSI task is configured when getting
DIF context from SCSI layer. Passing not CDB and offset separately
but SCSI task to SCSI layer is more concise and do in this patch.

In iscsi_send_datain(), we have to update task->scsi.offset for the
case that data is split into a sequence, but the update is no harm
because task has completed what it must to do.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I153352dfa7aa7325db4452f03d863df11b3e0cfa
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472510
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-11-21 08:01:29 +00:00
Shuhei Matsumoto
dc6d89b925 lib/scsi: Really wait for only outstanding tasks for LUN hotplug
One previous patch refined LUN hotplug process and updated the
comment but we still had checked not only outstanding tasks but
also pending tasks to be completed or aborted.  But, as written
in the comment, we can wait for only outstanding tasks now.

Management task is the highest priority and is pending only when
there is any outstanding management task, and the completion
callback of management task executes the first pending management
task.

The last patch changed us to abort all pending management tasks
after stopping new submission.

Hence we can do this change not only for IO task but also for
management task.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I66056f2a02af05d5bccaf6462c6f48c608cd0ca3
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474032
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>
2019-11-14 18:08:12 +00:00
Shuhei Matsumoto
8287ae7814 lib/scsi: Abort management tasks being queued when removing LUN
SCSI management task is for SCSI tasks which is submitted after it,
and all such SCSI tasks are aborted by the last patch when we
remove LUN dynamically. Hence we can abort all SCSI management tasks
being queued when removing LUN.

Add simple unit tests too.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I9be3f910ab4bbb99cd399f71dc716a7c40f34fe5
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474022
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>
2019-11-14 18:08:12 +00:00
Shuhei Matsumoto
db91cfe045 lib/scsi: Stop submitting new task and abort pending tasks for LUN hotplug
Previously iSCSI LUN hotplug had critical bugs and we had no choice but
accept submitting new tasks as late as possible. We fixed the bug now and
we can stop submitting new task immediately after starting LUN removal
process.

By this change, no task is submitted to the LUN and previously queued
tasks have no chance to be kicked. Hence we execute them instead after
stopping new task submission.

This change simplifies LUN hotplug process and reproduce LUN hotplug
issues solidly if we don't have the fix.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I9a33e6a217978b0863d15aaff3d35880dbdccfd4
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473596
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>
2019-11-14 18:08:12 +00:00
Shuhei Matsumoto
74ab9f9041 lib/scsi: Factor out submiting pending tasks in LUN into a function
This is a preparation to the next patch. If connections detect that
LUN is removed, we have no way to spdk_scsi_lun_execute_tasks()
to the pending tasks.  Hence the next patch will call the new
function scsi_lun_execute_tasks() in that case.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifdf630bd349c7d2099a6a14accc52f77c129f641
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473610
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-11-14 18:08:12 +00:00
Shuhei Matsumoto
b386a3a9a2 lib/scsi: Assert if ref count of task goes negative
We didn't have any check if ref count of SCSI task doesn't go negative.
This addition will verify the idea to LUN hotplug issue by subsequent
patches.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: I1d6ca9b9439bc7c4b701b65cc004cdf5cae16e91
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473585
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-11-14 18:08:12 +00:00
Shuhei Matsumoto
7cef60b657 lib/scsi: Close block device on the thread which opened it
All connections to a single LUN run on a single thread but
this thread may not be the same as the one which opened the backed
bdev. So hold pointer to the thread which opened the backed bdev
to struct spdk_scsi_lun and use it when calling spdk_bdev_close().

All resource of LUN are accessed on a single thread after getting
I/O channel, and so lock is not still necessary.

    Fixes issue #1024.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifc1e238d333afcde0cdf9e9b4af3b56ef65a4f7d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473002
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
2019-11-05 12:10:08 +00:00
Shuhei Matsumoto
6e7473f724 lib/scsi: Free bdev_io just after getting completion from bdev for management I/O
This is for management I/O and from the same idea as the last patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iae11de7848b38b9db1a699d80f595000a6ab2a47
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471696
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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
2019-10-22 17:20:51 +00:00
Shuhei Matsumoto
7a9ecf8284 lib/scsi: Free bdev_io just after getting completion from bdev for non-read I/O
Previously, for iSCSI target, freeing bdev_io of SCSI task was deferred
until the reference count of the SCSI task becomes zero.

But this will cause the use-after-free issue when doing LUN hotplug during
large write I/O workload.

The scenario is the following:

- Large iSCSI write I/O is split into multiple I/Os, the first I/O is from immediate,
  and subsetquent I/Os are from R2T.

1. The first I/O allocates iSCSI task as primary, and is submitted to  the bdev layer.
   The first I/O is pending in the bdev layer.
2. The second I/O allocates iSCSI task as secondary (secondary is associated with
   primary by incrementing reference count).
3. Before submitting the second I/O to the bdev layer, LUN hotplug is started.
   LUN hotplug waits for getting completion of the first write I/O from the bdev layer.
4. The bdev layer completes the first I/O. The primary iSCSI task is tried to free,
   but reference count is still one, and is not done yet.
5. LUN hotplug detects completion of the first write I/O, and returns
   LUN I/O channel to the bdev layer.
6. The second I/O is tried to submit to the bdev layer, but LUN is already removed,
   and so free the secondary iSCSI task.
7. Then the reference count of the primary iSCSI task becomes zero,
   and its bdev_io is freed. However, LUN I/O channel is already freed and freeing
   bdev_io fails.

This issue is caused by separating iSCSI task allocation and submission.

For write I/O, we don't have to keep bdev_io after getting completion
of it from the bdev layer.

This applies to other non-read I/O types.

So for non-read I/O, free bdev_io after getting SCSI status in
bdev_scsi_task_complete_cmd(), and for read I/O, set bdev_io to
task as same as before.

The next patch will do the same for management task.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I530fb491514880ce41858e1bea55d422d606dfc4
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471695
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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
2019-10-22 17:20:51 +00:00
Shuhei Matsumoto
1dc9a7627f lib/scsi: Check pending tasks for the SCSI device only from the specific initiator
Refine the public helper function spdk_scsi_dev_has_pending_tasks to
be able to check tasks only from the specific initiator.

Then use the function in iSCSI target to fix the issue.

Besides add UT code to test the updated spdk_scsi_dev_has_pending_tasks().
Automated multi hosts test is much better but some UT code will be of any
help to mitigate the risk of degradation.

Fixes #985

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I50afb940de7174360c8a30479450850002a3e525
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471337
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: Changpeng Liu <changpeng.liu@intel.com>
2019-10-18 17:30:13 +00:00
Shuhei Matsumoto
f9583f2c0d lib/scsi: Check pending tasks for the LUN only from the specific initiator
Refine helper functions spdk_scsi_lun_has_pending_mgmt_tasks() and
spdk_scsi_lun_has_pending_tasks() to be able to check tasks only from the
specific initiator.

SCSI port is used by passing the pointer and so simple pointer
comparison is appropriate in the functions.

Add UT code to test the updated functions.

The next patch will change spdk_scsi_dev_has_pending_tasks() to
get not only SCSI device but also initiator port and make iSCSI
target use the function to fix the issue.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I89c33e05bc6ab21baa6cbebf60950039a3dcecd0
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471336
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: Changpeng Liu <changpeng.liu@intel.com>
2019-10-18 17:30:13 +00:00
Shuhei Matsumoto
4787395283 lib/scsi: Change current function to check pending tasks to private
When closing iSCSI connection, if we check pending tasks, we must
check tasks only from the corresponding initiator.

We have to add new API to do that.

On the other hand, during IO submission or LUN hotplug, we must check
all tasks.

The latter case is done only in SCSI LUN, and the function is not
necessary to be public.

As a preparation, change scsi_lun_has_pending_tasks/_mgmt_tasks
from public to private.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I2d7d77109ed317435b6768fffb0bf4e21dd60f9f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471335
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: Changpeng Liu <changpeng.liu@intel.com>
2019-10-18 17:30:13 +00:00
Pawel Kaminski
617f17d814 rpc: Rename get_scsi_devices to scsi_get_devices
Change-Id: I6ebc7323835d192ef89dcb449be90529d63be46e
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468904
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: Jim Harris <james.r.harris@intel.com>
2019-10-03 23:01:27 +00:00
Ben Walker
a34248d38f Revert "scsi: Fix seg.fault due to the gap between IO channel put and LUN removal"
This reverts commit 8f33ac020d.

Causing build pool failures

Change-Id: Ib0dd2be4c327d76f67a00aec8a7c26f25bbaeb10
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467873
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Mike Carlin <mikefcarlin@protonmail.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-09 21:11:22 +00:00
Shuhei Matsumoto
8f33ac020d scsi: Fix seg.fault due to the gap between IO channel put and LUN removal
The reported github issue #938 has been reported intermettently.
The issue is that the bdev descriptor passed to spdk_bdev_reset()
is not valid and causes seg. fault.

Current implementation of LUN hot plug is that putting IO channel
and removing LUN are done by different poller. Hence if any task
management command is issued between the gap, the reported issue
is likely to occur.

The flag removing is set at the start of LUN hot plug and so
spdk_scsi_dev_get_lun() can return NULL even before completing
removal by referring the flag removing.

  Fixes #938.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I1a51d90cc700134e8c0ec399a3ce62620c84ef73
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467212
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-09-09 04:46:08 +00:00
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