Commit Graph

27 Commits

Author SHA1 Message Date
Ben Walker
c1dc8cd584 thread: Rename io_channel.h to thread.h
Leave io_channel.h in the repository and make it simply
include thread.h for backward compatibility.

Change-Id: I5320fb8e9e5bc6e39ee9ce44cd79570194a8b841
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/414699
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Madhu Pai <mpai@netapp.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2018-06-12 15:24:07 +00:00
Yanbo Zhou
881cbb60a4 include/io_channel.h: add comments for callback functions
Change-Id: I84bd599e9ad889843cd7d0db9954603b0c17bd6a
Signed-off-by: Yanbo Zhou <yanbo.zhou@intel.com>
Reviewed-on: https://review.gerrithub.io/407712
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-05-24 21:33:41 +00:00
Roman Sudarikov
c3bc40a6ef io_channel: add return value to pollers
This will be used to track time used in pollers - each poller can now
indicate if it found any work to do or not.

For cases where it was obvious and the infrastructure was already in
place, existing pollers have been modified to return 0 or a positive
value to indicate whether work was done.  Other pollers have been
modified to return -1 by default, indicating that the poller isn't
indicating anything about whether work was performed.  This will allow
us to find un-annotated pollers easily in the future and fix them
incrementally.

Change-Id: Ifebfa56604a38434fac5c76ba7263267574ff199
Signed-off-by: Roman Sudarikov <roman.sudarikov@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/391042
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-03-13 11:16:20 -04:00
Daniel Verkamp
abe4c73f40 io_channel: use spdk_poller_fn consistently
There are two separate function pointer types declared in io_channel.h:
spdk_thread_fn for cross-thread messages, and spdk_poller_fn for
pollers.  They currently have the same signature, but this will be
changing in an upcoming patch, so we need to fix the poller-related
functions to use the correct type (a few were using spdk_thread_fn by
mistake).

Change-Id: I0f0d8f1eea9905395125fc91e0355a49e65be99e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403598
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2018-03-13 11:16:20 -04:00
Yanbo Zhou
4dbff01ba3 include/io_channel.h: add comments for public APIs
Change-Id: I85dfac522eb77e5d53fb2fc9c5bb8a75463f1480
Signed-off-by: Yanbo Zhou <yanbo.zhou@intel.com>
Reviewed-on: https://review.gerrithub.io/392919
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-03-02 13:26:59 -05:00
Jim Harris
fb8acd90aa util: make spdk_io_channel_get_ctx() inline
This requires exposing struct spdk_io_channel in the
public header - mark it as internal with Doxygen
comments to make it extra clear that applications
should not use the data structure directly.

This is a very hot function in the main I/O path,
so making this function inline has a significant
performance benefit.  A bdevperf microbenchmark
using null bdevs shows a 11% improvement.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I70e30e184000705704bb004e8da1c7476a6aceeb

Reviewed-on: https://review.gerrithub.io/393824
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2018-01-09 12:46:35 -05:00
Ben Walker
5165aee686 channel: Make spdk_for_each_channel support async operations
While iterating, allow the user to perform asynchronous
operations. To continue iteration, the user is expected
to call spdk_for_each_channel_continue.

Change-Id: Ifd7d03d5fbf17cf13843704274b036d49ca0484a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/391309
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
2017-12-14 12:05:07 -05:00
Dave Boutcher
f58bc31505 include: wrap header files in extern "C" for c++
Update all the header files in include/spdk to include
extern "C" declarations.

Change-Id: I43299f68e962d0df18c1b23fbbaa19bc924fcb96
Signed-off-by: Dave Boutcher <dboutcher@ocient.com>
Reviewed-on: https://review.gerrithub.io/390896
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-12-07 19:13:47 -05:00
Ben Walker
111eef8f19 channel: Add spdk_for_each_thread
This function will send a message to each allocated
thread asynchronously, then call a callback on
the originating thread.

Change-Id: I3ebe7c6c5b460a944a32487d1091b601a482a256
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/388041
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-11-28 15:29:35 -05:00
Ben Walker
9c35e39c54 event: Move spdk_poller_register to io_channel
Make this generic and not directly dependent on
the event framework. That way our libraries can
register pollers without adding a dependency.

Change-Id: I7ad7a7ddc131596ca1791a7b0f43dabfda050f5f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387690
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-28 12:30:37 -05:00
Ziye Yang
5fa2274ccb io_channel: change return type of spdk_channel_msg
Change the return type of spdk_channel_msg from
void to int. If this msg executed in a failure,
we do not need continue sending the message to other
threads, we can just tell the original thread, and
let the orgiginal thread call the spdk_channel_for_each_cpl
call back.

Thus we can track the qpair creation/destroy case for bdev
reset in nvme bdev module;

Change-Id: Ide9dffd1f84a29fcf61d8339a9ece2a0245d968d
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/387284
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-11-17 11:25:14 -05:00
Ben Walker
95bbc6bf29 io_channel: Add spdk_io_channel_from_ctx
This is the inverse operation of spdk_io_channel_get_ctx.

Change-Id: Ica6593240dfb05cb53dc7ec910bc0a78270e81c0
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387679
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-11-17 11:11:23 -05:00
Daniel Verkamp
47182bd7c9 io_channel: allow user to provide a thread name
This moves the thread name setting code into the generic SPDK thread
setup code, so now all spdk_threads can be named, not just ones created
by the event framework.

Change-Id: I6c824cf4bcf12fe64a8e2fc7cdc2d6c949021e40
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375220
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-08-29 13:11:08 -04:00
Dariusz Stojaczyk
73358c99e1 util/nvme: added io_device unregister callback
Patch afe860ae deferred freeing the io_device. However, for nvme, the
io_device context (spdk_nvme_ctrlr) is still being destructed before
io_channels are destroyed, causing segfaults on hotremove.

This patch defers io_device context destruction and fixes nvme
hotremove.

Fixes: afe860aeb1 ("channel: Correctly defer unregisters if channels exist")
Fixes: 5533c3d208 ("util: defer put_io_channel")

Change-Id: I7af699174cac0c6c6a6faa2cc65418c47347eb9a
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/370459
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-07-20 16:07:02 -04:00
Dariusz Stojaczyk
ebaa8ff7f9 util: updated doc of spdk_put_io_channel
Patch 5533c3d2 changed spdk_put_io_channel behavior without updating the
docs. This patch fixes that.

Fixes: 5533c3d208 ("util: defer put_io_channel")

Change-Id: I587ce13f3caa4caa9d39e4ab85a197beea883f94
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/369720
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-07-17 19:06:42 -04:00
Daniel Verkamp
c013322dc6 io_channel: add helper to get an I/O channel's thread
This is faster than spdk_get_thread(), which iterates over all of the
threads under a lock until it finds the current one.

Change-Id: I957a68438efb5b7d632d2b9b1b567fed7714e02a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/365079
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-13 11:37:13 -04:00
Ben Walker
ff87d29cc3 io_channel: Add mechanism to call a function on each channel
For a given I/O device, call a user function on the correct
thread for each channel.

Change-Id: I568a443184ac834c80c5e36b80aa9b6f8bb0ac99
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362256
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-26 17:41:22 -04:00
Ben Walker
666bf939f1 io_channel: Rename io_channel_create_cb_t to spdk_io_channel_create_cb
Add spdk, remove _t

Change-Id: Ic05b405439020b5ec5f2098ab04d37a4dd3cb5b6
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362254
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-26 17:41:22 -04:00
Ben Walker
2ef5722f3c io_channel: Add a message passing callback
When a thread is registered, the user must provide
a function pointer that can pass a message to that thread.

Change-Id: I743b5e0d6e3b5118c0a68d2fcedbccdd6fb237f9
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362067
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2017-05-26 13:42:19 -04:00
Ben Walker
f1c5344b32 io_channel: Add a thread identifier
This will be used in the future to pass a message
to any given thread.

Change-Id: I3be5fe66244e360b7667427647fd8fdede110930
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362066
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-26 13:42:19 -04:00
Ben Walker
d969ac445a io_channel: Remove per-channel priority
This wasn't used anywhere and we currently believe there
are superior software-only techniques for controlling
quality of service.

Change-Id: Icdadd5870ed0629b338c307d2619bbc242c3e7a3
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362065
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-26 13:42:19 -04:00
Ben Walker
305cb239d2 io_channel: Remove unique flag
This is no longer used anywhere. For the places where we previously
used it, we've since found alternate solutions that do not
require it.

Change-Id: I738a80b95ef50348ce1c14969a3812b0a625b3fd
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/362064
Tested-by: <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-05-22 19:27:17 -04:00
Daniel Verkamp
45cab335bc include: move standard includes into spdk/stdinc.h
This is the first step toward isolating standard C and POSIX headers
into a single replaceable header file.

Change-Id: I527297f5e7260b01103018ad3429922962ee9add
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-05-08 10:11:01 -07:00
Jim Harris
08a6cba2f0 util: add stdbool.h include to io_channel.h
A previous commit added use of 'bool' but did not add
a stdbool.h include.  All files including io_channel.h
already were including stdbool.h, but adding it here
so that we do not depend on that for future usages.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iaa88a0747889fe02f327059c99bc751c9ab326f7
2016-09-30 15:30:25 -07:00
Jim Harris
32aa4fa0a3 util: add context parameter for unique I/O channels
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I296992b2e03b9b516cfd26726405e49616ad08a5
2016-09-28 07:53:47 -07:00
Jim Harris
c1e3a87bf7 util: add 'unique' parameter to spdk_get_io_channel
Some subsystems may wish to create unique I/O channels
which are not shared across all users of the same I/O
device on the same thread.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I3ade3675d57338cf85b6a301285e6f392bd6cd2e
2016-09-28 07:53:47 -07:00
Jim Harris
ee66e58e0a util: add spdk_thread and spdk_io_channel
This patch adds a basic framework for creating I/O channels
for I/O devices.  An spdk_io_channel represents a one-to-one
mapping between a calling thread (represented by spdk_thread)
and an I/O device that the thread will perform I/O operations
on.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I658ab7f995cc962f4e2a204e058cdd3ad3fd735d
2016-09-26 14:02:07 -07:00