Module Name:    src
Committed By:   jruoho
Date:           Fri Aug  6 18:36:10 UTC 2010

Modified Files:
        src/share/man/man7: sysctl.7
        src/sys/kern: sys_aio.c

Log Message:
Like with mqueue(3), create and remove the aio(3) sysctl nodes dynamically.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/sys_aio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man7/sysctl.7
diff -u src/share/man/man7/sysctl.7:1.50 src/share/man/man7/sysctl.7:1.51
--- src/share/man/man7/sysctl.7:1.50	Sat Jul 31 02:04:45 2010
+++ src/share/man/man7/sysctl.7	Fri Aug  6 18:36:09 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.50 2010/07/31 02:04:45 jruoho Exp $
+.\"	$NetBSD: sysctl.7,v 1.51 2010/08/06 18:36:09 jruoho Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
 .\"
-.Dd July 31, 2010
+.Dd August 6, 2010
 .Dt SYSCTL 7
 .Os
 .Sh NAME
@@ -239,6 +239,8 @@
 .Bl -column "kern.posix_reader_writer_locks" \
 "struct kinfo_drivers" "not applicable"
 .It Sy Second level name	Type	Changeable
+.It kern.aio_listio_max	integer	yes
+.It kern.aio_max	integer	yes
 .It kern.arandom	integer	no
 .It kern.argmax	integer	no
 .It kern.boothowto	integer	no
@@ -296,6 +298,7 @@
 .It kern.pipe	node	not applicable
 .\" .It kern.posix	node	not applicable
 .It kern.posix1version	integer	no
+.It kern.posix_aio	integer	no
 .It kern.posix_barriers	integer	no
 .It kern.posix_reader_writer_locks	integer	no
 .\".It kern.posix_sched	integer	yes
@@ -329,6 +332,16 @@
 .It kern.vnode	struct vnode	no
 .El
 .Bl -tag -width "123456"
+.It Li kern.aio_listio_max
+The maximum number of asynchronous
+.Tn I/O
+operations in a single list I/O call.
+Like with all variables related to
+.Xr aio 3 ,
+the variable may be created and removed dynamically
+upon loading or unloading the corresponding kernel module.
+.It Li kern.aio_max
+The maximum number of asynchronous I/O operations.
 .It Li kern.arandom
 This variable picks a random number each time it is queried.
 The used random number generator
@@ -784,6 +797,10 @@
 .It Li kern.posix1version ( KERN_POSIX1 )
 The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
 attempts to comply.
+.It Li kern.posix_aio
+The version of
+.St -p1003.1
+and its Asynchronous I/O option to which the system attempts to conform.
 .It Li kern.posix_barriers ( KERN_POSIX_BARRIERS )
 The version of
 .St -p1003.1

Index: src/sys/kern/sys_aio.c
diff -u src/sys/kern/sys_aio.c:1.34 src/sys/kern/sys_aio.c:1.35
--- src/sys/kern/sys_aio.c:1.34	Thu Jun 24 13:03:11 2010
+++ src/sys/kern/sys_aio.c	Fri Aug  6 18:36:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_aio.c,v 1.34 2010/06/24 13:03:11 hannken Exp $	*/
+/*	$NetBSD: sys_aio.c,v 1.35 2010/08/06 18:36:09 jruoho Exp $	*/
 
 /*
  * Copyright (c) 2007 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.34 2010/06/24 13:03:11 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.35 2010/08/06 18:36:09 jruoho Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -73,15 +73,20 @@
 static u_int		aio_max = AIO_MAX;
 static u_int		aio_jobs_count;
 
+static struct sysctllog	*aio_sysctl;
 static struct pool	aio_job_pool;
 static struct pool	aio_lio_pool;
 static void *		aio_ehook;
 
-static void	aio_worker(void *);
-static void	aio_process(struct aio_job *);
-static void	aio_sendsig(struct proc *, struct sigevent *);
-static int	aio_enqueue_job(int, void *, struct lio_req *);
-static void	aio_exit(proc_t *, void *);
+static void		aio_worker(void *);
+static void		aio_process(struct aio_job *);
+static void		aio_sendsig(struct proc *, struct sigevent *);
+static int		aio_enqueue_job(int, void *, struct lio_req *);
+static void		aio_exit(proc_t *, void *);
+
+static int		sysctl_aio_listio_max(SYSCTLFN_PROTO);
+static int		sysctl_aio_max(SYSCTLFN_PROTO);
+static int		sysctl_aio_init(void);
 
 static const struct syscall_package aio_syscalls[] = {
 	{ SYS_aio_cancel, 0, (sy_call_t *)sys_aio_cancel },
@@ -122,6 +127,9 @@
 			return EBUSY;
 		}
 	}
+	if (aio_sysctl != NULL)
+		sysctl_teardown(&aio_sysctl);
+
 	KASSERT(aio_jobs_count == 0);
 	exithook_disestablish(aio_ehook);
 	pool_destroy(&aio_job_pool);
@@ -142,9 +150,15 @@
 	pool_init(&aio_lio_pool, sizeof(struct lio_req), 0, 0, 0,
 	    "aio_lio_pool", &pool_allocator_nointr, IPL_NONE);
 	aio_ehook = exithook_establish(aio_exit, NULL);
+
+	error = sysctl_aio_init();
+	if (error != 0) {
+		(void)aio_fini(false);
+		return error;
+	}
 	error = syscall_establish(NULL, aio_syscalls);
 	if (error != 0)
-		aio_fini(false);
+		(void)aio_fini(false);
 	return error;
 }
 
@@ -1077,15 +1091,23 @@
 	return 0;
 }
 
-SYSCTL_SETUP(sysctl_aio_setup, "sysctl aio setup")
+static int
+sysctl_aio_init(void)
 {
+	int rv;
+
+	aio_sysctl = NULL;
 
-	sysctl_createv(clog, 0, NULL, NULL,
+	rv = sysctl_createv(&aio_sysctl, 0, NULL, NULL,
 		CTLFLAG_PERMANENT,
 		CTLTYPE_NODE, "kern", NULL,
 		NULL, 0, NULL, 0,
 		CTL_KERN, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
+
+	if (rv != 0)
+		return rv;
+
+	rv = sysctl_createv(&aio_sysctl, 0, NULL, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_IMMEDIATE,
 		CTLTYPE_INT, "posix_aio",
 		SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "
@@ -1093,20 +1115,30 @@
 			     "system attempts to conform"),
 		NULL, _POSIX_ASYNCHRONOUS_IO, NULL, 0,
 		CTL_KERN, CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
+
+	if (rv != 0)
+		return rv;
+
+	rv = sysctl_createv(&aio_sysctl, 0, NULL, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "aio_listio_max",
 		SYSCTL_DESCR("Maximum number of asynchronous I/O "
 			     "operations in a single list I/O call"),
 		sysctl_aio_listio_max, 0, &aio_listio_max, 0,
 		CTL_KERN, CTL_CREATE, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
+
+	if (rv != 0)
+		return rv;
+
+	rv = sysctl_createv(&aio_sysctl, 0, NULL, NULL,
 		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 		CTLTYPE_INT, "aio_max",
 		SYSCTL_DESCR("Maximum number of asynchronous I/O "
 			     "operations"),
 		sysctl_aio_max, 0, &aio_max, 0,
 		CTL_KERN, CTL_CREATE, CTL_EOL);
+
+	return rv;
 }
 
 /*

Reply via email to