From d99c155975c1a6a8e1e4b7e20dad0d79da225ff1 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Mon, 10 Apr 2006 03:55:13 +0000 Subject: [PATCH] Add g_wither_provider() to abstract the details of destroying a particular provider. Use this function where g_orphan_provider() is being called so that the flags are updated correctly and g_orphan_provider() is called only when allowed. --- sys/geom/geom.h | 1 + sys/geom/geom_disk.c | 2 +- sys/geom/geom_slice.c | 3 +-- sys/geom/geom_subr.c | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 7f6bf5ae1f16..79a2e3b4c872 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -239,6 +239,7 @@ void g_std_done(struct bio *bp); void g_std_spoiled(struct g_consumer *cp); void g_wither_geom(struct g_geom *gp, int error); void g_wither_geom_close(struct g_geom *gp, int error); +void g_wither_provider(struct g_provider *pp, int error); #ifdef DIAGNOSTIC int g_valid_obj(void const *ptr); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 75d8fc45ac8c..611510699796 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -428,7 +428,7 @@ disk_gone(struct disk *dp) gp = dp->d_geom; if (gp != NULL) LIST_FOREACH(pp, &gp->provider, provider) - g_orphan_provider(pp, ENXIO); + g_wither_provider(pp, ENXIO); } static void diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index 97b58f5e7f2a..2cf3385085da 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -338,8 +338,7 @@ g_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length return (0); if (bootverbose) printf("GEOM: Deconfigure %s\n", pp->name); - pp->flags |= G_PF_WITHER; - g_orphan_provider(pp, ENXIO); + g_wither_provider(pp, ENXIO); gsl->provider = NULL; gsp->nprovider--; return (0); diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index 8bedee9bc731..623650ab9148 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -317,6 +317,18 @@ g_wither_geom(struct g_geom *gp, int error) g_do_wither(); } +/* + * Convenience function to destroy a particular provider. + */ +void +g_wither_provider(struct g_provider *pp, int error) +{ + + pp->flags |= G_PF_WITHER; + if (!(pp->flags & G_PF_ORPHAN)) + g_orphan_provider(pp, error); +} + /* * This function is called (repeatedly) until the has withered away. */