diff options
author | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2019-12-29 15:47:37 +0000 |
---|---|---|
committer | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2019-12-29 15:47:37 +0000 |
commit | 645532a4487a4a5a5d203ff393322380b6e614ef (patch) | |
tree | 1b524da72b0ec6f21993fb58a9ff239c0ba2f4c8 | |
parent | ad382bd8eb4950033413f4c04f59dc085e043768 (diff) | |
download | src-645532a4487a4a5a5d203ff393322380b6e614ef.tar.gz src-645532a4487a4a5a5d203ff393322380b6e614ef.zip |
Notes
-rw-r--r-- | lib/geom/nop/gnop.8 | 4 | ||||
-rw-r--r-- | sys/geom/nop/g_nop.c | 27 |
2 files changed, 18 insertions, 13 deletions
diff --git a/lib/geom/nop/gnop.8 b/lib/geom/nop/gnop.8 index 21efb64a415e..67eef9e0a044 100644 --- a/lib/geom/nop/gnop.8 +++ b/lib/geom/nop/gnop.8 @@ -123,8 +123,8 @@ See Additional options: .Bl -tag -width "-c count_until_fail" .It Fl c Ar count_until_fail -Specifies the number of I/O requests to allow before setting the read and write -failure probabilities to 100%. +Specifies the number of I/O requests to allow before setting the read, write and +delay failure probabilities. .It Fl d Ar delaymsec Specifies the delay of the requests in milliseconds. Note that requests will be delayed before they are sent to the backing device. diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c index 84c8849d1fc7..c2e529cf03c1 100644 --- a/sys/geom/nop/g_nop.c +++ b/sys/geom/nop/g_nop.c @@ -204,31 +204,35 @@ g_nop_start(struct bio *bp) struct bio *cbp; u_int failprob, delayprob, delaytime; - failprob = delayprob = 0; + failprob = delayprob = delaytime = 0; gp = bp->bio_to->geom; sc = gp->softc; G_NOP_LOGREQ(bp, "Request received."); mtx_lock(&sc->sc_lock); - if (sc->sc_count_until_fail != 0 && --sc->sc_count_until_fail == 0) { - sc->sc_rfailprob = 100; - sc->sc_wfailprob = 100; - } switch (bp->bio_cmd) { case BIO_READ: sc->sc_reads++; sc->sc_readbytes += bp->bio_length; - failprob = sc->sc_rfailprob; - delayprob = sc->sc_rdelayprob; - delaytime = sc->sc_delaymsec; + 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; + } break; case BIO_WRITE: sc->sc_writes++; sc->sc_wrotebytes += bp->bio_length; - failprob = sc->sc_wfailprob; - delayprob = sc->sc_wdelayprob; - delaytime = sc->sc_delaymsec; + 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; + } break; case BIO_DELETE: sc->sc_deletes++; @@ -262,6 +266,7 @@ g_nop_start(struct bio *bp) break; } mtx_unlock(&sc->sc_lock); + if (failprob > 0) { u_int rval; |