From 969ff54d7028ef66a9cb3e07ad668cc61cdfad23 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 2 Aug 2004 00:37:40 +0000 Subject: [PATCH] - Fix unloading by the same way it is done in my other classes: set gp->softc to NULL and return ENXIO when it is NULL, so GEOM will not panic or hang, but unload one device on every 'unload'. This make 'unload' command usable, but it have to be executed + 1 times. - Made use of 'pp' variable. --- sys/geom/nop/g_nop.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c index c9e53ea5873..bedc2ef4ddc 100644 --- a/sys/geom/nop/g_nop.c +++ b/sys/geom/nop/g_nop.c @@ -85,8 +85,6 @@ g_nop_start(struct bio *bp) g_io_deliver(bp, ENOMEM); return; } - pp = LIST_FIRST(&gp->provider); - KASSERT(pp != NULL, ("NULL pp")); if (sc->sc_failprob > 0) { u_int rval; @@ -100,7 +98,9 @@ g_nop_start(struct bio *bp) cbp->bio_offset = bp->bio_offset + sc->sc_offset; cbp->bio_data = bp->bio_data; cbp->bio_length = bp->bio_length; - cbp->bio_to = LIST_FIRST(&gp->provider); + pp = LIST_FIRST(&gp->provider); + KASSERT(pp != NULL, ("NULL pp")); + cbp->bio_to = pp; G_NOP_LOGREQ(cbp, "Sending request."); g_io_request(cbp, LIST_FIRST(&gp->consumer)); } @@ -228,6 +228,8 @@ g_nop_destroy(struct g_geom *gp, boolean_t force) struct g_provider *pp; g_topology_assert(); + if (gp->softc == NULL) + return (ENXIO); pp = LIST_FIRST(&gp->provider); if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) { if (force) {