From b86c6b1704774dae38fdc3557874ebde2fc219da Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Fri, 27 Jul 2018 15:14:57 +0200 Subject: [PATCH] env_dpdk: delete all unnecessary files created by dpdk 18.05 DPDK 18.05 introduces a new "runtime" directory, which contains hugepage metadata to be accessed by secondary processes. There may be multiple files per each memseg and we cannot easily predict their count, so this patch deletes all regular files in that directory. $ ls -l /var/run/dpdk/spdk_pidX total 16784 -rw------- 1 root root 4096 Jul 27 15:10 fbarray_memseg-1048576k-1-0 -rw------- 1 root root 188416 Jul 27 15:10 fbarray_memzone -rw-r--r-- 1 root root 16974144 Jul 27 15:10 hugepage_data -rw-r--r-- 1 root root 12432 Jul 27 15:10 hugepage_info srwxr-xr-x 1 root root 0 Jul 27 15:10 mp_socket The DPDK config file is not located in this directory yet to preserve some of the backward compability. Eventually, it will moved there as well. Change-Id: I61cf1a47b306b51b0817c9d870841508f1e5e604 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/420659 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/env_dpdk/init.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 888f095ed..c6a2a4353 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -100,6 +100,10 @@ _sprintf_alloc(const char *format, ...) return NULL; } +#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) +const char *eal_get_runtime_dir(void); +#endif + static void spdk_env_unlink_shared_files(void) { @@ -110,10 +114,34 @@ spdk_env_unlink_shared_files(void) fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno); } +#if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0) snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_hugepage_info", getpid()); if (unlink(buffer)) { fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno); } +#else + DIR *dir; + struct dirent *d; + + dir = opendir(eal_get_runtime_dir()); + if (!dir) { + fprintf(stderr, "Failed to open DPDK runtime dir: %s (%d)\n", eal_get_runtime_dir(), errno); + return; + } + + while ((d = readdir(dir)) != NULL) { + if (d->d_type != DT_REG) { + continue; + } + + snprintf(buffer, PATH_MAX, "%s/%s", eal_get_runtime_dir(), d->d_name); + if (unlink(buffer)) { + fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno); + } + } + + closedir(dir); +#endif } void