From owner-p4-projects@FreeBSD.ORG Sat Jan 19 09:13:03 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2C40816A421; Sat, 19 Jan 2008 09:13:03 +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 E56D516A417 for ; Sat, 19 Jan 2008 09:13:02 +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 C76E213C465 for ; Sat, 19 Jan 2008 09:13:02 +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 m0J9D2kB008990 for ; Sat, 19 Jan 2008 09:13:02 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0J9D2bt008987 for perforce@freebsd.org; Sat, 19 Jan 2008 09:13:02 GMT (envelope-from scottl@freebsd.org) Date: Sat, 19 Jan 2008 09:13:02 GMT Message-Id: <200801190913.m0J9D2bt008987@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 133646 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 09:13:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=133646 Change 133646 by scottl@scottl-ix on 2008/01/19 09:12:20 Don't spam bp->bio_data while doing a re-aligned I/O operation. For reasons I don't understand, it causes problems during writes, but not during reads. Affected files ... .. //depot/projects/xen31-xenbus/sys/dev/xen/blkfront/blkfront.c#3 edit Differences ... ==== //depot/projects/xen31-xenbus/sys/dev/xen/blkfront/blkfront.c#3 (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. */ @@ -823,14 +826,15 @@ switch (bret->operation) { 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); + if (bp->bio_driver1) { + bcopy(bp->bio_driver2, bp->bio_data, bp->bio_bcount); + bp->bio_driver1 = NULL; + } 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; }