Date: Tue, 21 Mar 2006 03:00:03 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93678 for review Message-ID: <200603210300.k2L303kD094328@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93678 Change 93678 by kmacy@kmacy_storage:sun4vtmp on 2006/03/21 02:59:36 handle non page-aligned reads that straddle physical pages Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/simdisk.c#3 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/simdisk.c#3 (text+ko) ==== @@ -89,20 +89,34 @@ hvd_startio(struct hvd_softc *sc, struct bio *bp) { u_int r; - int len; + int len, rlen, wlen; + uint64_t page_off; + r = H_EOK; + len = 0; + + page_off = bp->bio_offset & PAGE_MASK; + switch (bp->bio_cmd) { case BIO_READ: - for (len = 0; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { - int rlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; + if (bp->bio_length > (PAGE_SIZE - page_off)) { + len = rlen = (PAGE_SIZE - page_off); + r = hv_sim_read(bp->bio_offset, vtophys((char *)bp->bio_data), rlen); + } + for (; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { + rlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; r = hv_sim_read(bp->bio_offset + len, vtophys((char *)bp->bio_data + len), rlen); } break; case BIO_WRITE: - for (len = 0; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { - int wlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; + if (bp->bio_length > (PAGE_SIZE - page_off)) { + len = wlen = (PAGE_SIZE - page_off); + r = hv_sim_write(bp->bio_offset, vtophys((char *)bp->bio_data), wlen); + } + for (; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { + wlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; r = hv_sim_write(bp->bio_offset + len, vtophys((char *)bp->bio_data + len), wlen); } break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603210300.k2L303kD094328>