PERFORCE change 93678 for review
Kip Macy
kmacy at FreeBSD.org
Tue Mar 21 03:00:04 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=93678
Change 93678 by kmacy at 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;
More information about the p4-projects
mailing list