Date: Mon, 10 May 2010 19:12:24 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r207878 - head/sys/geom/vinum Message-ID: <201005101912.o4AJCOFX042392@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jh Date: Mon May 10 19:12:23 2010 New Revision: 207878 URL: http://svn.freebsd.org/changeset/base/207878 Log: - Don't return EAGAIN from gv_unload(). It was used to work around the deadlock fixed in r207671. - Wait for worker process to exit at class unload. The worker process was not guaranteed to exit before the linker unloaded the module. - Use 0 as the worker process exit status instead of ENXIO and style the NOTREACHED comment. Reviewed by: lulf X-MFC after: r207671 Modified: head/sys/geom/vinum/geom_vinum.c head/sys/geom/vinum/geom_vinum.h head/sys/geom/vinum/geom_vinum_events.c head/sys/geom/vinum/geom_vinum_var.h Modified: head/sys/geom/vinum/geom_vinum.c ============================================================================== --- head/sys/geom/vinum/geom_vinum.c Mon May 10 19:08:53 2010 (r207877) +++ head/sys/geom/vinum/geom_vinum.c Mon May 10 19:12:23 2010 (r207878) @@ -186,7 +186,7 @@ gv_init(struct g_class *mp) mtx_init(&sc->config_mtx, "gv_config", NULL, MTX_DEF); mtx_init(&sc->equeue_mtx, "gv_equeue", NULL, MTX_DEF); mtx_init(&sc->bqueue_mtx, "gv_bqueue", NULL, MTX_DEF); - kproc_create(gv_worker, sc, NULL, 0, 0, "gv_worker"); + kproc_create(gv_worker, sc, &sc->worker, 0, 0, "gv_worker"); } static int @@ -200,10 +200,9 @@ gv_unload(struct gctl_req *req, struct g sc = gp->softc; if (sc != NULL) { - gv_post_event(sc, GV_EVENT_THREAD_EXIT, NULL, NULL, 0, 0); + gv_worker_exit(sc); gp->softc = NULL; g_wither_geom(gp, ENXIO); - return (EAGAIN); } return (0); @@ -984,8 +983,8 @@ gv_worker(void *arg) g_free(sc->bqueue_down); g_free(sc->bqueue_up); g_free(sc); - kproc_exit(ENXIO); - break; /* not reached */ + kproc_exit(0); + /* NOTREACHED */ default: G_VINUM_DEBUG(1, "unknown event %d", ev->type); Modified: head/sys/geom/vinum/geom_vinum.h ============================================================================== --- head/sys/geom/vinum/geom_vinum.h Mon May 10 19:08:53 2010 (r207877) +++ head/sys/geom/vinum/geom_vinum.h Mon May 10 19:12:23 2010 (r207878) @@ -122,6 +122,7 @@ int gv_detach_sd(struct gv_sd *, int) void gv_worker(void *); void gv_post_event(struct gv_softc *, int, void *, void *, intmax_t, intmax_t); +void gv_worker_exit(struct gv_softc *); struct gv_event *gv_get_event(struct gv_softc *); void gv_remove_event(struct gv_softc *, struct gv_event *); void gv_drive_tasted(struct gv_softc *, struct g_provider *); Modified: head/sys/geom/vinum/geom_vinum_events.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_events.c Mon May 10 19:08:53 2010 (r207877) +++ head/sys/geom/vinum/geom_vinum_events.c Mon May 10 19:12:23 2010 (r207878) @@ -58,6 +58,20 @@ gv_post_event(struct gv_softc *sc, int e mtx_unlock(&sc->equeue_mtx); } +void +gv_worker_exit(struct gv_softc *sc) +{ + struct gv_event *ev; + + ev = g_malloc(sizeof(*ev), M_WAITOK | M_ZERO); + ev->type = GV_EVENT_THREAD_EXIT; + + mtx_lock(&sc->equeue_mtx); + TAILQ_INSERT_TAIL(&sc->equeue, ev, events); + wakeup(sc); + msleep(sc->worker, &sc->equeue_mtx, PDROP, "gv_wor", 0); +} + struct gv_event * gv_get_event(struct gv_softc *sc) { Modified: head/sys/geom/vinum/geom_vinum_var.h ============================================================================== --- head/sys/geom/vinum/geom_vinum_var.h Mon May 10 19:08:53 2010 (r207877) +++ head/sys/geom/vinum/geom_vinum_var.h Mon May 10 19:12:23 2010 (r207878) @@ -238,6 +238,7 @@ struct gv_softc { struct bio_queue_head *bqueue_up; /* BIO queue for completed requests. */ struct g_geom *geom; /* Pointer to our VINUM geom. */ + struct proc *worker; /* Worker process. */ }; #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005101912.o4AJCOFX042392>