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

event: deinit old scheduler before init'ing new one



I think the idea here was to try to init the new scheduler first,
and then if that fails we just keep the old scheduler instead.

But this breaks the common case where you want to switch between
the dynamic and gscheduler schedulers. For example, if you switch
from dynamic to gscheduler, gscheduler will init() and set the
governor, but then dynamic deinit() will clear the governor.
gscheduler() then segfaults because the governor is now NULL.

Fixes issue #3388.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
parent ff69ab47
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -97,12 +97,20 @@ spdk_scheduler_set(const char *name)
		return 0;
	}

	rc = scheduler->init();
	if (rc == 0) {
	if (g_scheduler) {
		g_scheduler->deinit();
	}

	rc = scheduler->init();
	if (rc == 0) {
		g_scheduler = scheduler;
	} else {
		/* Could not switch to the new scheduler, so keep the old
		 * one. We need to ->init() it again.
		 */
		SPDK_ERRLOG("Could not ->init() '%s' scheduler, reverting to '%s'\n",
			    name, g_scheduler->name);
		g_scheduler->init();
	}

	return rc;