2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
5 * Copyright (c) 2019 Mariusz Zaborski <oshogbo@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/ctype.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/module.h>
39 #include <sys/mutex.h>
42 #include <sys/sysctl.h>
43 #include <sys/malloc.h>
44 #include <geom/geom.h>
45 #include <geom/geom_dbg.h>
46 #include <geom/nop/g_nop.h>
49 SYSCTL_DECL(_kern_geom);
50 static SYSCTL_NODE(_kern_geom, OID_AUTO, nop, CTLFLAG_RW, 0, "GEOM_NOP stuff");
51 static u_int g_nop_debug = 0;
52 SYSCTL_UINT(_kern_geom_nop, OID_AUTO, debug, CTLFLAG_RW, &g_nop_debug, 0,
55 static int g_nop_destroy(struct g_geom *gp, boolean_t force);
56 static int g_nop_destroy_geom(struct gctl_req *req, struct g_class *mp,
58 static void g_nop_config(struct gctl_req *req, struct g_class *mp,
60 static g_access_t g_nop_access;
61 static g_dumpconf_t g_nop_dumpconf;
62 static g_orphan_t g_nop_orphan;
63 static g_provgone_t g_nop_providergone;
64 static g_resize_t g_nop_resize;
65 static g_start_t g_nop_start;
67 struct g_class g_nop_class = {
68 .name = G_NOP_CLASS_NAME,
70 .ctlreq = g_nop_config,
71 .destroy_geom = g_nop_destroy_geom,
72 .access = g_nop_access,
73 .dumpconf = g_nop_dumpconf,
74 .orphan = g_nop_orphan,
75 .providergone = g_nop_providergone,
76 .resize = g_nop_resize,
81 struct callout dl_cal;
83 TAILQ_ENTRY(g_nop_delay) dl_next;
87 g_nop_verify_nprefix(const char *name)
91 for (i = 0; i < strlen(name); i++) {
92 if (isalpha(name[i]) == 0 && isdigit(name[i]) == 0) {
101 g_nop_orphan(struct g_consumer *cp)
105 g_nop_destroy(cp->geom, 1);
109 g_nop_resize(struct g_consumer *cp)
111 struct g_nop_softc *sc;
113 struct g_provider *pp;
121 if (sc->sc_explicitsize != 0)
123 if (cp->provider->mediasize < sc->sc_offset) {
124 g_nop_destroy(gp, 1);
127 size = cp->provider->mediasize - sc->sc_offset;
128 LIST_FOREACH(pp, &gp->provider, provider)
129 g_resize_provider(pp, size);
133 g_nop_dumper(void *priv, void *virtual, vm_offset_t physical, off_t offset,
141 g_nop_kerneldump(struct bio *bp, struct g_nop_softc *sc)
143 struct g_kerneldump *gkd;
145 struct g_provider *pp;
147 gkd = (struct g_kerneldump *)bp->bio_data;
148 gp = bp->bio_to->geom;
149 g_trace(G_T_TOPOLOGY, "%s(%s, %jd, %jd)", __func__, gp->name,
150 (intmax_t)gkd->offset, (intmax_t)gkd->length);
152 pp = LIST_FIRST(&gp->provider);
154 gkd->di.dumper = g_nop_dumper;
156 gkd->di.blocksize = pp->sectorsize;
157 gkd->di.maxiosize = DFLTPHYS;
158 gkd->di.mediaoffset = sc->sc_offset + gkd->offset;
159 if (gkd->offset > sc->sc_explicitsize) {
160 g_io_deliver(bp, ENODEV);
163 if (gkd->offset + gkd->length > sc->sc_explicitsize)
164 gkd->length = sc->sc_explicitsize - gkd->offset;
165 gkd->di.mediasize = gkd->length;
170 g_nop_pass(struct bio *cbp, struct g_geom *gp)
173 G_NOP_LOGREQ(cbp, "Sending request.");
174 g_io_request(cbp, LIST_FIRST(&gp->consumer));
178 g_nop_pass_timeout(void *data)
180 struct g_nop_softc *sc;
182 struct g_nop_delay *gndelay;
184 gndelay = (struct g_nop_delay *)data;
186 gp = gndelay->dl_bio->bio_to->geom;
189 mtx_lock(&sc->sc_lock);
190 TAILQ_REMOVE(&sc->sc_head_delay, gndelay, dl_next);
191 mtx_unlock(&sc->sc_lock);
193 g_nop_pass(gndelay->dl_bio, gp);
199 g_nop_start(struct bio *bp)
201 struct g_nop_softc *sc;
203 struct g_provider *pp;
205 u_int failprob, delayprob, delaytime;
207 failprob = delayprob = delaytime = 0;
209 gp = bp->bio_to->geom;
212 G_NOP_LOGREQ(bp, "Request received.");
213 mtx_lock(&sc->sc_lock);
214 switch (bp->bio_cmd) {
217 sc->sc_readbytes += bp->bio_length;
218 if (sc->sc_count_until_fail != 0) {
219 sc->sc_count_until_fail -= 1;
221 failprob = sc->sc_rfailprob;
222 delayprob = sc->sc_rdelayprob;
223 delaytime = sc->sc_delaymsec;
228 sc->sc_wrotebytes += bp->bio_length;
229 if (sc->sc_count_until_fail != 0) {
230 sc->sc_count_until_fail -= 1;
232 failprob = sc->sc_wfailprob;
233 delayprob = sc->sc_wdelayprob;
234 delaytime = sc->sc_delaymsec;
242 if (sc->sc_physpath &&
243 g_handleattr_str(bp, "GEOM::physpath", sc->sc_physpath))
245 else if (strcmp(bp->bio_attribute, "GEOM::kerneldump") == 0)
246 g_nop_kerneldump(bp, sc);
249 * Fallthrough to forwarding the GETATTR down to the
250 * lower level device.
253 mtx_unlock(&sc->sc_lock);
271 mtx_unlock(&sc->sc_lock);
276 rval = arc4random() % 100;
277 if (rval < failprob) {
278 G_NOP_LOGREQLVL(1, bp, "Returning error=%d.", sc->sc_error);
279 g_io_deliver(bp, sc->sc_error);
284 cbp = g_clone_bio(bp);
286 g_io_deliver(bp, ENOMEM);
289 cbp->bio_done = g_std_done;
290 cbp->bio_offset = bp->bio_offset + sc->sc_offset;
291 pp = LIST_FIRST(&gp->provider);
292 KASSERT(pp != NULL, ("NULL pp"));
296 struct g_nop_delay *gndelay;
299 rval = arc4random() % 100;
300 if (rval < delayprob) {
301 gndelay = g_malloc(sizeof(*gndelay), M_NOWAIT | M_ZERO);
302 if (gndelay != NULL) {
303 callout_init(&gndelay->dl_cal, 1);
305 gndelay->dl_bio = cbp;
307 mtx_lock(&sc->sc_lock);
308 TAILQ_INSERT_TAIL(&sc->sc_head_delay, gndelay,
310 mtx_unlock(&sc->sc_lock);
312 callout_reset(&gndelay->dl_cal,
313 MSEC_2_TICKS(delaytime), g_nop_pass_timeout,
324 g_nop_access(struct g_provider *pp, int dr, int dw, int de)
327 struct g_consumer *cp;
331 cp = LIST_FIRST(&gp->consumer);
332 error = g_access(cp, dr, dw, de);
338 g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
339 const char *gnopname, int ioerror, u_int count_until_fail,
340 u_int rfailprob, u_int wfailprob, u_int delaymsec, u_int rdelayprob,
341 u_int wdelayprob, off_t offset, off_t size, u_int secsize, off_t stripesize,
342 off_t stripeoffset, const char *physpath)
344 struct g_nop_softc *sc;
346 struct g_provider *newpp;
347 struct g_consumer *cp;
358 if ((offset % pp->sectorsize) != 0) {
359 gctl_error(req, "Invalid offset for provider %s.", pp->name);
362 if ((size % pp->sectorsize) != 0) {
363 gctl_error(req, "Invalid size for provider %s.", pp->name);
366 if (offset >= pp->mediasize) {
367 gctl_error(req, "Invalid offset for provider %s.", pp->name);
372 size = pp->mediasize - offset;
373 if (offset + size > pp->mediasize) {
374 gctl_error(req, "Invalid size for provider %s.", pp->name);
378 secsize = pp->sectorsize;
379 else if ((secsize % pp->sectorsize) != 0) {
380 gctl_error(req, "Invalid secsize for provider %s.", pp->name);
383 if (secsize > MAXPHYS) {
384 gctl_error(req, "secsize is too big.");
387 size -= size % secsize;
388 if ((stripesize % pp->sectorsize) != 0) {
389 gctl_error(req, "Invalid stripesize for provider %s.", pp->name);
392 if ((stripeoffset % pp->sectorsize) != 0) {
393 gctl_error(req, "Invalid stripeoffset for provider %s.", pp->name);
396 if (stripesize != 0 && stripeoffset >= stripesize) {
397 gctl_error(req, "stripeoffset is too big.");
400 if (gnopname != NULL && !g_nop_verify_nprefix(gnopname)) {
401 gctl_error(req, "Name %s is invalid.", gnopname);
405 if (gnopname != NULL) {
406 n = snprintf(name, sizeof(name), "%s%s", gnopname,
409 n = snprintf(name, sizeof(name), "%s%s", pp->name,
412 if (n <= 0 || n >= sizeof(name)) {
413 gctl_error(req, "Invalid provider name.");
416 LIST_FOREACH(gp, &mp->geom, geom) {
417 if (strcmp(gp->name, name) == 0) {
418 gctl_error(req, "Provider %s already exists.", name);
422 gp = g_new_geomf(mp, "%s", name);
423 sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
424 sc->sc_offset = offset;
425 sc->sc_explicitsize = explicitsize;
426 sc->sc_stripesize = stripesize;
427 sc->sc_stripeoffset = stripeoffset;
428 if (physpath && strcmp(physpath, G_NOP_PHYSPATH_PASSTHROUGH)) {
429 sc->sc_physpath = strndup(physpath, MAXPATHLEN, M_GEOM);
431 sc->sc_physpath = NULL;
432 sc->sc_error = ioerror;
433 sc->sc_count_until_fail = count_until_fail;
434 sc->sc_rfailprob = rfailprob;
435 sc->sc_wfailprob = wfailprob;
436 sc->sc_delaymsec = delaymsec;
437 sc->sc_rdelayprob = rdelayprob;
438 sc->sc_wdelayprob = wdelayprob;
448 sc->sc_readbytes = 0;
449 sc->sc_wrotebytes = 0;
450 TAILQ_INIT(&sc->sc_head_delay);
451 mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF);
454 newpp = g_new_providerf(gp, "%s", gp->name);
455 newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
456 newpp->mediasize = size;
457 newpp->sectorsize = secsize;
458 newpp->stripesize = stripesize;
459 newpp->stripeoffset = stripeoffset;
461 cp = g_new_consumer(gp);
462 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
463 error = g_attach(cp, pp);
465 gctl_error(req, "Cannot attach to provider %s.", pp->name);
469 newpp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED;
470 g_error_provider(newpp, 0);
471 G_NOP_DEBUG(0, "Device %s created.", gp->name);
474 if (cp->provider != NULL)
476 g_destroy_consumer(cp);
477 g_destroy_provider(newpp);
478 mtx_destroy(&sc->sc_lock);
479 free(sc->sc_physpath, M_GEOM);
486 g_nop_providergone(struct g_provider *pp)
488 struct g_geom *gp = pp->geom;
489 struct g_nop_softc *sc = gp->softc;
491 KASSERT(TAILQ_EMPTY(&sc->sc_head_delay),
492 ("delayed request list is not empty"));
495 free(sc->sc_physpath, M_GEOM);
496 mtx_destroy(&sc->sc_lock);
501 g_nop_destroy(struct g_geom *gp, boolean_t force)
503 struct g_nop_softc *sc;
504 struct g_provider *pp;
510 pp = LIST_FIRST(&gp->provider);
511 if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
513 G_NOP_DEBUG(0, "Device %s is still open, so it "
514 "can't be definitely removed.", pp->name);
516 G_NOP_DEBUG(1, "Device %s is still open (r%dw%de%d).",
517 pp->name, pp->acr, pp->acw, pp->ace);
521 G_NOP_DEBUG(0, "Device %s removed.", gp->name);
524 g_wither_geom(gp, ENXIO);
530 g_nop_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
533 return (g_nop_destroy(gp, 0));
537 g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
539 struct g_provider *pp;
540 intmax_t *val, error, rfailprob, wfailprob, count_until_fail, offset,
541 secsize, size, stripesize, stripeoffset, delaymsec,
542 rdelayprob, wdelayprob;
543 const char *name, *physpath, *gnopname;
552 count_until_fail = -1;
562 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
564 gctl_error(req, "No '%s' argument", "nargs");
568 gctl_error(req, "Missing device(s).");
571 val = gctl_get_paraml_opt(req, "error", sizeof(*val));
575 val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
578 if (rfailprob < -1 || rfailprob > 100) {
579 gctl_error(req, "Invalid '%s' argument", "rfailprob");
583 val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
586 if (wfailprob < -1 || wfailprob > 100) {
587 gctl_error(req, "Invalid '%s' argument", "wfailprob");
591 val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
594 if (delaymsec < 1 && delaymsec != -1) {
595 gctl_error(req, "Invalid '%s' argument", "delaymsec");
599 val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
602 if (rdelayprob < -1 || rdelayprob > 100) {
603 gctl_error(req, "Invalid '%s' argument", "rdelayprob");
607 val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
610 if (wdelayprob < -1 || wdelayprob > 100) {
611 gctl_error(req, "Invalid '%s' argument", "wdelayprob");
615 val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
617 count_until_fail = *val;
618 if (count_until_fail < -1) {
619 gctl_error(req, "Invalid '%s' argument",
624 val = gctl_get_paraml_opt(req, "offset", sizeof(*val));
628 gctl_error(req, "Invalid '%s' argument", "offset");
632 val = gctl_get_paraml_opt(req, "size", sizeof(*val));
636 gctl_error(req, "Invalid '%s' argument", "size");
640 val = gctl_get_paraml_opt(req, "secsize", sizeof(*val));
644 gctl_error(req, "Invalid '%s' argument", "secsize");
648 val = gctl_get_paraml_opt(req, "stripesize", sizeof(*val));
651 if (stripesize < 0) {
652 gctl_error(req, "Invalid '%s' argument", "stripesize");
656 val = gctl_get_paraml_opt(req, "stripeoffset", sizeof(*val));
659 if (stripeoffset < 0) {
660 gctl_error(req, "Invalid '%s' argument",
665 physpath = gctl_get_asciiparam(req, "physpath");
666 gnopname = gctl_get_asciiparam(req, "gnopname");
668 for (i = 0; i < *nargs; i++) {
669 snprintf(param, sizeof(param), "arg%d", i);
670 name = gctl_get_asciiparam(req, param);
672 gctl_error(req, "No 'arg%d' argument", i);
675 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
676 name += strlen("/dev/");
677 pp = g_provider_by_name(name);
679 G_NOP_DEBUG(1, "Provider %s is invalid.", name);
680 gctl_error(req, "Provider %s is invalid.", name);
683 if (g_nop_create(req, mp, pp,
685 error == -1 ? EIO : (int)error,
686 count_until_fail == -1 ? 0 : (u_int)count_until_fail,
687 rfailprob == -1 ? 0 : (u_int)rfailprob,
688 wfailprob == -1 ? 0 : (u_int)wfailprob,
689 delaymsec == -1 ? 1 : (u_int)delaymsec,
690 rdelayprob == -1 ? 0 : (u_int)rdelayprob,
691 wdelayprob == -1 ? 0 : (u_int)wdelayprob,
692 (off_t)offset, (off_t)size, (u_int)secsize,
693 (off_t)stripesize, (off_t)stripeoffset,
701 g_nop_ctl_configure(struct gctl_req *req, struct g_class *mp)
703 struct g_nop_softc *sc;
704 struct g_provider *pp;
705 intmax_t *val, delaymsec, error, rdelayprob, rfailprob, wdelayprob,
706 wfailprob, count_until_fail;
713 count_until_fail = -1;
721 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
723 gctl_error(req, "No '%s' argument", "nargs");
727 gctl_error(req, "Missing device(s).");
730 val = gctl_get_paraml_opt(req, "error", sizeof(*val));
734 val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
736 count_until_fail = *val;
738 val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
741 if (rfailprob < -1 || rfailprob > 100) {
742 gctl_error(req, "Invalid '%s' argument", "rfailprob");
746 val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
749 if (wfailprob < -1 || wfailprob > 100) {
750 gctl_error(req, "Invalid '%s' argument", "wfailprob");
754 val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
757 if (delaymsec < 1 && delaymsec != -1) {
758 gctl_error(req, "Invalid '%s' argument", "delaymsec");
762 val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
765 if (rdelayprob < -1 || rdelayprob > 100) {
766 gctl_error(req, "Invalid '%s' argument", "rdelayprob");
770 val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
773 if (wdelayprob < -1 || wdelayprob > 100) {
774 gctl_error(req, "Invalid '%s' argument", "wdelayprob");
779 for (i = 0; i < *nargs; i++) {
780 snprintf(param, sizeof(param), "arg%d", i);
781 name = gctl_get_asciiparam(req, param);
783 gctl_error(req, "No 'arg%d' argument", i);
786 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
787 name += strlen("/dev/");
788 pp = g_provider_by_name(name);
789 if (pp == NULL || pp->geom->class != mp) {
790 G_NOP_DEBUG(1, "Provider %s is invalid.", name);
791 gctl_error(req, "Provider %s is invalid.", name);
794 sc = pp->geom->softc;
796 sc->sc_error = (int)error;
798 sc->sc_rfailprob = (u_int)rfailprob;
800 sc->sc_wfailprob = (u_int)wfailprob;
801 if (rdelayprob != -1)
802 sc->sc_rdelayprob = (u_int)rdelayprob;
803 if (wdelayprob != -1)
804 sc->sc_wdelayprob = (u_int)wdelayprob;
806 sc->sc_delaymsec = (u_int)delaymsec;
807 if (count_until_fail != -1)
808 sc->sc_count_until_fail = (u_int)count_until_fail;
812 static struct g_geom *
813 g_nop_find_geom(struct g_class *mp, const char *name)
817 LIST_FOREACH(gp, &mp->geom, geom) {
818 if (strcmp(gp->name, name) == 0)
825 g_nop_ctl_destroy(struct gctl_req *req, struct g_class *mp)
827 int *nargs, *force, error, i;
834 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
836 gctl_error(req, "No '%s' argument", "nargs");
840 gctl_error(req, "Missing device(s).");
843 force = gctl_get_paraml(req, "force", sizeof(*force));
845 gctl_error(req, "No 'force' argument");
849 for (i = 0; i < *nargs; i++) {
850 snprintf(param, sizeof(param), "arg%d", i);
851 name = gctl_get_asciiparam(req, param);
853 gctl_error(req, "No 'arg%d' argument", i);
856 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
857 name += strlen("/dev/");
858 gp = g_nop_find_geom(mp, name);
860 G_NOP_DEBUG(1, "Device %s is invalid.", name);
861 gctl_error(req, "Device %s is invalid.", name);
864 error = g_nop_destroy(gp, *force);
866 gctl_error(req, "Cannot destroy device %s (error=%d).",
874 g_nop_ctl_reset(struct gctl_req *req, struct g_class *mp)
876 struct g_nop_softc *sc;
877 struct g_provider *pp;
884 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
886 gctl_error(req, "No '%s' argument", "nargs");
890 gctl_error(req, "Missing device(s).");
894 for (i = 0; i < *nargs; i++) {
895 snprintf(param, sizeof(param), "arg%d", i);
896 name = gctl_get_asciiparam(req, param);
898 gctl_error(req, "No 'arg%d' argument", i);
901 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
902 name += strlen("/dev/");
903 pp = g_provider_by_name(name);
904 if (pp == NULL || pp->geom->class != mp) {
905 G_NOP_DEBUG(1, "Provider %s is invalid.", name);
906 gctl_error(req, "Provider %s is invalid.", name);
909 sc = pp->geom->softc;
919 sc->sc_readbytes = 0;
920 sc->sc_wrotebytes = 0;
925 g_nop_config(struct gctl_req *req, struct g_class *mp, const char *verb)
931 version = gctl_get_paraml(req, "version", sizeof(*version));
932 if (version == NULL) {
933 gctl_error(req, "No '%s' argument.", "version");
936 if (*version != G_NOP_VERSION) {
937 gctl_error(req, "Userland and kernel parts are out of sync.");
941 if (strcmp(verb, "create") == 0) {
942 g_nop_ctl_create(req, mp);
944 } else if (strcmp(verb, "configure") == 0) {
945 g_nop_ctl_configure(req, mp);
947 } else if (strcmp(verb, "destroy") == 0) {
948 g_nop_ctl_destroy(req, mp);
950 } else if (strcmp(verb, "reset") == 0) {
951 g_nop_ctl_reset(req, mp);
955 gctl_error(req, "Unknown verb.");
959 g_nop_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
960 struct g_consumer *cp, struct g_provider *pp)
962 struct g_nop_softc *sc;
964 if (pp != NULL || cp != NULL)
967 sbuf_printf(sb, "%s<Offset>%jd</Offset>\n", indent,
968 (intmax_t)sc->sc_offset);
969 sbuf_printf(sb, "%s<ReadFailProb>%u</ReadFailProb>\n", indent,
971 sbuf_printf(sb, "%s<WriteFailProb>%u</WriteFailProb>\n", indent,
973 sbuf_printf(sb, "%s<ReadDelayedProb>%u</ReadDelayedProb>\n", indent,
975 sbuf_printf(sb, "%s<WriteDelayedProb>%u</WriteDelayedProb>\n", indent,
977 sbuf_printf(sb, "%s<Delay>%d</Delay>\n", indent, sc->sc_delaymsec);
978 sbuf_printf(sb, "%s<CountUntilFail>%u</CountUntilFail>\n", indent,
979 sc->sc_count_until_fail);
980 sbuf_printf(sb, "%s<Error>%d</Error>\n", indent, sc->sc_error);
981 sbuf_printf(sb, "%s<Reads>%ju</Reads>\n", indent, sc->sc_reads);
982 sbuf_printf(sb, "%s<Writes>%ju</Writes>\n", indent, sc->sc_writes);
983 sbuf_printf(sb, "%s<Deletes>%ju</Deletes>\n", indent, sc->sc_deletes);
984 sbuf_printf(sb, "%s<Getattrs>%ju</Getattrs>\n", indent, sc->sc_getattrs);
985 sbuf_printf(sb, "%s<Flushes>%ju</Flushes>\n", indent, sc->sc_flushes);
986 sbuf_printf(sb, "%s<Speedups>%ju</Speedups>\n", indent, sc->sc_speedups);
987 sbuf_printf(sb, "%s<Cmd0s>%ju</Cmd0s>\n", indent, sc->sc_cmd0s);
988 sbuf_printf(sb, "%s<Cmd1s>%ju</Cmd1s>\n", indent, sc->sc_cmd1s);
989 sbuf_printf(sb, "%s<Cmd2s>%ju</Cmd2s>\n", indent, sc->sc_cmd2s);
990 sbuf_printf(sb, "%s<ReadBytes>%ju</ReadBytes>\n", indent,
992 sbuf_printf(sb, "%s<WroteBytes>%ju</WroteBytes>\n", indent,
996 DECLARE_GEOM_CLASS(g_nop_class, g_nop);
997 MODULE_VERSION(geom_nop, 0);