svn commit: r250906 - stable/9/sys/kern

Scott Long scottl at FreeBSD.org
Wed May 22 08:44:22 UTC 2013


Author: scottl
Date: Wed May 22 08:44:21 2013
New Revision: 250906
URL: http://svnweb.freebsd.org/changeset/base/250906

Log:
  MFC r250327
  
  Add a sysctl vfs.read_min to complement the exiting vfs.read_max.  It
  defaults to 1, meaning that it's off.
  
  When read-ahead is enabled on a file, the vfs cluster code deliberately
  breaks a read into 2 I/O transactions; one to satisfy the actual read,
  and one to perform read-ahead.  This makes sense in low-latency
  circumstances, but often produces unbalanced i/o transactions that
  penalize disks.  By setting vfs.read_min, we can tell the algorithm to
  fetch a larger transaction that what we asked for, achieving the same
  effect as the read-ahead but without the doubled, unbalanced transaction
  and the slightly lower latency.  This significantly helps our workloads
  with video streaming.
  
  Submitted by:   emax
  Reviewed by:    kib
  Obtained from:  Netflix

Modified:
  stable/9/sys/kern/vfs_cluster.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_cluster.c
==============================================================================
--- stable/9/sys/kern/vfs_cluster.c	Wed May 22 07:52:41 2013	(r250905)
+++ stable/9/sys/kern/vfs_cluster.c	Wed May 22 08:44:21 2013	(r250906)
@@ -75,6 +75,10 @@ static int read_max = 64;
 SYSCTL_INT(_vfs, OID_AUTO, read_max, CTLFLAG_RW, &read_max, 0,
     "Cluster read-ahead max block count");
 
+static int read_min = 1;
+SYSCTL_INT(_vfs, OID_AUTO, read_min, CTLFLAG_RW, &read_min, 0,
+    "Cluster read min block count");
+
 /* Page expended to mark partially backed buffers */
 extern vm_page_t	bogus_page;
 
@@ -169,6 +173,7 @@ cluster_read(vp, filesize, lblkno, size,
 	} else {
 		off_t firstread = bp->b_offset;
 		int nblks;
+		long minread;
 
 		KASSERT(bp->b_offset != NOOFFSET,
 		    ("cluster_read: no buffer offset"));
@@ -176,6 +181,13 @@ cluster_read(vp, filesize, lblkno, size,
 		ncontig = 0;
 
 		/*
+		 * Adjust totread if needed
+		 */
+		minread = read_min * size;
+		if (minread > totread)
+			totread = minread;
+
+		/*
 		 * Compute the total number of blocks that we should read
 		 * synchronously.
 		 */


More information about the svn-src-stable-9 mailing list