Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/nop/g_nop.c
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
g_nop_start(struct bio *bp) | g_nop_start(struct bio *bp) | ||||
{ | { | ||||
struct g_nop_softc *sc; | struct g_nop_softc *sc; | ||||
struct g_geom *gp; | struct g_geom *gp; | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
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; | ||||
if (sc->sc_count_until_fail != 0) { | |||||
sc->sc_count_until_fail -= 1; | |||||
} else { | |||||
failprob = sc->sc_rfailprob; | failprob = sc->sc_rfailprob; | ||||
delayprob = sc->sc_rdelayprob; | delayprob = sc->sc_rdelayprob; | ||||
delaytime = sc->sc_delaymsec; | 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; | ||||
if (sc->sc_count_until_fail != 0) { | |||||
sc->sc_count_until_fail -= 1; | |||||
} else { | |||||
failprob = sc->sc_wfailprob; | failprob = sc->sc_wfailprob; | ||||
delayprob = sc->sc_wdelayprob; | delayprob = sc->sc_wdelayprob; | ||||
delaytime = sc->sc_delaymsec; | delaytime = sc->sc_delaymsec; | ||||
} | |||||
break; | break; | ||||
case BIO_DELETE: | case BIO_DELETE: | ||||
sc->sc_deletes++; | sc->sc_deletes++; | ||||
break; | break; | ||||
case BIO_GETATTR: | case BIO_GETATTR: | ||||
sc->sc_getattrs++; | sc->sc_getattrs++; | ||||
if (sc->sc_physpath && | if (sc->sc_physpath && | ||||
g_handleattr_str(bp, "GEOM::physpath", sc->sc_physpath)) | g_handleattr_str(bp, "GEOM::physpath", sc->sc_physpath)) | ||||
Show All 17 Lines | g_nop_start(struct bio *bp) | ||||
case BIO_CMD1: | case BIO_CMD1: | ||||
sc->sc_cmd1s++; | sc->sc_cmd1s++; | ||||
break; | break; | ||||
case BIO_CMD2: | case BIO_CMD2: | ||||
sc->sc_cmd2s++; | sc->sc_cmd2s++; | ||||
break; | break; | ||||
} | } | ||||
mtx_unlock(&sc->sc_lock); | mtx_unlock(&sc->sc_lock); | ||||
if (failprob > 0) { | if (failprob > 0) { | ||||
u_int rval; | u_int rval; | ||||
rval = arc4random() % 100; | rval = arc4random() % 100; | ||||
if (rval < failprob) { | if (rval < failprob) { | ||||
G_NOP_LOGREQLVL(1, bp, "Returning error=%d.", sc->sc_error); | G_NOP_LOGREQLVL(1, bp, "Returning error=%d.", sc->sc_error); | ||||
g_io_deliver(bp, sc->sc_error); | g_io_deliver(bp, sc->sc_error); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 714 Lines • Show Last 20 Lines |