geom_slice.c revision 114504
192108Sphk/*- 292108Sphk * Copyright (c) 2002 Poul-Henning Kamp 392108Sphk * Copyright (c) 2002 Networks Associates Technology, Inc. 492108Sphk * All rights reserved. 592108Sphk * 692108Sphk * This software was developed for the FreeBSD Project by Poul-Henning Kamp 792108Sphk * and NAI Labs, the Security Research Division of Network Associates, Inc. 892108Sphk * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 992108Sphk * DARPA CHATS research program. 1092108Sphk * 1192108Sphk * Redistribution and use in source and binary forms, with or without 1292108Sphk * modification, are permitted provided that the following conditions 1392108Sphk * are met: 1492108Sphk * 1. Redistributions of source code must retain the above copyright 1592108Sphk * notice, this list of conditions and the following disclaimer. 1692108Sphk * 2. Redistributions in binary form must reproduce the above copyright 1792108Sphk * notice, this list of conditions and the following disclaimer in the 1892108Sphk * documentation and/or other materials provided with the distribution. 1992108Sphk * 3. The names of the authors may not be used to endorse or promote 2092108Sphk * products derived from this software without specific prior written 2192108Sphk * permission. 2292108Sphk * 2392108Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2492108Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2592108Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2692108Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2792108Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2892108Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2992108Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3092108Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3192108Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3292108Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3392108Sphk * SUCH DAMAGE. 3492108Sphk * 3592108Sphk * $FreeBSD: head/sys/geom/geom_slice.c 114504 2003-05-02 06:29:33Z phk $ 3692108Sphk */ 3792108Sphk 3892108Sphk 3992108Sphk#include <sys/param.h> 4092108Sphk#include <sys/systm.h> 4192108Sphk#include <sys/kernel.h> 4292108Sphk#include <sys/malloc.h> 4392108Sphk#include <sys/bio.h> 4492108Sphk#include <sys/sysctl.h> 4592108Sphk#include <sys/proc.h> 4692108Sphk#include <sys/kthread.h> 4792108Sphk#include <sys/lock.h> 4892108Sphk#include <sys/mutex.h> 4992108Sphk#include <sys/errno.h> 5092108Sphk#include <sys/sbuf.h> 5192108Sphk#include <geom/geom.h> 5292108Sphk#include <geom/geom_slice.h> 5392108Sphk#include <machine/stdarg.h> 5492108Sphk 5593776Sphkstatic g_orphan_t g_slice_orphan; 5693776Sphkstatic g_access_t g_slice_access; 5793776Sphkstatic g_start_t g_slice_start; 5893776Sphk 5995321Sphkstatic struct g_slicer * 60114493Sphkg_slice_alloc(unsigned nslice, unsigned scsize) 6192108Sphk{ 6292108Sphk struct g_slicer *gsp; 6392108Sphk 64111119Simp gsp = g_malloc(sizeof *gsp, M_WAITOK | M_ZERO); 65111119Simp gsp->softc = g_malloc(scsize, M_WAITOK | M_ZERO); 66104057Sphk gsp->slices = g_malloc(nslice * sizeof(struct g_slice), 67111119Simp M_WAITOK | M_ZERO); 6892108Sphk gsp->nslice = nslice; 6992108Sphk return (gsp); 7092108Sphk} 7192108Sphk 72114493Sphkstatic void 73114493Sphkg_slice_free(struct g_slicer *gsp) 74114493Sphk{ 75114493Sphk 76114493Sphk g_free(gsp->slices); 77114493Sphk if (gsp->hotspot != NULL) 78114493Sphk g_free(gsp->hotspot); 79114493Sphk g_free(gsp->softc); 80114493Sphk g_free(gsp); 81114493Sphk} 82114493Sphk 8393776Sphkstatic int 8492108Sphkg_slice_access(struct g_provider *pp, int dr, int dw, int de) 8592108Sphk{ 86107953Sphk int error; 87107953Sphk u_int u; 8892108Sphk struct g_geom *gp; 8992108Sphk struct g_consumer *cp; 9092108Sphk struct g_provider *pp2; 9192108Sphk struct g_slicer *gsp; 9292108Sphk struct g_slice *gsl, *gsl2; 9392108Sphk 9492108Sphk gp = pp->geom; 9592108Sphk cp = LIST_FIRST(&gp->consumer); 9692108Sphk KASSERT (cp != NULL, ("g_slice_access but no consumer")); 9792108Sphk gsp = gp->softc; 9892108Sphk gsl = &gsp->slices[pp->index]; 99107953Sphk for (u = 0; u < gsp->nslice; u++) { 100107953Sphk gsl2 = &gsp->slices[u]; 10192108Sphk if (gsl2->length == 0) 10292108Sphk continue; 103107953Sphk if (u == pp->index) 10492108Sphk continue; 10592108Sphk if (gsl->offset + gsl->length <= gsl2->offset) 10692108Sphk continue; 10792108Sphk if (gsl2->offset + gsl2->length <= gsl->offset) 10892108Sphk continue; 10992108Sphk /* overlap */ 11092108Sphk pp2 = gsl2->provider; 11192108Sphk if ((pp->acw + dw) > 0 && pp2->ace > 0) 11292108Sphk return (EPERM); 11392108Sphk if ((pp->ace + de) > 0 && pp2->acw > 0) 11492108Sphk return (EPERM); 11592108Sphk } 11692108Sphk /* On first open, grab an extra "exclusive" bit */ 11792108Sphk if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0) 11892108Sphk de++; 11992108Sphk /* ... and let go of it on last close */ 12092108Sphk if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1) 12192108Sphk de--; 12292108Sphk error = g_access_rel(cp, dr, dw, de); 12392108Sphk return (error); 12492108Sphk} 12592108Sphk 126113713Sphk/* 127113713Sphk * XXX: It should be possible to specify here if we should finish all of the 128113713Sphk * XXX: bio, or only the non-hot bits. This would get messy if there were 129113713Sphk * XXX: two hot spots in the same bio, so for now we simply finish off the 130113713Sphk * XXX: entire bio. Modifying hot data on the way to disk is frowned on 131113713Sphk * XXX: so making that considerably harder is not a bad idea anyway. 132113713Sphk */ 133107522Sphkvoid 134107522Sphkg_slice_finish_hot(struct bio *bp) 135107522Sphk{ 136107522Sphk struct bio *bp2; 137107522Sphk struct g_geom *gp; 138107522Sphk struct g_consumer *cp; 139107522Sphk struct g_slicer *gsp; 140107522Sphk struct g_slice *gsl; 141107953Sphk int idx; 142107522Sphk 143113713Sphk KASSERT(bp->bio_to != NULL, 144113713Sphk ("NULL bio_to in g_slice_finish_hot(%p)", bp)); 145113713Sphk KASSERT(bp->bio_from != NULL, 146113713Sphk ("NULL bio_from in g_slice_finish_hot(%p)", bp)); 147107522Sphk gp = bp->bio_to->geom; 148107522Sphk gsp = gp->softc; 149107522Sphk cp = LIST_FIRST(&gp->consumer); 150107522Sphk KASSERT(cp != NULL, ("NULL consumer in g_slice_finish_hot(%p)", bp)); 151107953Sphk idx = bp->bio_to->index; 152107953Sphk gsl = &gsp->slices[idx]; 153107522Sphk 154107522Sphk bp2 = g_clone_bio(bp); 155107522Sphk if (bp2 == NULL) { 156107522Sphk g_io_deliver(bp, ENOMEM); 157107522Sphk return; 158107522Sphk } 159107522Sphk if (bp2->bio_offset + bp2->bio_length > gsl->length) 160107522Sphk bp2->bio_length = gsl->length - bp2->bio_offset; 161107522Sphk bp2->bio_done = g_std_done; 162107522Sphk bp2->bio_offset += gsl->offset; 163107522Sphk g_io_request(bp2, cp); 164107522Sphk return; 165107522Sphk} 166107522Sphk 16793776Sphkstatic void 16892108Sphkg_slice_start(struct bio *bp) 16992108Sphk{ 17092108Sphk struct bio *bp2; 17192108Sphk struct g_provider *pp; 17292108Sphk struct g_geom *gp; 17392108Sphk struct g_consumer *cp; 17492108Sphk struct g_slicer *gsp; 175113712Sphk struct g_slice *gsl; 176113713Sphk struct g_slice_hot *ghp; 177107953Sphk int idx, error; 178107522Sphk u_int m_index; 17994287Sphk off_t t; 18092108Sphk 18192108Sphk pp = bp->bio_to; 18292108Sphk gp = pp->geom; 18392108Sphk gsp = gp->softc; 18492108Sphk cp = LIST_FIRST(&gp->consumer); 185107953Sphk idx = pp->index; 186107953Sphk gsl = &gsp->slices[idx]; 18792108Sphk switch(bp->bio_cmd) { 18892108Sphk case BIO_READ: 18992108Sphk case BIO_WRITE: 19092108Sphk case BIO_DELETE: 19192108Sphk if (bp->bio_offset > gsl->length) { 192104195Sphk g_io_deliver(bp, EINVAL); /* XXX: EWHAT ? */ 19392108Sphk return; 19492108Sphk } 195107522Sphk /* 196107522Sphk * Check if we collide with any hot spaces, and call the 197107522Sphk * method once if so. 198107522Sphk */ 199107832Sphk t = bp->bio_offset + gsl->offset; 200113712Sphk for (m_index = 0; m_index < gsp->nhotspot; m_index++) { 201113713Sphk ghp = &gsp->hotspot[m_index]; 202113713Sphk if (t >= ghp->offset + ghp->length) 203107522Sphk continue; 204113713Sphk if (t + bp->bio_length <= ghp->offset) 205107522Sphk continue; 206113713Sphk switch(bp->bio_cmd) { 207113713Sphk case BIO_READ: idx = ghp->ract; break; 208113713Sphk case BIO_WRITE: idx = ghp->wact; break; 209113713Sphk case BIO_DELETE: idx = ghp->dact; break; 210113713Sphk } 211113713Sphk switch(idx) { 212113713Sphk case G_SLICE_HOT_ALLOW: 213113713Sphk /* Fall out and continue normal processing */ 214113713Sphk continue; 215113713Sphk case G_SLICE_HOT_DENY: 216113713Sphk g_io_deliver(bp, EROFS); 217107522Sphk return; 218113713Sphk case G_SLICE_HOT_START: 219113713Sphk error = gsp->start(bp); 220113713Sphk if (error && error != EJUSTRETURN) 221113713Sphk g_io_deliver(bp, error); 222107522Sphk return; 223113713Sphk case G_SLICE_HOT_CALL: 224113937Sphk error = g_post_event(gsp->hot, bp, M_NOWAIT, 225113937Sphk gp, NULL); 226113713Sphk if (error) 227113713Sphk g_io_deliver(bp, error); 228113713Sphk return; 229107522Sphk } 230107522Sphk break; 231107522Sphk } 23292108Sphk bp2 = g_clone_bio(bp); 233104057Sphk if (bp2 == NULL) { 234104195Sphk g_io_deliver(bp, ENOMEM); 235104057Sphk return; 236104057Sphk } 23792108Sphk if (bp2->bio_offset + bp2->bio_length > gsl->length) 23892108Sphk bp2->bio_length = gsl->length - bp2->bio_offset; 23992108Sphk bp2->bio_done = g_std_done; 24092108Sphk bp2->bio_offset += gsl->offset; 24192108Sphk g_io_request(bp2, cp); 24292108Sphk return; 24392108Sphk case BIO_GETATTR: 24494287Sphk /* Give the real method a chance to override */ 245113878Sphk if (gsp->start != NULL && gsp->start(bp)) 24694287Sphk return; 24795038Sphk if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) { 24895038Sphk struct g_kerneldump *gkd; 24995038Sphk 25095038Sphk gkd = (struct g_kerneldump *)bp->bio_data; 251107953Sphk gkd->offset += gsp->slices[idx].offset; 252107953Sphk if (gkd->length > gsp->slices[idx].length) 253107953Sphk gkd->length = gsp->slices[idx].length; 25495038Sphk /* now, pass it on downwards... */ 25595038Sphk } 25692108Sphk bp2 = g_clone_bio(bp); 257104081Sphk if (bp2 == NULL) { 258104195Sphk g_io_deliver(bp, ENOMEM); 259104081Sphk return; 260104081Sphk } 26192108Sphk bp2->bio_done = g_std_done; 26292108Sphk g_io_request(bp2, cp); 26392108Sphk break; 26492108Sphk default: 265104195Sphk g_io_deliver(bp, EOPNOTSUPP); 26692108Sphk return; 26792108Sphk } 26892108Sphk} 26992108Sphk 27092108Sphkvoid 271107953Sphkg_slice_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp) 27292108Sphk{ 27392108Sphk struct g_slicer *gsp; 27492108Sphk 27592108Sphk gsp = gp->softc; 276106101Sphk if (indent == NULL) { 277106101Sphk sbuf_printf(sb, " i %u", pp->index); 278106101Sphk sbuf_printf(sb, " o %ju", 279106101Sphk (uintmax_t)gsp->slices[pp->index].offset); 280106101Sphk return; 281106101Sphk } 28292108Sphk if (pp != NULL) { 28392108Sphk sbuf_printf(sb, "%s<index>%u</index>\n", indent, pp->index); 284105540Sphk sbuf_printf(sb, "%s<length>%ju</length>\n", 285105540Sphk indent, (uintmax_t)gsp->slices[pp->index].length); 286105540Sphk sbuf_printf(sb, "%s<seclength>%ju</seclength>\n", indent, 287105540Sphk (uintmax_t)gsp->slices[pp->index].length / 512); 288105540Sphk sbuf_printf(sb, "%s<offset>%ju</offset>\n", indent, 289105540Sphk (uintmax_t)gsp->slices[pp->index].offset); 290105540Sphk sbuf_printf(sb, "%s<secoffset>%ju</secoffset>\n", indent, 291105540Sphk (uintmax_t)gsp->slices[pp->index].offset / 512); 29292108Sphk } 29392108Sphk} 29492108Sphk 295104064Sphkint 296107953Sphkg_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...) 297104064Sphk{ 298110710Sphk struct g_provider *pp, *pp2; 299104064Sphk struct g_slicer *gsp; 300104064Sphk struct g_slice *gsl; 301104064Sphk va_list ap; 302104064Sphk struct sbuf *sb; 303104064Sphk int error, acc; 304104064Sphk 305104195Sphk g_trace(G_T_TOPOLOGY, "g_slice_config(%s, %d, %d)", 306107953Sphk gp->name, idx, how); 307104064Sphk g_topology_assert(); 308104064Sphk gsp = gp->softc; 309104064Sphk error = 0; 310107953Sphk if (idx >= gsp->nslice) 311104064Sphk return(EINVAL); 312107953Sphk gsl = &gsp->slices[idx]; 313104064Sphk pp = gsl->provider; 314104064Sphk if (pp != NULL) 315104064Sphk acc = pp->acr + pp->acw + pp->ace; 316104064Sphk else 317104064Sphk acc = 0; 318104064Sphk if (acc != 0 && how != G_SLICE_CONFIG_FORCE) { 319104064Sphk if (length < gsl->length) 320104064Sphk return(EBUSY); 321104064Sphk if (offset != gsl->offset) 322104064Sphk return(EBUSY); 323104064Sphk } 324104064Sphk /* XXX: check offset + length <= MEDIASIZE */ 325104064Sphk if (how == G_SLICE_CONFIG_CHECK) 326104064Sphk return (0); 327104064Sphk gsl->length = length; 328104064Sphk gsl->offset = offset; 329105542Sphk gsl->sectorsize = sectorsize; 330105957Sphk if (length == 0) { 331105957Sphk if (pp == NULL) 332105957Sphk return (0); 333105957Sphk if (bootverbose) 334105957Sphk printf("GEOM: Deconfigure %s\n", pp->name); 335104064Sphk g_orphan_provider(pp, ENXIO); 336104064Sphk gsl->provider = NULL; 337104064Sphk gsp->nprovider--; 338104064Sphk return (0); 339104064Sphk } 340105957Sphk if (pp != NULL) { 341105957Sphk if (bootverbose) 342105957Sphk printf("GEOM: Reconfigure %s, start %jd length %jd end %jd\n", 343105957Sphk pp->name, (intmax_t)offset, (intmax_t)length, 344105957Sphk (intmax_t)(offset + length - 1)); 345107116Sphk pp->mediasize = gsl->length; 346105957Sphk return (0); 347105957Sphk } 348104064Sphk va_start(ap, fmt); 349104064Sphk sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); 350104064Sphk sbuf_vprintf(sb, fmt, ap); 351104064Sphk sbuf_finish(sb); 352104064Sphk pp = g_new_providerf(gp, sbuf_data(sb)); 353110710Sphk pp2 = LIST_FIRST(&gp->consumer)->provider; 354110710Sphk pp->flags = pp2->flags & G_PF_CANDELETE; 355110713Sphk if (pp2->stripesize > 0) { 356110713Sphk pp->stripesize = pp2->stripesize; 357110713Sphk pp->stripeoffset = (pp2->stripeoffset + offset) % pp->stripesize; 358110713Sphk } 359105957Sphk if (bootverbose) 360105957Sphk printf("GEOM: Configure %s, start %jd length %jd end %jd\n", 361105957Sphk pp->name, (intmax_t)offset, (intmax_t)length, 362105957Sphk (intmax_t)(offset + length - 1)); 363107953Sphk pp->index = idx; 364105542Sphk pp->mediasize = gsl->length; 365105542Sphk pp->sectorsize = gsl->sectorsize; 366104064Sphk gsl->provider = pp; 367104064Sphk gsp->nprovider++; 368104064Sphk g_error_provider(pp, 0); 369104064Sphk sbuf_delete(sb); 370104064Sphk return(0); 371104064Sphk} 372104064Sphk 373113713Sphk/* 374113713Sphk * Configure "hotspots". A hotspot is a piece of the parent device which 375113713Sphk * this particular slicer cares about for some reason. Typically because 376113713Sphk * it contains meta-data used to configure the slicer. 377113713Sphk * A hotspot is identified by its index number. The offset and length are 378113713Sphk * relative to the parent device, and the three "?act" fields specify 379113713Sphk * what action to take on BIO_READ, BIO_DELETE and BIO_WRITE. 380113713Sphk * 381113713Sphk * XXX: There may be a race relative to g_slice_start() here, if an existing 382113713Sphk * XXX: hotspot is changed wile I/O is happening. Should this become a problem 383113713Sphk * XXX: we can protect the hotspot stuff with a mutex. 384113713Sphk */ 385113713Sphk 386107522Sphkint 387113713Sphkg_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length, int ract, int dact, int wact) 388107522Sphk{ 389107522Sphk struct g_slicer *gsp; 390113712Sphk struct g_slice_hot *gsl, *gsl2; 391107522Sphk 392113713Sphk g_trace(G_T_TOPOLOGY, "g_slice_conf_hot(%s, idx: %d, off: %jd, len: %jd)", 393113713Sphk gp->name, idx, (intmax_t)offset, (intmax_t)length); 394107522Sphk g_topology_assert(); 395107522Sphk gsp = gp->softc; 396113712Sphk gsl = gsp->hotspot; 397113712Sphk if(idx >= gsp->nhotspot) { 398111119Simp gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO); 399113712Sphk if (gsp->hotspot != NULL) 400113712Sphk bcopy(gsp->hotspot, gsl2, gsp->nhotspot * sizeof *gsl2); 401113712Sphk gsp->hotspot = gsl2; 402113712Sphk if (gsp->hotspot != NULL) 403107522Sphk g_free(gsl); 404107522Sphk gsl = gsl2; 405113712Sphk gsp->nhotspot = idx + 1; 406107522Sphk } 407107953Sphk gsl[idx].offset = offset; 408107953Sphk gsl[idx].length = length; 409113878Sphk KASSERT(!((ract | dact | wact) & G_SLICE_HOT_START) 410113878Sphk || gsp->start != NULL, ("G_SLICE_HOT_START but no slice->start")); 411113878Sphk /* XXX: check that we _have_ a start function if HOT_START specified */ 412113713Sphk gsl[idx].ract = ract; 413113713Sphk gsl[idx].dact = dact; 414113713Sphk gsl[idx].wact = wact; 415107522Sphk return (0); 416107522Sphk} 417107522Sphk 418114504Sphkvoid 419114504Sphkg_slice_spoiled(struct g_consumer *cp) 420114504Sphk{ 421114504Sphk struct g_geom *gp; 422114504Sphk struct g_slicer *gsp; 423114504Sphk 424114504Sphk g_topology_assert(); 425114504Sphk gp = cp->geom; 426114504Sphk g_trace(G_T_TOPOLOGY, "g_slice_spoiled(%p/%s)", cp, gp->name); 427114504Sphk gsp = gp->softc; 428114504Sphk gp->softc = NULL; 429114504Sphk g_slice_free(gsp); 430114504Sphk g_wither_geom(gp, ENXIO); 431114504Sphk} 432114504Sphk 43392108Sphkstruct g_geom * 434107522Sphkg_slice_new(struct g_class *mp, u_int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start) 43592108Sphk{ 43692108Sphk struct g_geom *gp; 43792108Sphk struct g_slicer *gsp; 43892108Sphk struct g_consumer *cp; 43992108Sphk void **vp; 440113390Sphk int error; 44192108Sphk 44292108Sphk g_topology_assert(); 44392108Sphk vp = (void **)extrap; 44492108Sphk gp = g_new_geomf(mp, "%s", pp->name); 445114493Sphk gsp = g_slice_alloc(slices, extra); 44692108Sphk gsp->start = start; 44793776Sphk gp->access = g_slice_access; 44893776Sphk gp->orphan = g_slice_orphan; 44992108Sphk gp->softc = gsp; 45092108Sphk gp->start = g_slice_start; 451114504Sphk gp->spoiled = g_slice_spoiled; 45292108Sphk gp->dumpconf = g_slice_dumpconf; 45392108Sphk cp = g_new_consumer(gp); 454105551Sphk error = g_attach(cp, pp); 455105551Sphk if (error == 0) 456105551Sphk error = g_access_rel(cp, 1, 0, 0); 45792108Sphk if (error) { 458114504Sphk g_wither_geom(gp, ENXIO); 45992108Sphk return (NULL); 46092108Sphk } 46192108Sphk *vp = gsp->softc; 46292108Sphk *cpp = cp; 46392108Sphk return (gp); 46492108Sphk} 46592108Sphk 46693776Sphkstatic void 46793250Sphkg_slice_orphan(struct g_consumer *cp) 46892108Sphk{ 46992108Sphk 47092108Sphk g_trace(G_T_TOPOLOGY, "g_slice_orphan(%p/%s)", cp, cp->provider->name); 47192108Sphk g_topology_assert(); 47292108Sphk KASSERT(cp->provider->error != 0, 47392108Sphk ("g_slice_orphan with error == 0")); 47492108Sphk 475107522Sphk /* XXX: Not good enough we leak the softc and its suballocations */ 476114504Sphk g_slice_free(cp->geom->softc); 477114504Sphk g_wither_geom(cp->geom, cp->provider->error); 47892108Sphk} 479