mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
Fix devstat on md devices, second attempt. r341765 depends on
g_io_deliver() finishing initialization of the bio, but g_io_deliver() actually destroys the bio. INVARIANTS makes the bug obvious by overwriting the bio with garbage. Restore the old order for calling devstat (except don't restore not calling it for the error case), and translate to the devstat KPI so that this order works. Reviewed by: kib
This commit is contained in:
parent
1e3ecb57e0
commit
c907940bf9
1 changed files with 12 additions and 2 deletions
|
|
@ -1241,12 +1241,22 @@ md_kthread(void *arg)
|
|||
error = sc->start(sc, bp);
|
||||
}
|
||||
|
||||
if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
|
||||
/*
|
||||
* Devstat uses (bio_bcount, bio_resid) for
|
||||
* determining the length of the completed part of
|
||||
* the i/o. g_io_deliver() will translate from
|
||||
* bio_completed to that, but it also destroys the
|
||||
* bio so we must do our own translation.
|
||||
*/
|
||||
bp->bio_bcount = bp->bio_length;
|
||||
bp->bio_resid = (error == -1 ? bp->bio_bcount : 0);
|
||||
devstat_end_transaction_bio(sc->devstat, bp);
|
||||
}
|
||||
if (error != -1) {
|
||||
bp->bio_completed = bp->bio_length;
|
||||
g_io_deliver(bp, error);
|
||||
}
|
||||
if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)
|
||||
devstat_end_transaction_bio(sc->devstat, bp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue