From owner-p4-projects Tue Apr 9 10:53:51 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AB90B37B41F; Tue, 9 Apr 2002 10:53:39 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C8D5037B41D for ; Tue, 9 Apr 2002 10:53:38 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g39HrcE38215 for perforce@freebsd.org; Tue, 9 Apr 2002 10:53:38 -0700 (PDT) (envelope-from tmm@freebsd.org) Date: Tue, 9 Apr 2002 10:53:38 -0700 (PDT) Message-Id: <200204091753.g39HrcE38215@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to tmm@freebsd.org using -f From: Thomas Moestl Subject: PERFORCE change 9451 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9451 Change 9451 by tmm@tmm_sparc64 on 2002/04/09 10:52:50 Fix cluster read/write by adding the required offsets after calling vmiomapbuf(), and add a KASSERT() to the latter to catch such errors easily in the future. While being there, add two trunc_page()s to the vm_mdpg_*() functions; they are not necessary atm, but remove a pitfall. Head ending in a singularity to: tmm Affected files ... ... //depot/projects/sparc64/sys/kern/vfs_bio.c#22 edit ... //depot/projects/sparc64/sys/kern/vfs_cluster.c#10 edit ... //depot/projects/sparc64/sys/sparc64/sparc64/vm_machdep.c#48 edit Differences ... ==== //depot/projects/sparc64/sys/kern/vfs_bio.c#22 (text+ko) ==== @@ -3436,7 +3436,12 @@ vm_offset_t kva; int color; - kva = trunc_page((vm_offset_t)bp->b_data); + kva = (vm_offset_t)bp->b_data; + /* + * This indicates that the caller was not converted properly, and has + * added required offsets to b_data. + */ + KASSERT((kva & PAGE_MASK) == 0, ("vmiomapbuf: page offset present!")); color = vm_mdpg_pref_vcol(obj, offs, m, count); if (color != -1) { kva = vm_roundcolor2(kva, (vm_offset_t)color << PAGE_SHIFT, ==== //depot/projects/sparc64/sys/kern/vfs_cluster.c#10 (text+ko) ==== @@ -336,6 +336,7 @@ { struct buf *bp, *tbp; vm_object_t obj; + vm_offset_t boffs; daddr_t bn; int i, inc, j; @@ -378,8 +379,7 @@ * address may not be either. Inherit the b_data offset * from the original buffer. */ - bp->b_data = (char *)((vm_offset_t)bp->b_data | - ((vm_offset_t)tbp->b_data & PAGE_MASK)); + boffs = (vm_offset_t)tbp->b_data & PAGE_MASK; bp->b_flags = B_ASYNC | B_CLUSTER | B_VMIO; bp->b_iocmd = BIO_READ; bp->b_iodone = cluster_callback; @@ -532,6 +532,7 @@ VOP_GETVOBJECT(vp, &obj); vmiomapbuf(bp, obj, bp->b_offset, bp->b_pages, bp->b_npages, BIO_READ); + bp->b_data = (char *)((vm_offset_t)bp->b_data | boffs); return (bp); } @@ -787,6 +788,7 @@ int len; { struct buf *bp, *tbp; + vm_offset_t boffs; int i, j, s; int totalwritten = 0; int dbsize = btodb(size); @@ -856,8 +858,7 @@ * address may not be either. Inherit the b_data offset * from the original buffer. */ - bp->b_data = (char *)((vm_offset_t)bp->b_data | - ((vm_offset_t)tbp->b_data & PAGE_MASK)); + boffs = (vm_offset_t)tbp->b_data & PAGE_MASK; bp->b_flags |= B_CLUSTER | (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT | B_NOWDRAIN)); bp->b_iodone = cluster_callback; @@ -982,6 +983,7 @@ finishcluster: vmiomapbuf(bp, vp->v_object, bp->b_offset, bp->b_pages, bp->b_npages, bp->b_iocmd); + bp->b_data = (char *)((vm_offset_t)bp->b_data | boffs); if (bp->b_bufsize > bp->b_kvasize) panic( "cluster_wbuild: b_bufsize(%ld) > b_kvasize(%d)\n", ==== //depot/projects/sparc64/sys/sparc64/sparc64/vm_machdep.c#48 (text+ko) ==== @@ -484,6 +484,7 @@ int i; VMMD_STATS_INC(nstart_io); + kva = trunc_page(kva); switch (ioflag) { case VM_MDPG_WRITE: for (i = 0; i < count; i++) { @@ -535,6 +536,7 @@ int i; VMMD_STATS_INC(ndone_io); + kva = trunc_page(kva); switch (ioflag) { case VM_MDPG_WRITE: color = 0; /* silence warning. */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message