Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Apr 2002 10:53:38 -0700 (PDT)
From:      Thomas Moestl <tmm@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 9451 for review
Message-ID:  <200204091753.g39HrcE38215@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204091753.g39HrcE38215>