Commit Graph

162 Commits

Author SHA1 Message Date
Changpeng Liu
b0df03c531 lib/vhost: rename device stop function calls
Existing `vhost_user_session_send_event` is only used to
stop vhost user device's session now, so we rename it to
`vhost_user_wait_for_session_stop` and also rename the
whole function calls when stopping the device with
more apposite names.

Change-Id: Ib8ea48273e85f7856ca2dfca57b5fd933ac4cf7a
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15296
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2023-01-06 16:14:35 +00:00
Changpeng Liu
376c25ed0c lib/vhost: use user_dev's lock to protect vhost sessions
`spdk_vhost_dev` is created|deleted via RPC or APIs, and
we use a global `spdk_vhost_lock` to protect it, but for
some other places such as: vhost-user message processing,
we also use the global lock for now, actually we don't
need to use this lock, because these vhost-user messages
processing will not delete nor add vhost devices.

While here, we add a `spdk_vhost_user_dev` access lock to
protect vhost-user message processing as an optimization.

Change-Id: Ia9c45b056cebb7b65f458d56ed775a15e386f905
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15184
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Feng Li <lifeng1519@gmail.com>
2023-01-06 16:14:35 +00:00
Konrad Sztyber
0db7a0dc7f vhost: add (set|get)_coalescing to virtio_blk transport
This fixes the behavior of spdk_vhost_(set|get)_coalescing() on
non-vhost-user devices.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ia17cd4c0ed4bad262090e05f83727c1516c21f92
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15772
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-12-12 09:26:22 +00:00
Konrad Sztyber
25d55f48c1 vhost: add (set|get)_coalescing to backend interface
The current code for setting/getting coalescing setting only works with
vhost-user devices, while users can create virtio-blk devices with
non-vhost-user transport.  Calling spdk_vhost_(set|get)coalescing() on
such device results in a segfault.

So, spdk_vhost_dev_backend interface is extended with methods to
set / get coalescing parameters.  In the following patch, the virtio_blk
interface will be also extended with similar callbacks allowing us to
pipe coalescing settings to the appropriate transport.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ide5d5f633b17dcdbedb4b7804d5e45bf41373eca
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15771
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-12-12 09:26:22 +00:00
Michal Berger
3f912cf0e9 misc: Fix spelling mistakes
Found with misspell-fixer.

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: If062df0189d92e4fb2da3f055fb981909780dc04
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15207
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-12-09 08:16:18 +00:00
Changpeng Liu
b45556e2b2 include/bdev_module.h: add SPDK_ prefix to macros
`BDEV_IO_NUM_CHILD_IOV` and `BDEV_RESET_IO_DRAIN_RECOMMENDED_VALUE`
are public macro definitions without `SPDK_` prefix, so we add the
`SPDK_` prefix to them.

Change-Id: I4be86459f0b6ba3a4636a2c8130b2f12757ea2da
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15425
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2022-11-22 10:03:57 +00:00
paul luse
a6dbe3721e update Intel copyright notices
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the 4 digit year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc).  Contribution date used
"--follow -C95%" to get the most accurate date.

Note that several files in this patch didn't end the license/(c)
block with a blank comment line so these were added as the vast
majority of files do have this last blank line.  Simply there for
consistency.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Id5b7ce4f658fe87132f14139ead58d6e285c04d4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15192
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>
Community-CI: Mellanox Build Bot
2022-11-10 08:28:53 +00:00
Changpeng Liu
23baa6761d lib/vhost: don't restart device multiple times
We will stop/start the device multiple times when a new
vring is added, and also stop/start the device when
set vring's callfd, actually we only need to start
the device after a I/O queue is enabled, DPDK rte_vhost
will not help us to start the device in some scenarios,
so this is controlled in SPDK.

Now we improve the workaround to make it consistent with
vhost-user specification.

For each SET_VRING_KICK message, we will setup the new
added vring, and then we try to start the device.

For each SET_VRING_CALL message, we will add one more
interrupt count, previously this is done when enable
the vring, which is not accurate.

For each GET_VRING_BASE message, we will stop the
device before the first message.

With above changes, we will start/stop the device once,
any new added vrings after starting the device will be
polled in next `vdev_worker` poller.

Change-Id: I5a87c73d34ce7c5f96db7502a68c5fa2cb2e4f74
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14928
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-03 14:53:55 +00:00
Changpeng Liu
7fcbd0220e lib/vhost: alloc VQ tasks in VQ setting function
Currently we will allocate all VQ's tasks when starting
the device, it will not allow us to add new VQ after
starting the device, so here, we move it to VQ setting
function.

Change-Id: I59cfc393d66779ab8a0eb704bc73bcede3f0a2a0
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14926
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-11-03 14:53:55 +00:00
Jim Harris
75cc6fd62f vhost: move the session_start_done calls to common layer
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I355790f87ef148af85d5c13002260f1120749ae5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14340
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dong Yi <yidong0635@126.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-09-09 15:31:06 +00:00
Jim Harris
01cec2499f vhost: add start_session
vhost_blk_start and vhost_scsi_start are now just
a single vhost_user_session_send_event() call, so
make this more generic by adding a top-level
start_session function.

Now this function will do the
vhost_user_session_send_event(), using the
user_dev_backend's start_session function pointer.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia89ba15011e231f0474405fb7225e713dcc920bf
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14327
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-09-02 07:32:54 +00:00
王亚飞/Yafei WANG
6fcd7a79e9 lib/vhost: Add submit_inflight_desc() to cpu usage statistic
submit_inflight_desc() actually do some meaningful work, so when it really process tasks, the poller should return BUSY status.

Signed-off-by: YafeiWangAlice <yafei.wang@samsung.com>
Change-Id: I2103cea6d28e8b355dad4ddd603d917f10e44c08
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13486
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-08-09 11:48:51 +00:00
Ben Walker
8dd1cd2104 check_format: For C files only, fix return type breaks
In SPDK, declarations have the return type on the same line. Definitions
have the return type on a separate line. Astyle has an option for
enforcing this. Unfortunately, it seems to have two bugs:

1) It doesn't work correctly at all on C++ files.
2) It often fails on functions that return enums, or long type names

Deal with 1) by adjusting the check_format.sh script to only tell astyle
to fix return type line breaks for C files and not C++. Deal with 2) by
adding a few typedefs to work around the problem.

Change-Id: Idf28281466cab8411ce252d5f02ab384166790c6
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13437
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2022-06-27 09:33:48 +00:00
Jim Harris
488570ebd4 Replace most BSD 3-clause license text with SPDX identifier.
Many open source projects have moved to using SPDX identifiers
to specify license information, reducing the amount of
boilerplate code in every source file.  This patch replaces
the bulk of SPDK .c, .cpp and Makefiles with the BSD-3-Clause
identifier.

Almost all of these files share the exact same license text,
and this patch only modifies the files that contain the
most common license text.  There can be slight variations
because the third clause contains company names - most say
"Intel Corporation", but there are instances for Nvidia,
Samsung, Eideticom and even "the copyright holder".

Used a bash script to automate replacement of the license text
with SPDX identifier which is checked into scripts/spdx.sh.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iaa88ab5e92ea471691dc298cfe41ebfb5d169780
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12904
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: <qun.wan@intel.com>
2022-06-09 07:35:12 +00:00
Tomasz Zawadzki
b727e804d6 vhost: add virtio_blk abstraction
This patch adds virtio_blk abstraction for custom transports,
with the 'vhost_user_blk' first one being used.

Added spdk_virtio_blk_transport_ops describing the nessecary
callbacks to be implemented by each transport.
Please use SPDK_VIRTIO_BLK_TRANSPORT_REGISTER to register the transport.
Transports can use virtio_blk_process_request() to process the
incoming I/O from their queues.

virtio_blk_create_transport RPC was added to create one of the
registered transports, possibly with custom JSON arguments.

Added 'transport' argument to vhost_create_blk_controller RPC,
to specify which transport should create the controller.
By default the vhost_user_blk transport is used.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ic9d93a6e0f483796eb56b7174a678e41a6ea4808
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9540
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-05-23 17:31:16 +00:00
Tomasz Zawadzki
aec00435a0 lib/vhost: separate out bdev events handling
Generic vhost-blk layer is responsible for opening the bdev
attached to the vhost controller.

This patch adds vhost_user_bdev_event_cb() that is called
for vhost_user backend. This function will be replaced with
a callback to particular virtio-blk transport.

Having this piped through to the transports, allows
to adjust their behavior upon bdev events.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Id73f5131b6e57f0354e970d0bce92716ec69985b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12132
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-05-20 19:40:56 +00:00
Tomasz Zawadzki
34c7b6c18c lib/vhost: expose spdk_bdev to virtio_blk transports
There are configuration details that are needed to configure
the virtio device based on spdk_bdev properties.
Please see vhost_blk_get_config() for an example
of vhost_user retrieving properties of bdev such as size
or supported I/O type.

Rather than trying to anticipate every such property,
add vhost_blk_get_bdev() to allow usage of bdev API directly.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I757f96e2fb0861c97b07ce279a7c04c77a2ad11f

Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12373
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-05-20 19:40:56 +00:00
Tomasz Zawadzki
65bedb496f lib/vhost: add enum to differentiate the vhost backends
Each spdk_vhost_dev_backend is local to either
SCSI or BLK backends, so its not possible to gauge which
backend is used by the vdev on generic vhost layer.

Added a `type` field with matching enums to differentiate
between the two. Later patches will check that field
in vhost.c.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I2a95961b9f9b5f070db7b22d44cf5114a24b1067
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12675
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-05-16 12:25:03 +00:00
Rui Chang
3ed4c29a11 lib/vhost: Fix vhost user cpu usage statistic issue
Currently, when you run vhost user target, no matter if the reactor is
busy or not, spdk_top always shows 100% busy. Fix this by real load
status.

Signed-off-by: Rui Chang <rui.chang@arm.com>
Change-Id: I610a8c2f4e74f46bd56955d31284372c775507ed
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12647
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-05-16 10:14:52 +00:00
Tomasz Zawadzki
eef6af95d1 vhost_blk: separate out generic virtio_blk request processing
This patch adds process_virtio_blk_request() that will be called
by virtio_blk transports to process incoming requests.

Meanwhile vhost_user_blk_request_finish() will be replaced with
a callback to the virtio_blk transport to notify of the result.

blk_request_finish() should only be called as direct result of
process_virtio_blk_request(), usually from it.
Some error paths now call vhost_user_blk_request_finish() directly,
if vhost_user_process_blk_request() was not called yet.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I0cce22f15b922fe45f30fb659c384b6e836def4c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9537
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2022-04-27 08:51:55 +00:00
Tomasz Zawadzki
8c609f29bc lib/vhost_blk: split up vhost_blk task
struct spdk_vhost_blk_task shall contain only fields
that are relevant to the generic virtio blk layer.
Moved to vhost_internal.h header to allow for broader
use.

In contrast to spdk_vhost_user_blk_task that is
specific to vhost_user transport.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I8438d3e6dbca816855f55ee998a632f50acde045
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12282
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2022-04-27 08:51:55 +00:00
Tomasz Zawadzki
57e6a387c2 lib/vhost: remove vhost_user fields from I/O processing logs
Later in the series, the spdk_vhost_blk_task will not contain
vhost_user specific fields. As such the generic part of processing
I/O will not be able to refer to those.

References to req_idx are replaced with pointer to the task,
meanwhile bvsession reference when queueing I/O is removed.

Note that vhost_user fields are accessible in the final callback
for the I/O, and will be printed. See blk_request_finish().

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I100d60968146da778bd6bf4fbcf2a2694d3be6e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12335
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-04-27 08:51:55 +00:00
Tomasz Zawadzki
a8757f6081 lib/vhost: cache vdev and io channel for bdev io wait
Previously the blk_request_queue_io() and blk_request_resubmit()
relied on vdev and channel contained in task or bvsession structures.

In an effor to make the I/O processing for virtio blk not reliant
on vhost_user, this patch caches the vbdev and io channel submited
in process_blk_request().

Later in the series, vhost_user structures will be separated out from
the spdk_vhost_blk_task.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: If1ea38a77af8fcfee12054f5857a6db2db2093c6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12334
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-04-27 08:51:55 +00:00
Tomasz Zawadzki
c29112b1d7 lib/vhost: accept generic vhost arugments in process_blk_request()
process_blk_request() accepted spdk_vhost_blk_session argument
which is specific for vhost_user. In preparation to making
this function usable outside of vhost_user, replace this field
with struct spdk_io_channel and spdk_vhost_dev.

For this purpose vhost_user_process_blk_request() was created to
translate from spdk_vhost_blk_task to the generic arguments.

to_blk_dev() was moved further up so it can be more commonly used
throughout the file.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie61a1ae2a615c4f1a95601e533b9eec51998cd07
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12333
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-04-25 07:36:30 +00:00
Tomasz Zawadzki
0368340581 lib/vhost: consolidate successful and invalid request path
Both blk_request_finish() and invalid_blk_request()
acomplished the same thing, with variation on handled
statuses and debug logs.

Consolidating those two into single function will help
later on when replacing completion of request processing
to single callback.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Iae7b93db01bfd98819b2bb8fad9e11afcdb3a459
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12196
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
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>
2022-04-15 07:49:32 +00:00
Tomasz Zawadzki
4f95fd7be6 lib/vhost_blk: get bdev io_channels via vhost_blk functions
This patch adds vhost_blk_[get/put]_io_channel() to be used
by virtio_blk transports.

Functions related to vhost_user sessions were modified to
use it.

dummy_io_channel reference is managed at the vhost_blk
layer and as such continues to use the spdk_[get/put]_io_channel()
APIs. The description is updated to reflect its not specific to
vhost_user transport.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I6644198da83bfa0210c167e203d3875e96f1e7ea
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11101
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
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>
2022-04-15 07:49:32 +00:00
Jim Harris
7778bc3a33 vhost: copy virtio_blk_outhdr to local struct
Some SeaBIOS versions are not aligning virtio_blk_outhdr
on 8-byte boundary, causing ubsan failures.  To be safe,
let's just make sure on our end that we only access a
properly aligned structure by copying this small (16-byte)
data structure to a local structure variable.

Fixes issue #2452.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iacad72c3a1759fb8dc5ba411272a34d93ef2a6fc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12238
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-04-13 08:33:51 +00:00
Tomasz Zawadzki
f9fccbae63 lib/vhost: separate out vhost_user backend callbacks
Previously spdk_vhost_dev_backend held callbacks
for vhost_blk and vhost_scsi functionality, along
with ones that are called by the vhost_user backend.

This patch separates out those callbacks into two
structures:
- spdk_vhost_dev_backend - to be implemented by vhost_blk
and vhost_scsi
- spdk_vhost_user_dev_backend - is only implemented by
vhost_user backend, callbacks for session managment
specific to that transport

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I348090df5dddeb2b1945b082b85aec53d03c781b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11812
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2022-04-11 07:44:09 +00:00
Tomasz Zawadzki
c010a71f27 lib/vhost: make packed_ring_recovery per controller
Previously g_packed_ring_recovery was set globally.
Setting that during controller creation, would affect
all previously created controllers.

This is now set on per-controller basis and only
enabled if packed ring feature is used.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Idcc7231471446c805154648ab835a6af78f6543c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12040
Community-CI: Mellanox Build Bot
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>
2022-04-11 07:44:09 +00:00
sberbz
fd53562a87 vhost: parse JSON vhost_blk devices specific params
Separate parsing generic rpc vhost params form device specific,
this solution allow to create various device which share
common parameters.

Change-Id: I50b1a89a8260fb1394880a750591e95539995288
Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12026
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2022-04-11 07:44:09 +00:00
Kozlowski Mateusz
adc36d5be3 lib/vhost: Fix ENOMEM resubmission for vhost_blk
In the current behavior the iovcnt is lowered before sending it to
the next BDEV in the stack - however if the returned value is ENOMEM
(due to eg. not enough bdev requests in the pool), the request needs
to be returned to its original state, as it would be resubmitted with
skipped iov entries.

Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
Change-Id: I7240510a2ec04594b248f7347e86ac11ecfd26a0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11976
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-04-01 08:30:28 +00:00
Tomasz Zawadzki
d7cd645c9f lib/vhost: move rest of vsession managment to rte_vhost_user
Remaining functions that manage or interact with vsessions
are now placed in rte_vhost_user.
Renamed the functions appropriately with vhost_user_* prefix.

While here g_dpdk_sem was made static, since rest of references
from vhost.c was removed.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie9fbf5f08910c136711fb1dfab1b35a5488f0c25

Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11025
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-03-02 08:29:52 +00:00
Tomasz Zawadzki
8ca52b6d7c lib/vhost: move changing vsession interrupt_mode to rte_vhost_user
This functionality is specific for rte_vhost,
so move it to appropriate file.
Renamed to include vhost_user_* prefix.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I9630902f52d4944d0d18a39dfbff05945ce2bdba
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11024
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-03-02 08:29:52 +00:00
Liu Xiaodong
ba32ee2b29 vhost: set timeout for session's stop_poller
If there is still some inflight IO which prevents
vhost_session_stop_done(), stop_poller can try
within 4 seconds, and then call vhost_session_stop_done
with -ETIMEDOUT.

This can avoid endless blocking in ctrl pthread if there
is no response from vhost session or its backend bdev.
Then spdk vhost target can still serve all other vhost
devices and operations besides the error one.

Change-Id: I2fc78b4da926c936a2e42dc0e66ce1c60001330d
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10393
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
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>
2022-01-07 15:24:12 +00:00
Josh Soref
cc6920a476 spelling: lib
Part of #2256

* accessible
* activation
* additional
* allocate
* association
* attempt
* barrier
* broadcast
* buffer
* calculate
* cases
* channel
* children
* command
* completion
* connect
* copied
* currently
* descriptor
* destroy
* detachment
* doesn't
* enqueueing
* exceeds
* execution
* extended
* fallback
* finalize
* first
* handling
* hugepages
* ignored
* implementation
* in_capsule
* initialization
* initialized
* initializing
* initiator
* negotiated
* notification
* occurred
* original
* outstanding
* partially
* partition
* processing
* receive
* received
* receiving
* redirected
* regions
* request
* requested
* response
* retrieved
* running
* satisfied
* should
* snapshot
* status
* succeeds
* successfully
* supplied
* those
* transferred
* translate
* triggering
* unregister
* unsupported
* urlsafe
* virtqueue
* volumes
* workaround
* zeroed

Change-Id: I569218754bd9d332ba517d4a61ad23d29eedfd0c
Signed-off-by: Josh Soref <jsoref@gmail.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10405
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-12-03 08:12:55 +00:00
Li Feng
73f61bcdc1 vhost: fix the memory free in submit_inflight_desc
SPDK shouldn't use `free` to free the memory allocated by rte_zmalloc_socket.
Otherwises, the vhost-blk/scsi will continuously crash.

In this patch, SPDK don't free the dpdk allocated memory,
DPDK will free it finally. Add a flag to indice the resubmit handle.

Change-Id: I85fd84b7d27a091830006a0f84d541c48290cbb3
Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10383
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
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>
2021-12-02 08:09:18 +00:00
John Levon
fa20c0bb83 vhost-blk: fix interrupt names
Interrupts were all being registered with the name "fn". Directly pass in the
name instead to fix this.

Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: I38e59d784298a61ca2130090ede500101389685c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9346
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Rui Chang <rui.chang@arm.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2021-09-02 07:43:37 +00:00
Rui Chang
33acbe9caf spdk_top: fix vhost poller name issue
When run spdk_top against vhost, the poller name is displayed as
"bvdev->bdev ? vdev_worker : no_bdev_vdev_worker" which should be "vdev_worker".

Signed-off-by: Rui Chang <rui.chang@arm.com>
Change-Id: Ie97c69bd8cdd3fdafc5fe4dd80e1fde85a8e3238
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9130
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2021-08-10 08:19:33 +00:00
Changpeng Liu
75a507736b vhost-blk: use device name for VIRTIO_BLK_T_GET_ID
Block device product name is same among same type
of the block devices, while Guest VM may use this
value to generate UUID, so here we change it to
block device name instead.

Change-Id: I58c5fb271a6a436c15520616c2065eee9c37300a
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7996
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2021-05-27 07:35:37 +00:00
Liu Xiaodong
db8ac562b3 vhost-blk: add set interrupt mode to poller
Change-Id: Ie599e445aca8241cf2f71e152ea92a5f92dd4dc5
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5788
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2021-04-23 18:09:54 +00:00
Jin Yu
4ad4c76cba vhost-blk: resubmit inflight descs of packed ring
This patch is for packed ring live recovery.
After reconnection we should resubmit the inflight descs.

Change-Id: I133bf5f1c09029d3c693c0fef67a609d72f2bf69
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4127
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Community-CI: Mellanox Build Bot
2021-01-15 08:30:18 +00:00
Changpeng Liu
fb27c710f2 vhost/blk: make packed and split vring process in different function call
Code cleanup to make the code looks more clear, this helps the coming
inflight IOs support for packed ring.

Change-Id: Iebca17e01e597eab2a920dd7f38056c57ae2cd11
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5755
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: JinYu <jin.yu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-01-13 10:08:11 +00:00
Changpeng Liu
99c62dda60 vhost/blk: make process_blk_request() only process virtio_blk request
Previously the function also get the payload from vring descriptors,
this mixed the process of vring and virtio_blk together, now it's
only related with virtio_blk.

Also this make the resubmission process more clear.

Change-Id: I6dd17cf9e30dde99e50a7c6d345b6eee7fa5b758
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5754
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: JinYu <jin.yu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-01-13 10:08:11 +00:00
Changpeng Liu
e18788d30e vhost-blk: process VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP correctly
Flag VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP is only used for WRITE
ZEROES command, vhost-blk target may tell VM via 'write_zeroes_may_unmap'
configuration that the backend can support this flag, however, Linux
generic block driver doesn't have such logic, it will enable this
flag by default(without REQ_NOUNMAP) with WRITE ZEROES command,
so the backend may choose to ignore this flag, because WRITE ZEROES
with this flag isn't mandatory.

Fix issue #1714.

Change-Id: Ic9388f39269720a23c00d41cba585d2a5abc3cfb
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5565
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: <dongx.yi@intel.com>
2020-12-28 13:17:00 +00:00
Jin Yu
e28ac3bc6b vhost-blk: record inflight descs of packed ring
This patch is for packed ring live recovery.
First step is to track the packed ring descs.

This feature base on this QEMU patch:
https://patchwork.kernel.org/patch/11766697/

Change-Id: Id0ccb6fd12b3623cc367424f496b4ffc5323f390
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4126
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-12-16 08:56:12 +00:00
Liu Xiaodong
5568355eb0 vhost-blk: apply interrupt
If interrupt mode is set, related poller functions will be
registered to interrupt handler instead of poller.
interrupt_tgt can work as vhost-blk target to support VM.

Change-Id: I3a15f9a63532f44fe0d2f0cb69b0efdd72431d10
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4277
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>
2020-11-02 11:22:40 +00:00
Liu Xiaodong
36d2e93ea1 vhost-blk: extract per queue vdev worker
Change-Id: Id852585f3eb3b61f5a074336c73e300f020c594e
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4863
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-27 08:40:28 +00:00
Tomasz Zawadzki
b1f76f512f lib/vhost: remove legacy config support
This patch removes legacy config support in vhost_blk/scsi library.
All options through the legacy config are already reflected in JSON.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ia63651cdb7433267d1a8839a1739e68b436e5d08
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4621
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-10-20 02:42:16 +00:00
Changpeng Liu
6bd7bd0da2 vhost: deprecate internal vhost library support
The internal vhost library is used when DPDK's version
is older than 19.05 and the experiemntal vhost nvme
target.

For the CONFIG_INTERNAL_VHOST_LIB option, SPDK doesn't
enable this option by default over one year and CI
doesn't cover it either, so we may remove it with
this release.

As for the vhost-nvme target, since we are developing
a new vfio-user target solution, it's OK for us to remove
it now.

Change-Id: Ib2cce1db99cd09754307c2828b3187f2d4550304
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4562
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-10-20 02:42:16 +00:00
Shuhei Matsumoto
0238bb734a lib/vhost_blk: Open bdev by bdev_name first in spdk_vhost_blk_construct()
Open a bdev whose name matches bdev_name first in spdk_vhost_blk_construct()
to avoid using spdk_bdev_get_by_name() to fix the race condition
due to the time gap between spdk_bdev_get_by_name() and spdk_bdev_open_ext().
A pointer to a bdev is valid only while the bdev is opened.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I99fedd696aa44bb46c1fcc4f49ca37069f7adfef
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4502
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-10-14 08:07:06 +00:00