Commit ef72f4c5 authored by Jim Harris's avatar Jim Harris
Browse files

test/app/stub: try to unlink sentinel file on app start



For testing purposes, the stub app creates a sentinel file that scripts
can look for to see when the stub is ready to start accepting secondary
processes. We need to wait until after spdk_nvme_probe() completes which
can take a while depending on init time of the SSDs.

The stub app will unlink the file on normal shutdown, but if it crashes
unexpectedly, the file will remain and prevent the stub app from starting
again until user manually deletes it.

So immediately unlink the sentinel file at start of stub_start() - we know
at this point that *if* the file still exists it must be left over from a
crashed stub and not a currently running stub (since we can't get to this
point if there's already a primary process at this shm_id). Then create the
file after the spdk_nvme_probe() is complete.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I46cfc9fb1b76d859c9af5c4bbb008ca16b529b28
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22477


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent be619872
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -102,6 +102,13 @@ stub_start(void *arg1)
{
	int shm_id = (intptr_t)arg1;

	snprintf(g_path, sizeof(g_path), "/var/run/spdk_stub%d", shm_id);

	/* If sentinel file already exists from earlier crashed stub, delete
	 * it now to avoid mknod() failure after spdk_nvme_probe() completes.
	 */
	unlink(g_path);

	spdk_unaffinitize_thread();

	if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
@@ -109,7 +116,6 @@ stub_start(void *arg1)
		exit(1);
	}

	snprintf(g_path, sizeof(g_path), "/var/run/spdk_stub%d", shm_id);
	if (mknod(g_path, S_IFREG, 0) != 0) {
		fprintf(stderr, "could not create sentinel file %s\n", g_path);
		exit(1);