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 <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15984
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
GangCao 2022-12-16 01:32:47 -05:00 committed by Jim Harris
parent d7484395ac
commit 0ab8393c60

View File

@ -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,
},