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>
48 SYSCTL_DECL(_kern_geom);
49 static SYSCTL_NODE(_kern_geom, OID_AUTO, nop, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
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;
348 struct g_geom_alias *gap;
359 if ((offset % pp->sectorsize) != 0) {
360 gctl_error(req, "Invalid offset for provider %s.", pp->name);
363 if ((size % pp->sectorsize) != 0) {
364 gctl_error(req, "Invalid size for provider %s.", pp->name);
367 if (offset >= pp->mediasize) {
368 gctl_error(req, "Invalid offset for provider %s.", pp->name);
373 size = pp->mediasize - offset;
374 if (offset + size > pp->mediasize) {
375 gctl_error(req, "Invalid size for provider %s.", pp->name);
379 secsize = pp->sectorsize;
380 else if ((secsize % pp->sectorsize) != 0) {
381 gctl_error(req, "Invalid secsize for provider %s.", pp->name);
384 if (secsize > maxphys) {
385 gctl_error(req, "secsize is too big.");
388 size -= size % secsize;
389 if ((stripesize % pp->sectorsize) != 0) {
390 gctl_error(req, "Invalid stripesize for provider %s.", pp->name);
393 if ((stripeoffset % pp->sectorsize) != 0) {
394 gctl_error(req, "Invalid stripeoffset for provider %s.", pp->name);
397 if (stripesize != 0 && stripeoffset >= stripesize) {
398 gctl_error(req, "stripeoffset is too big.");
401 if (gnopname != NULL && !g_nop_verify_nprefix(gnopname)) {
402 gctl_error(req, "Name %s is invalid.", gnopname);
406 if (gnopname != NULL) {
407 n = snprintf(name, sizeof(name), "%s%s", gnopname,
410 n = snprintf(name, sizeof(name), "%s%s", pp->name,
413 if (n <= 0 || n >= sizeof(name)) {
414 gctl_error(req, "Invalid provider name.");
417 LIST_FOREACH(gp, &mp->geom, geom) {
418 if (strcmp(gp->name, name) == 0) {
419 gctl_error(req, "Provider %s already exists.", name);
423 gp = g_new_geomf(mp, "%s", name);
424 sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
425 sc->sc_offset = offset;
426 sc->sc_explicitsize = explicitsize;
427 sc->sc_stripesize = stripesize;
428 sc->sc_stripeoffset = stripeoffset;
429 if (physpath && strcmp(physpath, G_NOP_PHYSPATH_PASSTHROUGH)) {
430 sc->sc_physpath = strndup(physpath, MAXPATHLEN, M_GEOM);
432 sc->sc_physpath = NULL;
433 sc->sc_error = ioerror;
434 sc->sc_count_until_fail = count_until_fail;
435 sc->sc_rfailprob = rfailprob;
436 sc->sc_wfailprob = wfailprob;
437 sc->sc_delaymsec = delaymsec;
438 sc->sc_rdelayprob = rdelayprob;
439 sc->sc_wdelayprob = wdelayprob;
449 sc->sc_readbytes = 0;
450 sc->sc_wrotebytes = 0;
451 TAILQ_INIT(&sc->sc_head_delay);
452 mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF);
455 newpp = g_new_providerf(gp, "%s", gp->name);
456 newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
457 newpp->mediasize = size;
458 newpp->sectorsize = secsize;
459 newpp->stripesize = stripesize;
460 newpp->stripeoffset = stripeoffset;
461 LIST_FOREACH(gap, &pp->aliases, ga_next)
462 g_provider_add_alias(newpp, "%s%s", gap->ga_alias, G_NOP_SUFFIX);
464 cp = g_new_consumer(gp);
465 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
466 error = g_attach(cp, pp);
468 gctl_error(req, "Cannot attach to provider %s.", pp->name);
472 newpp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED;
473 g_error_provider(newpp, 0);
474 G_NOP_DEBUG(0, "Device %s created.", gp->name);
477 if (cp->provider != NULL)
479 g_destroy_consumer(cp);
480 g_destroy_provider(newpp);
481 mtx_destroy(&sc->sc_lock);
482 free(sc->sc_physpath, M_GEOM);
489 g_nop_providergone(struct g_provider *pp)
491 struct g_geom *gp = pp->geom;
492 struct g_nop_softc *sc = gp->softc;
494 KASSERT(TAILQ_EMPTY(&sc->sc_head_delay),
495 ("delayed request list is not empty"));
498 free(sc->sc_physpath, M_GEOM);
499 mtx_destroy(&sc->sc_lock);
504 g_nop_destroy(struct g_geom *gp, boolean_t force)
506 struct g_nop_softc *sc;
507 struct g_provider *pp;
513 pp = LIST_FIRST(&gp->provider);
514 if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
516 G_NOP_DEBUG(0, "Device %s is still open, so it "
517 "can't be definitely removed.", pp->name);
519 G_NOP_DEBUG(1, "Device %s is still open (r%dw%de%d).",
520 pp->name, pp->acr, pp->acw, pp->ace);
524 G_NOP_DEBUG(0, "Device %s removed.", gp->name);
527 g_wither_geom(gp, ENXIO);
533 g_nop_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
536 return (g_nop_destroy(gp, 0));
540 g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
542 struct g_provider *pp;
543 intmax_t *val, error, rfailprob, wfailprob, count_until_fail, offset,
544 secsize, size, stripesize, stripeoffset, delaymsec,
545 rdelayprob, wdelayprob;
546 const char *physpath, *gnopname;
555 count_until_fail = -1;
565 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
567 gctl_error(req, "No '%s' argument", "nargs");
571 gctl_error(req, "Missing device(s).");
574 val = gctl_get_paraml_opt(req, "error", sizeof(*val));
578 val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
581 if (rfailprob < -1 || rfailprob > 100) {
582 gctl_error(req, "Invalid '%s' argument", "rfailprob");
586 val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
589 if (wfailprob < -1 || wfailprob > 100) {
590 gctl_error(req, "Invalid '%s' argument", "wfailprob");
594 val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
597 if (delaymsec < 1 && delaymsec != -1) {
598 gctl_error(req, "Invalid '%s' argument", "delaymsec");
602 val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
605 if (rdelayprob < -1 || rdelayprob > 100) {
606 gctl_error(req, "Invalid '%s' argument", "rdelayprob");
610 val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
613 if (wdelayprob < -1 || wdelayprob > 100) {
614 gctl_error(req, "Invalid '%s' argument", "wdelayprob");
618 val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
620 count_until_fail = *val;
621 if (count_until_fail < -1) {
622 gctl_error(req, "Invalid '%s' argument",
627 val = gctl_get_paraml_opt(req, "offset", sizeof(*val));
631 gctl_error(req, "Invalid '%s' argument", "offset");
635 val = gctl_get_paraml_opt(req, "size", sizeof(*val));
639 gctl_error(req, "Invalid '%s' argument", "size");
643 val = gctl_get_paraml_opt(req, "secsize", sizeof(*val));
647 gctl_error(req, "Invalid '%s' argument", "secsize");
651 val = gctl_get_paraml_opt(req, "stripesize", sizeof(*val));
654 if (stripesize < 0) {
655 gctl_error(req, "Invalid '%s' argument", "stripesize");
659 val = gctl_get_paraml_opt(req, "stripeoffset", sizeof(*val));
662 if (stripeoffset < 0) {
663 gctl_error(req, "Invalid '%s' argument",
668 physpath = gctl_get_asciiparam(req, "physpath");
669 gnopname = gctl_get_asciiparam(req, "gnopname");
671 for (i = 0; i < *nargs; i++) {
672 snprintf(param, sizeof(param), "arg%d", i);
673 pp = gctl_get_provider(req, param);
676 if (g_nop_create(req, mp, pp,
678 error == -1 ? EIO : (int)error,
679 count_until_fail == -1 ? 0 : (u_int)count_until_fail,
680 rfailprob == -1 ? 0 : (u_int)rfailprob,
681 wfailprob == -1 ? 0 : (u_int)wfailprob,
682 delaymsec == -1 ? 1 : (u_int)delaymsec,
683 rdelayprob == -1 ? 0 : (u_int)rdelayprob,
684 wdelayprob == -1 ? 0 : (u_int)wdelayprob,
685 (off_t)offset, (off_t)size, (u_int)secsize,
686 (off_t)stripesize, (off_t)stripeoffset,
694 g_nop_ctl_configure(struct gctl_req *req, struct g_class *mp)
696 struct g_nop_softc *sc;
697 struct g_provider *pp;
698 intmax_t *val, delaymsec, error, rdelayprob, rfailprob, wdelayprob,
699 wfailprob, count_until_fail;
705 count_until_fail = -1;
713 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
715 gctl_error(req, "No '%s' argument", "nargs");
719 gctl_error(req, "Missing device(s).");
722 val = gctl_get_paraml_opt(req, "error", sizeof(*val));
726 val = gctl_get_paraml_opt(req, "count_until_fail", sizeof(*val));
728 count_until_fail = *val;
730 val = gctl_get_paraml_opt(req, "rfailprob", sizeof(*val));
733 if (rfailprob < -1 || rfailprob > 100) {
734 gctl_error(req, "Invalid '%s' argument", "rfailprob");
738 val = gctl_get_paraml_opt(req, "wfailprob", sizeof(*val));
741 if (wfailprob < -1 || wfailprob > 100) {
742 gctl_error(req, "Invalid '%s' argument", "wfailprob");
746 val = gctl_get_paraml_opt(req, "delaymsec", sizeof(*val));
749 if (delaymsec < 1 && delaymsec != -1) {
750 gctl_error(req, "Invalid '%s' argument", "delaymsec");
754 val = gctl_get_paraml_opt(req, "rdelayprob", sizeof(*val));
757 if (rdelayprob < -1 || rdelayprob > 100) {
758 gctl_error(req, "Invalid '%s' argument", "rdelayprob");
762 val = gctl_get_paraml_opt(req, "wdelayprob", sizeof(*val));
765 if (wdelayprob < -1 || wdelayprob > 100) {
766 gctl_error(req, "Invalid '%s' argument", "wdelayprob");
771 for (i = 0; i < *nargs; i++) {
772 snprintf(param, sizeof(param), "arg%d", i);
773 pp = gctl_get_provider(req, param);
776 if (pp->geom->class != mp) {
777 G_NOP_DEBUG(1, "Provider %s is invalid.", pp->name);
778 gctl_error(req, "Provider %s is invalid.", pp->name);
781 sc = pp->geom->softc;
783 sc->sc_error = (int)error;
785 sc->sc_rfailprob = (u_int)rfailprob;
787 sc->sc_wfailprob = (u_int)wfailprob;
788 if (rdelayprob != -1)
789 sc->sc_rdelayprob = (u_int)rdelayprob;
790 if (wdelayprob != -1)
791 sc->sc_wdelayprob = (u_int)wdelayprob;
793 sc->sc_delaymsec = (u_int)delaymsec;
794 if (count_until_fail != -1)
795 sc->sc_count_until_fail = (u_int)count_until_fail;
799 static struct g_geom *
800 g_nop_find_geom(struct g_class *mp, const char *name)
804 LIST_FOREACH(gp, &mp->geom, geom) {
805 if (strcmp(gp->name, name) == 0)
812 g_nop_ctl_destroy(struct gctl_req *req, struct g_class *mp)
814 int *nargs, *force, error, i;
821 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
823 gctl_error(req, "No '%s' argument", "nargs");
827 gctl_error(req, "Missing device(s).");
830 force = gctl_get_paraml(req, "force", sizeof(*force));
832 gctl_error(req, "No 'force' argument");
836 for (i = 0; i < *nargs; i++) {
837 snprintf(param, sizeof(param), "arg%d", i);
838 name = gctl_get_asciiparam(req, param);
840 gctl_error(req, "No 'arg%d' argument", i);
843 if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
844 name += strlen(_PATH_DEV);
845 gp = g_nop_find_geom(mp, name);
847 G_NOP_DEBUG(1, "Device %s is invalid.", name);
848 gctl_error(req, "Device %s is invalid.", name);
851 error = g_nop_destroy(gp, *force);
853 gctl_error(req, "Cannot destroy device %s (error=%d).",
861 g_nop_ctl_reset(struct gctl_req *req, struct g_class *mp)
863 struct g_nop_softc *sc;
864 struct g_provider *pp;
870 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
872 gctl_error(req, "No '%s' argument", "nargs");
876 gctl_error(req, "Missing device(s).");
880 for (i = 0; i < *nargs; i++) {
881 snprintf(param, sizeof(param), "arg%d", i);
882 pp = gctl_get_provider(req, param);
885 if (pp->geom->class != mp) {
886 G_NOP_DEBUG(1, "Provider %s is invalid.", pp->name);
887 gctl_error(req, "Provider %s is invalid.", pp->name);
890 sc = pp->geom->softc;
900 sc->sc_readbytes = 0;
901 sc->sc_wrotebytes = 0;
906 g_nop_config(struct gctl_req *req, struct g_class *mp, const char *verb)
912 version = gctl_get_paraml(req, "version", sizeof(*version));
913 if (version == NULL) {
914 gctl_error(req, "No '%s' argument.", "version");
917 if (*version != G_NOP_VERSION) {
918 gctl_error(req, "Userland and kernel parts are out of sync.");
922 if (strcmp(verb, "create") == 0) {
923 g_nop_ctl_create(req, mp);
925 } else if (strcmp(verb, "configure") == 0) {
926 g_nop_ctl_configure(req, mp);
928 } else if (strcmp(verb, "destroy") == 0) {
929 g_nop_ctl_destroy(req, mp);
931 } else if (strcmp(verb, "reset") == 0) {
932 g_nop_ctl_reset(req, mp);
936 gctl_error(req, "Unknown verb.");
940 g_nop_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
941 struct g_consumer *cp, struct g_provider *pp)
943 struct g_nop_softc *sc;
945 if (pp != NULL || cp != NULL)
948 sbuf_printf(sb, "%s<Offset>%jd</Offset>\n", indent,
949 (intmax_t)sc->sc_offset);
950 sbuf_printf(sb, "%s<ReadFailProb>%u</ReadFailProb>\n", indent,
952 sbuf_printf(sb, "%s<WriteFailProb>%u</WriteFailProb>\n", indent,
954 sbuf_printf(sb, "%s<ReadDelayedProb>%u</ReadDelayedProb>\n", indent,
956 sbuf_printf(sb, "%s<WriteDelayedProb>%u</WriteDelayedProb>\n", indent,
958 sbuf_printf(sb, "%s<Delay>%d</Delay>\n", indent, sc->sc_delaymsec);
959 sbuf_printf(sb, "%s<CountUntilFail>%u</CountUntilFail>\n", indent,
960 sc->sc_count_until_fail);
961 sbuf_printf(sb, "%s<Error>%d</Error>\n", indent, sc->sc_error);
962 sbuf_printf(sb, "%s<Reads>%ju</Reads>\n", indent, sc->sc_reads);
963 sbuf_printf(sb, "%s<Writes>%ju</Writes>\n", indent, sc->sc_writes);
964 sbuf_printf(sb, "%s<Deletes>%ju</Deletes>\n", indent, sc->sc_deletes);
965 sbuf_printf(sb, "%s<Getattrs>%ju</Getattrs>\n", indent, sc->sc_getattrs);
966 sbuf_printf(sb, "%s<Flushes>%ju</Flushes>\n", indent, sc->sc_flushes);
967 sbuf_printf(sb, "%s<Speedups>%ju</Speedups>\n", indent, sc->sc_speedups);
968 sbuf_printf(sb, "%s<Cmd0s>%ju</Cmd0s>\n", indent, sc->sc_cmd0s);
969 sbuf_printf(sb, "%s<Cmd1s>%ju</Cmd1s>\n", indent, sc->sc_cmd1s);
970 sbuf_printf(sb, "%s<Cmd2s>%ju</Cmd2s>\n", indent, sc->sc_cmd2s);
971 sbuf_printf(sb, "%s<ReadBytes>%ju</ReadBytes>\n", indent,
973 sbuf_printf(sb, "%s<WroteBytes>%ju</WroteBytes>\n", indent,
977 DECLARE_GEOM_CLASS(g_nop_class, g_nop);
978 MODULE_VERSION(geom_nop, 0);