From 0ab8393c605d617a186c66cb236109733a6e8f0c Mon Sep 17 00:00:00 2001 From: GangCao Date: Fri, 16 Dec 2022 01:32:47 -0500 Subject: [PATCH] examples/bdev/fio_plugin: add the RPC listen support With this support, user could send the RPC commands to FIO to query the IO statistics like output of below commands: root@storage35:/spdk# ./scripts/iostat.py cpu_stat: user_stat nice_stat system_stat iowait_stat steal_stat idle_stat 3.18% 0.00% 0.35% 0.00% 0.00% 96.46% Device tps KB_read/s KB_wrtn/s KB_dscd/s KB_read KB_wrtn KB_dscd TestPT 0.01 0.00 0.04 0.00 36.00 499608.00 0.00 Malloc1 0.61 0.00 2.42 0.00 36.00 31012820.00 0.00 Malloc3 0.01 0.00 0.04 0.00 36.00 499608.00 0.00 Change-Id: I694119313fb92cf9798c6897e61f788c2ac1f013 Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15984 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Xiaodong Liu Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- examples/bdev/fio_plugin/fio_plugin.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 5a58372f1..22863ce15 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -16,6 +16,7 @@ #include "spdk/string.h" #include "spdk/queue.h" #include "spdk/util.h" +#include "spdk/rpc.h" #include "spdk_internal/event.h" @@ -45,6 +46,7 @@ struct spdk_fio_options { int mem_single_seg; int initial_zone_reset; int zone_append; + char *rpc_listen_addr; }; struct spdk_fio_request { @@ -86,6 +88,7 @@ struct spdk_fio_zone_cb_arg { static bool g_spdk_env_initialized = false; static const char *g_json_config_file = NULL; +static const char *g_rpc_listen_addr = SPDK_DEFAULT_RPC_ADDR; static int spdk_fio_init(struct thread_data *td); static void spdk_fio_cleanup(struct thread_data *td); @@ -207,6 +210,10 @@ static void spdk_fio_bdev_init_done(int rc, void *cb_arg) { *(bool *)cb_arg = true; + + if (spdk_rpc_initialize(g_rpc_listen_addr) == 0) { + spdk_rpc_set_state(SPDK_RPC_RUNTIME); + } } static void @@ -222,6 +229,8 @@ static void spdk_fio_bdev_fini_done(void *cb_arg) { *(bool *)cb_arg = true; + + spdk_rpc_finish(); } static void @@ -265,6 +274,11 @@ spdk_init_thread_poll(void *arg) goto err_exit; } + /* Initialize the RPC listen address */ + if (eo->rpc_listen_addr) { + g_rpc_listen_addr = eo->rpc_listen_addr; + } + /* Initialize the environment library */ spdk_env_opts_init(&opts); opts.name = "fio"; @@ -1301,6 +1315,15 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_INVALID, }, + { + .name = "spdk_rpc_listen_addr", + .lname = "SPDK RPC listen address", + .type = FIO_OPT_STR_STORE, + .off1 = offsetof(struct spdk_fio_options, rpc_listen_addr), + .help = "The address to listen the RPC operations", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_INVALID, + }, { .name = NULL, },