Date: Sat, 19 Jan 2008 16:25:38 GMT From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 133662 for review Message-ID: <200801191625.m0JGPc69052408@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=133662 Change 133662 by scottl@scottl-ix on 2008/01/19 16:25:13 Merge back the blkfront fixes. I'm still not exactly sure why these make a difference, and due to the nature of the corruption it's hard to write a good test case to confirm the behavior. However, there is evidence that without these changes, sometimes data blocks would simply not get written to disk. Affected files ... .. //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#13 integrate Differences ... ==== //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#13 (text+ko) ==== @@ -656,6 +656,7 @@ */ static int blkif_queue_request(struct bio *bp) { + caddr_t alignbuf; unsigned long buffer_ma; blkif_request_t *ring_req; unsigned long id; @@ -683,16 +684,18 @@ PAGE_SIZE; caddr_t newbuf = malloc(bp->bio_bcount + align, M_DEVBUF, M_NOWAIT); - caddr_t alignbuf = (char *)roundup2((u_long)newbuf, align); + + alignbuf = (char *)roundup2((u_long)newbuf, align); /* save a copy of the current buffer */ - bp->bio_driver1 = bp->bio_data; + bp->bio_driver1 = newbuf; + bp->bio_driver2 = alignbuf; /* Copy the data for a write */ if (bp->bio_cmd == BIO_WRITE) bcopy(bp->bio_data, alignbuf, bp->bio_bcount); - bp->bio_data = alignbuf; - } + } else + alignbuf = bp->bio_data; /* Fill out a communications ring structure. */ ring_req = RING_GET_REQUEST(&info->ring, @@ -711,7 +714,7 @@ * chaining is not supported. */ - buffer_ma = vtomach(bp->bio_data); + buffer_ma = vtomach(alignbuf); fsect = (buffer_ma & PAGE_MASK) >> XBD_SECTOR_SHFT; lsect = fsect + (bp->bio_bcount >> XBD_SECTOR_SHFT) - 1; /* install a grant reference. */ @@ -824,13 +827,13 @@ case BLKIF_OP_READ: /* had an unaligned buffer that needs to be copied */ if (bp->bio_driver1) - bcopy(bp->bio_data, bp->bio_driver1, bp->bio_bcount); + bcopy(bp->bio_driver2, bp->bio_data, bp->bio_bcount); + /* FALLTHROUGH */ case BLKIF_OP_WRITE: /* free the copy buffer */ if (bp->bio_driver1) { - free(bp->bio_data, M_DEVBUF); - bp->bio_data = bp->bio_driver1; + free(bp->bio_driver1, M_DEVBUF); bp->bio_driver1 = NULL; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801191625.m0JGPc69052408>