rpc: Add thread_get_io_channels RPC

Add an new JSON RPC thread_get_io_channels to retrieve IO channels
of the threads. IO channel don't have its own name and so get the
name of the corresponding IO device instead.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id8fbb328ffba09e1eace35994cdbf36b24832b82
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/887
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: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-02-13 07:19:11 -05:00 committed by Tomasz Zawadzki
parent 8e05b15c11
commit 49cffc1e68
4 changed files with 103 additions and 0 deletions

View File

@ -663,6 +663,50 @@ Example response:
}
~~~
## thread_get_io_channels {#rpc_thread_get_io_channels}
Retrieve current IO channels of all the threads.
### Parameters
This method has no parameters.
### Response
The response is an array of objects containing IO channels of all the threads.
### Example
Example request:
~~~
{
"jsonrpc": "2.0",
"method": "thread_get_io_channels",
"id": 1
}
~~~
Example response:
~~~
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tick_rate": 2500000000,
"threads": [
{
"name": "app_thread",
"io_channels": [
{
"name": "nvmf_tgt",
"ref": 1
}
]
}
]
}
}
~~~
# Block Device Abstraction Layer {#jsonrpc_components_bdev}
## bdev_set_options {#rpc_bdev_set_options}

View File

@ -284,6 +284,49 @@ spdk_rpc_thread_get_pollers(struct spdk_jsonrpc_request *request,
SPDK_RPC_REGISTER("thread_get_pollers", spdk_rpc_thread_get_pollers, SPDK_RPC_RUNTIME)
static void
rpc_get_io_channel(struct spdk_io_channel *ch, struct spdk_json_write_ctx *w)
{
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "name", spdk_io_device_get_name(ch->dev));
spdk_json_write_named_uint32(w, "ref", ch->ref);
spdk_json_write_object_end(w);
}
static void
rpc_thread_get_io_channels(void *arg)
{
struct rpc_get_stats_ctx *ctx = arg;
struct spdk_thread *thread = spdk_get_thread();
struct spdk_io_channel *ch;
spdk_json_write_object_begin(ctx->w);
spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(thread));
spdk_json_write_named_array_begin(ctx->w, "io_channels");
TAILQ_FOREACH(ch, &thread->io_channels, tailq) {
rpc_get_io_channel(ch, ctx->w);
}
spdk_json_write_array_end(ctx->w);
spdk_json_write_object_end(ctx->w);
}
static void
spdk_rpc_thread_get_io_channels(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
if (params) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"'thread_get_io_channels' requires no arguments");
return;
}
rpc_thread_get_stats_for_each(request, rpc_thread_get_io_channels);
}
SPDK_RPC_REGISTER("thread_get_io_channels", spdk_rpc_thread_get_io_channels, SPDK_RPC_RUNTIME);
static void
rpc_framework_get_reactors_done(void *arg1, void *arg2)
{

View File

@ -2290,6 +2290,13 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
'thread_get_pollers', help='Display current pollers of all the threads')
p.set_defaults(func=thread_get_pollers)
def thread_get_io_channels(args):
print_dict(rpc.app.thread_get_io_channels(args.client))
p = subparsers.add_parser(
'thread_get_io_channels', help='Display current IO channels of all the threads')
p.set_defaults(func=thread_get_io_channels)
def env_dpdk_get_mem_stats(args):
print_dict(rpc.env_dpdk.env_dpdk_get_mem_stats(args.client))

View File

@ -67,3 +67,12 @@ def thread_get_pollers(client):
Current pollers.
"""
return client.call('thread_get_pollers')
def thread_get_io_channels(client):
"""Query current IO channels.
Returns:
Current IO channels.
"""
return client.call('thread_get_io_channels')