aboutsummaryrefslogtreecommitdiff
path: root/sys/geom
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2013-03-21 22:36:43 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2013-03-21 22:36:43 +0000
commite808788c05fed17c4269af808ad7f2183335e9af (patch)
treec86c25740b8bb980f7aa72966dd34434e5fea359 /sys/geom
parent46f10cc265c51d774ebeeb6c4f73b377fd5e3a1e (diff)
downloadsrc-e808788c05fed17c4269af808ad7f2183335e9af.tar.gz
src-e808788c05fed17c4269af808ad7f2183335e9af.zip
Correct the page count when excess length is trimmed from the bio.
Reported and tested by: Ivan Klymenko <fidaj@ukr.net
Notes
Notes: svn path=/head/; revision=248596
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index f6111684bc2b..25a90de242da 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,