From owner-svn-src-head@FreeBSD.ORG Wed May 6 18:21:49 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 220D01065673; Wed, 6 May 2009 18:21:49 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FCFA8FC20; Wed, 6 May 2009 18:21:49 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n46ILmrY025832; Wed, 6 May 2009 18:21:48 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n46ILmw8025827; Wed, 6 May 2009 18:21:48 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200905061821.n46ILmw8025827@svn.freebsd.org> From: Ulf Lilleengen Date: Wed, 6 May 2009 18:21:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191849 - head/sys/geom/vinum X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2009 18:21:50 -0000 Author: lulf Date: Wed May 6 18:21:48 2009 New Revision: 191849 URL: http://svn.freebsd.org/changeset/base/191849 Log: - Split the queue mutex into one for the event queue and one for the BIO queue, as they do not really relate and to prepare for an additional queue to be covered by the BIO queue mutex. - Implement wrappers for fetching the next element from the event queue as well as for putting a new element into the BIO queue. 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_plex.c head/sys/geom/vinum/geom_vinum_var.h Modified: head/sys/geom/vinum/geom_vinum.c ============================================================================== --- head/sys/geom/vinum/geom_vinum.c Wed May 6 17:52:38 2009 (r191848) +++ head/sys/geom/vinum/geom_vinum.c Wed May 6 18:21:48 2009 (r191849) @@ -81,6 +81,17 @@ gv_orphan(struct g_consumer *cp) } void +gv_post_bio(struct gv_softc *sc, struct bio *bp) +{ + + KASSERT(sc != NULL, ("NULL sc")); + mtx_lock(&sc->bqueue_mtx); + bioq_disksort(sc->bqueue, bp); + wakeup(sc); + mtx_unlock(&sc->bqueue_mtx); +} + +void gv_start(struct bio *bp) { struct g_geom *gp; @@ -100,10 +111,7 @@ gv_start(struct bio *bp) return; } - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, bp); - wakeup(sc); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, bp); } void @@ -118,10 +126,7 @@ gv_done(struct bio *bp) sc = gp->softc; bp->bio_cflags |= GV_BIO_DONE; - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, bp); - wakeup(sc); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, bp); } int @@ -181,7 +186,8 @@ gv_init(struct g_class *mp) LIST_INIT(&sc->volumes); TAILQ_INIT(&sc->equeue); mtx_init(&sc->config_mtx, "gv_config", NULL, MTX_DEF); - mtx_init(&sc->queue_mtx, "gv_queue", 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"); } @@ -637,13 +643,11 @@ gv_worker(void *arg) sc = arg; KASSERT(sc != NULL, ("NULL sc")); - mtx_lock(&sc->queue_mtx); for (;;) { /* Look at the events first... */ - ev = TAILQ_FIRST(&sc->equeue); + ev = gv_get_event(sc); if (ev != NULL) { - TAILQ_REMOVE(&sc->equeue, ev, events); - mtx_unlock(&sc->queue_mtx); + gv_remove_event(sc, ev); switch (ev->type) { case GV_EVENT_DRIVE_TASTED: @@ -959,9 +963,11 @@ gv_worker(void *arg) case GV_EVENT_THREAD_EXIT: G_VINUM_DEBUG(2, "event 'thread exit'"); g_free(ev); - mtx_lock(&sc->queue_mtx); + mtx_lock(&sc->equeue_mtx); + mtx_lock(&sc->bqueue_mtx); gv_cleanup(sc); - mtx_destroy(&sc->queue_mtx); + mtx_destroy(&sc->bqueue_mtx); + mtx_destroy(&sc->equeue_mtx); g_free(sc->bqueue); g_free(sc); kproc_exit(ENXIO); @@ -972,18 +978,18 @@ gv_worker(void *arg) } g_free(ev); - - mtx_lock(&sc->queue_mtx); continue; } /* ... then do I/O processing. */ + mtx_lock(&sc->bqueue_mtx); bp = bioq_takefirst(sc->bqueue); if (bp == NULL) { - msleep(sc, &sc->queue_mtx, PRIBIO, "-", hz/10); + msleep(sc, &sc->bqueue_mtx, PRIBIO, "-", hz/10); + mtx_unlock(&sc->bqueue_mtx); continue; } - mtx_unlock(&sc->queue_mtx); + mtx_unlock(&sc->bqueue_mtx); /* A bio that is coming up from an underlying device. */ if (bp->bio_cflags & GV_BIO_DONE) { @@ -1009,8 +1015,6 @@ gv_worker(void *arg) } else { gv_volume_start(sc, bp); } - - mtx_lock(&sc->queue_mtx); } } Modified: head/sys/geom/vinum/geom_vinum.h ============================================================================== --- head/sys/geom/vinum/geom_vinum.h Wed May 6 17:52:38 2009 (r191848) +++ head/sys/geom/vinum/geom_vinum.h Wed May 6 18:21:48 2009 (r191849) @@ -122,9 +122,12 @@ 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); +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 *); void gv_drive_lost(struct gv_softc *, struct gv_drive *); void gv_setup_objects(struct gv_softc *); +void gv_post_bio(struct gv_softc *, struct bio *); void gv_start(struct bio *); int gv_access(struct g_provider *, int, int, int); void gv_cleanup(struct gv_softc *); Modified: head/sys/geom/vinum/geom_vinum_events.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_events.c Wed May 6 17:52:38 2009 (r191848) +++ head/sys/geom/vinum/geom_vinum_events.c Wed May 6 18:21:48 2009 (r191849) @@ -52,10 +52,33 @@ gv_post_event(struct gv_softc *sc, int e ev->arg3 = arg3; ev->arg4 = arg4; - mtx_lock(&sc->queue_mtx); + mtx_lock(&sc->equeue_mtx); TAILQ_INSERT_TAIL(&sc->equeue, ev, events); wakeup(sc); - mtx_unlock(&sc->queue_mtx); + mtx_unlock(&sc->equeue_mtx); +} + +struct gv_event * +gv_get_event(struct gv_softc *sc) +{ + struct gv_event *ev; + + KASSERT(sc != NULL, ("NULL sc")); + mtx_lock(&sc->equeue_mtx); + ev = TAILQ_FIRST(&sc->equeue); + mtx_unlock(&sc->equeue_mtx); + return (ev); +} + +void +gv_remove_event(struct gv_softc *sc, struct gv_event *ev) +{ + + KASSERT(sc != NULL, ("NULL sc")); + KASSERT(ev != NULL, ("NULL ev")); + mtx_lock(&sc->equeue_mtx); + TAILQ_REMOVE(&sc->equeue, ev, events); + mtx_unlock(&sc->equeue_mtx); } void Modified: head/sys/geom/vinum/geom_vinum_plex.c ============================================================================== --- head/sys/geom/vinum/geom_vinum_plex.c Wed May 6 17:52:38 2009 (r191848) +++ head/sys/geom/vinum/geom_vinum_plex.c Wed May 6 18:21:48 2009 (r191849) @@ -360,9 +360,7 @@ gv_plex_raid5_done(struct gv_plex *p, st /* Bring the waiting bios back into the game. */ pbp = bioq_takefirst(p->wqueue); while (pbp != NULL) { - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, pbp); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, pbp); pbp = bioq_takefirst(p->wqueue); } } @@ -406,9 +404,7 @@ gv_plex_raid5_done(struct gv_plex *p, st /* Bring the waiting bios back into the game. */ pbp = bioq_takefirst(p->wqueue); while (pbp != NULL) { - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, pbp); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, pbp); pbp = bioq_takefirst(p->wqueue); } g_free(wp); @@ -581,9 +577,7 @@ gv_sync_request(struct gv_plex *from, st bp->bio_data = data; /* Send down next. */ - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, bp); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, bp); //gv_plex_start(from, bp); return (0); } @@ -696,9 +690,7 @@ gv_grow_request(struct gv_plex *p, off_t bp->bio_cflags |= GV_BIO_MALLOC; bp->bio_data = data; - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, bp); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, bp); //gv_plex_start(p, bp); return (0); } @@ -921,9 +913,7 @@ gv_parity_request(struct gv_plex *p, int /* We still have more parity to build. */ bp->bio_offset = offset; - mtx_lock(&sc->queue_mtx); - bioq_disksort(sc->bqueue, bp); - mtx_unlock(&sc->queue_mtx); + gv_post_bio(sc, bp); //gv_plex_start(p, bp); /* Send it down to the plex. */ } Modified: head/sys/geom/vinum/geom_vinum_var.h ============================================================================== --- head/sys/geom/vinum/geom_vinum_var.h Wed May 6 17:52:38 2009 (r191848) +++ head/sys/geom/vinum/geom_vinum_var.h Wed May 6 18:21:48 2009 (r191849) @@ -231,7 +231,8 @@ struct gv_softc { LIST_HEAD(,gv_volume) volumes; /* All volumes. */ TAILQ_HEAD(,gv_event) equeue; /* Event queue. */ - struct mtx queue_mtx; /* Queue lock. */ + struct mtx equeue_mtx; /* Event queue lock. */ + struct mtx bqueue_mtx; /* BIO queue lock. */ struct mtx config_mtx; /* Configuration lock. */ struct bio_queue_head *bqueue; /* BIO queue. */ struct g_geom *geom; /* Pointer to our VINUM geom. */