From owner-p4-projects@FreeBSD.ORG Sat Jan 19 16:25:39 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2609416A46D; Sat, 19 Jan 2008 16:25:39 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFF8B16A418 for ; Sat, 19 Jan 2008 16:25:38 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E219013C447 for ; Sat, 19 Jan 2008 16:25:38 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0JGPcVo052412 for ; Sat, 19 Jan 2008 16:25:38 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0JGPc69052408 for perforce@freebsd.org; Sat, 19 Jan 2008 16:25:38 GMT (envelope-from scottl@freebsd.org) Date: Sat, 19 Jan 2008 16:25:38 GMT Message-Id: <200801191625.m0JGPc69052408@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 133662 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2008 16:25:39 -0000 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; }