Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2007 16:18:28 GMT
From:      Alexander Leidinger <netchild@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 114975 for review
Message-ID:  <200702241618.l1OGISVs059862@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=114975

Change 114975 by netchild@netchild_magellan on 2007/02/24 16:18:14

	- Split out the linux aio stuff into its own module.
	- Let the linker find the symbols itself instead of guessing the
	  location.
	
	Submitted by:   Li, Xiao <intron@intron.ac>
	
	My modifications based upon his submission:
	 - Some files.* + NOTES glue to be able to compile this stuff into
	   the kernel (the files.* stuff is underdocumented, reviews welcome).
	 - amd64 part
	 - aio compilation fixes for non-linux kernel parts
	
	TODO:
	 - run test this stuff (i386 + amd64)
	 - review the complete linuxaio code

Affected files ...

.. //depot/projects/linuxolator/src/sys/amd64/conf/NOTES#5 edit
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux.h#19 edit
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_dummy.c#9 edit
.. //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#19 edit
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_aio.c#11 edit
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_aio.h#5 edit
.. //depot/projects/linuxolator/src/sys/conf/files.amd64#10 edit
.. //depot/projects/linuxolator/src/sys/conf/files.i386#9 edit
.. //depot/projects/linuxolator/src/sys/conf/files.pc98#7 edit
.. //depot/projects/linuxolator/src/sys/conf/options.amd64#2 edit
.. //depot/projects/linuxolator/src/sys/conf/options.i386#2 edit
.. //depot/projects/linuxolator/src/sys/conf/options.pc98#2 edit
.. //depot/projects/linuxolator/src/sys/i386/conf/NOTES#7 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/linux.h#15 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_dummy.c#9 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#18 edit
.. //depot/projects/linuxolator/src/sys/kern/vfs_aio.c#7 edit
.. //depot/projects/linuxolator/src/sys/modules/Makefile#8 edit
.. //depot/projects/linuxolator/src/sys/modules/aio/Makefile#5 edit
.. //depot/projects/linuxolator/src/sys/modules/linux/Makefile#5 edit
.. //depot/projects/linuxolator/src/sys/modules/linuxaio/Makefile#1 add
.. //depot/projects/linuxolator/src/sys/pc98/conf/NOTES#4 edit
.. //depot/projects/linuxolator/src/sys/sys/aio.h#2 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/amd64/conf/NOTES#5 (text+ko) ====

@@ -608,9 +608,12 @@
 # and PSEUDOFS)
 options 	LINPROCFS
 
-#Enable the linux-like sys filesystem support (requires COMPAT_LINUX32
+# Enable the linux-like sys filesystem support (requires COMPAT_LINUX32
 # and PSEUDOFS)
-options		LINSYSFS
+options 	LINSYSFS
+
+# Enable the linux aio support (requires COMPAT_LINUX32 and VFS_AIO)
+options 	LINUXAIO
 
 #
 # SysVR4 ABI emulation

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux.h#19 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_dummy.c#9 (text+ko) ====

@@ -111,6 +111,11 @@
 DUMMY(pselect6);
 DUMMY(ppoll);
 DUMMY(unshare);
+DUMMY(io_setup);
+DUMMY(io_destroy);
+DUMMY(io_getevents);
+DUMMY(io_submit);
+DUMMY(io_cancel);
 
 #define DUMMY_XATTR(s)						\
 int								\

==== //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#19 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/compat/linux/linux_aio.c#11 (text+ko) ====

@@ -44,9 +44,6 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/sx.h>
-#include <sys/linker.h>
-#include <sys/sysctl.h>
-#include <sys/syscall.h>
 #include <sys/sysproto.h>
 
 #ifdef COMPAT_LINUX32
@@ -193,13 +190,13 @@
  */
 #define	LINUX_AIO_LOCK(p)	{					\
 	if ((p)->p_aioinfo == NULL)					\
-		p_aio_init_aioinfo(p);					\
+		aio_init_aioinfo(p);					\
 	mtx_lock((struct mtx *)((p)->p_aioinfo));			\
 }
 
 #define	LINUX_AIO_UNLOCK(p)	{					\
 	if ((p)->p_aioinfo == NULL)					\
-		p_aio_init_aioinfo(p);					\
+		aio_init_aioinfo(p);					\
 	mtx_unlock((struct mtx *)((p)->p_aioinfo));			\
 }
 
@@ -208,48 +205,36 @@
 static eventhandler_tag linux_aio_exit_tag;
 
 /*
- * XXX
- * Calling external function/variable declared with "static" is DANGEROUS !!!
- * Compiler may use register to transfer calling arguments for optimization,
- * which is NOT a normal calling way and can cause kernel crash.
+ * To backup pointers to the dummy implementation of these
+ * system calls faked by the macro DUMMY() in linux_dummy.c.
+ */
+#define	PREPARE_DUMMY_SYSCALL_BACKUP(s)					\
+	static sy_call_t *p_dummy_linux_ ## s
+#define	SHOW_REAL_SYSCALL(s)	{					\
+	p_dummy_linux_ ## s = linux_sysent[LINUX_SYS_linux_ ## s].sy_call; \
+	linux_sysent[LINUX_SYS_linux_ ## s].sy_call = 			\
+		(sy_call_t *)(linux_ ## s);				\
+}
+/*
+ * The concept of "scope": the functions linux_io_xxx defined in this file
+ * always mask/screen/override/prevent homonymous functions defined in
+ * any other files.
  */
+#define	RESTORE_DUMMY_SYSCALL(s)	{				\
+	linux_sysent[LINUX_SYS_linux_ ## s].sy_call = p_dummy_linux_ ## s; \
+}
 
-#define	NATIVE_AIO_MODULE_NAME		"aio"
-static struct mod_depend native_aio_module_depend = {1, 1, 1};
-static linker_file_t native_aio_module_handle = NULL;
+PREPARE_DUMMY_SYSCALL_BACKUP(io_setup);
+PREPARE_DUMMY_SYSCALL_BACKUP(io_destroy);
+PREPARE_DUMMY_SYSCALL_BACKUP(io_getevents);
+PREPARE_DUMMY_SYSCALL_BACKUP(io_submit);
+PREPARE_DUMMY_SYSCALL_BACKUP(io_cancel);
 
-/* Mirror of sysctls in /sys/kern/vfs_aio.c */
-#define	NATIVE_AIO_SYSCTL_CAPACITY_PROC	"vfs.aio.max_aio_queue_per_proc"
-static int native_aio_capacity_proc;
-#define	NATIVE_AIO_SYSCTL_CAPACITY_SYS	"vfs.aio.max_aio_queue"
-static int native_aio_capacity_sys;
-
-/* For declaration of aio_aqueue(), defined in /sys/kern/vfs_aio.c */
-struct aioliojob;
-
-/* Functions in /sys/kern/vfs_aio.c, XXX defined with "static" */
-#define	GET_INTERNAL_FUNC_POINTER(s)	{				\
-	* ((caddr_t *) & p_ ## s) = linker_file_lookup_symbol(		\
-			native_aio_module_handle, #s, FALSE);		\
-	if (p_ ## s == NULL)						\
-		break;							\
-}
-static void (*p_aio_init_aioinfo) (struct proc *p);
-static int (*p_aio_aqueue) (struct thread *td, struct aiocb *job,
-			struct aioliojob *lio, int type, int osigev);
-
-/* System calls in /sys/kern/vfs_aio.c */
-#define	DEFINE_SYSCALL_POINTER_VARIABLE(s)				\
-	static int (* p_ ## s) (struct thread *, struct s ## _args *)
-#define	GET_SYSCALL_POINTER(s)		{				\
-	* ((sy_call_t **) & p_ ## s) = sysent[SYS_ ## s].sy_call;	\
-	if ((sy_call_t *) p_ ## s == (sy_call_t *)lkmressys)		\
-		break;							\
-}
-DEFINE_SYSCALL_POINTER_VARIABLE(aio_return);
-DEFINE_SYSCALL_POINTER_VARIABLE(aio_suspend);
-DEFINE_SYSCALL_POINTER_VARIABLE(aio_cancel);
-DEFINE_SYSCALL_POINTER_VARIABLE(aio_error);
+/*
+ * Substantially defined in linux_sysent.c.
+ * Also declared in linux_sysvec.c.
+ */
+extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
 
 static int user_mem_rw_verify(void *p, size_t s)
 {
@@ -331,7 +316,8 @@
 	if (isuserland) {
 		nerr = copyin(piocb, &localcb, sizeof(localcb));
 		pcb = &localcb;
-	} else
+	}
+	else
 		pcb = piocb;
 
 	DPPRINTF("Dump struct aiocb (%p, %s): %s",
@@ -419,85 +405,6 @@
 	return (nerr);
 }
 
-static int link_to_native_aio_module(struct thread *td)
-{
-	int nerr;
-
-	if (native_aio_module_handle != NULL) {
-	/* Linking has been done successfully. */
-		return (0);
-	}
-
-	nerr = linker_reference_module(NATIVE_AIO_MODULE_NAME,
-			&native_aio_module_depend, &native_aio_module_handle);
-	if (nerr)
-		return (nerr);
-
-	do {
-		nerr = EINVAL;
-
-		/* Kernel internal functions */
-		GET_INTERNAL_FUNC_POINTER(aio_init_aioinfo);
-		GET_INTERNAL_FUNC_POINTER(aio_aqueue);
-
-		/* System calls */
-		GET_SYSCALL_POINTER(aio_return);
-		GET_SYSCALL_POINTER(aio_suspend);
-		GET_SYSCALL_POINTER(aio_cancel);
-		GET_SYSCALL_POINTER(aio_error);
-
-		nerr = 0;
-	} while (0);
-
-	if (nerr) {
-		linker_release_module(NULL, NULL, native_aio_module_handle);
-		native_aio_module_handle = NULL;
-		
-		printf(LMSG("Unable to link to the native module \""
-				NATIVE_AIO_MODULE_NAME "\"."));
-		
-		return (nerr);
-	}
-
-	return (0);
-}
-
-#define	LINK_TO_NATIVE_AIO_MODULE()					\
-	if (link_to_native_aio_module(td)) {				\
-		printf(LMSG("Please load the module \""			\
-			NATIVE_AIO_MODULE_NAME "\" "			\
-			"to provide FreeBSD "				\
-			"native Asynchronous I/O support."));		\
-		return (ENOSYS);						\
-}
-
-static int mirror_native_aio_sysctl(struct thread *td)
-{
-	int nerr = 0;
-	size_t l;
-
-	l = sizeof(native_aio_capacity_proc);
-	nerr = kernel_sysctlbyname(td, NATIVE_AIO_SYSCTL_CAPACITY_PROC,
-			&native_aio_capacity_proc, &l, NULL, 0,
-			NULL ,0);
-	if (nerr)
-		return (nerr);
-
-	l = sizeof(native_aio_capacity_sys);
-	nerr = kernel_sysctlbyname(td, NATIVE_AIO_SYSCTL_CAPACITY_SYS,
-			&native_aio_capacity_sys, &l, NULL, 0,
-			NULL ,0);
-	if (nerr)
-		return (nerr);
-
-	DPRINTF(NATIVE_AIO_SYSCTL_CAPACITY_PROC "=%d, "
-			NATIVE_AIO_SYSCTL_CAPACITY_SYS "=%d",
-			native_aio_capacity_proc,
-			native_aio_capacity_sys);
-
-	return (nerr);
-}
-
 /* Linux system call io_setup(2) */
 int linux_io_setup(struct thread *td, struct linux_io_setup_args *args)
 {
@@ -508,27 +415,17 @@
 	int nerr = 0, nr, nrall, nq, arg_nr_reqs;
 
 	DARGPRINTF("%u, %p", args->nr_reqs, args->ctxp);
-	LINK_TO_NATIVE_AIO_MODULE();
-	nerr = mirror_native_aio_sysctl(td);
-	if (nerr) {
-		printf(LMSG("linux_io_setup(): Unable to query sysctls "
-			       NATIVE_AIO_SYSCTL_CAPACITY_PROC
-			       " and/or " NATIVE_AIO_SYSCTL_CAPACITY_SYS
-			       " ."));
-		return (nerr);
-	}
 
 	/* Signed integer is a little safer than unsigned */
 	arg_nr_reqs = args->nr_reqs;
 	if (arg_nr_reqs <= 0)
 		return (EINVAL);
 
-	if (arg_nr_reqs > native_aio_capacity_proc
-			|| arg_nr_reqs > native_aio_capacity_sys) {
+	if (arg_nr_reqs > max_aio_queue_per_proc
+			|| arg_nr_reqs > max_aio_queue_count) {
 		printf(LMSG("linux_io_setup(): Please increase sysctls "
-			       NATIVE_AIO_SYSCTL_CAPACITY_PROC
-			       " and/or " NATIVE_AIO_SYSCTL_CAPACITY_SYS
-			       " ."));
+			       "vfs.aio.max_aio_queue_per_proc "
+			       "and/or vfs.aio.max_aio_queue. "));
 		return (ENOMEM);
 	}
 
@@ -568,12 +465,12 @@
 		nq, nr, nrall);
 
 	/* Check whether there are enough resources for requested queue */
-	if (arg_nr_reqs > native_aio_capacity_proc - nr
-			|| arg_nr_reqs > native_aio_capacity_sys - nrall) {
+	if (arg_nr_reqs > max_aio_queue_per_proc - nr
+			|| arg_nr_reqs > max_aio_queue_count - nrall) {
 		printf(LMSG("linux_io_setup(): "
 			       "Please increase sysctls "
-			       NATIVE_AIO_SYSCTL_CAPACITY_PROC
-			       " and/or " NATIVE_AIO_SYSCTL_CAPACITY_SYS " ."
+			       "vfs.aio.max_aio_queue_per_proc "
+			       "and/or vfs.aio.max_aio_queue. "
 			       "Besides %d queues of %d requests totally "
 			       "for this process, and %d requests' queues "
 			       "totally for the whole system, "
@@ -632,7 +529,6 @@
 	struct aio_return_args aioretargs;
 
 	DARGPRINTF("%lx", (unsigned long)args->ctx);
-	LINK_TO_NATIVE_AIO_MODULE();
 
 	p = td->td_proc;
 
@@ -684,7 +580,7 @@
 		/* Cancel FreeBSD native clone */
 		cancelargs.fd = preq->req_linux.aio_fildes;
 		cancelargs.aiocbp = preq->req_pbsd;
-		p_aio_cancel(td, &cancelargs);
+		aio_cancel(td, &cancelargs);
 		DPRINTF("aio_cancel() returned %ld", (long)td->td_retval[0]);
 		if (td->td_retval[0] == AIO_NOTCANCELED)
 			printf(LMSG("linux_io_destroy(): Asynchronous IO "
@@ -698,7 +594,7 @@
 
 		if (td->td_retval[0] == AIO_ALLDONE) {
 			aioretargs.aiocbp = preq->req_pbsd;
-			p_aio_return(td, &aioretargs);
+			aio_return(td, &aioretargs);
 			DPRINTF("aio_return(%p) returned %ld",
 					aioretargs.aiocbp,
 					(long)td->td_retval[0]);
@@ -754,7 +650,6 @@
 			(unsigned long) args->ctx_id,
 			(long)args->min_nr, (long)args->nr,
 			args->events, args->timeout);
-	LINK_TO_NATIVE_AIO_MODULE();
 
 	if (args->nr <= 0)
 		return (EINVAL);
@@ -821,7 +716,7 @@
 	} else { /* Deal with the request queue */
 		i = 0; /*
 			* This variable's value will be the return value
-			* of linux_io_getevents() 
+			* of linux_io_getevents()
 			*/
 
 		nerr = user_malloc(td, (void **)&u_aiocbp,
@@ -839,14 +734,14 @@
 			/* Collecting finished requests and waiting for queued requests */
 
 			LINUX_AIO_REQ_FOREACH_SAFE(pctx, preq, ptmpreq) {
-				
+
 				/* Collect all finished requests */
 
 				if (i >= args->nr) /* Full */
 					break;
 
 				aioerrargs.aiocbp = preq->req_pbsd;
-				p_aio_error(td, &aioerrargs);
+				aio_error(td, &aioerrargs);
 				aio_ret = td->td_retval[0];
 				td->td_retval[0] = 0;
 
@@ -865,7 +760,7 @@
 				LINUX_AIO_REQ_UNHOOK(pctx, preq);
 
 				aioretargs.aiocbp = preq->req_pbsd;
-				aio_err = p_aio_return(td, &aioretargs);
+				aio_err = aio_return(td, &aioretargs);
 				aio_ret = td->td_retval[0];
 				td->td_retval[0] = 0;
 
@@ -947,7 +842,7 @@
 			LINUX_AIO_REQ_FOREACH(pctx, preq) {
 				copyout(&(preq->req_pbsd), &(u_aiocbp[j]),
 					sizeof(preq->req_pbsd));
-				j++;
+				j ++;
 			}
 			MPASS(j == pctx->ctx_nreq_cur);
 			aiosusargs.aiocbp = u_aiocbp;
@@ -961,7 +856,7 @@
 				aiosusargs.timeout = NULL;
 			}
 
-			aio_err = p_aio_suspend(td, &aiosusargs);
+			aio_err = aio_suspend(td, &aiosusargs);
 			DPRINTF("aio_suspend(%p, %d, %p) returned %ld",
 					aiosusargs.aiocbp, aiosusargs.nent,
 					aiosusargs.timeout, (long)aio_err);
@@ -991,7 +886,7 @@
 					pctx);
 				break;
 			}
-		} /* 
+		} /*
 		   * End of collecting finished requests
 		   * and waiting for queued requests
 		   */
@@ -1026,9 +921,7 @@
 	struct linux_iocb *porig;
 	struct aiocb iocb, *piocb;
 
-	DARGPRINTF("%lx, %ld, %p", (unsigned long)args->ctx_id,
-			(long)args->nr, args->iocbpp);
-	LINK_TO_NATIVE_AIO_MODULE();
+	DARGPRINTF("%lx, %ld, %p", (unsigned long)args->ctx_id, (long)args->nr, args->iocbpp);
 
 	if (args->nr <= 0)
 		return (EINVAL);
@@ -1072,7 +965,7 @@
 	LINUX_AIO_UNLOCK(p);      /* XXX Interlaced, seamless */
 
 	for (i = 0; pctx->ctx_nreq_cur < pctx->ctx_nreq_max && i < args->nr;
-			i++) {
+			i ++) {
 		/* Get user space Linux control block  */
 		nerr = copyin(&(args->iocbpp[i]), &porig, sizeof(porig));
 		if (nerr != 0)
@@ -1094,7 +987,7 @@
 		DUMP_FREEBSD_AIOCB(piocb, 1);
 
 		/* Submit user space control block */
-		nerr = p_aio_aqueue(td, piocb, NULL, iocb.aio_lio_opcode, 0);
+		nerr = aio_aqueue(td, piocb, NULL, iocb.aio_lio_opcode, 0);
 		if (nerr != 0) {
 			user_free(td, piocb, sizeof(*piocb));
 			break;
@@ -1139,9 +1032,7 @@
 	struct linux_io_event evt;
 	struct aio_cancel_args aiocnclargs;
 
-	DARGPRINTF("%lx, %p, %p", (unsigned long)args->ctx_id,
-			args->iocb, args->result);
-	LINK_TO_NATIVE_AIO_MODULE();
+	DARGPRINTF("%lx, %p, %p", (unsigned long)args->ctx_id, args->iocb, args->result);
 
 	nerr = copyin(args->iocb, &lcb, sizeof(lcb));
 	if (nerr != 0)
@@ -1205,7 +1096,7 @@
 		/* Cancel FreeBSD native clone */
 		aiocnclargs.fd = preq->req_linux.aio_fildes;
 		aiocnclargs.aiocbp = preq->req_pbsd;
-		p_aio_cancel(td, &aiocnclargs);
+		aio_cancel(td, &aiocnclargs);
 		DPRINTF("aio_cancel() returned %ld", (long)td->td_retval[0]);
 
 		if (td->td_retval[0] == AIO_CANCELED) {
@@ -1308,6 +1199,17 @@
 		linux_aio_exit_tag = EVENTHANDLER_REGISTER(process_exit,
 				linux_aio_proc_rundown,
 				NULL, EVENTHANDLER_PRI_ANY);
+
+		/*
+		 * Backup pointers to the dummy implementation of these
+		 * system calls faked by the macro DUMMY() in linux_dummy.c.
+		 * And then, show real system calls.
+		 */
+		SHOW_REAL_SYSCALL(io_setup);
+		SHOW_REAL_SYSCALL(io_destroy);
+		SHOW_REAL_SYSCALL(io_getevents);
+		SHOW_REAL_SYSCALL(io_submit);
+		SHOW_REAL_SYSCALL(io_cancel);
 		break;
 	case MOD_UNLOAD:
 		LINUX_AIO_CTX_LIST_LOCK();
@@ -1321,15 +1223,16 @@
 		mtx_destroy(&linux_aio_context_list_mtx);
 		uma_zdestroy(linux_aio_request_zone);
 		uma_zdestroy(linux_aio_context_zone);
-		if (native_aio_module_handle != NULL) {
-			/*
-			 * linker_release_module() cannot be used here.
-			 * It tries to hold "kld_sx", conflicting against
-			 * module_unload().
-			 */
-			linker_file_unload(native_aio_module_handle,
-				LINKER_UNLOAD_NORMAL);
-		}
+
+		/*
+		 * Restore pointers to the dummy implementation of these
+		 * system calls faked by the macro DUMMY() in linux_dummy.c.
+		 */
+		RESTORE_DUMMY_SYSCALL(io_setup);
+		RESTORE_DUMMY_SYSCALL(io_destroy);
+		RESTORE_DUMMY_SYSCALL(io_getevents);
+		RESTORE_DUMMY_SYSCALL(io_submit);
+		RESTORE_DUMMY_SYSCALL(io_cancel);
 		break;
 	case MOD_SHUTDOWN:
 		break;
@@ -1347,3 +1250,5 @@
 };
 
 DECLARE_MODULE(linuxaio, linux_aio_mod, SI_SUB_VFS, SI_ORDER_ANY);
+MODULE_DEPEND(linuxaio, aio, 1, 1, 1);
+MODULE_DEPEND(linuxaio, linux, 1, 1, 1);

==== //depot/projects/linuxolator/src/sys/compat/linux/linux_aio.h#5 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/conf/files.amd64#10 (text+ko) ====

@@ -233,6 +233,7 @@
 amd64/linux32/linux32_machdep.c	optional	compat_linux32
 amd64/linux32/linux32_sysent.c	optional	compat_linux32
 amd64/linux32/linux32_sysvec.c	optional	compat_linux32
+compat/linux/linux_aio.c	optional	linuxaio compat_linux32 vfs_aio
 compat/linux/linux_emul.c	optional	compat_linux32
 compat/linux/linux_file.c	optional	compat_linux32
 compat/linux/linux_futex.c	optional	compat_linux32

==== //depot/projects/linuxolator/src/sys/conf/files.i386#9 (text+ko) ====

@@ -85,6 +85,7 @@
 #
 compat/linprocfs/linprocfs.c	optional linprocfs
 compat/linsysfs/linsysfs.c	optional linsysfs
+compat/linux/linux_aio.c	optional linuxaio compat_linux aio
 compat/linux/linux_emul.c	optional compat_linux
 compat/linux/linux_file.c	optional compat_linux
 compat/linux/linux_futex.c	optional compat_linux

==== //depot/projects/linuxolator/src/sys/conf/files.pc98#7 (text+ko) ====

@@ -55,6 +55,7 @@
 #
 compat/linprocfs/linprocfs.c	optional linprocfs
 compat/linsysfs/linsysfs.c	optional linsysfs
+compat/linux/linux_aio.c	optional linuxaio compat_linux vfs_aio
 compat/linux/linux_emul.c	optional compat_linux
 compat/linux/linux_file.c	optional compat_linux
 compat/linux/linux_futex.c	optional compat_linux

==== //depot/projects/linuxolator/src/sys/conf/options.amd64#2 (text+ko) ====

@@ -19,6 +19,7 @@
 #DEBUG_SVR4		opt_svr4.h
 LINPROCFS		opt_dontuse.h
 LINSYSFS		opt_dontuse.h
+LINUXAIO		opt_dontuse.h
 NDISAPI			opt_dontuse.h
 
 CLK_CALIBRATION_LOOP		opt_clock.h

==== //depot/projects/linuxolator/src/sys/conf/options.i386#2 (text+ko) ====

@@ -26,6 +26,7 @@
 DEBUG_SVR4		opt_svr4.h
 LINPROCFS		opt_dontuse.h
 LINSYSFS		opt_dontuse.h
+LINUXAIO		opt_dontuse.h
 NDISAPI			opt_dontuse.h
 PECOFF_DEBUG		opt_pecoff.h
 PECOFF_SUPPORT		opt_dontuse.h

==== //depot/projects/linuxolator/src/sys/conf/options.pc98#2 (text+ko) ====

@@ -25,6 +25,7 @@
 DEBUG_SVR4		opt_svr4.h
 LINPROCFS		opt_dontuse.h
 LINSYSFS		opt_dontuse.h
+LINUXAIO		opt_dontuse.h
 PECOFF_DEBUG		opt_pecoff.h
 PECOFF_SUPPORT		opt_dontuse.h
 

==== //depot/projects/linuxolator/src/sys/i386/conf/NOTES#7 (text+ko) ====

@@ -1133,9 +1133,12 @@
 # and PSEUDOFS)
 options 	LINPROCFS
 
-#Enable the linux-like sys filesystem support (requires COMPAT_LINUX
+# Enable the linux-like sys filesystem support (requires COMPAT_LINUX
 # and PSEUDOFS)
-options		LINSYSFS
+options 	LINSYSFS
+
+# Enable the linux aio support (requires COMPAT_LINUX and VFS_AIO)
+options 	LINUXAIO
 
 #
 # SysVR4 ABI emulation

==== //depot/projects/linuxolator/src/sys/i386/linux/linux.h#15 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/i386/linux/linux_dummy.c#9 (text+ko) ====

@@ -101,6 +101,11 @@
 DUMMY(pselect6);
 DUMMY(ppoll);
 DUMMY(unshare);
+DUMMY(io_setup);
+DUMMY(io_destroy);
+DUMMY(io_getevents);
+DUMMY(io_submit);
+DUMMY(io_cancel);
 
 #define DUMMY_XATTR(s)						\
 int								\

==== //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#18 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/kern/vfs_aio.c#7 (text+ko) ====

@@ -139,8 +139,8 @@
 SYSCTL_INT(_vfs_aio, OID_AUTO, target_aio_procs, CTLFLAG_RW, &target_aio_procs,
 	0, "Preferred number of ready kernel threads for async IO");
 
-static int max_queue_count = MAX_AIO_QUEUE;
-SYSCTL_INT(_vfs_aio, OID_AUTO, max_aio_queue, CTLFLAG_RW, &max_queue_count, 0,
+int max_aio_queue_count = MAX_AIO_QUEUE;
+SYSCTL_INT(_vfs_aio, OID_AUTO, max_aio_queue, CTLFLAG_RW, &max_aio_queue_count, 0,
     "Maximum number of aio requests to queue, globally");
 
 static int num_queue_count = 0;
@@ -172,7 +172,7 @@
 SYSCTL_INT(_vfs_aio, OID_AUTO, max_aio_per_proc, CTLFLAG_RW, &max_aio_per_proc,
     0, "Maximum active aio requests per process (stored in the process)");
 
-static int max_aio_queue_per_proc = MAX_AIO_QUEUE_PER_PROC;
+int max_aio_queue_per_proc = MAX_AIO_QUEUE_PER_PROC;
 SYSCTL_INT(_vfs_aio, OID_AUTO, max_aio_queue_per_proc, CTLFLAG_RW,
     &max_aio_queue_per_proc, 0,
     "Maximum queued aio requests per process (stored in the process)");
@@ -257,19 +257,6 @@
 	struct thread *aiothread;		/* (*) the AIO thread */
 };
 
-/*
- * data-structure for lio signal management
- */
-struct aioliojob {
-	int	lioj_flags;			/* (a) listio flags */
-	int	lioj_count;			/* (a) listio flags */
-	int	lioj_finished_count;		/* (a) listio flags */
-	struct	sigevent lioj_signal;		/* (a) signal on all I/O done */
-	TAILQ_ENTRY(aioliojob) lioj_list;	/* (a) lio list */
-	struct  knlist klist;			/* (a) list of knotes */
-	ksiginfo_t lioj_ksi;			/* (a) Realtime signal info */
-};
-
 #define	LIOJ_SIGNAL		0x1	/* signal on all done (lio) */
 #define	LIOJ_SIGNAL_POSTED	0x2	/* signal has been posted */
 #define LIOJ_KEVENT_POSTED	0x4	/* kevent triggered */
@@ -313,13 +300,10 @@
 static TAILQ_HEAD(,aiocblist) aio_jobs;			/* (c) Async job list */
 static struct unrhdr *aiod_unr;
 
-void		aio_init_aioinfo(struct proc *p);
 static void	aio_onceonly(void);
 static int	aio_free_entry(struct aiocblist *aiocbe);
 static void	aio_process(struct aiocblist *aiocbe);
 static int	aio_newproc(int *);
-int		aio_aqueue(struct thread *td, struct aiocb *job,
-			struct aioliojob *lio, int type, int osigev);
 static void	aio_physwakeup(struct buf *bp);
 static void	aio_proc_rundown(void *arg, struct proc *p);
 static void	aio_proc_rundown_exec(void *arg, struct proc *p, struct image_params *imgp);
@@ -1347,7 +1331,7 @@
 	suword(&job->_aiocb_private.error, 0);
 	suword(&job->_aiocb_private.kernelinfo, -1);
 
-	if (num_queue_count >= max_queue_count ||
+	if (num_queue_count >= max_aio_queue_count ||
 	    ki->kaio_count >= ki->kaio_qallowed_count) {
 		suword(&job->_aiocb_private.error, EAGAIN);
 		return (EAGAIN);

==== //depot/projects/linuxolator/src/sys/modules/Makefile#8 (text+ko) ====

@@ -138,6 +138,7 @@
 	${_linprocfs} \
 	${_linsysfs} \
 	${_linux} \
+	${_linuxaio} \
 	lmc \
 	lpt \
 	mac_biba \
@@ -371,6 +372,7 @@
 _linprocfs=	linprocfs
 _linsysfs=	linsysfs
 _linux=		linux
+_linuxaio=	linuxaio
 _mse=		mse
 .if ${MK_NCP} != "no"
 _ncp=		ncp
@@ -479,6 +481,7 @@
 _linprocfs=	linprocfs
 _linsysfs=	linsysfs
 _linux=		linux
+_linuxaio=	linuxaio
 _mly=		mly
 _mxge=		mxge
 _ndis=		ndis
@@ -498,8 +501,8 @@
 
 .if ${MACHINE_ARCH} == "ia64"
 # Modules not enabled on ia64 (as compared to i386) include:
-#	aac acpi aout apm atspeaker drm ibcs2 linprocfs linux ncv
-#	nsp oltr pecoff s3 sbni stg vesa
+#	aac acpi aout apm atspeaker drm ibcs2 linsysfs linprocfs linux
+#	linuxaio ncv nsp oltr pecoff s3 sbni stg vesa
 # acpi is not enabled because it is broken as a module on ia64
 _aic=		aic
 #_ar=		ar	not 64-bit clean

==== //depot/projects/linuxolator/src/sys/modules/aio/Makefile#5 (text+ko) ====

@@ -5,6 +5,7 @@
 KMOD=	aio
 SRCS=	vfs_aio.c opt_vfs_aio.h vnode_if.h
 
-EXPORT_SYMS= aio_init_aioinfo aio_aqueue
+EXPORT_SYMS= aio_init_aioinfo aio_aqueue max_aio_queue_count \
+	max_aio_queue_per_proc
 
 .include <bsd.kmod.mk>

==== //depot/projects/linuxolator/src/sys/modules/linux/Makefile#5 (text+ko) ====

@@ -8,7 +8,7 @@
 .PATH: ${.CURDIR}/../../compat/linux ${.CURDIR}/../../${MACHINE_ARCH}/linux${SFX}
 
 KMOD=	linux
-SRCS=	linux_aio.c linux${SFX}_dummy.c linux_emul.c linux_file.c \
+SRCS=	linux${SFX}_dummy.c linux_emul.c linux_file.c \
 	linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c \
 	linux${SFX}_machdep.c linux_mib.c linux_misc.c linux_signal.c \
 	linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \

==== //depot/projects/linuxolator/src/sys/pc98/conf/NOTES#4 (text+ko) ====

@@ -695,6 +695,9 @@
 # and PSEUDOFS)
 options 	LINSYSFS
 
+# Enable the linux aio support (requires COMPAT_LINUX and VFS_AIO)
+options 	LINUXAIO
+
 #
 # SysVR4 ABI emulation
 #

==== //depot/projects/linuxolator/src/sys/sys/aio.h#2 (text+ko) ====

@@ -23,6 +23,12 @@
 #include <sys/types.h>
 #include <sys/signal.h>
 
+#ifdef _KERNEL
+#include <sys/event.h>
+#include <sys/queue.h>
+#include <sys/signalvar.h>
+#endif
+
 /*
  * Returned by aio_cancel:
  */
@@ -135,6 +141,28 @@
 
 extern void (*aio_swake)(struct socket *, struct sockbuf *);
 
+/* To be used by the Linux AIO module */
+extern int max_aio_queue_count;
+extern int max_aio_queue_per_proc;
+
+/*
+ * data-structure for lio signal management
+ */
+struct aioliojob {
+	int	lioj_flags;			/* (a) listio flags */
+	int	lioj_count;			/* (a) listio flags */
+	int	lioj_finished_count;		/* (a) listio flags */
+	struct	sigevent lioj_signal;		/* (a) signal on all I/O done */
+	TAILQ_ENTRY(aioliojob) lioj_list;	/* (a) lio list */
+	struct  knlist klist;			/* (a) list of knotes */
+	ksiginfo_t lioj_ksi;			/* (a) Realtime signal info */
+};
+
+/* To be used by the Linux AIO module */
+extern void aio_init_aioinfo(struct proc *p);
+extern int aio_aqueue(struct thread *td, struct aiocb *job,
+	struct aioliojob *lio, int type, int osigev);
+
 #endif
 
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702241618.l1OGISVs059862>