diff options
author | kib <kib@FreeBSD.org> | 2013-03-21 22:36:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-03-21 22:36:43 +0000 |
commit | c966fdfb31aaad19afdaeaa7727b7f658662f433 (patch) | |
tree | c86c25740b8bb980f7aa72966dd34434e5fea359 /sys/geom | |
parent | bd09044d6148e7a6bec4db9c22e02d52c744be21 (diff) | |
download | FreeBSD-src-c966fdfb31aaad19afdaeaa7727b7f658662f433.zip FreeBSD-src-c966fdfb31aaad19afdaeaa7727b7f658662f433.tar.gz |
Correct the page count when excess length is trimmed from the bio.
Reported and tested by: Ivan Klymenko <fidaj@ukr.net
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_io.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index f611168..25a90de 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -718,8 +718,17 @@ g_io_schedule_down(struct thread *tp __unused) */ excess = bp->bio_offset + bp->bio_length; if (excess > bp->bio_to->mediasize) { + KASSERT((bp->bio_flags & BIO_UNMAPPED) == 0 || + round_page(bp->bio_ma_offset + + bp->bio_length) / PAGE_SIZE == bp->bio_ma_n, + ("excess bio %p too short", bp)); excess -= bp->bio_to->mediasize; bp->bio_length -= excess; + if ((bp->bio_flags & BIO_UNMAPPED) != 0) { + bp->bio_ma_n = round_page( + bp->bio_ma_offset + + bp->bio_length) / PAGE_SIZE; + } if (excess > 0) CTR3(KTR_GEOM, "g_down truncated bio " "%p provider %s by %d", bp, |