2002-03-11 21:42:35 +00:00
|
|
|
/*-
|
2017-11-27 15:17:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2002-03-11 21:42:35 +00:00
|
|
|
* Copyright (c) 2002 Poul-Henning Kamp
|
|
|
|
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed for the FreeBSD Project by Poul-Henning Kamp
|
|
|
|
* and NAI Labs, the Security Research Division of Network Associates, Inc.
|
|
|
|
* under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
|
|
|
* DARPA CHATS research program.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The names of the authors may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-06-11 06:49:16 +00:00
|
|
|
#include <sys/cdefs.h>
|
2002-03-11 21:42:35 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/bio.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/sbuf.h>
|
|
|
|
#include <geom/geom.h>
|
|
|
|
#include <geom/geom_slice.h>
|
|
|
|
#include <machine/stdarg.h>
|
|
|
|
|
2002-04-04 09:54:13 +00:00
|
|
|
static g_access_t g_slice_access;
|
|
|
|
static g_start_t g_slice_start;
|
|
|
|
|
2002-04-23 19:03:03 +00:00
|
|
|
static struct g_slicer *
|
2003-05-02 05:33:27 +00:00
|
|
|
g_slice_alloc(unsigned nslice, unsigned scsize)
|
2002-03-11 21:42:35 +00:00
|
|
|
{
|
|
|
|
struct g_slicer *gsp;
|
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
gsp = g_malloc(sizeof *gsp, M_WAITOK | M_ZERO);
|
2004-06-24 10:50:20 +00:00
|
|
|
if (scsize > 0)
|
|
|
|
gsp->softc = g_malloc(scsize, M_WAITOK | M_ZERO);
|
|
|
|
else
|
|
|
|
gsp->softc = NULL;
|
2002-09-27 20:47:23 +00:00
|
|
|
gsp->slices = g_malloc(nslice * sizeof(struct g_slice),
|
2003-02-19 05:47:46 +00:00
|
|
|
M_WAITOK | M_ZERO);
|
2002-03-11 21:42:35 +00:00
|
|
|
gsp->nslice = nslice;
|
|
|
|
return (gsp);
|
|
|
|
}
|
|
|
|
|
2003-05-02 05:33:27 +00:00
|
|
|
static void
|
2017-11-01 10:53:10 +00:00
|
|
|
g_slice_free(struct g_geom *gp)
|
2003-05-02 05:33:27 +00:00
|
|
|
{
|
2017-11-01 10:53:10 +00:00
|
|
|
struct g_slicer *gsp;
|
|
|
|
|
|
|
|
gsp = gp->softc;
|
|
|
|
gp->softc = NULL;
|
2003-05-02 05:33:27 +00:00
|
|
|
|
2017-11-01 10:53:10 +00:00
|
|
|
/*
|
|
|
|
* We can get multiple spoiled events before wither-washer
|
|
|
|
* detaches our consumer, so this can get called multiple
|
|
|
|
* times.
|
|
|
|
*/
|
|
|
|
if (gsp == NULL)
|
2004-07-25 09:41:31 +00:00
|
|
|
return;
|
2003-05-02 05:33:27 +00:00
|
|
|
g_free(gsp->slices);
|
2022-12-28 15:34:09 +00:00
|
|
|
g_free(gsp->hotspot);
|
|
|
|
g_free(gsp->softc);
|
2003-05-02 05:33:27 +00:00
|
|
|
g_free(gsp);
|
|
|
|
}
|
|
|
|
|
2002-04-04 09:54:13 +00:00
|
|
|
static int
|
2002-03-11 21:42:35 +00:00
|
|
|
g_slice_access(struct g_provider *pp, int dr, int dw, int de)
|
|
|
|
{
|
2002-12-16 22:33:27 +00:00
|
|
|
int error;
|
|
|
|
u_int u;
|
2002-03-11 21:42:35 +00:00
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
struct g_provider *pp2;
|
|
|
|
struct g_slicer *gsp;
|
|
|
|
struct g_slice *gsl, *gsl2;
|
|
|
|
|
|
|
|
gp = pp->geom;
|
|
|
|
cp = LIST_FIRST(&gp->consumer);
|
|
|
|
KASSERT (cp != NULL, ("g_slice_access but no consumer"));
|
|
|
|
gsp = gp->softc;
|
2004-07-04 13:44:48 +00:00
|
|
|
if (dr > 0 || dw > 0 || de > 0) {
|
|
|
|
gsl = &gsp->slices[pp->index];
|
|
|
|
for (u = 0; u < gsp->nslice; u++) {
|
|
|
|
gsl2 = &gsp->slices[u];
|
|
|
|
if (gsl2->length == 0)
|
|
|
|
continue;
|
|
|
|
if (u == pp->index)
|
|
|
|
continue;
|
|
|
|
if (gsl->offset + gsl->length <= gsl2->offset)
|
|
|
|
continue;
|
|
|
|
if (gsl2->offset + gsl2->length <= gsl->offset)
|
|
|
|
continue;
|
|
|
|
/* overlap */
|
|
|
|
pp2 = gsl2->provider;
|
|
|
|
if ((pp->acw + dw) > 0 && pp2->ace > 0)
|
|
|
|
return (EPERM);
|
|
|
|
if ((pp->ace + de) > 0 && pp2->acw > 0)
|
|
|
|
return (EPERM);
|
|
|
|
}
|
2002-03-11 21:42:35 +00:00
|
|
|
}
|
|
|
|
/* On first open, grab an extra "exclusive" bit */
|
|
|
|
if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0)
|
|
|
|
de++;
|
|
|
|
/* ... and let go of it on last close */
|
|
|
|
if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
|
|
|
|
de--;
|
2004-02-12 22:42:11 +00:00
|
|
|
error = g_access(cp, dr, dw, de);
|
2017-10-31 10:10:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the softc if all providers have been closed and this geom
|
|
|
|
* is being removed.
|
|
|
|
*/
|
|
|
|
if (error == 0 && (gp->flags & G_GEOM_WITHER) != 0 &&
|
|
|
|
(cp->acr + cp->acw + cp->ace) == 0)
|
2017-11-01 10:53:10 +00:00
|
|
|
g_slice_free(gp);
|
2017-10-31 10:10:13 +00:00
|
|
|
|
2002-03-11 21:42:35 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2003-04-19 10:14:39 +00:00
|
|
|
/*
|
|
|
|
* XXX: It should be possible to specify here if we should finish all of the
|
|
|
|
* XXX: bio, or only the non-hot bits. This would get messy if there were
|
|
|
|
* XXX: two hot spots in the same bio, so for now we simply finish off the
|
|
|
|
* XXX: entire bio. Modifying hot data on the way to disk is frowned on
|
|
|
|
* XXX: so making that considerably harder is not a bad idea anyway.
|
|
|
|
*/
|
2002-12-02 19:59:25 +00:00
|
|
|
void
|
|
|
|
g_slice_finish_hot(struct bio *bp)
|
|
|
|
{
|
|
|
|
struct bio *bp2;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
struct g_slicer *gsp;
|
|
|
|
struct g_slice *gsl;
|
2002-12-16 22:33:27 +00:00
|
|
|
int idx;
|
2002-12-02 19:59:25 +00:00
|
|
|
|
2003-04-19 10:14:39 +00:00
|
|
|
KASSERT(bp->bio_to != NULL,
|
|
|
|
("NULL bio_to in g_slice_finish_hot(%p)", bp));
|
|
|
|
KASSERT(bp->bio_from != NULL,
|
|
|
|
("NULL bio_from in g_slice_finish_hot(%p)", bp));
|
2002-12-02 19:59:25 +00:00
|
|
|
gp = bp->bio_to->geom;
|
|
|
|
gsp = gp->softc;
|
|
|
|
cp = LIST_FIRST(&gp->consumer);
|
|
|
|
KASSERT(cp != NULL, ("NULL consumer in g_slice_finish_hot(%p)", bp));
|
2002-12-16 22:33:27 +00:00
|
|
|
idx = bp->bio_to->index;
|
|
|
|
gsl = &gsp->slices[idx];
|
2002-12-02 19:59:25 +00:00
|
|
|
|
|
|
|
bp2 = g_clone_bio(bp);
|
|
|
|
if (bp2 == NULL) {
|
|
|
|
g_io_deliver(bp, ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (bp2->bio_offset + bp2->bio_length > gsl->length)
|
|
|
|
bp2->bio_length = gsl->length - bp2->bio_offset;
|
|
|
|
bp2->bio_done = g_std_done;
|
|
|
|
bp2->bio_offset += gsl->offset;
|
|
|
|
g_io_request(bp2, cp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-05 17:52:22 +00:00
|
|
|
static void
|
|
|
|
g_slice_done(struct bio *bp)
|
|
|
|
{
|
|
|
|
|
|
|
|
KASSERT(bp->bio_cmd == BIO_GETATTR &&
|
|
|
|
strcmp(bp->bio_attribute, "GEOM::ident") == 0,
|
|
|
|
("bio_cmd=0x%x bio_attribute=%s", bp->bio_cmd, bp->bio_attribute));
|
|
|
|
|
|
|
|
if (bp->bio_error == 0 && bp->bio_data[0] != '\0') {
|
|
|
|
char idx[8];
|
|
|
|
|
|
|
|
/* Add index to the ident received. */
|
|
|
|
snprintf(idx, sizeof(idx), "s%d",
|
|
|
|
bp->bio_parent->bio_to->index);
|
|
|
|
if (strlcat(bp->bio_data, idx, bp->bio_length) >=
|
|
|
|
bp->bio_length) {
|
|
|
|
bp->bio_error = EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_std_done(bp);
|
|
|
|
}
|
|
|
|
|
2002-04-04 09:54:13 +00:00
|
|
|
static void
|
2002-03-11 21:42:35 +00:00
|
|
|
g_slice_start(struct bio *bp)
|
|
|
|
{
|
|
|
|
struct bio *bp2;
|
|
|
|
struct g_provider *pp;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
struct g_slicer *gsp;
|
2003-04-19 10:00:22 +00:00
|
|
|
struct g_slice *gsl;
|
2003-04-19 10:14:39 +00:00
|
|
|
struct g_slice_hot *ghp;
|
2002-12-16 22:33:27 +00:00
|
|
|
int idx, error;
|
2002-12-02 19:59:25 +00:00
|
|
|
u_int m_index;
|
2002-04-09 15:43:32 +00:00
|
|
|
off_t t;
|
2002-03-11 21:42:35 +00:00
|
|
|
|
|
|
|
pp = bp->bio_to;
|
|
|
|
gp = pp->geom;
|
|
|
|
gsp = gp->softc;
|
|
|
|
cp = LIST_FIRST(&gp->consumer);
|
2002-12-16 22:33:27 +00:00
|
|
|
idx = pp->index;
|
|
|
|
gsl = &gsp->slices[idx];
|
2002-03-11 21:42:35 +00:00
|
|
|
switch(bp->bio_cmd) {
|
|
|
|
case BIO_READ:
|
|
|
|
case BIO_WRITE:
|
|
|
|
case BIO_DELETE:
|
|
|
|
if (bp->bio_offset > gsl->length) {
|
2002-09-30 08:54:46 +00:00
|
|
|
g_io_deliver(bp, EINVAL); /* XXX: EWHAT ? */
|
2002-03-11 21:42:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-12-02 19:59:25 +00:00
|
|
|
/*
|
|
|
|
* Check if we collide with any hot spaces, and call the
|
|
|
|
* method once if so.
|
|
|
|
*/
|
2002-12-13 21:31:13 +00:00
|
|
|
t = bp->bio_offset + gsl->offset;
|
2003-04-19 10:00:22 +00:00
|
|
|
for (m_index = 0; m_index < gsp->nhotspot; m_index++) {
|
2003-04-19 10:14:39 +00:00
|
|
|
ghp = &gsp->hotspot[m_index];
|
|
|
|
if (t >= ghp->offset + ghp->length)
|
2002-12-02 19:59:25 +00:00
|
|
|
continue;
|
2003-04-19 10:14:39 +00:00
|
|
|
if (t + bp->bio_length <= ghp->offset)
|
2002-12-02 19:59:25 +00:00
|
|
|
continue;
|
2003-04-19 10:14:39 +00:00
|
|
|
switch(bp->bio_cmd) {
|
|
|
|
case BIO_READ: idx = ghp->ract; break;
|
|
|
|
case BIO_WRITE: idx = ghp->wact; break;
|
|
|
|
case BIO_DELETE: idx = ghp->dact; break;
|
|
|
|
}
|
|
|
|
switch(idx) {
|
|
|
|
case G_SLICE_HOT_ALLOW:
|
|
|
|
/* Fall out and continue normal processing */
|
|
|
|
continue;
|
|
|
|
case G_SLICE_HOT_DENY:
|
|
|
|
g_io_deliver(bp, EROFS);
|
|
|
|
return;
|
|
|
|
case G_SLICE_HOT_START:
|
|
|
|
error = gsp->start(bp);
|
|
|
|
if (error && error != EJUSTRETURN)
|
|
|
|
g_io_deliver(bp, error);
|
2002-12-02 19:59:25 +00:00
|
|
|
return;
|
2003-04-19 10:14:39 +00:00
|
|
|
case G_SLICE_HOT_CALL:
|
2003-04-23 20:46:12 +00:00
|
|
|
error = g_post_event(gsp->hot, bp, M_NOWAIT,
|
|
|
|
gp, NULL);
|
2003-04-19 10:14:39 +00:00
|
|
|
if (error)
|
|
|
|
g_io_deliver(bp, error);
|
2002-12-02 19:59:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2002-03-11 21:42:35 +00:00
|
|
|
bp2 = g_clone_bio(bp);
|
2002-09-27 20:47:23 +00:00
|
|
|
if (bp2 == NULL) {
|
2002-09-30 08:54:46 +00:00
|
|
|
g_io_deliver(bp, ENOMEM);
|
2002-09-27 20:47:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-03-11 21:42:35 +00:00
|
|
|
if (bp2->bio_offset + bp2->bio_length > gsl->length)
|
|
|
|
bp2->bio_length = gsl->length - bp2->bio_offset;
|
|
|
|
bp2->bio_done = g_std_done;
|
|
|
|
bp2->bio_offset += gsl->offset;
|
|
|
|
g_io_request(bp2, cp);
|
|
|
|
return;
|
|
|
|
case BIO_GETATTR:
|
2002-04-09 15:43:32 +00:00
|
|
|
/* Give the real method a chance to override */
|
2003-04-22 21:19:17 +00:00
|
|
|
if (gsp->start != NULL && gsp->start(bp))
|
2002-04-09 15:43:32 +00:00
|
|
|
return;
|
2007-05-05 17:52:22 +00:00
|
|
|
if (!strcmp("GEOM::ident", bp->bio_attribute)) {
|
|
|
|
bp2 = g_clone_bio(bp);
|
|
|
|
if (bp2 == NULL) {
|
|
|
|
g_io_deliver(bp, ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bp2->bio_done = g_slice_done;
|
|
|
|
g_io_request(bp2, cp);
|
|
|
|
return;
|
|
|
|
}
|
2002-04-19 09:24:12 +00:00
|
|
|
if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) {
|
|
|
|
struct g_kerneldump *gkd;
|
|
|
|
|
|
|
|
gkd = (struct g_kerneldump *)bp->bio_data;
|
2002-12-16 22:33:27 +00:00
|
|
|
gkd->offset += gsp->slices[idx].offset;
|
|
|
|
if (gkd->length > gsp->slices[idx].length)
|
|
|
|
gkd->length = gsp->slices[idx].length;
|
2002-04-19 09:24:12 +00:00
|
|
|
/* now, pass it on downwards... */
|
|
|
|
}
|
2006-10-31 21:23:51 +00:00
|
|
|
/* FALLTHROUGH */
|
2020-01-17 01:15:55 +00:00
|
|
|
case BIO_SPEEDUP:
|
2006-10-31 21:23:51 +00:00
|
|
|
case BIO_FLUSH:
|
2002-03-11 21:42:35 +00:00
|
|
|
bp2 = g_clone_bio(bp);
|
2002-09-28 08:16:50 +00:00
|
|
|
if (bp2 == NULL) {
|
2002-09-30 08:54:46 +00:00
|
|
|
g_io_deliver(bp, ENOMEM);
|
2002-09-28 08:16:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-03-11 21:42:35 +00:00
|
|
|
bp2->bio_done = g_std_done;
|
|
|
|
g_io_request(bp2, cp);
|
|
|
|
break;
|
|
|
|
default:
|
2002-09-30 08:54:46 +00:00
|
|
|
g_io_deliver(bp, EOPNOTSUPP);
|
2002-03-11 21:42:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-12-16 22:33:27 +00:00
|
|
|
g_slice_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp)
|
2002-03-11 21:42:35 +00:00
|
|
|
{
|
|
|
|
struct g_slicer *gsp;
|
|
|
|
|
|
|
|
gsp = gp->softc;
|
2002-10-28 22:43:54 +00:00
|
|
|
if (indent == NULL) {
|
|
|
|
sbuf_printf(sb, " i %u", pp->index);
|
|
|
|
sbuf_printf(sb, " o %ju",
|
|
|
|
(uintmax_t)gsp->slices[pp->index].offset);
|
|
|
|
return;
|
|
|
|
}
|
2002-03-11 21:42:35 +00:00
|
|
|
if (pp != NULL) {
|
|
|
|
sbuf_printf(sb, "%s<index>%u</index>\n", indent, pp->index);
|
2002-10-20 18:48:12 +00:00
|
|
|
sbuf_printf(sb, "%s<length>%ju</length>\n",
|
|
|
|
indent, (uintmax_t)gsp->slices[pp->index].length);
|
|
|
|
sbuf_printf(sb, "%s<seclength>%ju</seclength>\n", indent,
|
|
|
|
(uintmax_t)gsp->slices[pp->index].length / 512);
|
|
|
|
sbuf_printf(sb, "%s<offset>%ju</offset>\n", indent,
|
|
|
|
(uintmax_t)gsp->slices[pp->index].offset);
|
|
|
|
sbuf_printf(sb, "%s<secoffset>%ju</secoffset>\n", indent,
|
|
|
|
(uintmax_t)gsp->slices[pp->index].offset / 512);
|
2002-03-11 21:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-27 21:37:11 +00:00
|
|
|
int
|
2002-12-16 22:33:27 +00:00
|
|
|
g_slice_config(struct g_geom *gp, u_int idx, int how, off_t offset, off_t length, u_int sectorsize, const char *fmt, ...)
|
2002-09-27 21:37:11 +00:00
|
|
|
{
|
2003-02-11 14:57:34 +00:00
|
|
|
struct g_provider *pp, *pp2;
|
2002-09-27 21:37:11 +00:00
|
|
|
struct g_slicer *gsp;
|
|
|
|
struct g_slice *gsl;
|
|
|
|
va_list ap;
|
|
|
|
struct sbuf *sb;
|
2003-05-31 19:25:05 +00:00
|
|
|
int acc;
|
2002-09-27 21:37:11 +00:00
|
|
|
|
2002-09-30 08:54:46 +00:00
|
|
|
g_trace(G_T_TOPOLOGY, "g_slice_config(%s, %d, %d)",
|
2002-12-16 22:33:27 +00:00
|
|
|
gp->name, idx, how);
|
2002-09-27 21:37:11 +00:00
|
|
|
g_topology_assert();
|
|
|
|
gsp = gp->softc;
|
2002-12-16 22:33:27 +00:00
|
|
|
if (idx >= gsp->nslice)
|
2002-09-27 21:37:11 +00:00
|
|
|
return(EINVAL);
|
2002-12-16 22:33:27 +00:00
|
|
|
gsl = &gsp->slices[idx];
|
2002-09-27 21:37:11 +00:00
|
|
|
pp = gsl->provider;
|
|
|
|
if (pp != NULL)
|
|
|
|
acc = pp->acr + pp->acw + pp->ace;
|
|
|
|
else
|
|
|
|
acc = 0;
|
|
|
|
if (acc != 0 && how != G_SLICE_CONFIG_FORCE) {
|
|
|
|
if (length < gsl->length)
|
|
|
|
return(EBUSY);
|
|
|
|
if (offset != gsl->offset)
|
|
|
|
return(EBUSY);
|
|
|
|
}
|
|
|
|
/* XXX: check offset + length <= MEDIASIZE */
|
|
|
|
if (how == G_SLICE_CONFIG_CHECK)
|
|
|
|
return (0);
|
|
|
|
gsl->length = length;
|
|
|
|
gsl->offset = offset;
|
2002-10-20 19:18:07 +00:00
|
|
|
gsl->sectorsize = sectorsize;
|
2002-10-25 20:09:45 +00:00
|
|
|
if (length == 0) {
|
|
|
|
if (pp == NULL)
|
|
|
|
return (0);
|
|
|
|
if (bootverbose)
|
|
|
|
printf("GEOM: Deconfigure %s\n", pp->name);
|
2006-04-10 03:55:13 +00:00
|
|
|
g_wither_provider(pp, ENXIO);
|
2002-09-27 21:37:11 +00:00
|
|
|
gsl->provider = NULL;
|
|
|
|
gsp->nprovider--;
|
|
|
|
return (0);
|
|
|
|
}
|
2002-10-25 20:09:45 +00:00
|
|
|
if (pp != NULL) {
|
|
|
|
if (bootverbose)
|
|
|
|
printf("GEOM: Reconfigure %s, start %jd length %jd end %jd\n",
|
|
|
|
pp->name, (intmax_t)offset, (intmax_t)length,
|
|
|
|
(intmax_t)(offset + length - 1));
|
2013-10-18 09:14:19 +00:00
|
|
|
g_resize_provider(pp, gsl->length);
|
2002-10-25 20:09:45 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2008-08-09 11:14:05 +00:00
|
|
|
sb = sbuf_new_auto();
|
2003-06-07 10:16:53 +00:00
|
|
|
va_start(ap, fmt);
|
2002-09-27 21:37:11 +00:00
|
|
|
sbuf_vprintf(sb, fmt, ap);
|
2003-06-07 10:16:53 +00:00
|
|
|
va_end(ap);
|
2002-09-27 21:37:11 +00:00
|
|
|
sbuf_finish(sb);
|
2012-11-20 12:32:18 +00:00
|
|
|
pp = g_new_providerf(gp, "%s", sbuf_data(sb));
|
2003-02-11 14:57:34 +00:00
|
|
|
pp2 = LIST_FIRST(&gp->consumer)->provider;
|
2010-01-06 13:14:37 +00:00
|
|
|
pp->stripesize = pp2->stripesize;
|
|
|
|
pp->stripeoffset = pp2->stripeoffset + offset;
|
|
|
|
if (pp->stripesize > 0)
|
|
|
|
pp->stripeoffset %= pp->stripesize;
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
if (gsp->nhotspot == 0) {
|
2013-03-26 07:55:24 +00:00
|
|
|
pp->flags |= pp2->flags & G_PF_ACCEPT_UNMAPPED;
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
|
|
|
|
}
|
2004-11-03 09:08:10 +00:00
|
|
|
if (0 && bootverbose)
|
2002-10-25 20:09:45 +00:00
|
|
|
printf("GEOM: Configure %s, start %jd length %jd end %jd\n",
|
|
|
|
pp->name, (intmax_t)offset, (intmax_t)length,
|
|
|
|
(intmax_t)(offset + length - 1));
|
2002-12-16 22:33:27 +00:00
|
|
|
pp->index = idx;
|
2002-10-20 19:18:07 +00:00
|
|
|
pp->mediasize = gsl->length;
|
|
|
|
pp->sectorsize = gsl->sectorsize;
|
2002-09-27 21:37:11 +00:00
|
|
|
gsl->provider = pp;
|
|
|
|
gsp->nprovider++;
|
|
|
|
g_error_provider(pp, 0);
|
|
|
|
sbuf_delete(sb);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2003-04-19 10:14:39 +00:00
|
|
|
/*
|
|
|
|
* Configure "hotspots". A hotspot is a piece of the parent device which
|
|
|
|
* this particular slicer cares about for some reason. Typically because
|
|
|
|
* it contains meta-data used to configure the slicer.
|
|
|
|
* A hotspot is identified by its index number. The offset and length are
|
|
|
|
* relative to the parent device, and the three "?act" fields specify
|
|
|
|
* what action to take on BIO_READ, BIO_DELETE and BIO_WRITE.
|
|
|
|
*
|
|
|
|
* XXX: There may be a race relative to g_slice_start() here, if an existing
|
|
|
|
* XXX: hotspot is changed wile I/O is happening. Should this become a problem
|
|
|
|
* XXX: we can protect the hotspot stuff with a mutex.
|
|
|
|
*/
|
|
|
|
|
2002-12-02 19:59:25 +00:00
|
|
|
int
|
2003-04-19 10:14:39 +00:00
|
|
|
g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length, int ract, int dact, int wact)
|
2002-12-02 19:59:25 +00:00
|
|
|
{
|
|
|
|
struct g_slicer *gsp;
|
2003-04-19 10:00:22 +00:00
|
|
|
struct g_slice_hot *gsl, *gsl2;
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
struct g_consumer *cp;
|
2013-03-26 07:55:24 +00:00
|
|
|
struct g_provider *pp;
|
2002-12-02 19:59:25 +00:00
|
|
|
|
2003-04-19 10:14:39 +00:00
|
|
|
g_trace(G_T_TOPOLOGY, "g_slice_conf_hot(%s, idx: %d, off: %jd, len: %jd)",
|
|
|
|
gp->name, idx, (intmax_t)offset, (intmax_t)length);
|
2002-12-02 19:59:25 +00:00
|
|
|
g_topology_assert();
|
|
|
|
gsp = gp->softc;
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
/* Deny unmapped I/O and direct dispatch if hotspots are used. */
|
2013-03-26 07:55:24 +00:00
|
|
|
if (gsp->nhotspot == 0) {
|
|
|
|
LIST_FOREACH(pp, &gp->provider, provider)
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
pp->flags &= ~(G_PF_ACCEPT_UNMAPPED |
|
|
|
|
G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE);
|
|
|
|
LIST_FOREACH(cp, &gp->consumer, consumer)
|
|
|
|
cp->flags &= ~(G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE);
|
2013-03-26 07:55:24 +00:00
|
|
|
}
|
2003-04-19 10:00:22 +00:00
|
|
|
gsl = gsp->hotspot;
|
|
|
|
if(idx >= gsp->nhotspot) {
|
2003-02-19 05:47:46 +00:00
|
|
|
gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO);
|
2003-04-19 10:00:22 +00:00
|
|
|
if (gsp->hotspot != NULL)
|
|
|
|
bcopy(gsp->hotspot, gsl2, gsp->nhotspot * sizeof *gsl2);
|
|
|
|
gsp->hotspot = gsl2;
|
|
|
|
if (gsp->hotspot != NULL)
|
2002-12-02 19:59:25 +00:00
|
|
|
g_free(gsl);
|
|
|
|
gsl = gsl2;
|
2003-04-19 10:00:22 +00:00
|
|
|
gsp->nhotspot = idx + 1;
|
2002-12-02 19:59:25 +00:00
|
|
|
}
|
2002-12-16 22:33:27 +00:00
|
|
|
gsl[idx].offset = offset;
|
|
|
|
gsl[idx].length = length;
|
2003-04-22 21:19:17 +00:00
|
|
|
KASSERT(!((ract | dact | wact) & G_SLICE_HOT_START)
|
|
|
|
|| gsp->start != NULL, ("G_SLICE_HOT_START but no slice->start"));
|
|
|
|
/* XXX: check that we _have_ a start function if HOT_START specified */
|
2003-04-19 10:14:39 +00:00
|
|
|
gsl[idx].ract = ract;
|
|
|
|
gsl[idx].dact = dact;
|
|
|
|
gsl[idx].wact = wact;
|
2002-12-02 19:59:25 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-05-02 06:29:33 +00:00
|
|
|
void
|
2017-10-31 10:10:13 +00:00
|
|
|
g_slice_orphan(struct g_consumer *cp)
|
2003-05-02 06:29:33 +00:00
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
gp = cp->geom;
|
2017-10-31 10:10:13 +00:00
|
|
|
g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name);
|
2003-05-02 06:29:33 +00:00
|
|
|
g_wither_geom(gp, ENXIO);
|
2017-10-31 10:10:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We can safely free the softc now if there are no accesses,
|
|
|
|
* otherwise g_slice_access() will do that after the last close.
|
|
|
|
*/
|
|
|
|
if ((cp->acr + cp->acw + cp->ace) == 0)
|
2017-11-01 10:53:10 +00:00
|
|
|
g_slice_free(gp);
|
2017-10-31 10:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_slice_spoiled(struct g_consumer *cp)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, cp->geom->name);
|
|
|
|
cp->flags |= G_CF_ORPHAN;
|
|
|
|
g_slice_orphan(cp);
|
2003-05-02 06:29:33 +00:00
|
|
|
}
|
|
|
|
|
2003-05-31 19:25:05 +00:00
|
|
|
int
|
|
|
|
g_slice_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_slice_spoiled(LIST_FIRST(&gp->consumer));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2002-03-11 21:42:35 +00:00
|
|
|
struct g_geom *
|
2002-12-02 19:59:25 +00:00
|
|
|
g_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)
|
2002-03-11 21:42:35 +00:00
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_slicer *gsp;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
void **vp;
|
2003-04-12 08:41:26 +00:00
|
|
|
int error;
|
2002-03-11 21:42:35 +00:00
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
vp = (void **)extrap;
|
|
|
|
gp = g_new_geomf(mp, "%s", pp->name);
|
2003-05-02 05:33:27 +00:00
|
|
|
gsp = g_slice_alloc(slices, extra);
|
2002-03-11 21:42:35 +00:00
|
|
|
gsp->start = start;
|
|
|
|
gp->softc = gsp;
|
|
|
|
gp->start = g_slice_start;
|
2017-10-31 10:10:13 +00:00
|
|
|
gp->access = g_slice_access;
|
|
|
|
gp->orphan = g_slice_orphan;
|
2003-05-02 06:29:33 +00:00
|
|
|
gp->spoiled = g_slice_spoiled;
|
2004-08-18 21:42:08 +00:00
|
|
|
if (gp->dumpconf == NULL)
|
|
|
|
gp->dumpconf = g_slice_dumpconf;
|
2003-05-31 19:25:05 +00:00
|
|
|
if (gp->class->destroy_geom == NULL)
|
|
|
|
gp->class->destroy_geom = g_slice_destroy_geom;
|
2002-03-11 21:42:35 +00:00
|
|
|
cp = g_new_consumer(gp);
|
Merge GEOM direct dispatch changes from the projects/camlock branch.
When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.
The defined now safety requirements are:
- caller should not hold any locks and should be reenterable;
- callee should not depend on GEOM dual-threaded concurency semantics;
- on the way down, if request is unmapped while callee doesn't support it,
the context should be sleepable;
- kernel thread stack usage should be below 50%.
To keep compatibility with GEOM classes not meeting above requirements
new provider and consumer flags added:
- G_CF_DIRECT_SEND -- consumer code meets caller requirements (request);
- G_CF_DIRECT_RECEIVE -- consumer code meets callee requirements (done);
- G_PF_DIRECT_SEND -- provider code meets caller requirements (done);
- G_PF_DIRECT_RECEIVE -- provider code meets callee requirements (request).
Capable GEOM class can set them, allowing direct dispatch in cases where
it is safe. If any of requirements are not met, request is queued to
g_up or g_down thread same as before.
Such GEOM classes were reviewed and updated to support direct dispatch:
CONCAT, DEV, DISK, GATE, MD, MIRROR, MULTIPATH, NOP, PART, RAID, STRIPE,
VFS, ZERO, ZFS::VDEV, ZFS::ZVOL, all classes based on g_slice KPI (LABEL,
MAP, FLASHMAP, etc).
To declare direct completion capability disk(9) KPI got new flag equivalent
to G_PF_DIRECT_SEND -- DISKFLAG_DIRECT_COMPLETION. da(4) and ada(4) disk
drivers got it set now thanks to earlier CAM locking work.
This change more then twice increases peak block storage performance on
systems with manu CPUs, together with earlier CAM locking changes reaching
more then 1 million IOPS (512 byte raw reads from 16 SATA SSDs on 4 HBAs to
256 user-level threads).
Sponsored by: iXsystems, Inc.
MFC after: 2 months
2013-10-22 08:22:19 +00:00
|
|
|
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
|
2002-10-20 20:28:24 +00:00
|
|
|
error = g_attach(cp, pp);
|
|
|
|
if (error == 0)
|
2004-02-12 22:42:11 +00:00
|
|
|
error = g_access(cp, 1, 0, 0);
|
2002-03-11 21:42:35 +00:00
|
|
|
if (error) {
|
2003-05-02 06:29:33 +00:00
|
|
|
g_wither_geom(gp, ENXIO);
|
2002-03-11 21:42:35 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
2004-06-24 10:50:20 +00:00
|
|
|
if (extrap != NULL)
|
|
|
|
*vp = gsp->softc;
|
2002-03-11 21:42:35 +00:00
|
|
|
*cpp = cp;
|
|
|
|
return (gp);
|
|
|
|
}
|