RPC: rename set_bdev_qos_limit to bdev_set_qos_limit

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ia22b0043307e92222541b6e7278e3d1485b61987
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468084
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Maciej Wawryk 2019-09-11 12:32:34 +02:00 committed by Ben Walker
parent a96afb8b0a
commit c61e14be6c
7 changed files with 37 additions and 34 deletions

View File

@ -70,9 +70,9 @@ Example response
} }
~~~ ~~~
## set_bdev_qos_limit {#set_bdev_qos_limit} ## bdev_set_qos_limit {#bdev_set_qos_limit}
Users can use the `set_bdev_qos_limit` RPC command to enable, adjust, and disable Users can use the `bdev_set_qos_limit` RPC command to enable, adjust, and disable
rate limits on an existing bdev. Two types of rate limits are supported: rate limits on an existing bdev. Two types of rate limits are supported:
IOPS and bandwidth. The rate limits can be enabled, adjusted, and disabled at any IOPS and bandwidth. The rate limits can be enabled, adjusted, and disabled at any
time for the specified bdev. The bdev name is a required parameter for this time for the specified bdev. The bdev name is a required parameter for this

View File

@ -272,7 +272,7 @@ Example response:
"iscsi_get_initiator_groups", "iscsi_get_initiator_groups",
"set_iscsi_options", "set_iscsi_options",
"set_bdev_options", "set_bdev_options",
"set_bdev_qos_limit", "bdev_set_qos_limit",
"bdev_get_bdevs", "bdev_get_bdevs",
"bdev_get_iostat", "bdev_get_iostat",
"get_subsystem_config", "get_subsystem_config",
@ -773,7 +773,7 @@ Note that histogram field is trimmed, actual encoded histogram length is ~80kb.
} }
~~~ ~~~
## set_bdev_qos_limit {#rpc_set_bdev_qos_limit} ## bdev_set_qos_limit {#rpc_bdev_set_qos_limit}
Set the quality of service rate limit on a bdev. Set the quality of service rate limit on a bdev.
@ -795,7 +795,7 @@ Example request:
{ {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 1, "id": 1,
"method": "set_bdev_qos_limit", "method": "bdev_set_qos_limit",
"params": { "params": {
"name": "Malloc0" "name": "Malloc0"
"rw_ios_per_sec": 20000 "rw_ios_per_sec": 20000

View File

@ -759,7 +759,7 @@ spdk_bdev_qos_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
spdk_bdev_get_qos_rate_limits(bdev, limits); spdk_bdev_get_qos_rate_limits(bdev, limits);
spdk_json_write_object_begin(w); spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "set_bdev_qos_limit"); spdk_json_write_named_string(w, "method", "bdev_set_qos_limit");
spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_object_begin(w, "params");
spdk_json_write_named_string(w, "name", bdev->name); spdk_json_write_named_string(w, "name", bdev->name);

View File

@ -410,43 +410,43 @@ SPDK_RPC_REGISTER("bdev_set_qd_sampling_period",
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_set_qd_sampling_period, SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_set_qd_sampling_period,
set_bdev_qd_sampling_period) set_bdev_qd_sampling_period)
struct rpc_set_bdev_qos_limit { struct rpc_bdev_set_qos_limit {
char *name; char *name;
uint64_t limits[SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES]; uint64_t limits[SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES];
}; };
static void static void
free_rpc_set_bdev_qos_limit(struct rpc_set_bdev_qos_limit *r) free_rpc_bdev_set_qos_limit(struct rpc_bdev_set_qos_limit *r)
{ {
free(r->name); free(r->name);
} }
static const struct spdk_json_object_decoder rpc_set_bdev_qos_limit_decoders[] = { static const struct spdk_json_object_decoder rpc_bdev_set_qos_limit_decoders[] = {
{"name", offsetof(struct rpc_set_bdev_qos_limit, name), spdk_json_decode_string}, {"name", offsetof(struct rpc_bdev_set_qos_limit, name), spdk_json_decode_string},
{ {
"rw_ios_per_sec", offsetof(struct rpc_set_bdev_qos_limit, "rw_ios_per_sec", offsetof(struct rpc_bdev_set_qos_limit,
limits[SPDK_BDEV_QOS_RW_IOPS_RATE_LIMIT]), limits[SPDK_BDEV_QOS_RW_IOPS_RATE_LIMIT]),
spdk_json_decode_uint64, true spdk_json_decode_uint64, true
}, },
{ {
"rw_mbytes_per_sec", offsetof(struct rpc_set_bdev_qos_limit, "rw_mbytes_per_sec", offsetof(struct rpc_bdev_set_qos_limit,
limits[SPDK_BDEV_QOS_RW_BPS_RATE_LIMIT]), limits[SPDK_BDEV_QOS_RW_BPS_RATE_LIMIT]),
spdk_json_decode_uint64, true spdk_json_decode_uint64, true
}, },
{ {
"r_mbytes_per_sec", offsetof(struct rpc_set_bdev_qos_limit, "r_mbytes_per_sec", offsetof(struct rpc_bdev_set_qos_limit,
limits[SPDK_BDEV_QOS_R_BPS_RATE_LIMIT]), limits[SPDK_BDEV_QOS_R_BPS_RATE_LIMIT]),
spdk_json_decode_uint64, true spdk_json_decode_uint64, true
}, },
{ {
"w_mbytes_per_sec", offsetof(struct rpc_set_bdev_qos_limit, "w_mbytes_per_sec", offsetof(struct rpc_bdev_set_qos_limit,
limits[SPDK_BDEV_QOS_W_BPS_RATE_LIMIT]), limits[SPDK_BDEV_QOS_W_BPS_RATE_LIMIT]),
spdk_json_decode_uint64, true spdk_json_decode_uint64, true
}, },
}; };
static void static void
spdk_rpc_set_bdev_qos_limit_complete(void *cb_arg, int status) spdk_rpc_bdev_set_qos_limit_complete(void *cb_arg, int status)
{ {
struct spdk_jsonrpc_request *request = cb_arg; struct spdk_jsonrpc_request *request = cb_arg;
struct spdk_json_write_ctx *w; struct spdk_json_write_ctx *w;
@ -464,15 +464,15 @@ spdk_rpc_set_bdev_qos_limit_complete(void *cb_arg, int status)
} }
static void static void
spdk_rpc_set_bdev_qos_limit(struct spdk_jsonrpc_request *request, spdk_rpc_bdev_set_qos_limit(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params) const struct spdk_json_val *params)
{ {
struct rpc_set_bdev_qos_limit req = {NULL, {UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX}}; struct rpc_bdev_set_qos_limit req = {NULL, {UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX}};
struct spdk_bdev *bdev; struct spdk_bdev *bdev;
int i; int i;
if (spdk_json_decode_object(params, rpc_set_bdev_qos_limit_decoders, if (spdk_json_decode_object(params, rpc_bdev_set_qos_limit_decoders,
SPDK_COUNTOF(rpc_set_bdev_qos_limit_decoders), SPDK_COUNTOF(rpc_bdev_set_qos_limit_decoders),
&req)) { &req)) {
SPDK_ERRLOG("spdk_json_decode_object failed\n"); SPDK_ERRLOG("spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR, spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
@ -498,13 +498,14 @@ spdk_rpc_set_bdev_qos_limit(struct spdk_jsonrpc_request *request,
goto cleanup; goto cleanup;
} }
spdk_bdev_set_qos_rate_limits(bdev, req.limits, spdk_rpc_set_bdev_qos_limit_complete, request); spdk_bdev_set_qos_rate_limits(bdev, req.limits, spdk_rpc_bdev_set_qos_limit_complete, request);
cleanup: cleanup:
free_rpc_set_bdev_qos_limit(&req); free_rpc_bdev_set_qos_limit(&req);
} }
SPDK_RPC_REGISTER("set_bdev_qos_limit", spdk_rpc_set_bdev_qos_limit, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("bdev_set_qos_limit", spdk_rpc_bdev_set_qos_limit, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_set_qos_limit, set_bdev_qos_limit)
/* SPDK_RPC_ENABLE_BDEV_HISTOGRAM */ /* SPDK_RPC_ENABLE_BDEV_HISTOGRAM */

View File

@ -617,15 +617,16 @@ if __name__ == "__main__":
type=int) type=int)
p.set_defaults(func=bdev_set_qd_sampling_period) p.set_defaults(func=bdev_set_qd_sampling_period)
def set_bdev_qos_limit(args): def bdev_set_qos_limit(args):
rpc.bdev.set_bdev_qos_limit(args.client, rpc.bdev.bdev_set_qos_limit(args.client,
name=args.name, name=args.name,
rw_ios_per_sec=args.rw_ios_per_sec, rw_ios_per_sec=args.rw_ios_per_sec,
rw_mbytes_per_sec=args.rw_mbytes_per_sec, rw_mbytes_per_sec=args.rw_mbytes_per_sec,
r_mbytes_per_sec=args.r_mbytes_per_sec, r_mbytes_per_sec=args.r_mbytes_per_sec,
w_mbytes_per_sec=args.w_mbytes_per_sec) w_mbytes_per_sec=args.w_mbytes_per_sec)
p = subparsers.add_parser('set_bdev_qos_limit', help='Set QoS rate limit on a blockdev') p = subparsers.add_parser('bdev_set_qos_limit', aliases=['set_bdev_qos_limit'],
help='Set QoS rate limit on a blockdev')
p.add_argument('name', help='Blockdev name to set QoS. Example: Malloc0') p.add_argument('name', help='Blockdev name to set QoS. Example: Malloc0')
p.add_argument('--rw_ios_per_sec', p.add_argument('--rw_ios_per_sec',
help='R/W IOs per second limit (>=10000, example: 20000). 0 means unlimited.', help='R/W IOs per second limit (>=10000, example: 20000). 0 means unlimited.',
@ -639,7 +640,7 @@ if __name__ == "__main__":
p.add_argument('--w_mbytes_per_sec', p.add_argument('--w_mbytes_per_sec',
help="Write megabytes per second limit (>=10, example: 100). 0 means unlimited.", help="Write megabytes per second limit (>=10, example: 100). 0 means unlimited.",
type=int, required=False) type=int, required=False)
p.set_defaults(func=set_bdev_qos_limit) p.set_defaults(func=bdev_set_qos_limit)
def bdev_error_inject_error(args): def bdev_error_inject_error(args):
rpc.bdev.bdev_error_inject_error(args.client, rpc.bdev.bdev_error_inject_error(args.client,

View File

@ -790,7 +790,8 @@ def bdev_set_qd_sampling_period(client, name, period):
return client.call('bdev_set_qd_sampling_period', params) return client.call('bdev_set_qd_sampling_period', params)
def set_bdev_qos_limit( @deprecated_alias('set_bdev_qos_limit')
def bdev_set_qos_limit(
client, client,
name, name,
rw_ios_per_sec=None, rw_ios_per_sec=None,
@ -816,7 +817,7 @@ def set_bdev_qos_limit(
params['r_mbytes_per_sec'] = r_mbytes_per_sec params['r_mbytes_per_sec'] = r_mbytes_per_sec
if w_mbytes_per_sec is not None: if w_mbytes_per_sec is not None:
params['w_mbytes_per_sec'] = w_mbytes_per_sec params['w_mbytes_per_sec'] = w_mbytes_per_sec
return client.call('set_bdev_qos_limit', params) return client.call('bdev_set_qos_limit', params)
@deprecated_alias('apply_firmware') @deprecated_alias('apply_firmware')

View File

@ -99,34 +99,34 @@ READ_BANDWIDTH_LIMIT_MB=$(($READ_BANDWIDTH_LIMIT/1024/1024))
READ_BANDWIDTH_LIMIT=$(($READ_BANDWIDTH_LIMIT_MB*1024*1024)) READ_BANDWIDTH_LIMIT=$(($READ_BANDWIDTH_LIMIT_MB*1024*1024))
# Limit the I/O rate by RPC, then confirm the observed rate matches. # Limit the I/O rate by RPC, then confirm the observed rate matches.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT $rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
run_fio Malloc0 run_fio Malloc0
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
# Now disable the rate limiting, and confirm the observed rate is not limited anymore. # Now disable the rate limiting, and confirm the observed rate is not limited anymore.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec 0 $rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec 0
run_fio Malloc0 run_fio Malloc0
[ "$IOPS_RESULT" -gt "$IOPS_LIMIT" ] [ "$IOPS_RESULT" -gt "$IOPS_LIMIT" ]
# Limit the I/O rate again. # Limit the I/O rate again.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT $rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
run_fio Malloc0 run_fio Malloc0
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
echo "I/O rate limiting tests successful" echo "I/O rate limiting tests successful"
# Limit the I/O bandwidth rate by RPC, then confirm the observed rate matches. # Limit the I/O bandwidth rate by RPC, then confirm the observed rate matches.
$rpc_py set_bdev_qos_limit Malloc0 --rw_ios_per_sec 0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB $rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec 0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB
run_fio Malloc0 run_fio Malloc0
verify_qos_limits $BANDWIDTH_RESULT $BANDWIDTH_LIMIT verify_qos_limits $BANDWIDTH_RESULT $BANDWIDTH_LIMIT
# Now disable the bandwidth rate limiting, and confirm the observed rate is not limited anymore. # Now disable the bandwidth rate limiting, and confirm the observed rate is not limited anymore.
$rpc_py set_bdev_qos_limit Malloc0 --rw_mbytes_per_sec 0 $rpc_py bdev_set_qos_limit Malloc0 --rw_mbytes_per_sec 0
run_fio Malloc0 run_fio Malloc0
[ "$BANDWIDTH_RESULT" -gt "$BANDWIDTH_LIMIT" ] [ "$BANDWIDTH_RESULT" -gt "$BANDWIDTH_LIMIT" ]
# Limit the I/O bandwidth rate again with both read/write and read/only. # Limit the I/O bandwidth rate again with both read/write and read/only.
$rpc_py set_bdev_qos_limit Malloc0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB --r_mbytes_per_sec $READ_BANDWIDTH_LIMIT_MB $rpc_py bdev_set_qos_limit Malloc0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB --r_mbytes_per_sec $READ_BANDWIDTH_LIMIT_MB
run_fio Malloc0 run_fio Malloc0
verify_qos_limits $BANDWIDTH_RESULT $READ_BANDWIDTH_LIMIT verify_qos_limits $BANDWIDTH_RESULT $READ_BANDWIDTH_LIMIT