examples/nvme: add missed spdk_env_fini() when exiting
Althrough `rte_eal_cleanup` will be called in the destructor function when exiting the application, it's OK not to call `spdk_env_fini`, we still add this function call in case there are cleanup function need to call in future. Change-Id: I0a3eca44c5ed1d62059796ea8f1977fb19356939 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10904 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
parent
6ac23b3e60
commit
9ec9c8b33d
@ -1074,8 +1074,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (spdk_env_init(&opts) < 0) {
|
||||
fprintf(stderr, "Unable to initialize SPDK env\n");
|
||||
rc = -1;
|
||||
goto cleanup;
|
||||
unregister_trids();
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsc_rate = spdk_get_ticks_hz();
|
||||
@ -1135,6 +1135,8 @@ cleanup:
|
||||
unregister_namespaces();
|
||||
unregister_controllers();
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "%s: errors occurred\n", argv[0]);
|
||||
}
|
||||
|
@ -1093,7 +1093,7 @@ main(int argc, char **argv)
|
||||
struct worker_thread *worker, *main_worker;
|
||||
unsigned main_core;
|
||||
char task_pool_name[30];
|
||||
uint32_t task_count;
|
||||
uint32_t task_count = 0;
|
||||
struct spdk_env_opts opts;
|
||||
|
||||
rc = parse_args(argc, argv);
|
||||
@ -1114,15 +1114,18 @@ main(int argc, char **argv)
|
||||
g_arbitration.tsc_rate = spdk_get_ticks_hz();
|
||||
|
||||
if (register_workers() != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (register_controllers() != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (associate_workers_with_ns() != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", getpid());
|
||||
@ -1140,7 +1143,8 @@ main(int argc, char **argv)
|
||||
sizeof(struct arb_task), 0, SPDK_ENV_SOCKET_ID_ANY);
|
||||
if (task_pool == NULL) {
|
||||
fprintf(stderr, "could not initialize task pool\n");
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
print_configuration(argv[0]);
|
||||
@ -1166,10 +1170,12 @@ main(int argc, char **argv)
|
||||
|
||||
print_stats();
|
||||
|
||||
exit:
|
||||
unregister_controllers();
|
||||
|
||||
cleanup(task_count);
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "%s: errors occurred\n", argv[0]);
|
||||
}
|
||||
|
@ -327,5 +327,7 @@ int main(int argc, char **argv)
|
||||
spdk_nvme_detach_poll(detach_ctx);
|
||||
}
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1464,6 +1464,10 @@ static void spdk_fio_cleanup(struct thread_data *td)
|
||||
pthread_join(g_ctrlr_thread_id, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_spdk_env_initialized) {
|
||||
spdk_env_fini();
|
||||
}
|
||||
}
|
||||
|
||||
/* This function enables addition of SPDK parameters to the fio config
|
||||
|
@ -507,14 +507,14 @@ int main(int argc, char **argv)
|
||||
rc = spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
cleanup();
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (TAILQ_EMPTY(&g_controllers)) {
|
||||
fprintf(stderr, "no NVMe controllers found\n");
|
||||
cleanup();
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
printf("Initialization complete.\n");
|
||||
@ -524,5 +524,8 @@ int main(int argc, char **argv)
|
||||
spdk_vmd_fini();
|
||||
}
|
||||
|
||||
return 0;
|
||||
exit:
|
||||
cleanup();
|
||||
spdk_env_fini();
|
||||
return rc;
|
||||
}
|
||||
|
@ -555,7 +555,8 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Detect the controllers that are plugged in at startup. */
|
||||
if (register_controllers() != 0) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Initialization complete. Starting I/O...\n");
|
||||
@ -564,14 +565,17 @@ int main(int argc, char **argv)
|
||||
if (g_expected_insert_times != -1 && g_insert_times != g_expected_insert_times) {
|
||||
fprintf(stderr, "Expected inserts %d != actual inserts %d\n",
|
||||
g_expected_insert_times, g_insert_times);
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (g_expected_removal_times != -1 && g_removal_times != g_expected_removal_times) {
|
||||
fprintf(stderr, "Expected removals %d != actual removals %d\n",
|
||||
g_expected_removal_times, g_removal_times);
|
||||
return 1;
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
cleanup:
|
||||
spdk_env_fini();
|
||||
return rc;
|
||||
}
|
||||
|
@ -2246,7 +2246,8 @@ int main(int argc, char **argv)
|
||||
ctrlr = spdk_nvme_connect(&g_trid, &opts, sizeof(opts));
|
||||
if (!ctrlr) {
|
||||
fprintf(stderr, "spdk_nvme_connect() failed\n");
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
g_controllers_found++;
|
||||
@ -2254,7 +2255,8 @@ int main(int argc, char **argv)
|
||||
spdk_nvme_detach_async(ctrlr, &g_detach_ctx);
|
||||
} else if (spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (g_detach_ctx) {
|
||||
@ -2265,9 +2267,12 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "No NVMe controllers found.\n");
|
||||
}
|
||||
|
||||
exit:
|
||||
if (g_vmd) {
|
||||
spdk_vmd_fini();
|
||||
}
|
||||
|
||||
return 0;
|
||||
spdk_env_fini();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -1634,6 +1634,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
spdk_env_fini();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1704,5 +1705,7 @@ int main(int argc, char **argv)
|
||||
spdk_nvme_detach_poll(detach_ctx);
|
||||
}
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2860,12 +2860,13 @@ int main(int argc, char **argv)
|
||||
rc = pthread_mutex_init(&g_stats_mutex, NULL);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "Failed to init mutex\n");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (spdk_env_init(&opts) < 0) {
|
||||
fprintf(stderr, "Unable to initialize SPDK env\n");
|
||||
rc = -1;
|
||||
goto cleanup;
|
||||
unregister_trids();
|
||||
pthread_mutex_destroy(&g_stats_mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = setup_sig_handlers();
|
||||
@ -2956,6 +2957,8 @@ cleanup:
|
||||
unregister_controllers();
|
||||
unregister_workers();
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
pthread_mutex_destroy(&g_stats_mutex);
|
||||
|
||||
if (rc != 0) {
|
||||
|
@ -1095,8 +1095,8 @@ int main(int argc, char **argv)
|
||||
opts.hugepage_single_segments = g_dpdk_mem_single_seg;
|
||||
if (spdk_env_init(&opts) < 0) {
|
||||
fprintf(stderr, "Unable to initialize SPDK env\n");
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
unregister_trids();
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_tsc_rate = spdk_get_ticks_hz();
|
||||
@ -1159,6 +1159,8 @@ cleanup:
|
||||
unregister_controllers();
|
||||
unregister_workers();
|
||||
|
||||
spdk_env_fini();
|
||||
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "%s: errors occurred\n", argv[0]);
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user