Commit 8b682653 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

trace: do not shm_unlink if tracepoints were specified



This allows us to use the tracepoints as forensics when
a crash occurs - basically a high-powered trace buffer.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I27f6c7a196501b4100cfc19c0354f2c6095ff3bb

Reviewed-on: https://review.gerrithub.io/424282


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent aa37b4f9
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -128,10 +128,23 @@ trace_init_err:
void
spdk_trace_cleanup(void)
{
	if (g_trace_histories) {
	bool unlink;

	if (g_trace_histories == NULL) {
		return;
	}

	/*
	 * Only unlink the shm if there were no tracepoints enabled.  This ensures the file
	 * can be used after this process exits/crashes for debugging.
	 * Note that we have to calculate this value before g_trace_histories gets unmapped.
	 */
	unlink = spdk_mem_all_zero(g_trace_flags->tpoint_mask, sizeof(g_trace_flags->tpoint_mask));
	munmap(g_trace_histories, sizeof(struct spdk_trace_histories));
	g_trace_histories = NULL;
	close(g_trace_fd);
	}

	if (unlink) {
		shm_unlink(g_shm_name);
	}
}