Commit af0d9076 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

bdev: wait_for_examine during spdk_bdev_finish.



Wait for all bdevs to finish examination before
proceeding with the spdk_bdev_finish shutdown
logic.  This ensures the bdev layer and its
modules are not trying to examine bdevs after
the bdev layer has reported it has shut down.

Theoretically, bdev modules could all defer their
fini callbacks until any outstanding examinations
are complete, but it is WAY simpler to just use
the existing spdK_bdev_wait_for_examine API
instead.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: If90cc2a786281d348b82de8beb17ac37ba269c64
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13850


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent a100b4a4
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -1867,9 +1867,17 @@ spdk_bdev_module_fini_start_done(void)
	}
}

static void
bdev_finish_wait_for_examine_done(void *cb_arg)
{
	bdev_module_fini_start_iter(NULL);
}

void
spdk_bdev_finish(spdk_bdev_fini_cb cb_fn, void *cb_arg)
{
	int rc;

	assert(cb_fn != NULL);

	g_fini_thread = spdk_get_thread();
@@ -1877,7 +1885,11 @@ spdk_bdev_finish(spdk_bdev_fini_cb cb_fn, void *cb_arg)
	g_fini_cb_fn = cb_fn;
	g_fini_cb_arg = cb_arg;

	bdev_module_fini_start_iter(NULL);
	rc = spdk_bdev_wait_for_examine(bdev_finish_wait_for_examine_done, NULL);
	if (rc != 0) {
		SPDK_ERRLOG("wait_for_examine failed: %s\n", spdk_strerror(-rc));
		bdev_finish_wait_for_examine_done(NULL);
	}
}

struct spdk_bdev_io *