gnop: change the "count until fail" option
Change the "count_until_fail" option of gnop, now it enables the failing rating instead of setting them to 100%. The original patch introduced the new flag, which sets the fail/rate to 100% after N requests. In some cases, we don't want to have 100% of failure probabilities. We want to start failing at some point. For example, on the early stage, we may like to allow some read/writes requests before having some requests delayed - when we try to mount the partition, or when we are trying to import the pool. Another case may be to check how scrub in ZFS will behave on different stages. This allows us to cover more cases. The previous behavior still may be configured. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22632
This commit is contained in:
parent
ad382bd8eb
commit
645532a448
@ -123,8 +123,8 @@ See
|
|||||||
Additional options:
|
Additional options:
|
||||||
.Bl -tag -width "-c count_until_fail"
|
.Bl -tag -width "-c count_until_fail"
|
||||||
.It Fl c Ar 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
|
Specifies the number of I/O requests to allow before setting the read, write and
|
||||||
failure probabilities to 100%.
|
delay failure probabilities.
|
||||||
.It Fl d Ar delaymsec
|
.It Fl d Ar delaymsec
|
||||||
Specifies the delay of the requests in milliseconds.
|
Specifies the delay of the requests in milliseconds.
|
||||||
Note that requests will be delayed before they are sent to the backing device.
|
Note that requests will be delayed before they are sent to the backing device.
|
||||||
|
@ -204,31 +204,35 @@ g_nop_start(struct bio *bp)
|
|||||||
struct bio *cbp;
|
struct bio *cbp;
|
||||||
u_int failprob, delayprob, delaytime;
|
u_int failprob, delayprob, delaytime;
|
||||||
|
|
||||||
failprob = delayprob = 0;
|
failprob = delayprob = delaytime = 0;
|
||||||
|
|
||||||
gp = bp->bio_to->geom;
|
gp = bp->bio_to->geom;
|
||||||
sc = gp->softc;
|
sc = gp->softc;
|
||||||
|
|
||||||
G_NOP_LOGREQ(bp, "Request received.");
|
G_NOP_LOGREQ(bp, "Request received.");
|
||||||
mtx_lock(&sc->sc_lock);
|
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) {
|
switch (bp->bio_cmd) {
|
||||||
case BIO_READ:
|
case BIO_READ:
|
||||||
sc->sc_reads++;
|
sc->sc_reads++;
|
||||||
sc->sc_readbytes += bp->bio_length;
|
sc->sc_readbytes += bp->bio_length;
|
||||||
failprob = sc->sc_rfailprob;
|
if (sc->sc_count_until_fail != 0) {
|
||||||
delayprob = sc->sc_rdelayprob;
|
sc->sc_count_until_fail -= 1;
|
||||||
delaytime = sc->sc_delaymsec;
|
} else {
|
||||||
|
failprob = sc->sc_rfailprob;
|
||||||
|
delayprob = sc->sc_rdelayprob;
|
||||||
|
delaytime = sc->sc_delaymsec;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BIO_WRITE:
|
case BIO_WRITE:
|
||||||
sc->sc_writes++;
|
sc->sc_writes++;
|
||||||
sc->sc_wrotebytes += bp->bio_length;
|
sc->sc_wrotebytes += bp->bio_length;
|
||||||
failprob = sc->sc_wfailprob;
|
if (sc->sc_count_until_fail != 0) {
|
||||||
delayprob = sc->sc_wdelayprob;
|
sc->sc_count_until_fail -= 1;
|
||||||
delaytime = sc->sc_delaymsec;
|
} else {
|
||||||
|
failprob = sc->sc_wfailprob;
|
||||||
|
delayprob = sc->sc_wdelayprob;
|
||||||
|
delaytime = sc->sc_delaymsec;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BIO_DELETE:
|
case BIO_DELETE:
|
||||||
sc->sc_deletes++;
|
sc->sc_deletes++;
|
||||||
@ -262,6 +266,7 @@ g_nop_start(struct bio *bp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mtx_unlock(&sc->sc_lock);
|
mtx_unlock(&sc->sc_lock);
|
||||||
|
|
||||||
if (failprob > 0) {
|
if (failprob > 0) {
|
||||||
u_int rval;
|
u_int rval;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user