mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Always set bio_resid properly in fdstrategy(),
as should every block device strategy routine. There was at least one evil consequence of not doing so: Some errors returned by fdstrategy() could be lost (EAGAIN, in particular.) PR: kern/52338 (in the audit-trail) Discussed with: bde
This commit is contained in:
parent
29ec21d1e3
commit
83efe35a66
2 changed files with 4 additions and 6 deletions
|
|
@ -1669,6 +1669,7 @@ fdstrategy(struct bio *bp)
|
|||
panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
|
||||
(u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev));
|
||||
fdc = fd->fdc;
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
if (fd->type == FDT_NONE || fd->ft == 0) {
|
||||
bp->bio_error = ENXIO;
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
|
|
@ -1712,9 +1713,7 @@ fdstrategy(struct bio *bp)
|
|||
nblocks = fd->ft->size;
|
||||
if (blknum + bp->bio_bcount / fdblk > nblocks) {
|
||||
if (blknum >= nblocks) {
|
||||
if (bp->bio_cmd == BIO_READ)
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
else {
|
||||
if (bp->bio_cmd != BIO_READ) {
|
||||
bp->bio_error = ENOSPC;
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1669,6 +1669,7 @@ fdstrategy(struct bio *bp)
|
|||
panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
|
||||
(u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev));
|
||||
fdc = fd->fdc;
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
if (fd->type == FDT_NONE || fd->ft == 0) {
|
||||
bp->bio_error = ENXIO;
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
|
|
@ -1712,9 +1713,7 @@ fdstrategy(struct bio *bp)
|
|||
nblocks = fd->ft->size;
|
||||
if (blknum + bp->bio_bcount / fdblk > nblocks) {
|
||||
if (blknum >= nblocks) {
|
||||
if (bp->bio_cmd == BIO_READ)
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
else {
|
||||
if (bp->bio_cmd != BIO_READ) {
|
||||
bp->bio_error = ENOSPC;
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue