Author: jhb
Date: Fri Nov 15 15:29:53 2013
New Revision: 258174
URL: http://svnweb.freebsd.org/changeset/base/258174

Log:
  Don't allow vfs.lorunningspace or vfs.hirunningspace to be set such
  that lorunningspace is greater than hirunningspace as the system
  performs terribly if it is mistuned in this fashion.
  
  MFC after:    1 week

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==============================================================================
--- head/sys/kern/vfs_bio.c     Fri Nov 15 15:14:07 2013        (r258173)
+++ head/sys/kern/vfs_bio.c     Fri Nov 15 15:29:53 2013        (r258174)
@@ -118,6 +118,7 @@ static int flushbufqueues(int, int);
 static void buf_daemon(void);
 static void bremfreel(struct buf *bp);
 static __inline void bd_wakeup(void);
+static int sysctl_runningspace(SYSCTL_HANDLER_ARGS);
 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 static int sysctl_bufspace(SYSCTL_HANDLER_ARGS);
@@ -167,10 +168,12 @@ static int bufdefragcnt;
 SYSCTL_INT(_vfs, OID_AUTO, bufdefragcnt, CTLFLAG_RW, &bufdefragcnt, 0,
     "Number of times we have had to repeat buffer allocation to defragment");
 static long lorunningspace;
-SYSCTL_LONG(_vfs, OID_AUTO, lorunningspace, CTLFLAG_RW, &lorunningspace, 0,
+SYSCTL_PROC(_vfs, OID_AUTO, lorunningspace, CTLTYPE_LONG | CTLFLAG_MPSAFE |
+    CTLFLAG_RW, &lorunningspace, 0, sysctl_runningspace, "L",
     "Minimum preferred space used for in-progress I/O");
 static long hirunningspace;
-SYSCTL_LONG(_vfs, OID_AUTO, hirunningspace, CTLFLAG_RW, &hirunningspace, 0,
+SYSCTL_PROC(_vfs, OID_AUTO, hirunningspace, CTLTYPE_LONG | CTLFLAG_MPSAFE |
+    CTLFLAG_RW, &hirunningspace, 0, sysctl_runningspace, "L",
     "Maximum amount of space to use for in-progress I/O");
 int dirtybufferflushes;
 SYSCTL_INT(_vfs, OID_AUTO, dirtybufferflushes, CTLFLAG_RW, &dirtybufferflushes,
@@ -332,6 +335,34 @@ const char *buf_wmesg = BUF_WMESG;
 #define VFS_BIO_NEED_FREE      0x04    /* wait for free bufs, hi hysteresis */
 #define VFS_BIO_NEED_BUFSPACE  0x08    /* wait for buf space, lo hysteresis */
 
+static int
+sysctl_runningspace(SYSCTL_HANDLER_ARGS)
+{
+       long value;
+       int error;
+
+       value = *(long *)arg1;
+       error = sysctl_handle_long(oidp, &value, 0, req);
+       if (error != 0 || req->newptr == NULL)
+               return (error);
+       mtx_lock(&rbreqlock);
+       if (arg1 == &hirunningspace) {
+               if (value < lorunningspace)
+                       error = EINVAL;
+               else
+                       hirunningspace = value;
+       } else {
+               KASSERT(arg1 == &lorunningspace,
+                   ("%s: unknown arg1", __func__));
+               if (value > hirunningspace)
+                       error = EINVAL;
+               else
+                       lorunningspace = value;
+       }
+       mtx_unlock(&rbreqlock);
+       return (error);
+}
+
 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 static int
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to