Commit 4a3ef933 authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

env/dpdk: unlink hugepage_info and config files immediately for single process apps



There is no need to wait until an atexit() to unlink these - we can do it immediately
since the open refs will still be valid.

Note: changed the remove() calls to unlink() to be more precise, since these are
files and not directories.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ib160131bcf3beb9783c6fc4de021f64c43c943a9
Reviewed-on: https://review.gerrithub.io/382697


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
parent 5589fc4a
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -99,18 +99,18 @@ _sprintf_alloc(const char *format, ...)
}

static void
spdk_env_delete_shared_files(void)
spdk_env_unlink_shared_files(void)
{
	char buffer[PATH_MAX];

	snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_config", getpid());
	if (remove(buffer)) {
		fprintf(stderr, "Unable to remove shared memory file: %s. Error code: %d\n", buffer, errno);
	if (unlink(buffer)) {
		fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno);
	}

	snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_hugepage_info", getpid());
	if (remove(buffer)) {
		fprintf(stderr, "Unable to remove shared memory file: %s. Error code: %d\n", buffer, errno);
	if (unlink(buffer)) {
		fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno);
	}
}

@@ -304,16 +304,14 @@ void spdk_env_init(const struct spdk_env_opts *opts)
		exit(-1);
	}

	/* If the shared memory id is less than 0, that means that we are
	 * starting a single process application. There will be no other
	 * processes relying on the shared configuration files created by
	 * dpdk for this process, and they can be deleted upon exit.
	 * Specifying a shared memory id >= 0 implies that there will be multiple
	 * processes relying on those configuration files, and we cannot delete
	 * them when this process exits.
	 */
	if (opts->shm_id < 0) {
		atexit(spdk_env_delete_shared_files);
		/*
		 * Unlink hugepage and config info files after init.  This will ensure they get
		 *  deleted on app exit, even if the app crashes and does not exit normally.
		 *  Only do this when not in multi-process mode, since for multi-process other
		 *  apps will need to open these files.
		 */
		spdk_env_unlink_shared_files();
	}

	spdk_mem_map_init();