Commit 411f1c90 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei 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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 95754cd1
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -445,6 +445,16 @@ bdevperf_fini(int 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
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");
		}

		if (g_request && !g_shutdown) {
			rpc_perform_tests_cb(g_run_rc);
		} else {
			bdevperf_fini(g_run_rc);
		}
		bdevperf_test_done(g_run_rc);
	}
}

@@ -1318,7 +1324,7 @@ bdevperf_run(void *arg1)

	rc = bdevperf_test();
	if (rc) {
		bdevperf_fini(rc);
		bdevperf_test_done(rc);
		return;
	}
}
@@ -1349,7 +1355,7 @@ spdk_bdevperf_shutdown_cb(void)
	}

	if (g_target_count == 0) {
		bdevperf_fini(g_run_rc);
		bdevperf_test_done(g_run_rc);
		return;
	}

@@ -1460,7 +1466,7 @@ rpc_perform_tests(struct spdk_jsonrpc_request *request, const struct spdk_json_v

	rc = bdevperf_test();
	if (rc) {
		rpc_perform_tests_cb(rc);
		bdevperf_test_done(rc);
	}
}
SPDK_RPC_REGISTER("perform_tests", rpc_perform_tests, SPDK_RPC_RUNTIME)