bdevperf: Factor out finish operation of command line and RPC invocation

Factor out test finish operation of command line invocation case and
RPC invocation case.  Then apply the new funciton bdevperf_test_done()
to all calls bdevperf_fini() or rpc_perform_tests_cb().

The purpose of this refactoring is as follows:
- Consolidating finish operation improves code readability and
  maintainability, and may enable further improvement in future.
- The next patch will consolidate bdevperf_free_targets() from
  bdevperf_fini() and rpc_perform_tests_cb() into bdevperf_test_done().
  This refactoring is a preparation.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I06801541e4c4ed28774debad56d901dbeb5a9193
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479372
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-01-05 23:32:49 -05:00 committed by Tomasz Zawadzki
parent 95754cd170
commit 411f1c90c6

View File

@ -445,6 +445,16 @@ bdevperf_fini(int rc)
spdk_app_stop(rc); spdk_app_stop(rc);
} }
static void
bdevperf_test_done(int rc)
{
if (g_request && !g_shutdown) {
rpc_perform_tests_cb(rc);
} else {
bdevperf_fini(rc);
}
}
static void static void
end_run(void *arg1, void *arg2) end_run(void *arg1, void *arg2)
{ {
@ -469,11 +479,7 @@ end_run(void *arg1, void *arg2)
printf("Test time less than one microsecond, no performance data will be shown\n"); printf("Test time less than one microsecond, no performance data will be shown\n");
} }
if (g_request && !g_shutdown) { bdevperf_test_done(g_run_rc);
rpc_perform_tests_cb(g_run_rc);
} else {
bdevperf_fini(g_run_rc);
}
} }
} }
@ -1318,7 +1324,7 @@ bdevperf_run(void *arg1)
rc = bdevperf_test(); rc = bdevperf_test();
if (rc) { if (rc) {
bdevperf_fini(rc); bdevperf_test_done(rc);
return; return;
} }
} }
@ -1349,7 +1355,7 @@ spdk_bdevperf_shutdown_cb(void)
} }
if (g_target_count == 0) { if (g_target_count == 0) {
bdevperf_fini(g_run_rc); bdevperf_test_done(g_run_rc);
return; return;
} }
@ -1460,7 +1466,7 @@ rpc_perform_tests(struct spdk_jsonrpc_request *request, const struct spdk_json_v
rc = bdevperf_test(); rc = bdevperf_test();
if (rc) { if (rc) {
rpc_perform_tests_cb(rc); bdevperf_test_done(rc);
} }
} }
SPDK_RPC_REGISTER("perform_tests", rpc_perform_tests, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("perform_tests", rpc_perform_tests, SPDK_RPC_RUNTIME)