This gives us a place to initialize iobuf pools, specify subsystem dependencies, and execute RPCs to configure the sizes of the pools. We allow users to configure the size of the pools either through the options in spdk_bdev_opts or through the new RPC, iobuf_set_options. The second option has higher priority, so it will override the options set by the bdev layer. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I7c45ace04bc71c8343658f98248fc7babcf24e5d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15765 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright (C) 2022 Intel Corporation.
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#include "spdk/stdinc.h"
|
|
#include "spdk/thread.h"
|
|
#include "spdk/rpc.h"
|
|
#include "spdk/string.h"
|
|
#include "spdk_internal/init.h"
|
|
|
|
int iobuf_set_opts(struct spdk_iobuf_opts *opts);
|
|
|
|
static const struct spdk_json_object_decoder rpc_iobuf_set_options_decoders[] = {
|
|
{"small_pool_count", offsetof(struct spdk_iobuf_opts, small_pool_count), spdk_json_decode_uint64, true},
|
|
{"large_pool_count", offsetof(struct spdk_iobuf_opts, large_pool_count), spdk_json_decode_uint64, true},
|
|
{"small_bufsize", offsetof(struct spdk_iobuf_opts, small_bufsize), spdk_json_decode_uint32, true},
|
|
{"large_bufsize", offsetof(struct spdk_iobuf_opts, large_bufsize), spdk_json_decode_uint32, true},
|
|
};
|
|
|
|
static void
|
|
rpc_iobuf_set_options(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
|
|
{
|
|
struct spdk_iobuf_opts opts;
|
|
int rc;
|
|
|
|
spdk_iobuf_get_opts(&opts);
|
|
rc = spdk_json_decode_object(params, rpc_iobuf_set_options_decoders,
|
|
SPDK_COUNTOF(rpc_iobuf_set_options_decoders), &opts);
|
|
if (rc != 0) {
|
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
|
"spdk_json_decode_object failed");
|
|
return;
|
|
}
|
|
|
|
rc = iobuf_set_opts(&opts);
|
|
if (rc != 0) {
|
|
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
|
return;
|
|
}
|
|
|
|
spdk_jsonrpc_send_bool_response(request, true);
|
|
}
|
|
SPDK_RPC_REGISTER("iobuf_set_options", rpc_iobuf_set_options, SPDK_RPC_STARTUP)
|