PERFORCE change 133662 for review
Scott Long
scottl at FreeBSD.org
Sat Jan 19 08:25:39 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133662
Change 133662 by scottl at 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;
}
More information about the p4-projects
mailing list