PERFORCE change 188022 for review

Zheng Liu lz at FreeBSD.org
Fri Jan 21 03:21:35 UTC 2011


http://p4web.freebsd.org/@@188022?ac=10

Change 188022 by lz at gnehzuil-freebsd on 2011/01/21 03:20:55

	       Add two sysctl variables to control reservation window algorithm.

Affected files ...

.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#29 edit

Differences ...

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#29 (text+ko) ====

@@ -42,6 +42,7 @@
 #include <sys/vnode.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
+#include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/buf.h>
 
@@ -91,6 +92,14 @@
  *   groups without preference.
  */
 
+SYSCTL_NODE(_vfs, OID_AUTO, ext2fs, CTLFLAG_RW, 0, "EXT2FS filesystem");
+
+static int rsv = 1;
+SYSCTL_INT(_vfs_ext2fs, OID_AUTO, rsv, CTLFLAG_RW, &rsv, 0, "");
+
+static int rsv_winsize = 8;
+SYSCTL_UINT(_vfs_ext2fs, OID_AUTO, rsv_winsize, CTLFLAG_RW, &rsv_winsize, 0, "");
+
 /*
  * Allocate a free block.
  *
@@ -206,7 +215,10 @@
 	rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
 	rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
 
-	rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
+        if (rsv_winsize < EXT2_RSV_MAX_RESERVE_BLKS)
+                rp->rsv_goal_size = rsv_winsize;
+        else
+                rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
 	rp->rsv_alloc_hit = 0;
 
 	ip->i_rsv = rp;
@@ -236,7 +248,10 @@
         EXT2_TREE_LOCK(ip->i_e2fs);
         ext2_remove_rsv_win(ip->i_e2fs, rp);
         EXT2_TREE_UNLOCK(ip->i_e2fs);
-        rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
+        if (rsv_winsize < EXT2_RSV_MAX_RESERVE_BLKS)
+                rp->rsv_goal_size = rsv_winsize;
+        else
+                rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
 }
 
 /*
@@ -475,7 +490,7 @@
 /*
  * Allocate a block using reservation window in ext2 file system.
  *
- * NOTE: This function will replace the ext2_alloc() function.
+ * XXX: This function will replace the ext2_alloc() function.
  */
 int
 ext2_alloc_rsv(struct inode *ip, int32_t lbn, int32_t bpref,
@@ -505,6 +520,12 @@
 	else
 		cg = dtog(fs, bpref);
 
+        if (rsv == 0) {
+                bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize,
+                                                        ext2_alloccg);
+                goto allocated;
+        }
+
         /* If cg has some free blocks, then try to allocate a free block from this cg */
         if (fs->e2fs_gd[cg].ext2bgd_nbfree > 0) {
                 /* Read block bitmap from buffer */


More information about the p4-projects mailing list