Commit Graph

620 Commits

Author SHA1 Message Date
Jim Harris
6b97cccf34 bdev, bdev_nvme: deprecate VTUNE support
This VTune integration was added many years ago, but
hasn't been tested and to my knowledge is not being
used by anyone.  The statistics it enables are very
limited, specific to the bdev nvme module with no
insight into the rest of an SPDK application.

So deprecate this support now, we will remove it
immediately after the v23.01 release.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I5552d85084c350e9d0b2570946801acd65a89d64
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16294
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2023-01-16 08:30:47 +00:00
GangCao
58396fb135 lib/bdev: check valid pointer before calling free
Change-Id: I4fbf2d86119d4bacafccb6fdf6a67c7ef66c865c
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16175
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2023-01-10 13:14:01 +00:00
Mike Gerdts
5d41f22d24 bdev: spdk_bdev_module_init_done with async init
spdk_bdev_module_init() must only be called if the module sets
async_init to true. This patch fixes the doc string to match the
implementation and adds an assert() to catch API usage errors early.

Change-Id: I677345de028c8f7597ecf81ff9b9b855867bbf01
Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16133
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 <smatsumoto@nvidia.com>
2023-01-10 13:13:17 +00:00
Shuhei Matsumoto
f287da5cb0 bdev: Fix the bug that counters for copy command were not reset
Fix the bug that counters for copy command, bytes_copied, num_copy_ops,
and copy_latency_ticks were not reset via bdev_reset_io_stat() function.

Reported-by: Richael Zhuang <richael.zhuang@arm.com>
Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Ia7ad415d051a010e515c21fcb5c73f8835c37f78
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16185
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2023-01-10 13:12:05 +00:00
Mike Gerdts
4bb902a6f4 bdev: add claim type
In preparation for supporting additional claim types, create a claim
type that represents the current claim type.  Everything that sticks to
the public APIs should continue to work as before.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I0d02e4b3f4bbf4eb5a7391028aa31e999f9da915
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15286
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2023-01-05 23:28:32 +00:00
Mike Gerdts
9fd2f931cd bdev: claim_module becomes claim.v1.module
In preparation for an updated claims API, refactor
bdev->internal.claim_module into a union that will eventually hold
different information based on the the type of claim.

Change-Id: I7ade6f03128bdb0f8375a95ae953cb63d6aa686d
Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15285
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>
Community-CI: Mellanox Build Bot
2023-01-05 23:28:32 +00:00
Mike Gerdts
93b53c0268 bdev: call bdev_ok_to_examine() once per examine
This calls bdev_ok_to_examine() once per bdev_examine(). Prior to this
commit, bdev_ok_to_examine() may be called up to twice per bdev module.

The results returned by bdev_ok_to_examine() could be affected by:

1. g_bdev_opts.bdev_auto_examime changing
2. spdk_bdev_examine() being called on a particular bdev
3. An alias being added for an existing bdev

It's not clear that anything good comes from racing in conditions 1 and
3. In condition 2, spdk_bdev_examine() calls bdev_examine(), so any
required examine_config() and examine_disk() calls are still made, just
now with less of a race with the previous invocation of
spdk_examine_confg().

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I496fc44fd74693837d6b449d7fa60f58f9dbf36f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15284
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
2023-01-05 23:28:32 +00:00
Mike Gerdts
7241a075be bdev: hold spinlock while changing claim_module
This closes races between concurrent spdk_bdev_module_claim_bdev()
and/or spdk_bdev_module_release_bdev() calls affecting the same bdev by
holding bdev->internal.spinlock while claiming and releasing a bdev. It
also closes a potential TOCTOU bug in that optimizing compilers probably
already eliminate in bdev_finish_unregister_bdevs_iter() and documents
that bdev->internal.claim_module is protected by
bdev->internal.spinlock.

This can be removed when the bdev_register_examine_thread deprecation
is removed.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: Ib48552df065d5172139a61bbc00b391f36552c0c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15282
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>
Community-CI: Mellanox Build Bot
2023-01-05 23:28:32 +00:00
Mike Gerdts
b5075dcc5b bdev: action_in_progress counting is racy
Since bdev_examine() can happen on any thread and it happens without any
other lock being held on the spdk_bdev_module, it is possible for
multiple threads to try to simultaneously increment
module->internal.action_in_progress. Decrements may also race.

This commit adds bdev_module->internal.spinlock and holds it while
modifying module->internal.action_in_progress.

This can be removed when the bdev_register_examine_thread deprecation
is removed.

Change-Id: I9c401eeb3c7c97c484e16fa9cfd82668b32e508b
Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15281
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>
Community-CI: Mellanox Build Bot
2023-01-05 23:28:32 +00:00
Mike Gerdts
a6e58cc44c bdev: examine and register on app thread
This introduces a deprecation for calling spdk_bdev_register() and
spdk_bdev_examine() on a thread other than the app thread. The
deprecation period starts in SPDK 23.01 and removal is expected in SPDK
23.05.

The intent of this deprecation is to ensure that bdev modules'
examine_config() and examine_disk() callbacks are only ever called on
the app thread. This largely a formalization of what has long happened
due to the RPC poller running on the first thread started by
spdk_app_start().

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: Ic9d7b87b6522be20357d2eab2d0c77cd5753452f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15690
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: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Mateusz Kozlowski <mateusz.kozlowski@intel.com>
2023-01-05 23:28:32 +00:00
Shuhei Matsumoto
53a9a8c4d1 bdev: Add counts per I/O error status into I/O statistics
Define struct spdk_bdev_io_error_stat privately in lib/bdev/bdev.c.

Add a pointer to struct spdk_bdev_io_error_stat to struct
spdk_bdev_io_stat.

Allocate spdk_bdev_io_error_stat for bdev and RPC, but do not allocate
spdk_bdev_io_error_stat for I/O channel.

Dump the contents of spdk_bdev_io_error_stat only if its total is
non-zero.

As a result of these, only spdk_bdev_get_device_stat() can query
spdk_bdev_io_error_stat for the bdev_get_iostat RPC. This will be
acceptable.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Idae868afe65347a96529eedc3dcc692101de4a29
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14826
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2023-01-04 08:22:31 +00:00
Shuhei Matsumoto
c134d11ca7 bdev: Rename io_stat helper functions to bdev_ + verb + _io_stat
The following patches will make some of io_stat helper functions
public APIs. Then, for consistency, bdev_ + verb + _io_stat will
be better naming rules.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: If36d4ed29253e87954c23c270e8414731d083f03
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15896
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Konrad Sztyber <konrad.sztyber@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@nvidia.com>
2023-01-04 08:22:31 +00:00
GangCao
1450c5470b lib/bdev: send back the eligible QoS IO to the original thread
Fix issue: #2815

Change-Id: Ic1533b9ed055734a721be0fd7159754e5db1791b
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15917
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-12-16 09:43:28 +00:00
Konrad Sztyber
5a3e64efe4 bdev: replace internal buffer pools with iobuf
The internal mempools were replaced with the newly added iobuf
interface.

To make sure we respect spdk_bdev_opts's (small|large)_buf_pool_size, we
call spdk_iobuf_set_opts() from spdk_bdev_set_opts().  These two options
are now deprecated and users should switch to spdk_iobuf_set_opts().

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ib1424dc5446796230d103104e272100fac649b42
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15328
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 <smatsumoto@nvidia.com>
2022-12-16 09:06:07 +00:00
Konrad Sztyber
f2409773de bdev: move max buf length calculation to a function
This is done in a couple of places, so it makes sense to extract it to a
separate function.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id34b2545d9912c2b7b65b1277711e9683db92658
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15327
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-12-16 09:06:07 +00:00
Richael Zhuang
36f8f8da27 bdev: remove bdev parameter
Remove bdev parameter from spdk_bdev_channel_get_histogram since
it's not used.

Change-Id: I89f0b142cc6f80ecf39811976995f738e4cfecdb
Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15837
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
2022-12-12 09:42:03 +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
Shuhei Matsumoto
d7ad7bca3c bdev: Add mode to bdev_reset_iostat RPC to reset only max/min fields
Both max and min should be reset periodically. We can use the queue
depth sampling poller to reset these but the queue depth sampling poller
is optional. We extend the bdev_reset_iostat RPC to support mode to
reset all or only max/min fields.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I9ce54892f6e808f6a82754b6930092f3a16d51ff
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15444
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
15040628ec bdev: Add min/max_latency_read/write/unmap_ticks into I/O statistics
Add max/min_read/write/unmap_latency_ticks into the struct
spdk_bdev_io_stat.

When initializing or resetting the instance of the struct
spdk_bdev_io_stat, initialize max to 0 and min to UINT64_MAX.

Then update max if a new value is larger than the current max,
and update min if a new value is smaller than the current min.

For the bdev_get_iostat RPC, it prints max and prints min if min is not
UINT64_MAX or 0 if min is UINT64_MAX.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I1b30b3825c15e37e9f0cf20104b866186de788a2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14825
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
cf4e8664bb bdev: Add bdev_reset_iostat RPC
Add a helper function bdev_reset_device_stat() to reset I/O statistics.
This funciton is used for the bdev_reset_iostat RPC.

We do not have any plan to use bdev_reset_device_stat() outside
lib/bdev. Hence, we do not add this as a public API.

Then, add a new RPC bdev_reset_iostat to reset I/O statistics of a
single bdev or all bdevs.

Resetting I/O statistics affects all consumers. Add a note to CHANGELOG
and doc/jsonrpc.md.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I97af09107b5c3ad1f9c19bf3cbf027457c4fbae7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15350
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
319d1cbb4e bdev: Store bdev_io data into local variables to update I/O statistics
Hold not only io_stat pointer but also num_blocks and blocklen in local
variables.

This will shorten and simplify bdev_io_update_io_stat(), and improve
readability and changeability.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I527b72538a169a1faafd32863ff539306a8763a9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15732
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
8985382b96 bdev: Factor out I/O trace update at completion into a helper function
The following patches will add max/min latencies and more optional
counters. This factorization will improve the readability.

In addition to factorization, add spdk_likely to check if completed
successfully or not.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I57581ece2b73d486aa138f8d26a5afaf6953a322
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15480
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
fab3558f2e bdev: Change name and parameter order of function to dump I/O statistics
For consistency, rename a JSON dump function by bdev_io_stat_dump_json()
and change the parameter order.

Other public APIs and function pointers in the generic bdev layer,
spdk_bdev_dump_info_json(), spdk_bdev_fn_table::dump_info_json, and
spdk_bdev_fn_table::write_config_json have a json_write_ctx pointer
as the last parameter. For consistency, swap a statistics pointer and
a json_write_ctx pointer.

This is another preparation to extend I/O statistics to include error
counters and module specific counters to output these via the
bdev_get_iostat RPC.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I6f3bb6f2752f7da856d4fe66c0f1f8a2eedc176b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15731
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: Aleksey Marchuk <alexeymar@nvidia.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
5d269efe96 bdev: Move helper function to dump I/O statistics into bdev.c
Move a JSON dump functionbdev_get_iostat_dump() for I/O statistics
into lib/bdev/bdev.c.

The next patch will rename the function and change the parameter order.

This is another preparation to extend I/O statistics to include error
counters and module specific counters to output these via the
bdev_get_iostat RPC.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I6a90d15fcbaa2e2a250167754135623bc9e7f362
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14837
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: Aleksey Marchuk <alexeymar@nvidia.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
24eab32532 bdev: Add helper functions to allocate/free/get spdk_bdev_io_stat
Add helper functions, bdev_io_stat_alloc(), bdev_io_stat_free(),
and bdev_io_stat_get() for struct spdk_bdev_io_stat.

Then replace a bdev_io_stat_add() call by bdev_io_stat_get() at
spdk_bdev_get_device_stat() because the saved data is queried first.

This is another preparation to extend I/O statistics to include error
counters and module specific counters to output these via the
bdev_get_iostat RPC.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I9547757421a1de1b8cb44e0f8ade4b5c2bcad4e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15443
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
571638b9b9 bdev: Alloc spdk_bdev_io_stat dynamically for spdk_bdev
The following patches will extend I/O statistics to include error
counters and module specific counters to output these via the
bdev_get_iostat RPC.

In this case, the size of the struct spdk_bdev_iostat will be variable.

As a preparation, allocate spdk_bdev_io_stat dynamically.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I1979a9d867859d5cb5d05717bfcc677f07fa03f8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15479
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
2022-12-08 12:54:23 +00:00
Shuhei Matsumoto
e84bc517c3 bdev: Alloc spdk_bdev_io_stat dynamically for spdk_bdev_channel
The following patches will extend I/O statistics to include error
counters and module specific counters to output these via the
bdev_get_iostat RPC.

In this case, the size of the struct spdk_bdev_iostat will be variable.

As a preparation, allocate spdk_bdev_io_stat dynamically.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I50b57f792b451cf748ea8eb0611fe65d693d5a14
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15478
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
2022-12-08 12:54:23 +00:00
Mike Gerdts
6e140e3544 bdev: enforce documented lock requirements
Replace comments saying that particular locks must be held with
assertions that enforce that those locks are held. Remove the comments
so that there is no chance of comments and code getting out of sync in
the future.

This also fixes a caller of bdev_close() that did not hold a required
lock.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I3a540f1ad9b9826f925c523986334aa8fcd302f2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15440
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-12-06 21:20:17 +00:00
Mike Gerdts
0dc6aac101 bdev: use SPDK spinlocks
Transition from pthread spinlocks to SPDK spinlocks for improved error
checking.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I7877c3a4601d7d5cf03e632df493974f97782272
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15439
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-12-06 21:20:17 +00:00
Konrad Sztyber
9e647c1f46 bdev: disallow get_buf() calls from other threads
This is unsafe, because we touch need_buf_* queues, which aren't
thread-safe.  Also, documented this requirement in
spdk_bdev_io_get_buf()'s description.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Iabc141e051c543fdd51f079ae212f69e980d8148
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15668
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-12-05 09:51:26 +00:00
Richael Zhuang
f192c11bbf bdev: support to get histogram per channel
Added new API 'spdk_bdev_histogram_get_channel' to get histogram of
a specified channel for a bdev. A callback function is passed to it
to process the histogram.

Change-Id: If5d56cbb5fe6c39cda7882f887dcc9c6afa769ac
Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15539
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
2022-11-29 08:28:57 +00:00
wanghailiangx
0da97a15cc lib/bdev: print num_blocks and the write_unit_size in SPDK_ERRLOG
Print out the specific values in this SPDK_ERRLOG,
this can help to find where the error is.

Change-Id: I2a38aa2d4270e0bbf554ddb348a73d40967d1b16
Signed-off-by: wanghailiangx <hailiangx.e.wang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15618
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
2022-11-28 09:46:12 +00:00
Mike Gerdts
8dbaca1300 bdev: use spinlock instead of mutex
SPDK threads generally run on dedicated cores and locks should be rarely
contended. Thus, putting a thread to sleep while waiting on a mutex does
not free up CPU cycles for other pthreads or processes. Even when
running in interrupt mode, lock contention should be low enough that
spinlocks are a net win by avoiding context switches.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I6e2e78b2835bbadb56bbec34918d998d75280dfd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15438
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: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2022-11-24 10:08:17 +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
yupeng
c0c333e2ed bdev: provide all available bdevs when loop bdevs
The bdev hot remove might be an async process. The bdev_open will
return an error during the hot remove process. If someone invoke the
bdev_get_bdevs API when a bdev is in the middle of a hot remove
process, the spdk_for_each_bdev function will stop its loop when a
bdev_open return an error. Thus the bdev_get_bdevs will only return
partual bdevs or even return an empty list if the hot remove bdev is
the first bdev in the loop. When spdk_for_each_bdev and
spdk_for_each_bdev_leaf loop for each bdevs, if a bdev returns an
error, we skip that bdev instead of stop the whole loop.

Signed-off-by: Peng Yu <yupeng0921@gmail.com>
Change-Id: Ib35b817e23e47569fc5762a883b4ff8e322ae173
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15322
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-22 10:03:48 +00:00
Krzysztof Karas
a1c7ae2d3f bdev: remove generation of UUIDs for bdevs that do not provide one
Remove automatic generation of UUIDs for bdevs
that do not provide this value themselves.
This is to clarify whether this field can be
depended upon.

Modified match files to reflect change in UUID
generation.

Disabled nullglob shell option, as it deletes
empty arrays during word splitting. Bdevs with no
aliases would instead of "[]", have nullpointer
printed, which makes resulting JSON invalid.

Part of enhancement proposed in #2516.

Change-Id: Ic1d5f8f8d001ae1a219e876aef2a19b1ff0b2f2c
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15150
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
2022-11-18 08:38:13 +00:00
Shuhei Matsumoto
0ac95a684b bdev: Consolidate two TRACE_BDEV_IO_START calls into a single call
For I/Os controlled by QoS, TRACE_BDEV_IO_DONE is collected after
redirecting to the original thread. Hence, TRACE_BDEV_IO_START should
be collected on the original thread too.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I15411be823450ee5ddaa7582509a7aa068476fc5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14824
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-17 08:56:49 +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
Richael Zhuang
cabbb25d5d bdev: add API to get submit tsc of a bdev I/O
Add API spdk_bdev_io_get_submit_tsc to get submit tsc of a bdev I/O,
which can be used in bdev modules to avoid calling expensive
spdk_get_ticks().

Change-Id: Ifbcecb1bc663344997c5e73b72a1dfb5d0422946
Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14989
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: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-04 10:15:46 +00:00
GangCao
7f7b468b48 lib/bdev: new __io_ch_to_bdev_ch and __io_ch_to_bdev_mgmt_ch utilities
Change-Id: Ie7d818a9a648e28cd191588164420173149af38b
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15167
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-02 15:25:21 +00:00
GangCao
cb55e8493f Lib/Bdev: update calling to spdk_bdev_for_each_channel
Change-Id: I541ccffc90e7dc54b416da385e862e952d9db71d
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14638
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-02 15:25:21 +00:00
Evgeniy Kochetov
8c3590a983 bdev: Add copy IO statistics
Signed-off-by: Evgeniy Kochetov <evgeniik@nvidia.com>
Change-Id: Id51ac80bce33a27a8ccea273c076f39019b98339
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14348
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
2022-11-02 10:33:00 +00:00
Evgeniy Kochetov
d14afd5000 bdev: Add copy IO type
Copy operation is defined by source and destination LBAs and LBA count
to copy. For destiantion LBA and LBA count we reuse exiting fields
`offset_blocks` and `num_blocks` in `struct spdk_bdev_io`. For source
LBA new field `src_offset_blocks` was added.

`spdk_bdev_get_max_copy()` function can be used to retrieve maximum
possible unsplit copy size. Zero values means unlimited. It is allowed
to submit larger copy size but it will be split into several bdev IOs.

Signed-off-by: Evgeniy Kochetov <evgeniik@nvidia.com>
Change-Id: I2ad56294b6c062595c026ffcf9b435f0100d3d7e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14344
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
2022-11-02 10:33:00 +00:00
GangCao
f0494649e3 Lib/Bdev: add the new API spdk_bdev_for_each_channel
And also related function pointers and APIs:
	spdk_bdev_for_each_channel_msg;
	spdk_bdev_for_each_channel_done;
	spdk_bdev_for_each_channel_continue;

Change-Id: I52f0f6f27717d53c238faf2f998810c9c5ee45d4
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14614
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>
Community-CI: Mellanox Build Bot
2022-10-28 06:51:19 +00:00
liu.darong
7e17de3d81 bdev/trace: add support to trace with bdev name
Fixes #2585

Signed-off-by: liu.darong <liu.darong@xsky.com>
Change-Id: I3f9b6d4719b5eed004f383e86db8a17b8b0287f5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13823
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-10-25 07:12:52 +00:00
GangCao
8afb3d0037 lib/bdev: return error when failing to get resource
To fix issue: 2719

Change-Id: I983ef607fad154608fff9bb9355645968caf0c5a
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14746
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2022-10-04 07:07:04 +00:00
Artur Paszkiewicz
a51649faf6 bdev: use write_unit_size for acwu and write_zeroes
Change-Id: Idbcfc110c153a62082f84f3304f1e245f2fc3daf
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14716
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>
2022-09-29 22:52:45 +00:00
Artur Paszkiewicz
d6e9827e9f bdev: split writes based on write_unit_size
Add new bdev property split_on_write_unit which, if set to true, causes
writes to be split to match write_unit_size and fail if not aligned to
or not multiple of write_unit_size.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Change-Id: Id49f58a3288ddf5cfe4921ce4020ae4bcdd67298
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11390
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-09-29 22:52:45 +00:00
Krzysztof Karas
dfc9894396 bdev: send bdev reset based on outstanding IO and a new timeout parameter
A new parameter io_drain_timeout has been added to spdk_bdev
structure. If this value is unset, the bdev reset behavior
does not change.
The io_drain_timeout controls how long a bdev reset must wait for IO
to complete prior to issuing a reset to the underlying device.
If there is no outstanding IO at the end of that period, the reset
is skipped.

Change-Id: I585af427064ce234a4f60afc3d69bc9fc3252432
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14501
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2022-09-22 19:18:30 +00:00
Damiano
6defafc913 bdev: Add functions to [hole,data] seek
These functions start from a given offset and seek for next
data or for next hole. For bdevs that do not support seeking,
it is assumed that only data and no holes are present

Signed-off-by: Damiano Cipriani <damiano.cipriani@suse.com>
Change-Id: I6bc831970223333b25683f60ce3fcbbfebb5bb81
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14361
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
2022-09-15 08:23:56 +00:00