diff options
author | wollman <wollman@FreeBSD.org> | 2002-10-27 18:07:41 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 2002-10-27 18:07:41 +0000 |
commit | 7e9d4df21f95c33c9f6ee36ceffeb83ea7bcbe61 (patch) | |
tree | 2822b6cd0c488f5c61a84aca6c46f88a41665440 /sys/kern | |
parent | 17bae0e5c0378e3bd58d79dec5a359f2d1b8347d (diff) | |
download | FreeBSD-src-7e9d4df21f95c33c9f6ee36ceffeb83ea7bcbe61.zip FreeBSD-src-7e9d4df21f95c33c9f6ee36ceffeb83ea7bcbe61.tar.gz |
Change the way support for asynchronous I/O is indicated to applications
to conform to 1003.1-2001. Make it possible for applications to actually
tell whether or not asynchronous I/O is supported.
Since FreeBSD's aio implementation works on all descriptor types, don't
call down into file or vnode ops when [f]pathconf() is asked about
_PC_ASYNC_IO; this avoids the need for every file and vnode op to know about
it.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_descrip.c | 7 | ||||
-rw-r--r-- | sys/kern/posix4_mib.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_aio.c | 2 | ||||
-rw-r--r-- | sys/kern/vfs_extattr.c | 15 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 15 |
5 files changed, 40 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 6c9ca9d..13b339b 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -969,6 +969,12 @@ fpathconf(td, uap) if ((error = fget(td, uap->fd, &fp)) != 0) return (error); + + /* If asynchronous I/O is available, it works for all descriptors. */ + if (uap->name == _PC_ASYNC_IO) { + td->td_retval[0] = async_io_version; + goto out; + } switch (fp->f_type) { case DTYPE_PIPE: case DTYPE_SOCKET: @@ -990,6 +996,7 @@ fpathconf(td, uap) error = EOPNOTSUPP; break; } +out: fdrop(fp, td); return (error); } diff --git a/sys/kern/posix4_mib.c b/sys/kern/posix4_mib.c index d368593..6f1fe46 100644 --- a/sys/kern/posix4_mib.c +++ b/sys/kern/posix4_mib.c @@ -36,6 +36,7 @@ #include <sys/kernel.h> #include <sys/queue.h> #include <sys/sysctl.h> +#include <sys/vnode.h> #include <posix4/posix4.h> static int facility[CTL_P1003_1B_MAXID - 1]; @@ -64,7 +65,8 @@ SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B"); #endif -P1B_SYSCTL(CTL_P1003_1B_ASYNCHRONOUS_IO, asynchronous_io); +SYSCTL_INT(_p1003_1b, CTL_P1003_1B_ASYNCHRONOUS_IO, \ + asynchronous_io, CTLFLAG_RD, &async_io_version, 0, ""); P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files); P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock); P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range); diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index e105cbd..556f37c 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -348,6 +348,7 @@ aio_onceonly(void) aiod_timeout = AIOD_TIMEOUT_DEFAULT; aiod_lifetime = AIOD_LIFETIME_DEFAULT; jobrefid = 1; + async_io_version = _POSIX_VERSION; } /* @@ -365,6 +366,7 @@ aio_unload(void) if (!unloadable) return (EOPNOTSUPP); + async_io_version = 0; aio_swake = NULL; rm_at_exit(aio_proc_rundown); rm_at_exec(aio_proc_rundown); diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 6e2aa6b..55aea6e 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -93,6 +93,14 @@ int (*union_dircheckp)(struct thread *td, struct vnode **, struct file *); int (*softdep_fsync_hook)(struct vnode *); /* + * The module initialization routine for POSIX asynchronous I/O will + * set this to the version of AIO that it implements. (Zero means + * that it is not implemented.) This value is used here by pathconf() + * and in kern_descrip.c by fpathconf(). + */ +int async_io_version; + +/* * Sync each mounted filesystem. */ #ifndef _SYS_SYSPROTO_H_ @@ -1823,7 +1831,12 @@ pathconf(td, uap) if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), td->td_retval); + + /* If asynchronous I/O is available, it works for all files. */ + if (uap->name == _PC_ASYNC_IO) + td->td_retval[0] = async_io_version; + else + error = VOP_PATHCONF(nd.ni_vp, uap->name, td->td_retval); vput(nd.ni_vp); return (error); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 6e2aa6b..55aea6e 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -93,6 +93,14 @@ int (*union_dircheckp)(struct thread *td, struct vnode **, struct file *); int (*softdep_fsync_hook)(struct vnode *); /* + * The module initialization routine for POSIX asynchronous I/O will + * set this to the version of AIO that it implements. (Zero means + * that it is not implemented.) This value is used here by pathconf() + * and in kern_descrip.c by fpathconf(). + */ +int async_io_version; + +/* * Sync each mounted filesystem. */ #ifndef _SYS_SYSPROTO_H_ @@ -1823,7 +1831,12 @@ pathconf(td, uap) if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), td->td_retval); + + /* If asynchronous I/O is available, it works for all files. */ + if (uap->name == _PC_ASYNC_IO) + td->td_retval[0] = async_io_version; + else + error = VOP_PATHCONF(nd.ni_vp, uap->name, td->td_retval); vput(nd.ni_vp); return (error); } |