+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for max number of concurrent aio requests. Makes sure
+ * the system wide limit is greater than the per process
+ * limit.
+ */
+static int
+sysctl_aiomax( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value;
+
+ if ( oldp && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp )
+ error = copyout( &aio_max_requests, oldp, sizeof(int) );
+ if ( error == 0 && newp )
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && newp ) {
+ if ( new_value >= aio_max_requests_per_process )
+ aio_max_requests = new_value;
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_aiomax */
+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for max number of concurrent aio requests per process.
+ * Makes sure per process limit is less than the system wide
+ * limit.
+ */
+static int
+sysctl_aioprocmax( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value = 0;
+
+ if ( oldp && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp )
+ error = copyout( &aio_max_requests_per_process, oldp, sizeof(int) );
+ if ( error == 0 && newp )
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && newp ) {
+ if ( new_value <= aio_max_requests && new_value >= AIO_LISTIO_MAX )
+ aio_max_requests_per_process = new_value;
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_aioprocmax */
+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for max number of async IO worker threads.
+ * We only allow an increase in the number of worker threads.
+ */
+static int
+sysctl_aiothreads( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value;
+
+ if ( oldp && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp )
+ error = copyout( &aio_worker_threads, oldp, sizeof(int) );
+ if ( error == 0 && newp )
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && newp ) {
+ if (new_value > aio_worker_threads ) {
+ _aio_create_worker_threads( (new_value - aio_worker_threads) );
+ aio_worker_threads = new_value;
+ }
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_aiothreads */
+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for max number of processes per UID.
+ * Makes sure per UID limit is less than the system wide limit.
+ */
+static int
+sysctl_maxprocperuid( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value;
+
+ if ( oldp != NULL && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp != NULL && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp != NULL )
+ error = copyout( &maxprocperuid, oldp, sizeof(int) );
+ if ( error == 0 && newp != NULL ) {
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && new_value <= maxproc && new_value > 0 )
+ maxprocperuid = new_value;
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_maxprocperuid */
+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for max number of files per process.
+ * Makes sure per process limit is less than the system-wide limit.
+ */
+static int
+sysctl_maxfilesperproc( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value;
+
+ if ( oldp != NULL && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp != NULL && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp != NULL )
+ error = copyout( &maxfilesperproc, oldp, sizeof(int) );
+ if ( error == 0 && newp != NULL ) {
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && new_value < maxfiles && new_value > 0 )
+ maxfilesperproc = new_value;
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_maxfilesperproc */
+
+
+/*
+ * Validate parameters and get old / set new parameters
+ * for the system-wide limit on the max number of processes.
+ * Makes sure the system-wide limit is less than the configured hard
+ * limit set at kernel compilation.
+ */
+static int
+sysctl_maxproc( void *oldp, size_t *oldlenp, void *newp, size_t newlen )
+{
+ int error = 0;
+ int new_value;
+
+ if ( oldp != NULL && *oldlenp < sizeof(int) )
+ return (ENOMEM);
+ if ( newp != NULL && newlen != sizeof(int) )
+ return (EINVAL);
+
+ *oldlenp = sizeof(int);
+ if ( oldp != NULL )
+ error = copyout( &maxproc, oldp, sizeof(int) );
+ if ( error == 0 && newp != NULL ) {
+ error = copyin( newp, &new_value, sizeof(int) );
+ if ( error == 0 && new_value <= hard_maxproc && new_value > 0 )
+ maxproc = new_value;
+ else
+ error = EINVAL;
+ }
+ return( error );
+
+} /* sysctl_maxproc */