2004-05-20 10:15:53 +00:00
|
|
|
/*-
|
2017-11-27 15:17:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2006-09-08 09:21:21 +00:00
|
|
|
* Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
2019-12-29 15:40:02 +00:00
|
|
|
* Copyright (c) 2019 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
2004-05-20 10:15:53 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
2006-02-01 12:06:01 +00:00
|
|
|
*
|
2004-05-20 10:15:53 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
2019-12-29 15:40:02 +00:00
|
|
|
#include <sys/ctype.h>
|
2004-05-20 10:15:53 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/bio.h>
|
2011-07-11 05:22:31 +00:00
|
|
|
#include <sys/sbuf.h>
|
2004-05-20 10:15:53 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <geom/geom.h>
|
2019-08-07 19:28:35 +00:00
|
|
|
#include <geom/geom_dbg.h>
|
2004-05-20 10:15:53 +00:00
|
|
|
#include <geom/nop/g_nop.h>
|
|
|
|
|
|
|
|
SYSCTL_DECL(_kern_geom);
|
2020-02-26 14:26:36 +00:00
|
|
|
static SYSCTL_NODE(_kern_geom, OID_AUTO, nop, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
|
|
|
|
"GEOM_NOP stuff");
|
2004-05-20 10:15:53 +00:00
|
|
|
static u_int g_nop_debug = 0;
|
|
|
|
SYSCTL_UINT(_kern_geom_nop, OID_AUTO, debug, CTLFLAG_RW, &g_nop_debug, 0,
|
|
|
|
"Debug level");
|
|
|
|
|
|
|
|
static int g_nop_destroy(struct g_geom *gp, boolean_t force);
|
|
|
|
static int g_nop_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
|
|
|
struct g_geom *gp);
|
|
|
|
static void g_nop_config(struct gctl_req *req, struct g_class *mp,
|
|
|
|
const char *verb);
|
2019-05-25 00:07:49 +00:00
|
|
|
static g_access_t g_nop_access;
|
|
|
|
static g_dumpconf_t g_nop_dumpconf;
|
|
|
|
static g_orphan_t g_nop_orphan;
|
|
|
|
static g_provgone_t g_nop_providergone;
|
|
|
|
static g_resize_t g_nop_resize;
|
|
|
|
static g_start_t g_nop_start;
|
2004-05-20 10:15:53 +00:00
|
|
|
|
|
|
|
struct g_class g_nop_class = {
|
|
|
|
.name = G_NOP_CLASS_NAME,
|
2004-08-08 07:57:53 +00:00
|
|
|
.version = G_VERSION,
|
2004-05-20 10:15:53 +00:00
|
|
|
.ctlreq = g_nop_config,
|
2019-05-25 00:07:49 +00:00
|
|
|
.destroy_geom = g_nop_destroy_geom,
|
|
|
|
.access = g_nop_access,
|
|
|
|
.dumpconf = g_nop_dumpconf,
|
|
|
|
.orphan = g_nop_orphan,
|
|
|
|
.providergone = g_nop_providergone,
|
|
|
|
.resize = g_nop_resize,
|
|
|
|
.start = g_nop_start,
|
2004-05-20 10:15:53 +00:00
|
|
|
};
|
|
|
|
|
2019-07-31 17:47:12 +00:00
|
|
|
struct g_nop_delay {
|
|
|
|
struct callout dl_cal;
|
|
|
|
struct bio *dl_bio;
|
|
|
|
TAILQ_ENTRY(g_nop_delay) dl_next;
|
|
|
|
};
|
|
|
|
|
2019-12-29 15:40:02 +00:00
|
|
|
static bool
|
|
|
|
g_nop_verify_nprefix(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < strlen(name); i++) {
|
|
|
|
if (isalpha(name[i]) == 0 && isdigit(name[i]) == 0) {
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
static void
|
|
|
|
g_nop_orphan(struct g_consumer *cp)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
g_nop_destroy(cp->geom, 1);
|
|
|
|
}
|
|
|
|
|
2012-07-07 22:22:13 +00:00
|
|
|
static void
|
|
|
|
g_nop_resize(struct g_consumer *cp)
|
|
|
|
{
|
|
|
|
struct g_nop_softc *sc;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp;
|
|
|
|
off_t size;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
gp = cp->geom;
|
|
|
|
sc = gp->softc;
|
|
|
|
|
|
|
|
if (sc->sc_explicitsize != 0)
|
|
|
|
return;
|
|
|
|
if (cp->provider->mediasize < sc->sc_offset) {
|
|
|
|
g_nop_destroy(gp, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
size = cp->provider->mediasize - sc->sc_offset;
|
|
|
|
LIST_FOREACH(pp, &gp->provider, provider)
|
|
|
|
g_resize_provider(pp, size);
|
|
|
|
}
|
|
|
|
|
2019-04-22 03:25:49 +00:00
|
|
|
static int
|
|
|
|
g_nop_dumper(void *priv, void *virtual, vm_offset_t physical, off_t offset,
|
|
|
|
size_t length)
|
|
|
|
{
|
2019-07-31 17:51:06 +00:00
|
|
|
|
2019-04-22 03:25:49 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_nop_kerneldump(struct bio *bp, struct g_nop_softc *sc)
|
|
|
|
{
|
|
|
|
struct g_kerneldump *gkd;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp;
|
|
|
|
|
|
|
|
gkd = (struct g_kerneldump *)bp->bio_data;
|
|
|
|
gp = bp->bio_to->geom;
|
|
|
|
g_trace(G_T_TOPOLOGY, "%s(%s, %jd, %jd)", __func__, gp->name,
|
|
|
|
(intmax_t)gkd->offset, (intmax_t)gkd->length);
|
|
|
|
|
|
|
|
pp = LIST_FIRST(&gp->provider);
|
|
|
|
|
|
|
|
gkd->di.dumper = g_nop_dumper;
|
|
|
|
gkd->di.priv = sc;
|
|
|
|
gkd->di.blocksize = pp->sectorsize;
|
|
|
|
gkd->di.maxiosize = DFLTPHYS;
|
|
|
|
gkd->di.mediaoffset = sc->sc_offset + gkd->offset;
|
|
|
|
if (gkd->offset > sc->sc_explicitsize) {
|
|
|
|
g_io_deliver(bp, ENODEV);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (gkd->offset + gkd->length > sc->sc_explicitsize)
|
|
|
|
gkd->length = sc->sc_explicitsize - gkd->offset;
|
|
|
|
gkd->di.mediasize = gkd->length;
|
|
|
|
g_io_deliver(bp, 0);
|
|
|
|
}
|
|
|
|
|
2019-07-31 17:47:12 +00:00
|
|
|
static void
|
|
|
|
g_nop_pass(struct bio *cbp, struct g_geom *gp)
|
|
|
|
{
|
|
|
|
|
|
|
|
G_NOP_LOGREQ(cbp, "Sending request.");
|
|
|
|
g_io_request(cbp, LIST_FIRST(&gp->consumer));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_nop_pass_timeout(void *data)
|
|
|
|
{
|
|
|
|
struct g_nop_softc *sc;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_nop_delay *gndelay;
|
|
|
|
|
|
|
|
gndelay = (struct g_nop_delay *)data;
|
|
|
|
|
|
|
|
gp = gndelay->dl_bio->bio_to->geom;
|
|
|
|
sc = gp->softc;
|
|
|
|
|
|
|
|
mtx_lock(&sc->sc_lock);
|
|
|
|
TAILQ_REMOVE(&sc->sc_head_delay, gndelay, dl_next);
|
|
|
|
mtx_unlock(&sc->sc_lock);
|
|
|
|
|
|
|
|
g_nop_pass(gndelay->dl_bio, gp);
|
|
|
|
|
|
|
|
g_free(data);
|
|
|
|
}
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
static void
|
|
|
|
g_nop_start(struct bio *bp)
|
|
|
|
{
|
2004-07-19 07:52:56 +00:00
|
|
|
struct g_nop_softc *sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp;
|
|
|
|
struct bio *cbp;
|
2019-07-31 17:47:12 +00:00
|
|
|
u_int failprob, delayprob, delaytime;
|
|
|
|
|
2019-12-29 15:47:37 +00:00
|
|
|
failprob = delayprob = delaytime = 0;
|
2004-05-20 10:15:53 +00:00
|
|
|
|
|
|
|
gp = bp->bio_to->geom;
|
2004-07-19 07:52:56 +00:00
|
|
|
sc = gp->softc;
|
2019-07-31 17:47:12 +00:00
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
G_NOP_LOGREQ(bp, "Request received.");
|
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
|
|
|
mtx_lock(&sc->sc_lock);
|
2005-12-08 23:00:31 +00:00
|
|
|
switch (bp->bio_cmd) {
|
|
|
|
case BIO_READ:
|
|
|
|
sc->sc_reads++;
|
|
|
|
sc->sc_readbytes += bp->bio_length;
|
2019-12-29 15:47:37 +00:00
|
|
|
if (sc->sc_count_until_fail != 0) {
|
|
|
|
sc->sc_count_until_fail -= 1;
|
|
|
|
} else {
|
|
|
|
failprob = sc->sc_rfailprob;
|
|
|
|
delayprob = sc->sc_rdelayprob;
|
|
|
|
delaytime = sc->sc_delaymsec;
|
|
|
|
}
|
2005-12-08 23:00:31 +00:00
|
|
|
break;
|
|
|
|
case BIO_WRITE:
|
|
|
|
sc->sc_writes++;
|
|
|
|
sc->sc_wrotebytes += bp->bio_length;
|
2019-12-29 15:47:37 +00:00
|
|
|
if (sc->sc_count_until_fail != 0) {
|
|
|
|
sc->sc_count_until_fail -= 1;
|
|
|
|
} else {
|
|
|
|
failprob = sc->sc_wfailprob;
|
|
|
|
delayprob = sc->sc_wdelayprob;
|
|
|
|
delaytime = sc->sc_delaymsec;
|
|
|
|
}
|
2005-12-08 23:00:31 +00:00
|
|
|
break;
|
2015-10-10 09:03:31 +00:00
|
|
|
case BIO_DELETE:
|
|
|
|
sc->sc_deletes++;
|
|
|
|
break;
|
|
|
|
case BIO_GETATTR:
|
|
|
|
sc->sc_getattrs++;
|
2019-07-31 17:51:06 +00:00
|
|
|
if (sc->sc_physpath &&
|
2019-04-22 03:25:49 +00:00
|
|
|
g_handleattr_str(bp, "GEOM::physpath", sc->sc_physpath))
|
|
|
|
;
|
|
|
|
else if (strcmp(bp->bio_attribute, "GEOM::kerneldump") == 0)
|
|
|
|
g_nop_kerneldump(bp, sc);
|
|
|
|
else
|
|
|
|
/*
|
|
|
|
* Fallthrough to forwarding the GETATTR down to the
|
|
|
|
* lower level device.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
mtx_unlock(&sc->sc_lock);
|
|
|
|
return;
|
2015-10-10 09:03:31 +00:00
|
|
|
case BIO_FLUSH:
|
|
|
|
sc->sc_flushes++;
|
|
|
|
break;
|
2020-01-17 01:15:55 +00:00
|
|
|
case BIO_SPEEDUP:
|
|
|
|
sc->sc_speedups++;
|
|
|
|
break;
|
2015-10-10 09:03:31 +00:00
|
|
|
case BIO_CMD0:
|
|
|
|
sc->sc_cmd0s++;
|
|
|
|
break;
|
|
|
|
case BIO_CMD1:
|
|
|
|
sc->sc_cmd1s++;
|
|
|
|
break;
|
|
|
|
case BIO_CMD2:
|
|
|
|
sc->sc_cmd2s++;
|
|
|
|
break;
|
2005-12-08 23:00:31 +00:00
|
|
|
}
|
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
|
|
|
mtx_unlock(&sc->sc_lock);
|
2019-12-29 15:47:37 +00:00
|
|
|
|
2006-09-08 09:21:21 +00:00
|
|
|
if (failprob > 0) {
|
2004-05-20 10:15:53 +00:00
|
|
|
u_int rval;
|
|
|
|
|
|
|
|
rval = arc4random() % 100;
|
2006-09-08 09:21:21 +00:00
|
|
|
if (rval < failprob) {
|
2013-04-13 19:02:58 +00:00
|
|
|
G_NOP_LOGREQLVL(1, bp, "Returning error=%d.", sc->sc_error);
|
2006-09-08 09:21:21 +00:00
|
|
|
g_io_deliver(bp, sc->sc_error);
|
2004-05-20 10:15:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
|
2006-01-17 07:22:44 +00:00
|
|
|
cbp = g_clone_bio(bp);
|
|
|
|
if (cbp == NULL) {
|
|
|
|
g_io_deliver(bp, ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-20 10:15:53 +00:00
|
|
|
cbp->bio_done = g_std_done;
|
2004-07-19 07:52:56 +00:00
|
|
|
cbp->bio_offset = bp->bio_offset + sc->sc_offset;
|
2004-08-02 00:37:40 +00:00
|
|
|
pp = LIST_FIRST(&gp->provider);
|
|
|
|
KASSERT(pp != NULL, ("NULL pp"));
|
|
|
|
cbp->bio_to = pp;
|
2019-07-31 17:47:12 +00:00
|
|
|
|
|
|
|
if (delayprob > 0) {
|
|
|
|
struct g_nop_delay *gndelay;
|
|
|
|
u_int rval;
|
|
|
|
|
|
|
|
rval = arc4random() % 100;
|
|
|
|
if (rval < delayprob) {
|
|
|
|
gndelay = g_malloc(sizeof(*gndelay), M_NOWAIT | M_ZERO);
|
|
|
|
if (gndelay != NULL) {
|
|
|
|
callout_init(&gndelay->dl_cal, 1);
|
|
|
|
|
|
|
|
gndelay->dl_bio = cbp;
|
|
|
|
|
|
|
|
mtx_lock(&sc->sc_lock);
|
|
|
|
TAILQ_INSERT_TAIL(&sc->sc_head_delay, gndelay,
|
|
|
|
dl_next);
|
|
|
|
mtx_unlock(&sc->sc_lock);
|
|
|
|
|
|
|
|
callout_reset(&gndelay->dl_cal,
|
|
|
|
MSEC_2_TICKS(delaytime), g_nop_pass_timeout,
|
|
|
|
gndelay);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_nop_pass(cbp, gp);
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_nop_access(struct g_provider *pp, int dr, int dw, int de)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
gp = pp->geom;
|
|
|
|
cp = LIST_FIRST(&gp->consumer);
|
|
|
|
error = g_access(cp, dr, dw, de);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
|
2019-12-29 15:40:02 +00:00
|
|
|
const char *gnopname, int ioerror, u_int count_until_fail,
|
|
|
|
u_int rfailprob, u_int wfailprob, u_int delaymsec, u_int rdelayprob,
|
|
|
|
u_int wdelayprob, off_t offset, off_t size, u_int secsize, off_t stripesize,
|
|
|
|
off_t stripeoffset, const char *physpath)
|
2004-05-20 10:15:53 +00:00
|
|
|
{
|
2004-07-19 07:52:56 +00:00
|
|
|
struct g_nop_softc *sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *newpp;
|
|
|
|
struct g_consumer *cp;
|
2020-05-13 19:17:28 +00:00
|
|
|
struct g_geom_alias *gap;
|
2004-06-07 13:33:09 +00:00
|
|
|
char name[64];
|
2019-12-29 15:40:02 +00:00
|
|
|
int error, n;
|
2012-07-07 22:22:13 +00:00
|
|
|
off_t explicitsize;
|
2004-05-20 10:15:53 +00:00
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
gp = NULL;
|
|
|
|
newpp = NULL;
|
|
|
|
cp = NULL;
|
|
|
|
|
2004-07-19 07:52:56 +00:00
|
|
|
if ((offset % pp->sectorsize) != 0) {
|
|
|
|
gctl_error(req, "Invalid offset for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
if ((size % pp->sectorsize) != 0) {
|
|
|
|
gctl_error(req, "Invalid size for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
if (offset >= pp->mediasize) {
|
|
|
|
gctl_error(req, "Invalid offset for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2012-07-07 22:22:13 +00:00
|
|
|
explicitsize = size;
|
2004-07-19 07:52:56 +00:00
|
|
|
if (size == 0)
|
|
|
|
size = pp->mediasize - offset;
|
|
|
|
if (offset + size > pp->mediasize) {
|
|
|
|
gctl_error(req, "Invalid size for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2004-07-30 08:19:22 +00:00
|
|
|
if (secsize == 0)
|
|
|
|
secsize = pp->sectorsize;
|
|
|
|
else if ((secsize % pp->sectorsize) != 0) {
|
|
|
|
gctl_error(req, "Invalid secsize for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
Make MAXPHYS tunable. Bump MAXPHYS to 1M.
Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.
Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*). Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.
Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys. Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight. Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.
Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.
Suggested by: mav (*)
Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27225
2020-11-28 12:12:51 +00:00
|
|
|
if (secsize > maxphys) {
|
2011-01-12 12:26:10 +00:00
|
|
|
gctl_error(req, "secsize is too big.");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2011-01-11 13:22:20 +00:00
|
|
|
size -= size % secsize;
|
2015-09-15 18:01:59 +00:00
|
|
|
if ((stripesize % pp->sectorsize) != 0) {
|
|
|
|
gctl_error(req, "Invalid stripesize for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
if ((stripeoffset % pp->sectorsize) != 0) {
|
|
|
|
gctl_error(req, "Invalid stripeoffset for provider %s.", pp->name);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
if (stripesize != 0 && stripeoffset >= stripesize) {
|
|
|
|
gctl_error(req, "stripeoffset is too big.");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2019-12-29 15:40:02 +00:00
|
|
|
if (gnopname != NULL && !g_nop_verify_nprefix(gnopname)) {
|
|
|
|
gctl_error(req, "Name %s is invalid.", gnopname);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gnopname != NULL) {
|
|
|
|
n = snprintf(name, sizeof(name), "%s%s", gnopname,
|
|
|
|
G_NOP_SUFFIX);
|
|
|
|
} else {
|
|
|
|
n = snprintf(name, sizeof(name), "%s%s", pp->name,
|
|
|
|
G_NOP_SUFFIX);
|
|
|
|
}
|
|
|
|
if (n <= 0 || n >= sizeof(name)) {
|
|
|
|
gctl_error(req, "Invalid provider name.");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2004-06-07 13:33:09 +00:00
|
|
|
LIST_FOREACH(gp, &mp->geom, geom) {
|
|
|
|
if (strcmp(gp->name, name) == 0) {
|
|
|
|
gctl_error(req, "Provider %s already exists.", name);
|
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
}
|
2012-11-20 12:32:18 +00:00
|
|
|
gp = g_new_geomf(mp, "%s", name);
|
2013-10-23 01:34:18 +00:00
|
|
|
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
|
2004-07-19 07:52:56 +00:00
|
|
|
sc->sc_offset = offset;
|
2012-07-07 22:22:13 +00:00
|
|
|
sc->sc_explicitsize = explicitsize;
|
2015-09-15 18:01:59 +00:00
|
|
|
sc->sc_stripesize = stripesize;
|
|
|
|
sc->sc_stripeoffset = stripeoffset;
|
2018-01-18 05:57:10 +00:00
|
|
|
if (physpath && strcmp(physpath, G_NOP_PHYSPATH_PASSTHROUGH)) {
|
|
|
|
sc->sc_physpath = strndup(physpath, MAXPATHLEN, M_GEOM);
|
|
|
|
} else
|
|
|
|
sc->sc_physpath = NULL;
|
2006-09-08 09:21:21 +00:00
|
|
|
sc->sc_error = ioerror;
|
2019-09-13 23:03:56 +00:00
|
|
|
sc->sc_count_until_fail = count_until_fail;
|
2006-09-08 09:21:21 +00:00
|
|
|
sc->sc_rfailprob = rfailprob;
|
|
|
|
sc->sc_wfailprob = wfailprob;
|
2019-07-31 17:47:12 +00:00
|
|
|
sc->sc_delaymsec = delaymsec;
|
|
|
|
sc->sc_rdelayprob = rdelayprob;
|
|
|
|
sc->sc_wdelayprob = wdelayprob;
|
2005-12-08 23:00:31 +00:00
|
|
|
sc->sc_reads = 0;
|
|
|
|
sc->sc_writes = 0;
|
2015-10-10 09:03:31 +00:00
|
|
|
sc->sc_deletes = 0;
|
|
|
|
sc->sc_getattrs = 0;
|
|
|
|
sc->sc_flushes = 0;
|
2020-01-17 01:15:55 +00:00
|
|
|
sc->sc_speedups = 0;
|
2015-10-10 09:03:31 +00:00
|
|
|
sc->sc_cmd0s = 0;
|
|
|
|
sc->sc_cmd1s = 0;
|
|
|
|
sc->sc_cmd2s = 0;
|
2005-12-08 23:00:31 +00:00
|
|
|
sc->sc_readbytes = 0;
|
|
|
|
sc->sc_wrotebytes = 0;
|
2019-07-31 17:47:12 +00:00
|
|
|
TAILQ_INIT(&sc->sc_head_delay);
|
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
|
|
|
mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF);
|
2004-07-19 07:52:56 +00:00
|
|
|
gp->softc = sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
|
2012-11-20 12:32:18 +00:00
|
|
|
newpp = g_new_providerf(gp, "%s", gp->name);
|
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
|
|
|
newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
|
2004-07-19 07:52:56 +00:00
|
|
|
newpp->mediasize = size;
|
2004-07-30 08:19:22 +00:00
|
|
|
newpp->sectorsize = secsize;
|
2015-09-15 18:01:59 +00:00
|
|
|
newpp->stripesize = stripesize;
|
|
|
|
newpp->stripeoffset = stripeoffset;
|
2020-05-13 19:17:28 +00:00
|
|
|
LIST_FOREACH(gap, &pp->aliases, ga_next)
|
|
|
|
g_provider_add_alias(newpp, "%s%s", gap->ga_alias, G_NOP_SUFFIX);
|
2004-05-20 10:15:53 +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;
|
2004-05-20 10:15:53 +00:00
|
|
|
error = g_attach(cp, pp);
|
|
|
|
if (error != 0) {
|
|
|
|
gctl_error(req, "Cannot attach to provider %s.", pp->name);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2013-03-26 05:58:49 +00:00
|
|
|
newpp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED;
|
2004-05-20 10:15:53 +00:00
|
|
|
g_error_provider(newpp, 0);
|
|
|
|
G_NOP_DEBUG(0, "Device %s created.", gp->name);
|
|
|
|
return (0);
|
|
|
|
fail:
|
2011-03-31 06:30:59 +00:00
|
|
|
if (cp->provider != NULL)
|
|
|
|
g_detach(cp);
|
|
|
|
g_destroy_consumer(cp);
|
|
|
|
g_destroy_provider(newpp);
|
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
|
|
|
mtx_destroy(&sc->sc_lock);
|
2018-01-18 05:57:10 +00:00
|
|
|
free(sc->sc_physpath, M_GEOM);
|
2011-03-31 06:30:59 +00:00
|
|
|
g_free(gp->softc);
|
|
|
|
g_destroy_geom(gp);
|
2004-05-20 10:15:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2019-05-25 00:07:49 +00:00
|
|
|
static void
|
|
|
|
g_nop_providergone(struct g_provider *pp)
|
|
|
|
{
|
|
|
|
struct g_geom *gp = pp->geom;
|
|
|
|
struct g_nop_softc *sc = gp->softc;
|
|
|
|
|
2019-07-31 17:47:12 +00:00
|
|
|
KASSERT(TAILQ_EMPTY(&sc->sc_head_delay),
|
|
|
|
("delayed request list is not empty"));
|
|
|
|
|
2019-05-25 00:07:49 +00:00
|
|
|
gp->softc = NULL;
|
|
|
|
free(sc->sc_physpath, M_GEOM);
|
|
|
|
mtx_destroy(&sc->sc_lock);
|
|
|
|
g_free(sc);
|
|
|
|
}
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
static int
|
|
|
|
g_nop_destroy(struct g_geom *gp, boolean_t force)
|
|
|
|
{
|
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_nop_softc *sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
struct g_provider *pp;
|
|
|
|
|
|
|
|
g_topology_assert();
|
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
|
|
|
sc = gp->softc;
|
|
|
|
if (sc == NULL)
|
2004-08-02 00:37:40 +00:00
|
|
|
return (ENXIO);
|
2004-05-20 10:15:53 +00:00
|
|
|
pp = LIST_FIRST(&gp->provider);
|
|
|
|
if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
|
|
|
|
if (force) {
|
|
|
|
G_NOP_DEBUG(0, "Device %s is still open, so it "
|
|
|
|
"can't be definitely removed.", pp->name);
|
|
|
|
} else {
|
|
|
|
G_NOP_DEBUG(1, "Device %s is still open (r%dw%de%d).",
|
|
|
|
pp->name, pp->acr, pp->acw, pp->ace);
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
G_NOP_DEBUG(0, "Device %s removed.", gp->name);
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
g_wither_geom(gp, ENXIO);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_nop_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (g_nop_destroy(gp, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
2019-10-16 21:49:44 +00:00
|
|
|
intmax_t *val, error, rfailprob, wfailprob, count_until_fail, offset,
|
|
|
|
secsize, size, stripesize, stripeoffset, delaymsec,
|
|
|
|
rdelayprob, wdelayprob;
|
2020-07-22 02:15:21 +00:00
|
|
|
const char *physpath, *gnopname;
|
2004-05-20 10:15:53 +00:00
|
|
|
char param[16];
|
|
|
|
int i, *nargs;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
2019-10-16 21:49:44 +00:00
|
|
|
error = -1;
|
|
|
|
rfailprob = -1;
|
|
|
|
wfailprob = -1;
|
|
|
|
count_until_fail = -1;
|
|
|
|
offset = 0;
|
|
|
|
secsize = 0;
|
|
|
|
size = 0;
|
|
|
|
stripesize = 0;
|
|
|
|
stripeoffset = 0;
|
|
|
|
delaymsec = -1;
|
|
|
|
rdelayprob = -1;
|
|
|
|
wdelayprob = -1;
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs <= 0) {
|
|
|
|
gctl_error(req, "Missing device(s).");
|
|
|
|
return;
|
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "error", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
error = *val;
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
rfailprob = *val;
|
|
|
|
if (rfailprob < -1 || rfailprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "rfailprob");
|
|
|
|
return;
|
|
|
|
}
|
2019-09-13 23:03:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
wfailprob = *val;
|
|
|
|
if (wfailprob < -1 || wfailprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "wfailprob");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-19 07:52:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
delaymsec = *val;
|
|
|
|
if (delaymsec < 1 && delaymsec != -1) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "delaymsec");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-19 07:52:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
rdelayprob = *val;
|
|
|
|
if (rdelayprob < -1 || rdelayprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "rdelayprob");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-19 07:52:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
wdelayprob = *val;
|
|
|
|
if (wdelayprob < -1 || wdelayprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "wdelayprob");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-19 07:52:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
count_until_fail = *val;
|
|
|
|
if (count_until_fail < -1) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument",
|
|
|
|
"count_until_fail");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-30 08:19:22 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "offset", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
offset = *val;
|
|
|
|
if (offset < 0) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "offset");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-30 08:19:22 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "size", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
size = *val;
|
|
|
|
if (size < 0) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "size");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-15 18:01:59 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "secsize", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
secsize = *val;
|
|
|
|
if (secsize < 0) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "secsize");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-15 18:01:59 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "stripesize", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
stripesize = *val;
|
|
|
|
if (stripesize < 0) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "stripesize");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-15 18:01:59 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "stripeoffset", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
stripeoffset = *val;
|
|
|
|
if (stripeoffset < 0) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument",
|
|
|
|
"stripeoffset");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-15 18:01:59 +00:00
|
|
|
}
|
2018-01-18 05:57:10 +00:00
|
|
|
physpath = gctl_get_asciiparam(req, "physpath");
|
2019-12-29 15:40:02 +00:00
|
|
|
gnopname = gctl_get_asciiparam(req, "gnopname");
|
2004-05-20 10:15:53 +00:00
|
|
|
|
|
|
|
for (i = 0; i < *nargs; i++) {
|
|
|
|
snprintf(param, sizeof(param), "arg%d", i);
|
2020-07-22 02:15:21 +00:00
|
|
|
pp = gctl_get_provider(req, param);
|
|
|
|
if (pp == NULL)
|
2004-05-20 10:15:53 +00:00
|
|
|
return;
|
2006-09-08 09:21:21 +00:00
|
|
|
if (g_nop_create(req, mp, pp,
|
2019-12-29 15:40:02 +00:00
|
|
|
gnopname,
|
2019-10-16 21:49:44 +00:00
|
|
|
error == -1 ? EIO : (int)error,
|
|
|
|
count_until_fail == -1 ? 0 : (u_int)count_until_fail,
|
|
|
|
rfailprob == -1 ? 0 : (u_int)rfailprob,
|
|
|
|
wfailprob == -1 ? 0 : (u_int)wfailprob,
|
|
|
|
delaymsec == -1 ? 1 : (u_int)delaymsec,
|
|
|
|
rdelayprob == -1 ? 0 : (u_int)rdelayprob,
|
|
|
|
wdelayprob == -1 ? 0 : (u_int)wdelayprob,
|
|
|
|
(off_t)offset, (off_t)size, (u_int)secsize,
|
|
|
|
(off_t)stripesize, (off_t)stripeoffset,
|
2018-01-18 05:57:10 +00:00
|
|
|
physpath) != 0) {
|
2004-05-20 10:15:53 +00:00
|
|
|
return;
|
2004-07-19 07:52:56 +00:00
|
|
|
}
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-21 15:23:48 +00:00
|
|
|
g_nop_ctl_configure(struct gctl_req *req, struct g_class *mp)
|
2004-05-20 10:15:53 +00:00
|
|
|
{
|
2004-07-19 07:52:56 +00:00
|
|
|
struct g_nop_softc *sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
struct g_provider *pp;
|
2019-10-16 21:49:44 +00:00
|
|
|
intmax_t *val, delaymsec, error, rdelayprob, rfailprob, wdelayprob,
|
|
|
|
wfailprob, count_until_fail;
|
2004-05-20 10:15:53 +00:00
|
|
|
char param[16];
|
|
|
|
int i, *nargs;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
2019-10-16 21:49:44 +00:00
|
|
|
count_until_fail = -1;
|
|
|
|
delaymsec = -1;
|
|
|
|
error = -1;
|
|
|
|
rdelayprob = -1;
|
|
|
|
rfailprob = -1;
|
|
|
|
wdelayprob = -1;
|
|
|
|
wfailprob = -1;
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs <= 0) {
|
|
|
|
gctl_error(req, "Missing device(s).");
|
|
|
|
return;
|
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "error", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
error = *val;
|
2006-09-08 09:21:21 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
count_until_fail = *val;
|
2019-09-13 23:03:56 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
rfailprob = *val;
|
|
|
|
if (rfailprob < -1 || rfailprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "rfailprob");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
wfailprob = *val;
|
|
|
|
if (wfailprob < -1 || wfailprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "wfailprob");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
delaymsec = *val;
|
|
|
|
if (delaymsec < 1 && delaymsec != -1) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "delaymsec");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
rdelayprob = *val;
|
|
|
|
if (rdelayprob < -1 || rdelayprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "rdelayprob");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
2019-10-16 21:49:44 +00:00
|
|
|
val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
|
|
|
|
if (val != NULL) {
|
|
|
|
wdelayprob = *val;
|
|
|
|
if (wdelayprob < -1 || wdelayprob > 100) {
|
|
|
|
gctl_error(req, "Invalid '%s' argument", "wdelayprob");
|
|
|
|
return;
|
|
|
|
}
|
2019-07-31 17:47:12 +00:00
|
|
|
}
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
for (i = 0; i < *nargs; i++) {
|
|
|
|
snprintf(param, sizeof(param), "arg%d", i);
|
2020-07-22 02:15:21 +00:00
|
|
|
pp = gctl_get_provider(req, param);
|
|
|
|
if (pp == NULL)
|
2004-05-20 10:15:53 +00:00
|
|
|
return;
|
2020-07-22 02:15:21 +00:00
|
|
|
if (pp->geom->class != mp) {
|
|
|
|
G_NOP_DEBUG(1, "Provider %s is invalid.", pp->name);
|
|
|
|
gctl_error(req, "Provider %s is invalid.", pp->name);
|
2006-02-01 12:06:01 +00:00
|
|
|
return;
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
2004-07-19 07:52:56 +00:00
|
|
|
sc = pp->geom->softc;
|
2019-10-16 21:49:44 +00:00
|
|
|
if (error != -1)
|
|
|
|
sc->sc_error = (int)error;
|
|
|
|
if (rfailprob != -1)
|
|
|
|
sc->sc_rfailprob = (u_int)rfailprob;
|
|
|
|
if (wfailprob != -1)
|
|
|
|
sc->sc_wfailprob = (u_int)wfailprob;
|
|
|
|
if (rdelayprob != -1)
|
|
|
|
sc->sc_rdelayprob = (u_int)rdelayprob;
|
|
|
|
if (wdelayprob != -1)
|
|
|
|
sc->sc_wdelayprob = (u_int)wdelayprob;
|
|
|
|
if (delaymsec != -1)
|
|
|
|
sc->sc_delaymsec = (u_int)delaymsec;
|
|
|
|
if (count_until_fail != -1)
|
|
|
|
sc->sc_count_until_fail = (u_int)count_until_fail;
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct g_geom *
|
|
|
|
g_nop_find_geom(struct g_class *mp, const char *name)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
|
|
|
|
LIST_FOREACH(gp, &mp->geom, geom) {
|
|
|
|
if (strcmp(gp->name, name) == 0)
|
|
|
|
return (gp);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_nop_ctl_destroy(struct gctl_req *req, struct g_class *mp)
|
|
|
|
{
|
|
|
|
int *nargs, *force, error, i;
|
|
|
|
struct g_geom *gp;
|
|
|
|
const char *name;
|
|
|
|
char param[16];
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs <= 0) {
|
|
|
|
gctl_error(req, "Missing device(s).");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
force = gctl_get_paraml(req, "force", sizeof(*force));
|
|
|
|
if (force == NULL) {
|
|
|
|
gctl_error(req, "No 'force' argument");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < *nargs; i++) {
|
|
|
|
snprintf(param, sizeof(param), "arg%d", i);
|
2006-02-01 12:06:01 +00:00
|
|
|
name = gctl_get_asciiparam(req, param);
|
2004-05-20 10:15:53 +00:00
|
|
|
if (name == NULL) {
|
|
|
|
gctl_error(req, "No 'arg%d' argument", i);
|
|
|
|
return;
|
|
|
|
}
|
2020-07-09 02:52:39 +00:00
|
|
|
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
|
|
|
name += strlen(_PATH_DEV);
|
2004-05-20 10:15:53 +00:00
|
|
|
gp = g_nop_find_geom(mp, name);
|
|
|
|
if (gp == NULL) {
|
|
|
|
G_NOP_DEBUG(1, "Device %s is invalid.", name);
|
|
|
|
gctl_error(req, "Device %s is invalid.", name);
|
2006-02-01 12:06:01 +00:00
|
|
|
return;
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
error = g_nop_destroy(gp, *force);
|
|
|
|
if (error != 0) {
|
|
|
|
gctl_error(req, "Cannot destroy device %s (error=%d).",
|
|
|
|
gp->name, error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-08 23:00:31 +00:00
|
|
|
static void
|
|
|
|
g_nop_ctl_reset(struct gctl_req *req, struct g_class *mp)
|
|
|
|
{
|
|
|
|
struct g_nop_softc *sc;
|
|
|
|
struct g_provider *pp;
|
|
|
|
char param[16];
|
|
|
|
int i, *nargs;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs <= 0) {
|
|
|
|
gctl_error(req, "Missing device(s).");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < *nargs; i++) {
|
|
|
|
snprintf(param, sizeof(param), "arg%d", i);
|
2020-07-22 02:15:21 +00:00
|
|
|
pp = gctl_get_provider(req, param);
|
|
|
|
if (pp == NULL)
|
2005-12-08 23:00:31 +00:00
|
|
|
return;
|
2020-07-22 02:15:21 +00:00
|
|
|
if (pp->geom->class != mp) {
|
|
|
|
G_NOP_DEBUG(1, "Provider %s is invalid.", pp->name);
|
|
|
|
gctl_error(req, "Provider %s is invalid.", pp->name);
|
2006-02-01 12:06:01 +00:00
|
|
|
return;
|
2005-12-08 23:00:31 +00:00
|
|
|
}
|
|
|
|
sc = pp->geom->softc;
|
|
|
|
sc->sc_reads = 0;
|
|
|
|
sc->sc_writes = 0;
|
2015-10-10 09:03:31 +00:00
|
|
|
sc->sc_deletes = 0;
|
|
|
|
sc->sc_getattrs = 0;
|
|
|
|
sc->sc_flushes = 0;
|
2020-01-17 01:15:55 +00:00
|
|
|
sc->sc_speedups = 0;
|
2015-10-10 09:03:31 +00:00
|
|
|
sc->sc_cmd0s = 0;
|
|
|
|
sc->sc_cmd1s = 0;
|
|
|
|
sc->sc_cmd2s = 0;
|
2005-12-08 23:00:31 +00:00
|
|
|
sc->sc_readbytes = 0;
|
|
|
|
sc->sc_wrotebytes = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-20 10:15:53 +00:00
|
|
|
static void
|
|
|
|
g_nop_config(struct gctl_req *req, struct g_class *mp, const char *verb)
|
|
|
|
{
|
|
|
|
uint32_t *version;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
version = gctl_get_paraml(req, "version", sizeof(*version));
|
|
|
|
if (version == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument.", "version");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*version != G_NOP_VERSION) {
|
|
|
|
gctl_error(req, "Userland and kernel parts are out of sync.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(verb, "create") == 0) {
|
|
|
|
g_nop_ctl_create(req, mp);
|
|
|
|
return;
|
2004-05-21 15:23:48 +00:00
|
|
|
} else if (strcmp(verb, "configure") == 0) {
|
|
|
|
g_nop_ctl_configure(req, mp);
|
2004-05-20 10:15:53 +00:00
|
|
|
return;
|
|
|
|
} else if (strcmp(verb, "destroy") == 0) {
|
|
|
|
g_nop_ctl_destroy(req, mp);
|
|
|
|
return;
|
2005-12-08 23:00:31 +00:00
|
|
|
} else if (strcmp(verb, "reset") == 0) {
|
|
|
|
g_nop_ctl_reset(req, mp);
|
|
|
|
return;
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gctl_error(req, "Unknown verb.");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_nop_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
|
|
|
|
struct g_consumer *cp, struct g_provider *pp)
|
|
|
|
{
|
2004-07-19 07:52:56 +00:00
|
|
|
struct g_nop_softc *sc;
|
2004-05-20 10:15:53 +00:00
|
|
|
|
2004-07-26 17:14:47 +00:00
|
|
|
if (pp != NULL || cp != NULL)
|
2004-07-19 07:52:56 +00:00
|
|
|
return;
|
|
|
|
sc = gp->softc;
|
2004-07-26 17:14:47 +00:00
|
|
|
sbuf_printf(sb, "%s<Offset>%jd</Offset>\n", indent,
|
2004-07-19 07:52:56 +00:00
|
|
|
(intmax_t)sc->sc_offset);
|
2006-09-08 09:21:21 +00:00
|
|
|
sbuf_printf(sb, "%s<ReadFailProb>%u</ReadFailProb>\n", indent,
|
|
|
|
sc->sc_rfailprob);
|
|
|
|
sbuf_printf(sb, "%s<WriteFailProb>%u</WriteFailProb>\n", indent,
|
|
|
|
sc->sc_wfailprob);
|
2019-07-31 17:47:12 +00:00
|
|
|
sbuf_printf(sb, "%s<ReadDelayedProb>%u</ReadDelayedProb>\n", indent,
|
|
|
|
sc->sc_rdelayprob);
|
|
|
|
sbuf_printf(sb, "%s<WriteDelayedProb>%u</WriteDelayedProb>\n", indent,
|
|
|
|
sc->sc_wdelayprob);
|
|
|
|
sbuf_printf(sb, "%s<Delay>%d</Delay>\n", indent, sc->sc_delaymsec);
|
2019-09-13 23:03:56 +00:00
|
|
|
sbuf_printf(sb, "%s<CountUntilFail>%u</CountUntilFail>\n", indent,
|
|
|
|
sc->sc_count_until_fail);
|
2006-09-08 13:46:18 +00:00
|
|
|
sbuf_printf(sb, "%s<Error>%d</Error>\n", indent, sc->sc_error);
|
2005-12-08 23:00:31 +00:00
|
|
|
sbuf_printf(sb, "%s<Reads>%ju</Reads>\n", indent, sc->sc_reads);
|
|
|
|
sbuf_printf(sb, "%s<Writes>%ju</Writes>\n", indent, sc->sc_writes);
|
2015-10-10 09:03:31 +00:00
|
|
|
sbuf_printf(sb, "%s<Deletes>%ju</Deletes>\n", indent, sc->sc_deletes);
|
|
|
|
sbuf_printf(sb, "%s<Getattrs>%ju</Getattrs>\n", indent, sc->sc_getattrs);
|
|
|
|
sbuf_printf(sb, "%s<Flushes>%ju</Flushes>\n", indent, sc->sc_flushes);
|
2020-01-17 01:15:55 +00:00
|
|
|
sbuf_printf(sb, "%s<Speedups>%ju</Speedups>\n", indent, sc->sc_speedups);
|
2015-10-10 09:03:31 +00:00
|
|
|
sbuf_printf(sb, "%s<Cmd0s>%ju</Cmd0s>\n", indent, sc->sc_cmd0s);
|
|
|
|
sbuf_printf(sb, "%s<Cmd1s>%ju</Cmd1s>\n", indent, sc->sc_cmd1s);
|
|
|
|
sbuf_printf(sb, "%s<Cmd2s>%ju</Cmd2s>\n", indent, sc->sc_cmd2s);
|
2005-12-19 06:05:40 +00:00
|
|
|
sbuf_printf(sb, "%s<ReadBytes>%ju</ReadBytes>\n", indent,
|
2005-12-08 23:00:31 +00:00
|
|
|
sc->sc_readbytes);
|
|
|
|
sbuf_printf(sb, "%s<WroteBytes>%ju</WroteBytes>\n", indent,
|
2005-12-09 11:38:02 +00:00
|
|
|
sc->sc_wrotebytes);
|
2004-05-20 10:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DECLARE_GEOM_CLASS(g_nop_class, g_nop);
|
2018-04-10 19:18:16 +00:00
|
|
|
MODULE_VERSION(geom_nop, 0);
|