git: 472f92731fb7 - stable/13 - GEOM: Minor polishing in geom_event.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 11 Jan 2022 02:45:35 UTC
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=472f92731fb7ccb8f82476a4f73973655aa367c3 commit 472f92731fb7ccb8f82476a4f73973655aa367c3 Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2021-12-28 01:52:59 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2022-01-11 02:45:30 +0000 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 (cherry picked from commit f4bf48c25c3a8de3fbfd49b45b2d59026df13a6a) --- 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 1aba1f46d6d5..d9ba42b005de 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -269,7 +269,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);