bdev/rpc: Factor out start RPC response of bdev_get_iostat

This is a preparation for the next patch to fix the race condition of
per channel mode.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I9eaefc527ccf82011af39b8261f5b3cc12983bda
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16365
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>
This commit is contained in:
Shuhei Matsumoto 2023-01-20 10:52:16 +09:00 committed by Tomasz Zawadzki
parent 69d4ec0708
commit db3869d1b2

View File

@ -175,15 +175,21 @@ struct bdev_get_iostat_ctx {
};
static void
rpc_get_iostat_started(struct rpc_get_iostat_ctx *rpc_ctx, struct spdk_bdev_desc *desc)
_rpc_get_iostat_started(struct rpc_get_iostat_ctx *rpc_ctx)
{
struct spdk_bdev *bdev;
rpc_ctx->w = spdk_jsonrpc_begin_result(rpc_ctx->request);
spdk_json_write_object_begin(rpc_ctx->w);
spdk_json_write_named_uint64(rpc_ctx->w, "tick_rate", spdk_get_ticks_hz());
spdk_json_write_named_uint64(rpc_ctx->w, "ticks", spdk_get_ticks());
}
static void
rpc_get_iostat_started(struct rpc_get_iostat_ctx *rpc_ctx, struct spdk_bdev_desc *desc)
{
struct spdk_bdev *bdev;
_rpc_get_iostat_started(rpc_ctx);
if (rpc_ctx->per_channel == false) {
spdk_json_write_named_array_begin(rpc_ctx->w, "bdevs");