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.
This commit is contained in:
Garrett Wollman 2002-10-27 18:07:41 +00:00
parent 7303fe0613
commit c7047e5204
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106057
7 changed files with 44 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -92,6 +92,14 @@ static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred,
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.
*/
@ -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);
}

View File

@ -92,6 +92,14 @@ static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred,
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.
*/
@ -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);
}

View File

@ -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);

View File

@ -355,6 +355,7 @@ extern int vttoif_tab[];
* Global vnode data.
*/
extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
extern int async_io_version; /* 0 or POSIX version of AIO i'face */
extern int desiredvnodes; /* number of vnodes desired */
extern struct uma_zone *namei_zone;
extern int prtactive; /* nonzero to call vprint() */