From d10d581667ba58ed6953eb404936236ee0e60b21 Mon Sep 17 00:00:00 2001 From: asomers Date: Wed, 27 May 2020 19:13:26 +0000 Subject: [PATCH] geli: fix a livelock during panic During any kind of shutdown, kern_reboot calls geli's pre_sync event hook, which tries to destroy all unused geli devices. But during a panic, geli can't destroy any devices, because the scheduler is stopped, so it can't switch threads. A livelock results, and the system never dumps core. This commit fixes the problem by refusing to destroy any devices during panic, used or otherwise. PR: 246207 Reviewed by: jhb MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D24697 --- sys/geom/eli/g_eli.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index ab1f02f34ed..2a7076c0fd2 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -1416,11 +1416,13 @@ g_eli_shutdown_pre_sync(void *arg, int howto) continue; pp = LIST_FIRST(&gp->provider); KASSERT(pp != NULL, ("No provider? gp=%p (%s)", gp, gp->name)); - if (pp->acr + pp->acw + pp->ace == 0) - error = g_eli_destroy(sc, TRUE); - else { + if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0 || + SCHEDULER_STOPPED()) + { sc->sc_flags |= G_ELI_FLAG_RW_DETACH; gp->access = g_eli_access; + } else { + error = g_eli_destroy(sc, TRUE); } } g_topology_unlock(); -- 2.45.0