bdev: add rpc for enabling queue_depth monitoring
Change-Id: Idb5e29b5d5b1d3431fbd1051ccaa6218f9a09600 Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/418107 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
760b868aa8
commit
0398702483
@ -452,6 +452,72 @@ invalid:
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_bdev", spdk_rpc_delete_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_set_bdev_qd_sampling_period {
|
||||
char *name;
|
||||
uint64_t period;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_set_bdev_qd_sampling_period(struct rpc_set_bdev_qd_sampling_period *r)
|
||||
{
|
||||
free(r->name);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder
|
||||
rpc_set_bdev_qd_sampling_period_decoders[] = {
|
||||
{"name", offsetof(struct rpc_set_bdev_qd_sampling_period, name), spdk_json_decode_string},
|
||||
{"period", offsetof(struct rpc_set_bdev_qd_sampling_period, period), spdk_json_decode_uint64},
|
||||
};
|
||||
|
||||
static void
|
||||
spdk_rpc_set_bdev_qd_sampling_period(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_set_bdev_qd_sampling_period req = {0};
|
||||
struct spdk_bdev *bdev;
|
||||
struct spdk_json_write_ctx *w;
|
||||
|
||||
req.period = UINT64_MAX;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_set_bdev_qd_sampling_period_decoders,
|
||||
SPDK_COUNTOF(rpc_set_bdev_qd_sampling_period_decoders),
|
||||
&req)) {
|
||||
SPDK_ERRLOG("spdk_json_decode_object failed\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (req.name) {
|
||||
bdev = spdk_bdev_get_by_name(req.name);
|
||||
if (bdev == NULL) {
|
||||
SPDK_ERRLOG("bdev '%s' does not exist\n", req.name);
|
||||
goto invalid;
|
||||
}
|
||||
} else {
|
||||
SPDK_ERRLOG("Missing name param\n");
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (req.period == UINT64_MAX) {
|
||||
SPDK_ERRLOG("Missing period param");
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_bdev_set_qd_sampling_period(bdev, req.period);
|
||||
|
||||
spdk_json_write_bool(w, true);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
free_rpc_set_bdev_qd_sampling_period(&req);
|
||||
return;
|
||||
|
||||
invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_set_bdev_qd_sampling_period(&req);
|
||||
return;
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_bdev_qd_sampling_period",
|
||||
spdk_rpc_set_bdev_qd_sampling_period,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_set_bdev_qos_limit_iops {
|
||||
char *name;
|
||||
uint64_t ios_per_sec;
|
||||
|
@ -382,6 +382,19 @@ if __name__ == "__main__":
|
||||
'bdev_name', help='Blockdev name to be deleted. Example: Malloc0.')
|
||||
p.set_defaults(func=delete_bdev)
|
||||
|
||||
@call_cmd
|
||||
def set_bdev_qd_sampling_period(args):
|
||||
rpc.bdev.set_bdev_qd_sampling_period(args.client,
|
||||
name=args.name,
|
||||
period=args.period)
|
||||
|
||||
p = subparsers.add_parser('set_bdev_qd_sampling_period', help="Enable or disable tracking of a bdev's queue depth.")
|
||||
p.add_argument('name', help='Blockdev name. Example: Malloc0')
|
||||
p.add_argument('period', help='Period with which to poll the block device queue depth in microseconds.'
|
||||
' If set to 0, polling will be disabled.',
|
||||
type=int)
|
||||
p.set_defaults(func=set_bdev_qd_sampling_period)
|
||||
|
||||
@call_cmd
|
||||
def set_bdev_qos_limit_iops(args):
|
||||
rpc.bdev.set_bdev_qos_limit_iops(args.client,
|
||||
|
@ -379,6 +379,20 @@ def bdev_inject_error(client, name, io_type, error_type, num=1):
|
||||
return client.call('bdev_inject_error', params)
|
||||
|
||||
|
||||
def set_bdev_qd_sampling_period(client, name, period):
|
||||
"""Enable queue depth tracking on a specified bdev.
|
||||
|
||||
Args:
|
||||
name: name of a bdev on which to track queue depth.
|
||||
period: period (in microseconds) at which to update the queue depth reading. If set to 0, polling will be disabled.
|
||||
"""
|
||||
|
||||
params = {}
|
||||
params['name'] = name
|
||||
params['period'] = period
|
||||
return client.call('set_bdev_qd_sampling_period', params)
|
||||
|
||||
|
||||
def set_bdev_qos_limit_iops(client, name, ios_per_sec):
|
||||
"""Set QoS IOPS limit on a block device.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user