Module Name:    src
Committed By:   tls
Date:           Sun Oct 14 14:33:32 UTC 2012

Modified Files:
        src/sys/ufs/ufs [tls-maxphys]: ufs_readwrite.c

Log Message:
In the FFS writebehind code (ufs_readwrite.c:WRITE()), use division
and multiplication instead of shifts, to accomodate devices with
MAXPHYS that is a multiple of the page size, but not a power of 2.

MegaRAID neatly writes out 192k chunks now.

An open question: is is really a good idea to always writebehind
at the largest size supported by the device?  Likely not, as this
could have a major impact on I/O fairness.  OS X and Solaris both
seem to limit transfers to 128k likely for this reason (the same
problem exists with the readahead code but since it is adaptive,
it will not *always* do huge transfers).

However, simply imposing a smallish limit like 128k here seems
like a bad idea because then we cannot accomodate greedy devices
like RAID, for which you want something like 128k * number of
data components.  Hmmmmmm.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.2.1 src/sys/ufs/ufs/ufs_readwrite.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.104 src/sys/ufs/ufs/ufs_readwrite.c:1.104.2.1
--- src/sys/ufs/ufs/ufs_readwrite.c:1.104	Sun Apr 29 22:54:01 2012
+++ src/sys/ufs/ufs/ufs_readwrite.c	Sun Oct 14 14:33:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.104 2012/04/29 22:54:01 chs Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.104.2.1 2012/10/14 14:33:32 tls Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.104 2012/04/29 22:54:01 chs Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.104.2.1 2012/10/14 14:33:32 tls Exp $");
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -414,13 +414,22 @@ WRITE(void *v)
 		 */
 
 #ifndef LFS_READWRITE
-		if (!async && oldoff >> 16 != uio->uio_offset >> 16) {
-			mutex_enter(vp->v_interlock);
-			error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16,
-			    (uio->uio_offset >> 16) << 16,
-			    PGO_CLEANIT | PGO_JOURNALLOCKED | PGO_LAZY);
-			if (error)
-				break;
+		{
+			int maximum = vp->v_mount->mnt_maxphys;
+			off_t oldchunk, newchunk;
+
+			oldchunk = (oldoff / maximum) * maximum;
+			newchunk = (uio->uio_offset / maximum) * maximum;
+
+			if (!async && oldchunk != newchunk) {
+				mutex_enter(vp->v_interlock);
+				error = VOP_PUTPAGES(vp, oldchunk, newchunk,
+						     PGO_CLEANIT |
+						     PGO_JOURNALLOCKED |
+						     PGO_LAZY);
+				if (error)
+					break;
+			}
 		}
 #endif
 	}

Reply via email to