log: remove "trace" from log flag RPCs

We will keep the RPCs for now but mark them deprecated.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I0407dcb392ea0c9e89c0f26cd5670aed2dbfadef

Reviewed-on: https://review.gerrithub.io/435345
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2018-11-27 00:26:59 -07:00
parent 72f8c6a1f3
commit 870b0e5b29
6 changed files with 133 additions and 56 deletions

View File

@ -39,6 +39,12 @@ allows virtual bdevs to be shut down cleanly as opposed to the
previous behavior that didn't differentiate between hotremove and
planned shutdown.
### log
"trace flags" are now referred to as "log flags" in the SPDK log API. The
set_trace_flag, clear_trace_flag and get_trace_flags RPCs are now deprecated,
and set_log_flag, clear_log_flag and get_log_flags RPCs have been added.
## v18.10:
### nvme

View File

@ -237,9 +237,9 @@ Example response:
"get_nbd_disks",
"stop_nbd_disk",
"start_nbd_disk",
"get_trace_flags",
"clear_trace_flag",
"set_trace_flag",
"get_log_flags",
"clear_log_flag",
"set_log_flag",
"get_log_level",
"set_log_level",
"get_log_print_level",

View File

@ -36,7 +36,7 @@
#include "spdk_internal/log.h"
struct rpc_trace_flag {
struct rpc_log_flag {
char *flag;
};
@ -45,7 +45,7 @@ struct rpc_log_level {
};
static void
free_rpc_trace_flag(struct rpc_trace_flag *p)
free_rpc_log_flag(struct rpc_log_flag *p)
{
free(p->flag);
}
@ -56,8 +56,8 @@ free_rpc_log_level(struct rpc_log_level *p)
free(p->level);
}
static const struct spdk_json_object_decoder rpc_trace_flag_decoders[] = {
{"flag", offsetof(struct rpc_trace_flag, flag), spdk_json_decode_string},
static const struct spdk_json_object_decoder rpc_log_flag_decoders[] = {
{"flag", offsetof(struct rpc_log_flag, flag), spdk_json_decode_string},
};
static const struct spdk_json_object_decoder rpc_log_level_decoders[] = {
@ -147,7 +147,7 @@ spdk_rpc_get_log_print_level(struct spdk_jsonrpc_request *request,
if (params != NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"get_trace_flags requires no parameters");
"get_log_print_level requires no parameters");
return;
}
@ -220,7 +220,7 @@ spdk_rpc_get_log_level(struct spdk_jsonrpc_request *request,
if (params != NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"get_trace_flags requires no parameters");
"get_log_level requires no parameters");
return;
}
@ -244,14 +244,14 @@ spdk_rpc_get_log_level(struct spdk_jsonrpc_request *request,
SPDK_RPC_REGISTER("get_log_level", spdk_rpc_get_log_level, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
spdk_rpc_set_log_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct rpc_trace_flag req = {};
struct rpc_log_flag req = {};
struct spdk_json_write_ctx *w;
if (spdk_json_decode_object(params, rpc_trace_flag_decoders,
SPDK_COUNTOF(rpc_trace_flag_decoders), &req)) {
if (spdk_json_decode_object(params, rpc_log_flag_decoders,
SPDK_COUNTOF(rpc_log_flag_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
goto invalid;
}
@ -262,7 +262,7 @@ spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
}
spdk_log_set_flag(req.flag);
free_rpc_trace_flag(&req);
free_rpc_log_flag(&req);
w = spdk_jsonrpc_begin_result(request);
if (w == NULL) {
@ -275,19 +275,29 @@ spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_trace_flag(&req);
free_rpc_log_flag(&req);
}
SPDK_RPC_REGISTER("set_log_flag", spdk_rpc_set_log_flag, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
SPDK_ERRLOG("set_log_flag is deprecated\n");
spdk_rpc_set_log_flag(request, params);
}
SPDK_RPC_REGISTER("set_trace_flag", spdk_rpc_set_trace_flag, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
spdk_rpc_clear_log_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct rpc_trace_flag req = {};
struct rpc_log_flag req = {};
struct spdk_json_write_ctx *w;
if (spdk_json_decode_object(params, rpc_trace_flag_decoders,
SPDK_COUNTOF(rpc_trace_flag_decoders), &req)) {
if (spdk_json_decode_object(params, rpc_log_flag_decoders,
SPDK_COUNTOF(rpc_log_flag_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
goto invalid;
}
@ -298,7 +308,7 @@ spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
}
spdk_log_clear_flag(req.flag);
free_rpc_trace_flag(&req);
free_rpc_log_flag(&req);
w = spdk_jsonrpc_begin_result(request);
if (w == NULL) {
@ -311,21 +321,32 @@ spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_trace_flag(&req);
free_rpc_log_flag(&req);
}
SPDK_RPC_REGISTER("clear_log_flag", spdk_rpc_clear_log_flag,
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
SPDK_ERRLOG("clear_log_flag RPC is deprecated\n");
spdk_rpc_clear_log_flag(request, params);
}
SPDK_RPC_REGISTER("clear_trace_flag", spdk_rpc_clear_trace_flag,
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_get_trace_flags(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
spdk_rpc_get_log_flags(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct spdk_json_write_ctx *w;
struct spdk_log_flag *flag;
if (params != NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"get_trace_flags requires no parameters");
"get_log_flags requires no parameters");
return;
}
@ -344,4 +365,14 @@ spdk_rpc_get_trace_flags(struct spdk_jsonrpc_request *request,
spdk_json_write_object_end(w);
spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("get_log_flags", spdk_rpc_get_log_flags, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_get_trace_flags(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
SPDK_ERRLOG("get_trace_flags RPC is deprecated\n");
spdk_rpc_get_log_flags(request, params);
}
SPDK_RPC_REGISTER("get_trace_flags", spdk_rpc_get_trace_flags, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)

View File

@ -952,8 +952,18 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
p.set_defaults(func=get_scsi_devices)
# log
@call_cmd
def set_log_flag(args):
rpc.log.set_log_flag(args.client, flag=args.flag)
p = subparsers.add_parser('set_log_flag', help='set log flag')
p.add_argument(
'flag', help='log flag we want to set. (for example "nvme").')
p.set_defaults(func=set_log_flag)
@call_cmd
def set_trace_flag(args):
print("set_trace_flag is deprecated - use set_log_flag instead")
rpc.log.set_trace_flag(args.client, flag=args.flag)
p = subparsers.add_parser('set_trace_flag', help='set trace flag')
@ -961,8 +971,18 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
'flag', help='trace mask we want to set. (for example "nvme").')
p.set_defaults(func=set_trace_flag)
@call_cmd
def clear_log_flag(args):
rpc.log.clear_log_flag(args.client, flag=args.flag)
p = subparsers.add_parser('clear_log_flag', help='clear log flag')
p.add_argument(
'flag', help='log flag we want to clear. (for example "nvme").')
p.set_defaults(func=clear_log_flag)
@call_cmd
def clear_trace_flag(args):
print("clear_trace_flag is deprecated - use clear_log_flag instead")
rpc.log.clear_trace_flag(args.client, flag=args.flag)
p = subparsers.add_parser('clear_trace_flag', help='clear trace flag')
@ -970,8 +990,16 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
'flag', help='trace mask we want to clear. (for example "nvme").')
p.set_defaults(func=clear_trace_flag)
@call_cmd
def get_log_flags(args):
print_dict(rpc.log.get_log_flags(args.client))
p = subparsers.add_parser('get_log_flags', help='get log flags')
p.set_defaults(func=get_log_flags)
@call_cmd
def get_trace_flags(args):
print("get_trace_flags is deprecated - use get_log_flags instead")
print_dict(rpc.log.get_trace_flags(args.client))
p = subparsers.add_parser('get_trace_flags', help='get trace flags')

View File

@ -1,30 +1,42 @@
def set_trace_flag(client, flag):
"""Set trace flag.
def set_log_flag(client, flag):
"""Set log flag.
Args:
flag: trace mask we want to set. (for example "nvme")
flag: log flag we want to set. (for example "nvme")
"""
params = {'flag': flag}
return client.call('set_trace_flag', params)
return client.call('set_log_flag', params)
def set_trace_flag(client, flag):
return set_log_flag(client, flag)
def clear_log_flag(client, flag):
"""Clear log flag.
Args:
flag: log flag we want to clear. (for example "nvme")
"""
params = {'flag': flag}
return client.call('clear_log_flag', params)
def clear_trace_flag(client, flag):
"""Clear trace flag.
return clear_log_flag(client, flag)
Args:
flag: trace mask we want to clear. (for example "nvme")
def get_log_flags(client):
"""Get log flags
Returns:
List of log flags
"""
params = {'flag': flag}
return client.call('clear_trace_flag', params)
return client.call('get_log_flags')
def get_trace_flags(client):
"""Get trace flags
Returns:
List of trace flag
"""
return client.call('get_trace_flags')
return get_log_flags(client)
def set_log_level(client, level):

View File

@ -42,7 +42,7 @@ rpc_param = {
'chap_group': 0,
'header_digest': False,
'data_digest': False,
'trace_flag': 'rpc',
'log_flag': 'rpc',
'cpumask': 0x1
}
@ -73,24 +73,24 @@ def verify(expr, retcode, msg):
raise RpcException(retcode, msg)
def verify_trace_flag_rpc_methods(rpc_py, rpc_param):
def verify_log_flag_rpc_methods(rpc_py, rpc_param):
rpc = spdk_rpc(rpc_py)
output = rpc.get_trace_flags()
output = rpc.get_log_flags()
jsonvalue = json.loads(output)
verify(not jsonvalue[rpc_param['trace_flag']], 1,
"get_trace_flags returned {}, expected false".format(jsonvalue))
rpc.set_trace_flag(rpc_param['trace_flag'])
output = rpc.get_trace_flags()
verify(not jsonvalue[rpc_param['log_flag']], 1,
"get_log_flags returned {}, expected false".format(jsonvalue))
rpc.set_log_flag(rpc_param['log_flag'])
output = rpc.get_log_flags()
jsonvalue = json.loads(output)
verify(jsonvalue[rpc_param['trace_flag']], 1,
"get_trace_flags returned {}, expected true".format(jsonvalue))
rpc.clear_trace_flag(rpc_param['trace_flag'])
output = rpc.get_trace_flags()
verify(jsonvalue[rpc_param['log_flag']], 1,
"get_log_flags returned {}, expected true".format(jsonvalue))
rpc.clear_log_flag(rpc_param['log_flag'])
output = rpc.get_log_flags()
jsonvalue = json.loads(output)
verify(not jsonvalue[rpc_param['trace_flag']], 1,
"get_trace_flags returned {}, expected false".format(jsonvalue))
verify(not jsonvalue[rpc_param['log_flag']], 1,
"get_log_flags returned {}, expected false".format(jsonvalue))
print("verify_trace_flag_rpc_methods passed")
print("verify_log_flag_rpc_methods passed")
def verify_iscsi_connection_rpc_methods(rpc_py):
@ -483,7 +483,7 @@ if __name__ == "__main__":
rpc_py = sys.argv[1]
try:
verify_trace_flag_rpc_methods(rpc_py, rpc_param)
verify_log_flag_rpc_methods(rpc_py, rpc_param)
verify_get_interfaces(rpc_py)
verify_add_delete_ip_address(rpc_py)
create_malloc_bdevs_rpc_methods(rpc_py, rpc_param)