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.
This commit is contained in:
Marcel Moolenaar 2006-04-10 03:55:13 +00:00
parent 123a5345c1
commit d99c155975
4 changed files with 15 additions and 3 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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.
*/