hammer - Adjust record and dirtybuf limits to handle large buffer caches
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 16 Sep 2012 01:43:26 +0000 (18:43 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 16 Sep 2012 01:43:26 +0000 (18:43 -0700)
* Adjust record and dirtybuf limits such that they don't blow up a hammer
  volume if the system's buffer cache is very large.

sys/vfs/hammer/hammer_blockmap.c
sys/vfs/hammer/hammer_vfsops.c

index 0dd146c..b00d2ad 100644 (file)
@@ -1516,7 +1516,7 @@ _hammer_checkspace(hammer_mount_t hmp, int slop, int64_t *resp)
                    hmp->rsv_recs * rec_size +
                    hmp->rsv_databytes +
                    ((int64_t)hmp->rsv_fromdelay << HAMMER_LARGEBLOCK_BITS) +
-                   ((int64_t)hidirtybufspace << 2) +
+                   ((int64_t)hammer_limit_dirtybufspace) +
                    (slop << HAMMER_LARGEBLOCK_BITS);
 
        hammer_count_extra_space_used = usedbytes;      /* debugging */
index 03049b3..7090e25 100644 (file)
@@ -330,7 +330,7 @@ MODULE_VERSION(hammer, 1);
 static int
 hammer_vfs_init(struct vfsconf *conf)
 {
-       int n;
+       long n;
 
        /*
         * Wait up to this long for an exclusive deadlock to clear
@@ -341,18 +341,24 @@ hammer_vfs_init(struct vfsconf *conf)
                hammer_tdmux_ticks = hz / 5;
 
        /*
-        * Autosize
+        * Autosize, but be careful because a hammer filesystem's
+        * reserve is partially calculated based on dirtybufspace,
+        * so we simply cannot allow it to get too large.
         */
        if (hammer_limit_recs == 0) {
-               hammer_limit_recs = nbuf * 25;
-               n = kmalloc_limit(M_HAMMER) / 512;
-               if (hammer_limit_recs > n)
-                       hammer_limit_recs = n;
+               n = nbuf * 25;
+               if (n > kmalloc_limit(M_HAMMER) / 512)
+                       n = kmalloc_limit(M_HAMMER) / 512;
+               if (n > 2 * 1024 * 1024)
+                       n = 2 * 1024 * 1024;
+               hammer_limit_recs = (int)n;
        }
        if (hammer_limit_dirtybufspace == 0) {
                hammer_limit_dirtybufspace = hidirtybufspace / 2;
-               if (hammer_limit_dirtybufspace < 100)
-                       hammer_limit_dirtybufspace = 100;
+               if (hammer_limit_dirtybufspace < 1L * 1024 * 1024)
+                       hammer_limit_dirtybufspace = 1024L * 1024;
+               if (hammer_limit_dirtybufspace > 1024L * 1024 * 1024)
+                       hammer_limit_dirtybufspace = 1024L * 1024 * 1024;
        }
 
        /*