svn commit: r211065 - stable/8/sys/geom/vinum

Jaakko Heinonen jh at FreeBSD.org
Sun Aug 8 09:12:30 UTC 2010


Author: jh
Date: Sun Aug  8 09:12:30 2010
New Revision: 211065
URL: http://svn.freebsd.org/changeset/base/211065

Log:
  MFC r207878:
  
  - 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.

Modified:
  stable/8/sys/geom/vinum/geom_vinum.c
  stable/8/sys/geom/vinum/geom_vinum.h
  stable/8/sys/geom/vinum/geom_vinum_events.c
  stable/8/sys/geom/vinum/geom_vinum_var.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cam/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/geom/vinum/geom_vinum.c
==============================================================================
--- stable/8/sys/geom/vinum/geom_vinum.c	Sun Aug  8 09:06:59 2010	(r211064)
+++ stable/8/sys/geom/vinum/geom_vinum.c	Sun Aug  8 09:12:30 2010	(r211065)
@@ -187,7 +187,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
@@ -201,10 +201,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);
@@ -970,8 +969,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: stable/8/sys/geom/vinum/geom_vinum.h
==============================================================================
--- stable/8/sys/geom/vinum/geom_vinum.h	Sun Aug  8 09:06:59 2010	(r211064)
+++ stable/8/sys/geom/vinum/geom_vinum.h	Sun Aug  8 09:12:30 2010	(r211065)
@@ -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: stable/8/sys/geom/vinum/geom_vinum_events.c
==============================================================================
--- stable/8/sys/geom/vinum/geom_vinum_events.c	Sun Aug  8 09:06:59 2010	(r211064)
+++ stable/8/sys/geom/vinum/geom_vinum_events.c	Sun Aug  8 09:12:30 2010	(r211065)
@@ -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: stable/8/sys/geom/vinum/geom_vinum_var.h
==============================================================================
--- stable/8/sys/geom/vinum/geom_vinum_var.h	Sun Aug  8 09:06:59 2010	(r211064)
+++ stable/8/sys/geom/vinum/geom_vinum_var.h	Sun Aug  8 09:12:30 2010	(r211065)
@@ -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
 


More information about the svn-src-all mailing list