rpc: Rename ocf get_bdevs and get_stats related rpcs.

Rename get_ocf_stats to bdev_ocf_get_stats.
Rename get_ocf_bdevs to bdev_ocf_get_bdevs.

Change-Id: I627d9ff7bcc3f30ec19d245e5caa06238cda3a9e
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466519
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Pawel Kaminski 2019-08-28 04:43:22 -04:00 committed by Jim Harris
parent 557f8ff9ec
commit 95482c547c
8 changed files with 56 additions and 50 deletions

View File

@ -898,7 +898,7 @@ Example response:
}
~~~
## get_ocf_stats {#rpc_get_ocf_stats}
## bdev_ocf_get_stats {#rpc_bdev_ocf_get_stats}
Get statistics of chosen OCF block device.
@ -919,7 +919,7 @@ Example request:
~~~
{
"jsonrpc": "2.0",
"method": "get_ocf_stats",
"method": "bdev_ocf_get_stats",
"id": 1
}
~~~
@ -1102,7 +1102,7 @@ Example response:
}
~~~
## get_ocf_bdevs {#rpc_get_ocf_bdevs}
## bdev_ocf_get_bdevs {#rpc_bdev_ocf_get_bdevs}
Get list of OCF devices including unregistered ones.
@ -1123,7 +1123,7 @@ Example request:
~~~
{
"jsonrpc": "2.0",
"method": "get_ocf_bdevs",
"method": "bdev_ocf_get_bdevs",
"id": 1
}
~~~

View File

@ -175,32 +175,33 @@ SPDK_RPC_REGISTER("bdev_ocf_delete", spdk_rpc_bdev_ocf_delete, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_ocf_delete, delete_ocf_bdev)
/* Structure to hold the parameters for this RPC method. */
struct rpc_get_ocf_stats {
struct rpc_bdev_ocf_get_stats {
char *name; /* master vbdev name */
};
static void
free_rpc_get_ocf_stats(struct rpc_get_ocf_stats *r)
free_rpc_bdev_ocf_get_stats(struct rpc_bdev_ocf_get_stats *r)
{
free(r->name);
}
/* Structure to decode the input parameters for this RPC method. */
static const struct spdk_json_object_decoder rpc_get_ocf_stats_decoders[] = {
{"name", offsetof(struct rpc_get_ocf_stats, name), spdk_json_decode_string},
static const struct spdk_json_object_decoder rpc_bdev_ocf_get_stats_decoders[] = {
{"name", offsetof(struct rpc_bdev_ocf_get_stats, name), spdk_json_decode_string},
};
static void
spdk_rpc_get_ocf_stats(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
spdk_rpc_bdev_ocf_get_stats(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct rpc_get_ocf_stats req = {NULL};
struct rpc_bdev_ocf_get_stats req = {NULL};
struct spdk_json_write_ctx *w;
struct vbdev_ocf *vbdev;
struct vbdev_ocf_stats stats;
int status;
if (spdk_json_decode_object(params, rpc_get_ocf_stats_decoders,
SPDK_COUNTOF(rpc_get_ocf_stats_decoders),
if (spdk_json_decode_object(params, rpc_bdev_ocf_get_stats_decoders,
SPDK_COUNTOF(rpc_bdev_ocf_get_stats_decoders),
&req)) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
@ -227,24 +228,25 @@ spdk_rpc_get_ocf_stats(struct spdk_jsonrpc_request *request, const struct spdk_j
spdk_jsonrpc_end_result(request, w);
end:
free_rpc_get_ocf_stats(&req);
free_rpc_bdev_ocf_get_stats(&req);
}
SPDK_RPC_REGISTER("get_ocf_stats", spdk_rpc_get_ocf_stats, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER("bdev_ocf_get_stats", spdk_rpc_bdev_ocf_get_stats, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_ocf_get_stats, get_ocf_stats)
/* Structure to hold the parameters for this RPC method. */
struct rpc_get_ocf_bdevs {
struct rpc_bdev_ocf_get_bdevs {
char *name;
};
static void
free_rpc_get_ocf_bdevs(struct rpc_get_ocf_bdevs *r)
free_rpc_bdev_ocf_get_bdevs(struct rpc_bdev_ocf_get_bdevs *r)
{
free(r->name);
}
/* Structure to decode the input parameters for this RPC method. */
static const struct spdk_json_object_decoder rpc_get_ocf_bdevs_decoders[] = {
{"name", offsetof(struct rpc_get_ocf_bdevs, name), spdk_json_decode_string, true},
static const struct spdk_json_object_decoder rpc_bdev_ocf_get_bdevs_decoders[] = {
{"name", offsetof(struct rpc_bdev_ocf_get_bdevs, name), spdk_json_decode_string, true},
};
struct get_bdevs_ctx {
@ -283,14 +285,15 @@ get_bdevs_fn(struct vbdev_ocf *vbdev, void *ctx)
}
static void
spdk_rpc_get_ocf_bdevs(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
spdk_rpc_bdev_ocf_get_bdevs(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct spdk_json_write_ctx *w;
struct rpc_get_ocf_bdevs req = {NULL};
struct rpc_bdev_ocf_get_bdevs req = {NULL};
struct get_bdevs_ctx cctx;
if (params && spdk_json_decode_object(params, rpc_get_ocf_bdevs_decoders,
SPDK_COUNTOF(rpc_get_ocf_bdevs_decoders),
if (params && spdk_json_decode_object(params, rpc_bdev_ocf_get_bdevs_decoders,
SPDK_COUNTOF(rpc_bdev_ocf_get_bdevs_decoders),
&req)) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
@ -317,6 +320,7 @@ spdk_rpc_get_ocf_bdevs(struct spdk_jsonrpc_request *request, const struct spdk_j
spdk_jsonrpc_end_result(request, w);
end:
free_rpc_get_ocf_bdevs(&req);
free_rpc_bdev_ocf_get_bdevs(&req);
}
SPDK_RPC_REGISTER("get_ocf_bdevs", spdk_rpc_get_ocf_bdevs, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER("bdev_ocf_get_bdevs", spdk_rpc_bdev_ocf_get_bdevs, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_ocf_get_bdevs, get_ocf_bdevs)

View File

@ -221,21 +221,21 @@ if __name__ == "__main__":
p.add_argument('name', help='Name of OCF bdev')
p.set_defaults(func=bdev_ocf_delete)
def get_ocf_stats(args):
print_dict(rpc.bdev.get_ocf_stats(args.client,
name=args.name))
p = subparsers.add_parser('get_ocf_stats',
def bdev_ocf_get_stats(args):
print_dict(rpc.bdev.bdev_ocf_get_stats(args.client,
name=args.name))
p = subparsers.add_parser('bdev_ocf_get_stats', aliases=['get_ocf_stats'],
help='Get statistics of chosen OCF block device')
p.add_argument('name', help='Name of OCF bdev')
p.set_defaults(func=get_ocf_stats)
p.set_defaults(func=bdev_ocf_get_stats)
def get_ocf_bdevs(args):
print_dict(rpc.bdev.get_ocf_bdevs(args.client,
name=args.name))
p = subparsers.add_parser('get_ocf_bdevs',
def bdev_ocf_get_bdevs(args):
print_dict(rpc.bdev.bdev_ocf_get_bdevs(args.client,
name=args.name))
p = subparsers.add_parser('bdev_ocf_get_bdevs', aliases=['get_ocf_bdevs'],
help='Get list of OCF devices including unregistered ones')
p.add_argument('name', nargs='?', default=None, help='name of OCF vbdev or name of cache device or name of core device (optional)')
p.set_defaults(func=get_ocf_bdevs)
p.set_defaults(func=bdev_ocf_get_bdevs)
def bdev_malloc_create(args):
num_blocks = (args.total_size * 1024 * 1024) // args.block_size

View File

@ -131,7 +131,8 @@ def bdev_ocf_delete(client, name):
return client.call('bdev_ocf_delete', params)
def get_ocf_stats(client, name):
@deprecated_alias('get_ocf_stats')
def bdev_ocf_get_stats(client, name):
"""Get statistics of chosen OCF block device
Args:
@ -142,10 +143,11 @@ def get_ocf_stats(client, name):
"""
params = {'name': name}
return client.call('get_ocf_stats', params)
return client.call('bdev_ocf_get_stats', params)
def get_ocf_bdevs(client, name=None):
@deprecated_alias('get_ocf_stats')
def bdev_ocf_get_bdevs(client, name=None):
"""Get list of OCF devices including unregistered ones
Args:
@ -157,7 +159,7 @@ def get_ocf_bdevs(client, name=None):
params = None
if name:
params = {'name': name}
return client.call('get_ocf_bdevs', params)
return client.call('bdev_ocf_get_bdevs', params)
@deprecated_alias('construct_malloc_bdev')

View File

@ -14,5 +14,5 @@ $bdevperf -c $curdir/mallocs.conf -q 128 -o 4096 -t 4 -w write -r /var/tmp/spdk.
bdev_perf_pid=$!
waitforlisten $bdev_perf_pid
sleep 1
$rpc_py get_ocf_stats MalCache1
$rpc_py bdev_ocf_get_stats MalCache1
wait $bdev_perf_pid

View File

@ -27,10 +27,10 @@ $rpc_py bdev_malloc_create 101 512 -b Malloc1
$rpc_py bdev_ocf_create PartCache wt Malloc0 NonExisting
$rpc_py get_ocf_bdevs PartCache | jq -e \
$rpc_py bdev_ocf_get_bdevs PartCache | jq -e \
'.[0] | .started == false and .cache.attached and .core.attached == false'
$rpc_py get_ocf_bdevs NonExisting | jq -e \
$rpc_py bdev_ocf_get_bdevs NonExisting | jq -e \
'.[0] | .name == "PartCache"'
if ! bdev_check_claimed Malloc0; then
@ -46,7 +46,7 @@ fi
$rpc_py bdev_ocf_create FullCache wt Malloc0 Malloc1
$rpc_py get_ocf_bdevs FullCache | jq -e \
$rpc_py bdev_ocf_get_bdevs FullCache | jq -e \
'.[0] | .started and .cache.attached and .core.attached'
if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then

View File

@ -30,24 +30,24 @@ $rpc_py bdev_malloc_create 1 512 -b Core1
$rpc_py bdev_ocf_create C1 wt Cache Core0
$rpc_py bdev_ocf_create C2 wt Cache Core1
$rpc_py get_ocf_bdevs | jq -e \
$rpc_py bdev_ocf_get_bdevs | jq -e \
'any(select(.started)) == false'
$rpc_py bdev_malloc_create 101 512 -b Cache
$rpc_py get_ocf_bdevs | jq -e \
$rpc_py bdev_ocf_get_bdevs | jq -e \
'all(select(.started)) == true'
# Detaching cores
$rpc_py bdev_ocf_delete C2
$rpc_py get_ocf_bdevs C1 | jq -e \
$rpc_py bdev_ocf_get_bdevs C1 | jq -e \
'.[0] | .started'
$rpc_py bdev_ocf_create C2 wt Cache Core1
$rpc_py get_ocf_bdevs C2 | jq -e \
$rpc_py bdev_ocf_get_bdevs C2 | jq -e \
'.[0] | .started'
# Normal shutdown
@ -64,12 +64,12 @@ $rpc_py bdev_malloc_create 1 512 -b Core
$rpc_py bdev_ocf_create C1 wt Cache Malloc
$rpc_py bdev_ocf_create C2 wt Cache Core
$rpc_py get_ocf_bdevs Cache | jq \
$rpc_py bdev_ocf_get_bdevs Cache | jq \
'length == 2'
$rpc_py delete_malloc_bdev Cache
$rpc_py get_ocf_bdevs | jq -e \
$rpc_py bdev_ocf_get_bdevs | jq -e \
'. == []'
# Not fully initialized shutdown

View File

@ -51,7 +51,7 @@ $rpc_py bdev_ocf_create ocfWB1 wb Nvme0n1p4 Nvme0n1p6
# Sorting bdevs because we dont guarantee that they are going to be
# in the same order after shutdown
($rpc_py get_ocf_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs
trap - SIGINT SIGTERM EXIT
@ -67,7 +67,7 @@ waitforlisten $spdk_pid
# OCF should be loaded now as well
($rpc_py get_ocf_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs_verify
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs_verify
diff ocf_bdevs ocf_bdevs_verify