From f4bf48c25c3a8de3fbfd49b45b2d59026df13a6a Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 27 Dec 2021 20:52:59 -0500 Subject: [PATCH] GEOM: Minor polishing in geom_event. - Remove timeouts from msleep()'s. Those should always be woken up. - Move wakeup() under the lock to not call on possibly freed pointer. - Remove some dead code. MFC after: 2 weeks --- sys/geom/geom.h | 1 - sys/geom/geom_event.c | 27 +++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 0d6d74d0b51c..d48deb0e0ae4 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -268,7 +268,6 @@ int g_attr_changed(struct g_provider *pp, const char *attr, int flag); int g_media_changed(struct g_provider *pp, int flag); int g_media_gone(struct g_provider *pp, int flag); void g_orphan_provider(struct g_provider *pp, int error); -void g_waitidlelock(void); struct g_event *g_alloc_event(int flag); void g_post_event_ep(g_event_t *func, void *arg, struct g_event *ep, ...); diff --git a/sys/geom/geom_event.c b/sys/geom/geom_event.c index f9a1d445d36a..359c7c984f07 100644 --- a/sys/geom/geom_event.c +++ b/sys/geom/geom_event.c @@ -90,29 +90,12 @@ g_waitidle(void) TSWAIT("GEOM events"); while (!TAILQ_EMPTY(&g_events)) msleep(&g_pending_events, &g_eventlock, PPAUSE, - "g_waitidle", hz/5); + "g_waitidle", 0); TSUNWAIT("GEOM events"); mtx_unlock(&g_eventlock); curthread->td_pflags &= ~TDP_GEOM; } -#if 0 -void -g_waitidlelock(void) -{ - - g_topology_assert(); - mtx_lock(&g_eventlock); - while (!TAILQ_EMPTY(&g_events)) { - g_topology_unlock(); - msleep(&g_pending_events, &g_eventlock, PPAUSE, - "g_waitidlel", hz/5); - g_topology_lock(); - } - mtx_unlock(&g_eventlock); -} -#endif - struct g_attrchanged_args { struct g_provider *pp; const char *attr; @@ -254,10 +237,6 @@ one_event(void) wakeup(&g_pending_events); return (0); } - if (ep->flag & EV_INPROGRESS) { - mtx_unlock(&g_eventlock); - return (1); - } ep->flag |= EV_INPROGRESS; mtx_unlock(&g_eventlock); g_topology_assert(); @@ -269,8 +248,8 @@ one_event(void) ep->flag &= ~EV_INPROGRESS; if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; - mtx_unlock(&g_eventlock); wakeup(ep); + mtx_unlock(&g_eventlock); } else { mtx_unlock(&g_eventlock); g_free(ep); @@ -457,7 +436,7 @@ g_waitfor_event(g_event_t *func, void *arg, int flag, ...) mtx_lock(&g_eventlock); while (!(ep->flag & EV_DONE)) - msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz); + msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", 0); if (ep->flag & EV_CANCELED) error = EAGAIN; mtx_unlock(&g_eventlock);