Commit Graph

734 Commits

Author SHA1 Message Date
Ziye Yang
c38a1bc002 sock: create spdk_sock_prep_reqs function.
The purpose is to reduce the duplicated functions
in posix and uring implmentation.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: Ia0568b2490d362e7e78fa59b3ca88a60313ba0bd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5284
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-27 09:22:30 +00:00
Shuhei Matsumoto
c8fa7f4c16 bdev/ocssd: Pass bdev_ocssd_io instead of spdk_bdev_io to I/O submit functions
This is the end of the series to make the code of ocssd_bdev more
similar with nvme_bdev.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I9dfc2634292ec581d6787500e46e74ad3b95aa90
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5251
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-26 10:15:03 +00:00
Shuhei Matsumoto
c132f1e190 bdev/ocssd: Extract and pass contents of spdk_bdev_io to I/O submit functions
Extract and pass contents of spdk_bdev_io to I/O submit functions.
Besides, adjust the coding style for I/O submit function calls
with nvme_bdev.

The next patch will replace spdk_bdev_io parameter by bdev_ocssd_io
parameter for I/O submit functions.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I2556d4a3c092d4ffacd47bbfc95db060da477bc3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5250
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-26 10:15:03 +00:00
Shuhei Matsumoto
1ce01e40a1 bdev/ocssd: Add nvme_ch parameter to reset_zone() and get ctrlr from nvme_ch
This follows the recent change in nvme_bdev.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I81a0d838a5bb1bd22275ee75e64b32b7b12cc67f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5249
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-26 10:15:03 +00:00
Shuhei Matsumoto
bd65fef240 bdev/ocssd: Add ocssd_bdev parameter to I/O submit functions
nvme_bdev passes not spdk_bdev_io but nvme_bdev_io pointer to I/O
submit functions, and gets spdk_bdev_io pointer from nvme_bdev_io
pointer in its completion callback functions.

This is very clean because spdk_bdev_io is processed by the generic bdev
layer and nvme_bdev_io is processed by the NVMe bdev module.

The patch series changes ocssd_bdev to pass not spdk_bdev_io but
bdev_ocssd_io pointer to its I/O submit functions.

This patch is the first of the series and add ocssd_bdev parameter
to I/O submit functions. ocssd_bdev pointer is got from
bdev_io->bdev->ctxt. Hence this patch removes one dependency on
spdk_bdev_io.

One noticeable small change is that get_zone_info() gets zone_info
from not bdev_io->bdev but nvme_bdev->disk to advance removing
the dependency on spdk_bdev_io.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ia3127ceb1fc8923e321a1404edbb19b63f5fde5d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5248
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-26 10:15:03 +00:00
Shuhei Matsumoto
0619909689 bdev/ocssd: Use cached pointers geometry_cb() for readability
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iff1db8002258947eba1bd9a312edd6a8ab781a80
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5133
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-26 10:15:03 +00:00
Shuhei Matsumoto
0aeab1f13d bdev/nvme: Add nvme_bdev_ctrlr pointer to struct nvme_io_channel
When we support ANA multipath, I/O path will get nvme_bdev_ns from
nvme_bdev_ctrlr->namespaces, and nvme_bdev_ctrlr will be got from
nvme_io_channel.

Hence this patch adds a pointer to nvme_bdev_ctrlr to struct
nvme_io_channel.

As a side effect, nvme_io_channel->ctrlr is helpful to simplify
admin command submit functions, and do it in this patch.

For ocssd_bdev, we will do the similar change later.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I6976d1543ccda37dde4b81b2124d88f0d05ed7eb
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5055
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-25 08:52:15 +00:00
Shuhei Matsumoto
54c4cd0000 bdev/nvme: Pass spdk_nvme_ns and spdk_nvme_qpair pointers directly to I/O submit functions
When we support ANA multipath, we will use spdk_nvme_ns and
spdk_nvme_qpair pointers for I/O submit functions after checking
ANA state of spdk_nvme_ns.

It will be efficient and easy to understand if we unify such check.
The next patch will provide a helper function to do such check.

This patch changes the parameters of I/O submit functions as a
preparation.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic741caa1d7e6df844b875beea776e79d4eb8d6fc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5204
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-25 08:52:15 +00:00
Shuhei Matsumoto
e979e1fd37 bdev/nvme: Add nvme_ch parameter to bdev_nvme_flush()
bdev_nvme_flush() just completes with success now and uses only
bio parameter now, but matching parameters with other similar I/O
APIs will be good for future enhancement and following patches.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I64be668fa781396ef68b6b506b22cb153d7b6850
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5203
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-25 08:52:15 +00:00
Shuhei Matsumoto
1a8c6c4d4a bdev/nvme: Get dif_check_flags via bdev_io->bdev in I/O paths
Using bdev_io->bdev will be more straightforward than using
bdev_io->bdev->ctxt and &nbdev->disk.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie5854ab063b7b21710e9f899dd93340624a8cb49
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5202
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-25 08:52:15 +00:00
Shuhei Matsumoto
3bf79d7c91 bdev/nvme: Use spdk_nvme_ns_get_ctrlr() for I/O passthrough
This changes follows the last patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I057a4e035e4010e5dd8ec8e7de78f91d562383cf
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5201
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-25 08:52:15 +00:00
Shuhei Matsumoto
8b26fdd5ea bdev/nvme: Use spdk_nvme_ns_get_max_io_xfer_size() for I/O passthrough
This and the next change will enable us to pass spdk_nvme_ns and
spdk_nvme_qpair as parameters to I/O passthrough APIs. When we support
ANA multipath, ANA state of spdk_nvme_ns will be checked. These changes
follow that.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id38a0e14501ff6402f9b151eaf9e44864079412b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5200
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-25 08:52:15 +00:00
Jin Yu
4c890c3160 virtio: add transitional virtio device support
SPDK virtio driver does not support the virtio legacy
device but it's ok for the modern and transitional
device. So update the probe function.

From the spec:
Transitional PCI Device ID Virtio Device
0x1000 network card
0x1001 block device
0x1002 memory ballooning (traditional)
0x1003 console
0x1004 SCSI host
0x1005 entropy source
0x1009 9P transport

Transitional Device: a device supporting both drivers conforming to
modern specification, and allowing legacy drivers.

Change-Id: I28cd277fb2b2e07a429082b7d7bd581f254eae9c
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5053
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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-11-20 11:00:53 +00:00
Nick Connolly
024179d8ee module: Use PRId64 for portability
POSIX defines PRId64/PRIu64/PRIx64 for printing 64-bit values in a
portable way. Replace a few references to %ld to remove the assumption
about the size of a long. Similarly, use %z with size_t arguments.

Where the value being printed is an unsigned 64-bit value, use PRIu64
instead of %ld.

Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
Change-Id: I0ec4c0cb5e7a8f4b94a1ee6272c8df9ee7f06aa6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5141
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-11-19 09:59:01 +00:00
Shuhei Matsumoto
c626ada01d bdev/ocssd: Cache zone pointer from ocdev_io->io.zone and use it
Using ocdev_io->io.zone to update zone is a little confusing,
and so cache zone pointer from ocdev_io->io.zone and use it for
clarification.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iaee9b1fa8a86240022ddf5038a8c86b48476ba78
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5148
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
73d7353f79 bdev/ocssd: Separate write_cb() and append_cb()
This refactoring increases the code size slightly but improves
readability, and will make the following patches easier.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I704eca60fe98e4622e0d39d2e54ead63844156f6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5147
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
f9faa0743d bdev/ocssd: Factor out pushing and notifying media event in chunk_notification_cb()
This is to improve readability even if the factored functions are
used only in a single place.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifa6c7ba4380124a957e66e31123e3743d83e7615
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5146
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
ae3b179a53 bdev/ocssd: Factor out getting chunk info. offset from _get_zone_info()
Factor out getting chunk info. offset into a helper function
bdev_ocssd_to_chunk_info_offset() and locate it next to
bdev_ocssd_to_disk_lba(). This will improve readability a little.

Besides, cache addr_shift first in bdev_ocssd_translate_lba() for
clarification.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I4c078e2002638d90b000b97f9f7cda90938d02ca
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5132
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
74438fc588 bdev/ocssd: Extract common operation from from_disk_lba() and lba_in_range()
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifd6b2b76c80d7b12bffdff6f9684b6c8dc3e3ed5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5131
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
ddc03b4584 bdev/ocssd: Factor out internal of bdev_ocssd_num_parallel_units()
Factor out the internal of bdev_ocssd_num_parallel_units() into an
new inline helper function ocssd_range_num_parallel_units(), and
apply the latter into a few functions.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I16550046ed2d6f543f66711810b30bd45f21c970
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5130
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
f90c6378a5 bdev/ocssd: Clean-up three small helper functions for zone
Clean-up bdev_ocssd_num_zones(), bdev_ocssd_get_zone_by_lba(),
and bdev_ocssd_get_zone_by_slba() to make a little easier to read
and understand.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I13c92dc86dc3855f1ec9ab5ae9d7097607f20512
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5129
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
729f7ec516 bdev/ocssd: Consolidate num_zones() calls in bdev_ocssd_init_zones()
Cache the return value of bdev_ocssd_num_zones() in bdev_ocssd_init_zones()
to improve readability.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: If71b40221694e512617389da03720211744f3b5c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5128
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-19 09:45:40 +00:00
Shuhei Matsumoto
7e4b8d79a4 bdev/ocssd: Adjust location of num_parallel_units() and num_zones()
Locating bdev_ocssd_num_parallel_units() and bdev_ocssd_num_zones()
closer to the related helper functions makes us a little easier to
understand the code.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0d96034bf26b2b1a39d879654ca2b30289349e4d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5127
Community-CI: Broadcom CI
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-19 09:45:40 +00:00
yidong0635
d73077b84a lib/jsonrpc: Add a new API to send response for writing bool result.
There are many duplicated codes about sending response for writing bool result.
That we need a function to do this.
Then we can reduce many codes.

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: Ic439111b1e9ca1013f8c657ab925f0c27a7be699
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5033
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 15:08:47 +00:00
Shuhei Matsumoto
fd798f8f9e bdev/nvme: Refactor dump_info_json() to clarify querying NVMe driver
Following a previous patch, cache pointers to spdk_nvme_ctrlr and
spdk_nvme_ns in bdev_nvme_dump_info_json().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I769d112f815e29262d52faee5ec17ccb914a7154
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5104
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-16 12:26:35 +00:00
Shuhei Matsumoto
b470ed628d bdev/nvme: Get the connected trid from NVMe driver in dump_info_json()
bdev_nvme_failover() updates trid of spdk_nvme_ctrlr using
spdk_nvme_ctrlr_set_trid(). Hence trid of spdk_nvme_ctrlr is always
up-to-date.

Hence bdev_nvme_dump_info_json() can query trid simply by calling
spdk_nvme_ctrlr_get_transport_id(). The queried trid is a const
parameter.  Hence add const to nvme_bdev_dump_trid_json().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id04881f9e7596b910bdf26c4f14f1ebcb3cdbbee
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5103
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-16 12:26:35 +00:00
Shuhei Matsumoto
1388d02447 bdev/nvme: Refactor io_type_supported to clarify querying NVMe driver
bdev_nvme_io_type_supported() queries NVMe driver to return if the
specified IO type is supported. To clarify it, cache pointers to
struct spdk_nvme_ctrlr and spdk_nvme_ns.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0956506e720722216e03cb808f61737ada617329
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5102
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
974daa68a6 bdev/nvme: Factor out creating NVMe bdev in nvme_ctrlr_populate_standard_namespace()
In the following patches, nvme_bdev_subsystem will be added and nvme_bdev_ns
will be added to not nvme_bdev but nvme_bdev_subsystem.

To do it easier, factor out creating an NVMe bdev into an new helper
function nvme_bdev_create().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ifa902912ba1ea979153b04ef4ac9fae10c09b7e2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5018
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
744414c087 bdev/nvme: Pass nvme_ch to bdev_nvme_reset() to queue I/O easily
bdev_nvme_reset() has been called only by a single caller now.
Hence pass nvme_ch to bdev_nvme_reset() to queue I/O easily.

This will improve readability and clarify the logic.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Idc22cb499fcf8455a2b04d44688f999344abc352
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4992
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
a563df3b83 bdev/nvme: Factor out the common opeartion of bdev_nvme_reset()
Factor out the common operation between internal calls and bdev I/O
calls of bdev_nvme_reset() into an new helper function
_bdev_nvme_reset().

This is to improve readability and to clean-up the operation only
for bdev I/O calls in the next patch.

Replace bdev_nvme_reset() by _bdev_nvme_reset() for internal calls.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7580a8fb40d5a1d694d5f913cde770ca95a0b0c8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4991
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
b14c7cd8f2 bdev/nvme: Rename _bdev_nvme_reset to _bdev_nvme_reset_ctrlr
_bdev_nvme_reset_ctrlr will figure out what it really does.
_bdev_nvme_reset will be used by an new helper function in the
next patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I890f962529a663ea412bcd416ef9ba31fadfbf61
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4990
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
460bd99a28 bdev/nvme: Consolidate error paths of _bdev_nvme_reset_create_qpairs_done()
Clarify the operation done in the error paths for readability.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Icb8a1a7c569e88d474737d0449c8eef73759a633
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4989
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
4e8f5d39ec bdev/nvme: Fix bdev_nvme_delete() to call ctrlr_get_by_name() and set destruct to true in a lock
bdev_nvme_delete() had called nvme_bdev_ctrlr_get_by_name() and
then called remove_cb(). But nvme_bdev_ctrlr_get_by_name() had not
been guarded by lock and remove_cb() parsed the list again by using
spdk_nvme_ctrlr as a key.

These were not safe and efficient.

This patch refines bdev_nvme_delete() to inline remove_cb() into
it and acquire mutex before calling nvme_bdev_ctrlr_get_by_name().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibf39859809efa6f22899353c53b7b1eef58aa470
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4842
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
edbb7ace72 bdev/nvme: Include path removal into bdev_nvme_failover()
Add the second parameter remove and include path removal into
bdev_nvme_failover(). Additionally, bdev_nvme_failover() returns
only two return values, 0 or -EAGAIN, and hence change
bdev_nvme_remove_trid() to return the return value of
bdev_nvme_failover() directly.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ife560f886e32ecec23691e01e87069502e27cc0c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4867
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
b0100cef46 bdev/nvme: Extract failover case from bdev_nvme_reset() into bdev_nvme_failover()
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ib0517ed5bcf9ee5741f7a4d7106e2bc0ba7c36cc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4866
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
f1fb19e332 bdev/nvme: Fix the race condition between destruct and reset controller
nvme_bdev_ctrlr_destruct() had checked first if poller is already
registered. On the other hand, nvme_bdev_ctrlr_destruct() had been
used as a poller function.

Hence nvme_bdev_ctrlr_destruct() had no way to unregister poller
if destruct and reset controller were raced.

This patch fixes the issue. The previous patch ensures nvme_bdev_ctrlr_destruct()
is called only once.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iba5424c42a4a3e5f03575df2616ec2a817e38f51
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4827
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
01f769c62a bdev/nvme: Ensure ctrlr->destruct is set only once
Checking if destruct is false and setting destruct to true are
separated by mutex in remove_cb() and bdev_nvme_library_fini().

It was possible that multiple threads called nvme_bdev_ctrlr_destruct()
because the caller could call nvme_bdev_ctrlr_destruct() before
setting destruct to true after knowing it was false.

This patch ensures that nvme_bdev_ctrlr_destruct() is called only once.

Set ctrlr->destruct to true without releasing mutex after checking
if ctrlr->destruct is false.

If destruct is set to true before calling nvme_ctrlr_depopulate_namespaces(),
nvme_ctrlr_depopulate_namespace_done() may call nvme_bdev_ctrlr_destruct()
because it is likely that reference count is zero and destruct is true.
In this case, remove_cb() or bdev_nvme_library_fini() cannot call
nvme_bdev_destruct() after returning from nvme_ctrlr_depopulate_namespaces().

On the other hand, if a controller has no namespace,
nvme_ctrlr_depopulate_namespaces() does nothing and
nvme_ctrlr_depopulate_namespace_done() is not called. Hence
remove_cb() or bdev_nvme_library_fini() has to call nvme_bdev_destruct()
after returning nvme_ctrlr_depopulate_namespaces().

To unify both cases, initialize reference count to one as a sentinel value
and remove_cb() and bdev_nvme_library_fini() decrement reference count
and then calls nvme_bdev_ctrlr_destruct() if reference count is zero
after returning from nvme_ctrlr_depopulate_namespaces().

Additionally, add assert to check if reference count is not negative
to find bug in future.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I8a617b5aa4d0a9faff832e63c2ed4b353341dd6b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4817
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
844e6bfa8c bdev/nvme: Add subnqn of controller to bdev_nvme_dump_info_json()
subnqn will be used to manage subsystem, and so add it to the output
of bdev_nvme_dump_info_json().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id28023754fa19d14aa9297f4e6676d235f024e0f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4974
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
93a91be642 bdev/nvme: Factor out common operation of create_cb() and reset_create_qpair()
To improve readability and make the following patches easier,
factor out the common operation of bdev_nvme_create_cb() and
_bdev_nvme_reset_create_qpair() into bdev_nvme_create_qpair(),
and factor out the main operation of bdev_nvme_destroy_cb()
into bdev_nvme_destroy_qpair(). bdev_nvme_destroy_qpair() is used
in the error path of bdev_nvme_create_qpair().

Updating g_opts.io_queue_requests again is no harm and so is done
in bdev_nvme_create_qpair().

Use the term nvme_ch in bdev_nvme_create_cb() and bdev_nvme_destroy_cb()
for clarification.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie0a4251023037958d122fbb5d7ee72d42238b3ed
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4981
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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-16 12:23:04 +00:00
Shuhei Matsumoto
0768aa10e3 bdev/nvme: Rename ch by nvme_ch of create_cb() and destroy_cb()
This change will make the next patch smaller and its review easier.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I2784fa74dce98676958180bbf80a9a4f938454db
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5101
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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-16 12:23:04 +00:00
Liu Xiaodong
b7f7bbd16b sock/uring: reap if some sock has data in pipe
Since spdk_sock_group_poll should do level trigger to
the callback func registered in spdk_sock_group_add_sock,
if there is data in pipe, but not event occurs, poll func
should still reap sock who has data in pipe.

Change-Id: If3a983f80fd04708e45ad0398c7d34018ec52bc7
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5072
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2020-11-16 12:22:43 +00:00
sunshihao520
bf13dc4801 bdev/rpc: use goto to make code reuse.
delte duplicate code and use goto to make code reuse.

Signed-off-by: sunshihao <sunshihao@huawei.com>
Change-Id: Ib5eae0d31699fa7e3a0e6147b1572d383208df0b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5052
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-11-11 01:02:31 +00:00
Shuhei Matsumoto
db853f0510 bdev/nvme: Consolidate nvme_ctrlr_populate_namespace_done() calls
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I1190740d949eba78e1b9f8915a5b044d0cec1d9e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4919
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-06 08:11:50 +00:00
Shuhei Matsumoto
4a9d0af5a8 bdev/nvme: Register nvme_bdev_ctrlr to the argument of the timeout callback
This change removes the necessity to get nvme_bdev_ctrlr by calling
nvme_bdev_ctrlr_get_by_name() and simplifies the code.

bdev_nvme_reset() checks if nvme_bdev_ctrlr->destruct is false first.

Hence we will not degrade stability.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7a3baab666644c3063af404905284c3e16bc62ab
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4843
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: Aleksey Marchuk <alexeymar@mellanox.com>
2020-11-06 08:11:50 +00:00
Rafal Stefanowski
ebd8ef4bc5 bdev/ocf: Fix metadata updater call
OCF metadata updater is handling all the requests at once and when
it finishes the cache can deinitialize, so in the rare circumstances
when the thread is not aware of cache not existing any more, there
is another metadata kick request and check for the random pointer
is performed instead of expected cache.
The solution is to increase/decrease cache ref count prior sending
a message to a thread and after metadata has been updated.

Fixes #1533

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
Change-Id: I77d2ae400110fcb4d491350e5fec334245f4bb90
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5030
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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-11-06 08:11:19 +00:00
Ben Walker
7dbe9cfa0f bdev/nvme: When detecing multipath, only compare active namespaces
Calling spdk_nvme_ns_get_data(ns) on an inactive namespace will crash.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: Ib8cfa84e785a4a04dc3b1826c700a22eeec51e3c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5013
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>
2020-11-05 09:40:33 +00:00
Alexey Marchuk
9b19abae3c sock/posix: Disable zcopy send by default
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: I4825c681d742946dfcf5bdc209356194766a15cd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4978
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>
2020-10-30 14:51:34 +00:00
yidong0635
eb9577f8d5 module/nvme: Fix warning about scanbuild.
Analyzer treats these as warning, they are unused.

Issue:
bdev_nvme_rpc.c:706:7: warning: Although the value
stored to 'rc' is used in the enclosing expression,
the value is never actually read from 'rc'
        if ((rc = spdk_nvme_ctrlr_reset(firm_ctx->ctrlr)) != 0) {
             ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bdev_nvme_rpc.c:851:8: warning: Although the value
stored to 'rc' is used in the enclosing expression,
the value is never actually read from 'rc'
         if ((rc = spdk_bdev_open(bdev2, true, NULL, NULL, &desc)) != 0) {
              ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
nvme_rpc.c:375:10: warning: Although the value stored
to 'rc' is used in the enclosing expression, the value is
never actually read from 'rc'
        return rc = val->type == SPDK_JSON_VAL_STRING ? -ENOMEM : -EINVAL;
                ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: I1d58db97b00ac2d102c1a46d7852c2ce3f559fda
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4824
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-10-27 08:42:32 +00:00
Liu Xiaodong
47962dc7a3 bdev_aio: fix interrupt mode notify error
Change-Id: Ie4492aa33028e8090da96e2b592b20293d694120
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4865
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
2020-10-26 11:49:03 +00:00
Liu Xiaodong
ad8c05dc7c bdev_aio: apply interrupt mode
If interrupt is set, related poller functions will be
registered to thread interrupt  instead of poller.
interrupt_tgt can create aio bdev now.

Change-Id: Id777a55c8b7dc7a220f94ab837f7039ecea4fcb4
Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4273
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>
2020-10-23 16:23:48 +00:00