FreeBSD kernel kern code
vfs_aio.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/capsicum.h>
#include <sys/eventhandler.h>
#include <sys/sysproto.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/kthread.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/unistd.h>
#include <sys/posix4.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/syscallsubr.h>
#include <sys/protosw.h>
#include <sys/rwlock.h>
#include <sys/sema.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syscall.h>
#include <sys/sysent.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/sx.h>
#include <sys/taskqueue.h>
#include <sys/vnode.h>
#include <sys/conf.h>
#include <sys/event.h>
#include <sys/mount.h>
#include <geom/geom.h>
#include <machine/atomic.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/uma.h>
#include <sys/aio.h>
Include dependency graph for vfs_aio.c:

Go to the source code of this file.

Data Structures

struct  aioproc
 
struct  aioliojob
 
struct  kaioinfo
 
struct  aiocb_ops
 

Macros

#define MAX_AIO_PER_PROC   32
 
#define MAX_AIO_QUEUE_PER_PROC   256
 
#define MAX_AIO_QUEUE   1024 /* Bigger than MAX_AIO_QUEUE_PER_PROC */
 
#define MAX_BUF_AIO   16
 
#define KAIOCB_QUEUEING   0x01
 
#define KAIOCB_CANCELLED   0x02
 
#define KAIOCB_CANCELLING   0x04
 
#define KAIOCB_CHECKSYNC   0x08
 
#define KAIOCB_CLEARED   0x10
 
#define KAIOCB_FINISHED   0x20
 
#define AIOP_FREE   0x1 /* proc on free queue */
 
#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 */
 
#define AIO_LOCK(ki)   mtx_lock(&(ki)->kaio_mtx)
 
#define AIO_UNLOCK(ki)   mtx_unlock(&(ki)->kaio_mtx)
 
#define AIO_LOCK_ASSERT(ki, f)   mtx_assert(&(ki)->kaio_mtx, (f))
 
#define AIO_MTX(ki)   (&(ki)->kaio_mtx)
 
#define KAIO_RUNDOWN   0x1 /* process is being run down */
 
#define KAIO_WAKEUP   0x2 /* wakeup process when AIO completes */
 

Functions

 __FBSDID ("$FreeBSD$")
 
 FEATURE (aio, "Asynchronous I/O")
 
 SYSCTL_DECL (_p1003_1b)
 
static MALLOC_DEFINE (M_LIO, "lio", "listio aio control block list")
 
static MALLOC_DEFINE (M_AIOS, "aios", "aio_suspend aio control block list")
 
static SYSCTL_NODE (_vfs, OID_AUTO, aio, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "Async IO management")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, enable_unsafe, CTLFLAG_RW, &enable_aio_unsafe, 0, "Permit asynchronous IO on all file types, not just known-safe types")
 
 SYSCTL_UINT (_vfs_aio, OID_AUTO, unsafe_warningcnt, CTLFLAG_RW, &unsafe_warningcnt, 0, "Warnings that will be triggered upon failed IO requests on unsafe files")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, max_aio_procs, CTLFLAG_RW, &max_aio_procs, 0, "Maximum number of kernel processes to use for handling async IO ")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, num_aio_procs, CTLFLAG_RD, &num_aio_procs, 0, "Number of presently active kernel processes for async IO")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, target_aio_procs, CTLFLAG_RW, &target_aio_procs, 0, "Preferred number of ready kernel processes for async IO")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, max_aio_queue, CTLFLAG_RW, &max_queue_count, 0, "Maximum number of aio requests to queue, globally")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, num_queue_count, CTLFLAG_RD, &num_queue_count, 0, "Number of queued aio requests")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, num_buf_aio, CTLFLAG_RD, &num_buf_aio, 0, "Number of aio requests presently handled by the buf subsystem")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, num_unmapped_aio, CTLFLAG_RD, &num_unmapped_aio, 0, "Number of aio requests presently handled by unmapped I/O buffers")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, aiod_lifetime, CTLFLAG_RW, &aiod_lifetime, 0, "Maximum lifetime for idle aiod")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, max_aio_per_proc, CTLFLAG_RW, &max_aio_per_proc, 0, "Maximum active aio requests per process")
 
 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")
 
 SYSCTL_INT (_vfs_aio, OID_AUTO, max_buf_aio, CTLFLAG_RW, &max_buf_aio, 0, "Maximum buf aio requests per process")
 
 SYSCTL_INT (_p1003_1b, CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max, CTLFLAG_RD|CTLFLAG_CAPRD, &max_aio_queue_per_proc, 0, "Maximum aio requests for a single lio_listio call")
 
static TAILQ_HEAD (aioproc)
 
 TASKQUEUE_DEFINE_THREAD (aiod_kick)
 
static int aio_modload (struct module *module, int cmd, void *arg)
 
 DECLARE_MODULE (aio, aio_mod, SI_SUB_VFS, SI_ORDER_ANY)
 
 MODULE_VERSION (aio, 1)
 
static int aio_onceonly (void)
 
void aio_init_aioinfo (struct proc *p)
 
static int aio_sendsig (struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi, bool ext)
 
static int aio_free_entry (struct kaiocb *job)
 
static void aio_proc_rundown_exec (void *arg, struct proc *p, struct image_params *imgp __unused)
 
static int aio_cancel_job (struct proc *p, struct kaioinfo *ki, struct kaiocb *job)
 
static void aio_proc_rundown (void *arg, struct proc *p)
 
static struct kaiocb * aio_selectjob (struct aioproc *aiop)
 
static int aio_fsync_vnode (struct thread *td, struct vnode *vp, int op)
 
static void aio_process_rw (struct kaiocb *job)
 
static void aio_process_sync (struct kaiocb *job)
 
static void aio_process_mlock (struct kaiocb *job)
 
static void aio_bio_done_notify (struct proc *userp, struct kaiocb *job)
 
static void aio_schedule_fsync (void *context, int pending)
 
bool aio_cancel_cleared (struct kaiocb *job)
 
static bool aio_clear_cancel_function_locked (struct kaiocb *job)
 
bool aio_clear_cancel_function (struct kaiocb *job)
 
static bool aio_set_cancel_function_locked (struct kaiocb *job, aio_cancel_fn_t *func)
 
bool aio_set_cancel_function (struct kaiocb *job, aio_cancel_fn_t *func)
 
void aio_complete (struct kaiocb *job, long status, int error)
 
void aio_cancel (struct kaiocb *job)
 
void aio_switch_vmspace (struct kaiocb *job)
 
static void aio_daemon (void *_id)
 
static int aio_newproc (int *start)
 
static int aio_qbio (struct proc *p, struct kaiocb *job)
 
static int aiocb_copyin (struct aiocb *ujob, struct kaiocb *kjob, int type)
 
static long aiocb_fetch_status (struct aiocb *ujob)
 
static long aiocb_fetch_error (struct aiocb *ujob)
 
static int aiocb_store_status (struct aiocb *ujob, long status)
 
static int aiocb_store_error (struct aiocb *ujob, long error)
 
static int aiocb_store_kernelinfo (struct aiocb *ujob, long jobref)
 
static int aiocb_store_aiocb (struct aiocb **ujobp, struct aiocb *ujob)
 
int aio_aqueue (struct thread *td, struct aiocb *ujob, struct aioliojob *lj, int type, struct aiocb_ops *ops)
 
static void aio_cancel_daemon_job (struct kaiocb *job)
 
void aio_schedule (struct kaiocb *job, aio_handle_fn_t *func)
 
static void aio_cancel_sync (struct kaiocb *job)
 
int aio_queue_file (struct file *fp, struct kaiocb *job)
 
static void aio_kick_nowait (struct proc *userp)
 
static int aio_kick (struct proc *userp)
 
static void aio_kick_helper (void *context, int pending)
 
static int kern_aio_return (struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
 
int sys_aio_return (struct thread *td, struct aio_return_args *uap)
 
static int kern_aio_suspend (struct thread *td, int njoblist, struct aiocb **ujoblist, struct timespec *ts)
 
int sys_aio_suspend (struct thread *td, struct aio_suspend_args *uap)
 
int sys_aio_cancel (struct thread *td, struct aio_cancel_args *uap)
 
static int kern_aio_error (struct thread *td, struct aiocb *ujob, struct aiocb_ops *ops)
 
int sys_aio_error (struct thread *td, struct aio_error_args *uap)
 
int sys_aio_read (struct thread *td, struct aio_read_args *uap)
 
int sys_aio_readv (struct thread *td, struct aio_readv_args *uap)
 
int sys_aio_write (struct thread *td, struct aio_write_args *uap)
 
int sys_aio_writev (struct thread *td, struct aio_writev_args *uap)
 
int sys_aio_mlock (struct thread *td, struct aio_mlock_args *uap)
 
static int kern_lio_listio (struct thread *td, int mode, struct aiocb *const *uacb_list, struct aiocb **acb_list, int nent, struct sigevent *sig, struct aiocb_ops *ops)
 
int sys_lio_listio (struct thread *td, struct lio_listio_args *uap)
 
static void aio_biocleanup (struct bio *bp)
 
static void aio_biowakeup (struct bio *bp)
 
static int kern_aio_waitcomplete (struct thread *td, struct aiocb **ujobp, struct timespec *ts, struct aiocb_ops *ops)
 
int sys_aio_waitcomplete (struct thread *td, struct aio_waitcomplete_args *uap)
 
static int kern_aio_fsync (struct thread *td, int op, struct aiocb *ujob, struct aiocb_ops *ops)
 
int sys_aio_fsync (struct thread *td, struct aio_fsync_args *uap)
 
static int filt_aioattach (struct knote *kn)
 
static void filt_aiodetach (struct knote *kn)
 
static int filt_aio (struct knote *kn, long hint)
 
static int filt_lioattach (struct knote *kn)
 
static void filt_liodetach (struct knote *kn)
 
static int filt_lio (struct knote *kn, long hint)
 

Variables

static u_long jobrefid
 
static uint64_t jobseqno
 
static int enable_aio_unsafe = 0
 
static unsigned int unsafe_warningcnt = 1
 
static int max_aio_procs = MAX_AIO_PROCS
 
static int num_aio_procs = 0
 
static int target_aio_procs = TARGET_AIO_PROCS
 
static int max_queue_count = MAX_AIO_QUEUE
 
static int num_queue_count = 0
 
static int num_buf_aio = 0
 
static int num_unmapped_aio = 0
 
static int num_aio_resv_start = 0
 
static int aiod_lifetime
 
static int max_aio_per_proc = MAX_AIO_PER_PROC
 
static int max_aio_queue_per_proc = MAX_AIO_QUEUE_PER_PROC
 
static int max_buf_aio = MAX_BUF_AIO
 
static struct filterops lio_filtops
 
static eventhandler_tag exit_tag
 
static eventhandler_tag exec_tag
 
static moduledata_t aio_mod
 
static struct aiocb_ops aiocb_ops
 

Macro Definition Documentation

◆ AIO_LOCK

#define AIO_LOCK (   ki)    mtx_lock(&(ki)->kaio_mtx)

Definition at line 282 of file vfs_aio.c.

◆ AIO_LOCK_ASSERT

#define AIO_LOCK_ASSERT (   ki,
 
)    mtx_assert(&(ki)->kaio_mtx, (f))

Definition at line 284 of file vfs_aio.c.

◆ AIO_MTX

#define AIO_MTX (   ki)    (&(ki)->kaio_mtx)

Definition at line 285 of file vfs_aio.c.

◆ AIO_UNLOCK

#define AIO_UNLOCK (   ki)    mtx_unlock(&(ki)->kaio_mtx)

Definition at line 283 of file vfs_aio.c.

◆ AIOP_FREE

#define AIOP_FREE   0x1 /* proc on free queue */

Definition at line 238 of file vfs_aio.c.

◆ KAIO_RUNDOWN

#define KAIO_RUNDOWN   0x1 /* process is being run down */

Definition at line 287 of file vfs_aio.c.

◆ KAIO_WAKEUP

#define KAIO_WAKEUP   0x2 /* wakeup process when AIO completes */

Definition at line 288 of file vfs_aio.c.

◆ KAIOCB_CANCELLED

#define KAIOCB_CANCELLED   0x02

Definition at line 229 of file vfs_aio.c.

◆ KAIOCB_CANCELLING

#define KAIOCB_CANCELLING   0x04

Definition at line 230 of file vfs_aio.c.

◆ KAIOCB_CHECKSYNC

#define KAIOCB_CHECKSYNC   0x08

Definition at line 231 of file vfs_aio.c.

◆ KAIOCB_CLEARED

#define KAIOCB_CLEARED   0x10

Definition at line 232 of file vfs_aio.c.

◆ KAIOCB_FINISHED

#define KAIOCB_FINISHED   0x20

Definition at line 233 of file vfs_aio.c.

◆ KAIOCB_QUEUEING

#define KAIOCB_QUEUEING   0x01

Definition at line 228 of file vfs_aio.c.

◆ LIOJ_KEVENT_POSTED

#define LIOJ_KEVENT_POSTED   0x4 /* kevent triggered */

Definition at line 261 of file vfs_aio.c.

◆ LIOJ_SIGNAL

#define LIOJ_SIGNAL   0x1 /* signal on all done (lio) */

Definition at line 259 of file vfs_aio.c.

◆ LIOJ_SIGNAL_POSTED

#define LIOJ_SIGNAL_POSTED   0x2 /* signal has been posted */

Definition at line 260 of file vfs_aio.c.

◆ MAX_AIO_PER_PROC

#define MAX_AIO_PER_PROC   32

Definition at line 89 of file vfs_aio.c.

◆ MAX_AIO_QUEUE

#define MAX_AIO_QUEUE   1024 /* Bigger than MAX_AIO_QUEUE_PER_PROC */

Definition at line 97 of file vfs_aio.c.

◆ MAX_AIO_QUEUE_PER_PROC

#define MAX_AIO_QUEUE_PER_PROC   256

Definition at line 93 of file vfs_aio.c.

◆ MAX_BUF_AIO

#define MAX_BUF_AIO   16

Definition at line 101 of file vfs_aio.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ aio_aqueue()

◆ aio_bio_done_notify()

static void aio_bio_done_notify ( struct proc *  userp,
struct kaiocb *  job 
)
static

◆ aio_biocleanup()

static void aio_biocleanup ( struct bio *  bp)
static

Definition at line 2446 of file vfs_aio.c.

References AIO_LOCK, AIO_UNLOCK, buf, free(), maxphys, num_buf_aio, and num_unmapped_aio.

Referenced by aio_biowakeup(), and aio_qbio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_biowakeup()

static void aio_biowakeup ( struct bio *  bp)
static

Definition at line 2473 of file vfs_aio.c.

References aio_biocleanup(), aio_complete(), flags, and nbytes.

Referenced by aio_qbio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_cancel()

void aio_cancel ( struct kaiocb *  job)

Definition at line 1053 of file vfs_aio.c.

References aio_complete().

Referenced by aio_cancel_daemon_job(), aio_cancel_sync(), aio_queue_file(), aio_schedule(), soaio_process_job(), and soo_aio_cancel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_cancel_cleared()

bool aio_cancel_cleared ( struct kaiocb *  job)

Definition at line 966 of file vfs_aio.c.

References KAIOCB_CLEARED.

Referenced by aio_cancel_daemon_job(), aio_cancel_sync(), and soo_aio_cancel().

Here is the caller graph for this function:

◆ aio_cancel_daemon_job()

static void aio_cancel_daemon_job ( struct kaiocb *  job)
static

Definition at line 1751 of file vfs_aio.c.

References aio_cancel(), and aio_cancel_cleared().

Referenced by aio_schedule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_cancel_job()

static int aio_cancel_job ( struct proc *  p,
struct kaioinfo ki,
struct kaiocb *  job 
)
static

Definition at line 579 of file vfs_aio.c.

References aio_bio_done_notify(), AIO_LOCK, AIO_LOCK_ASSERT, AIO_UNLOCK, KAIOCB_CANCELLED, KAIOCB_CANCELLING, and KAIOCB_FINISHED.

Referenced by aio_proc_rundown(), and sys_aio_cancel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_cancel_sync()

static void aio_cancel_sync ( struct kaiocb *  job)
static

Definition at line 1778 of file vfs_aio.c.

References aio_cancel(), aio_cancel_cleared(), AIO_LOCK, and AIO_UNLOCK.

Referenced by aio_queue_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_clear_cancel_function()

bool aio_clear_cancel_function ( struct kaiocb *  job)

Definition at line 993 of file vfs_aio.c.

References aio_clear_cancel_function_locked(), AIO_LOCK, and AIO_UNLOCK.

Referenced by aio_selectjob(), and soaio_process_sb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_clear_cancel_function_locked()

static bool aio_clear_cancel_function_locked ( struct kaiocb *  job)
static

Definition at line 979 of file vfs_aio.c.

References AIO_LOCK_ASSERT, KAIOCB_CANCELLING, and KAIOCB_CLEARED.

Referenced by aio_bio_done_notify(), and aio_clear_cancel_function().

Here is the caller graph for this function:

◆ aio_complete()

void aio_complete ( struct kaiocb *  job,
long  status,
int  error 
)

Definition at line 1030 of file vfs_aio.c.

References aio_bio_done_notify(), AIO_LOCK, AIO_UNLOCK, KAIOCB_CANCELLING, KAIOCB_FINISHED, and KAIOCB_QUEUEING.

Referenced by aio_biowakeup(), aio_cancel(), aio_process_mlock(), aio_process_rw(), aio_process_sync(), soaio_process_job(), and soo_aio_cancel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_daemon()

static void aio_daemon ( void *  _id)
static

Definition at line 1071 of file vfs_aio.c.

References aio_selectjob(), aiod_lifetime, AIOP_FREE, aioproc::aioprocflags, free_unr(), kaioinfo::kaio_active_count, kproc_exit(), num_aio_procs, and target_aio_procs.

Referenced by aio_newproc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_free_entry()

static int aio_free_entry ( struct kaiocb *  job)
static

Definition at line 494 of file vfs_aio.c.

References AIO_LOCK, AIO_LOCK_ASSERT, AIO_UNLOCK, crfree(), free(), kaioinfo::kaio_count, KAIOCB_FINISHED, aioliojob::lioj_count, aioliojob::lioj_finished_count, num_queue_count, and sigqueue_take().

Referenced by aio_proc_rundown(), kern_aio_return(), and kern_aio_waitcomplete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_fsync_vnode()

static int aio_fsync_vnode ( struct thread *  td,
struct vnode *  vp,
int  op 
)
static

Definition at line 724 of file vfs_aio.c.

References vn_finished_write(), and vn_start_write().

Referenced by aio_process_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_init_aioinfo()

void aio_init_aioinfo ( struct proc *  p)

◆ aio_kick()

static int aio_kick ( struct proc *  userp)
static

Definition at line 1870 of file vfs_aio.c.

References aio_newproc(), aioproc::aioprocflags, kaioinfo::kaio_active_count, max_aio_per_proc, max_aio_procs, num_aio_procs, num_aio_resv_start, and wakeup().

Referenced by aio_kick_helper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_kick_helper()

static void aio_kick_helper ( void *  context,
int  pending 
)
static

Definition at line 1899 of file vfs_aio.c.

References aio_kick().

Referenced by aio_init_aioinfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_kick_nowait()

static void aio_kick_nowait ( struct proc *  userp)
static

Definition at line 1853 of file vfs_aio.c.

References aioproc::aioprocflags, kaioinfo::kaio_active_count, max_aio_per_proc, max_aio_procs, num_aio_procs, num_aio_resv_start, taskqueue_enqueue(), and wakeup().

Referenced by aio_schedule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_modload()

static int aio_modload ( struct module module,
int  cmd,
void *  arg 
)
static

Definition at line 371 of file vfs_aio.c.

References aio_onceonly().

Here is the call graph for this function:

◆ aio_newproc()

static int aio_newproc ( int *  start)
static

Definition at line 1178 of file vfs_aio.c.

References aio_daemon(), alloc_unr(), free_unr(), kproc_create(), num_aio_procs, and start.

Referenced by aio_init_aioinfo(), and aio_kick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_onceonly()

static int aio_onceonly ( void  )
static

Definition at line 401 of file vfs_aio.c.

References aio_proc_rundown(), aio_proc_rundown_exec(), aiod_lifetime, exec_tag, exit_tag, jobrefid, kqueue_add_filteropts(), lio_filtops, MAX_AIO_QUEUE, new_unrhdr(), p31b_setcfg(), and sema_init().

Referenced by aio_modload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_proc_rundown()

static void aio_proc_rundown ( void *  arg,
struct proc *  p 
)
static

◆ aio_proc_rundown_exec()

static void aio_proc_rundown_exec ( void *  arg,
struct proc *  p,
struct image_params *imgp  __unused 
)
static

Definition at line 572 of file vfs_aio.c.

References aio_proc_rundown().

Referenced by aio_onceonly().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_process_mlock()

static void aio_process_mlock ( struct kaiocb *  job)
static

Definition at line 863 of file vfs_aio.c.

References aio_complete(), and aio_switch_vmspace().

Referenced by aio_aqueue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_process_rw()

static void aio_process_rw ( struct kaiocb *  job)
static

Definition at line 763 of file vfs_aio.c.

References aio_complete(), aio_switch_vmspace(), bwillwrite(), and kern_psignal().

Referenced by aio_queue_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_process_sync()

static void aio_process_sync ( struct kaiocb *  job)
static

Definition at line 840 of file vfs_aio.c.

References aio_complete(), and aio_fsync_vnode().

Referenced by aio_queue_file(), and aio_schedule_fsync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_qbio()

static int aio_qbio ( struct proc *  p,
struct kaiocb *  job 
)
static

Definition at line 1213 of file vfs_aio.c.

References aio_biocleanup(), aio_biowakeup(), AIO_LOCK, AIO_UNLOCK, buf, dev_relthread(), devvn_refthread(), free(), kaioinfo::kaio_buffer_count, malloc(), max_buf_aio, maxphys, nbytes, num_buf_aio, num_unmapped_aio, and unmapped_buf.

Referenced by aio_queue_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_queue_file()

int aio_queue_file ( struct file *  fp,
struct kaiocb *  job 
)

Definition at line 1791 of file vfs_aio.c.

References aio_cancel(), aio_cancel_sync(), AIO_LOCK, aio_process_rw(), aio_process_sync(), aio_qbio(), aio_schedule(), aio_set_cancel_function_locked(), AIO_UNLOCK, counted_warning(), enable_aio_unsafe, KAIOCB_CHECKSYNC, and unsafe_warningcnt.

Referenced by aio_aqueue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_schedule()

void aio_schedule ( struct kaiocb *  job,
aio_handle_fn_t *  func 
)

Definition at line 1762 of file vfs_aio.c.

References aio_cancel(), aio_cancel_daemon_job(), aio_kick_nowait(), and aio_set_cancel_function().

Referenced by aio_aqueue(), aio_queue_file(), and aio_schedule_fsync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_schedule_fsync()

static void aio_schedule_fsync ( void *  context,
int  pending 
)
static

Definition at line 948 of file vfs_aio.c.

References AIO_LOCK, aio_process_sync(), aio_schedule(), and AIO_UNLOCK.

Referenced by aio_init_aioinfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_selectjob()

static struct kaiocb * aio_selectjob ( struct aioproc aiop)
static

Definition at line 694 of file vfs_aio.c.

References aio_clear_cancel_function(), kaioinfo::kaio_active_count, and max_aio_per_proc.

Referenced by aio_daemon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_sendsig()

static int aio_sendsig ( struct proc *  p,
struct sigevent *  sigev,
ksiginfo_t *  ksi,
bool  ext 
)
static

Definition at line 470 of file vfs_aio.c.

References sigev_findtd(), and tdsendsignal().

Referenced by aio_bio_done_notify(), and kern_lio_listio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_set_cancel_function()

bool aio_set_cancel_function ( struct kaiocb *  job,
aio_cancel_fn_t *  func 
)

Definition at line 1017 of file vfs_aio.c.

References AIO_LOCK, aio_set_cancel_function_locked(), and AIO_UNLOCK.

Referenced by aio_schedule(), soaio_process_job(), and soo_aio_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aio_set_cancel_function_locked()

static bool aio_set_cancel_function_locked ( struct kaiocb *  job,
aio_cancel_fn_t *  func 
)
static

Definition at line 1006 of file vfs_aio.c.

References AIO_LOCK_ASSERT, and KAIOCB_CANCELLED.

Referenced by aio_queue_file(), and aio_set_cancel_function().

Here is the caller graph for this function:

◆ aio_switch_vmspace()

void aio_switch_vmspace ( struct kaiocb *  job)

Definition at line 1060 of file vfs_aio.c.

Referenced by aio_process_mlock(), aio_process_rw(), and soaio_process_job().

Here is the caller graph for this function:

◆ aiocb_copyin()

static int aiocb_copyin ( struct aiocb *  ujob,
struct kaiocb *  kjob,
int  type 
)
static

Definition at line 1418 of file vfs_aio.c.

References copyinuio(), and type.

Here is the call graph for this function:

◆ aiocb_fetch_error()

static long aiocb_fetch_error ( struct aiocb *  ujob)
static

Definition at line 1445 of file vfs_aio.c.

References fuword().

Here is the call graph for this function:

◆ aiocb_fetch_status()

static long aiocb_fetch_status ( struct aiocb *  ujob)
static

Definition at line 1438 of file vfs_aio.c.

References fuword().

Here is the call graph for this function:

◆ aiocb_store_aiocb()

static int aiocb_store_aiocb ( struct aiocb **  ujobp,
struct aiocb *  ujob 
)
static

Definition at line 1473 of file vfs_aio.c.

◆ aiocb_store_error()

static int aiocb_store_error ( struct aiocb *  ujob,
long  error 
)
static

Definition at line 1459 of file vfs_aio.c.

◆ aiocb_store_kernelinfo()

static int aiocb_store_kernelinfo ( struct aiocb *  ujob,
long  jobref 
)
static

Definition at line 1466 of file vfs_aio.c.

◆ aiocb_store_status()

static int aiocb_store_status ( struct aiocb *  ujob,
long  status 
)
static

Definition at line 1452 of file vfs_aio.c.

◆ DECLARE_MODULE()

DECLARE_MODULE ( aio  ,
aio_mod  ,
SI_SUB_VFS  ,
SI_ORDER_ANY   
)

◆ FEATURE()

FEATURE ( aio  ,
"Asynchronous I/O"   
)

◆ filt_aio()

static int filt_aio ( struct knote kn,
long  hint 
)
static

Definition at line 2666 of file vfs_aio.c.

References KAIOCB_FINISHED.

◆ filt_aioattach()

static int filt_aioattach ( struct knote kn)
static

Definition at line 2629 of file vfs_aio.c.

References knlist_add().

Here is the call graph for this function:

◆ filt_aiodetach()

static void filt_aiodetach ( struct knote kn)
static

Definition at line 2652 of file vfs_aio.c.

References knlist_empty(), and knlist_remove().

Here is the call graph for this function:

◆ filt_lio()

static int filt_lio ( struct knote kn,
long  hint 
)
static

Definition at line 2716 of file vfs_aio.c.

References aioliojob::lioj_flags, and LIOJ_KEVENT_POSTED.

◆ filt_lioattach()

static int filt_lioattach ( struct knote kn)
static

Definition at line 2679 of file vfs_aio.c.

References knlist_add().

Here is the call graph for this function:

◆ filt_liodetach()

static void filt_liodetach ( struct knote kn)
static

Definition at line 2702 of file vfs_aio.c.

References knlist_empty(), and knlist_remove().

Here is the call graph for this function:

◆ kern_aio_error()

static int kern_aio_error ( struct thread *  td,
struct aiocb *  ujob,
struct aiocb_ops ops 
)
static

Definition at line 2126 of file vfs_aio.c.

References AIO_LOCK, AIO_UNLOCK, aiocb_ops::fetch_error, aiocb_ops::fetch_status, and KAIOCB_FINISHED.

Referenced by sys_aio_error().

Here is the caller graph for this function:

◆ kern_aio_fsync()

static int kern_aio_fsync ( struct thread *  td,
int  op,
struct aiocb *  ujob,
struct aiocb_ops ops 
)
static

Definition at line 2601 of file vfs_aio.c.

References aio_aqueue().

Referenced by sys_aio_fsync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_aio_return()

static int kern_aio_return ( struct thread *  td,
struct aiocb *  ujob,
struct aiocb_ops ops 
)
static

Definition at line 1916 of file vfs_aio.c.

References aio_free_entry(), AIO_LOCK, AIO_UNLOCK, KAIOCB_FINISHED, aiocb_ops::store_error, and aiocb_ops::store_status.

Referenced by sys_aio_return().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_aio_suspend()

static int kern_aio_suspend ( struct thread *  td,
int  njoblist,
struct aiocb **  ujoblist,
struct timespec *  ts 
)
static

Definition at line 1962 of file vfs_aio.c.

References AIO_LOCK, AIO_MTX, AIO_UNLOCK, itimerfix(), kaioinfo::kaio_flags, KAIO_WAKEUP, KAIOCB_FINISHED, ts, and tvtohz().

Referenced by sys_aio_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_aio_waitcomplete()

static int kern_aio_waitcomplete ( struct thread *  td,
struct aiocb **  ujobp,
struct timespec *  ts,
struct aiocb_ops ops 
)
static

Definition at line 2513 of file vfs_aio.c.

References aio_free_entry(), aio_init_aioinfo(), AIO_LOCK, AIO_MTX, AIO_UNLOCK, itimerfix(), kaioinfo::kaio_flags, KAIO_WAKEUP, KAIOCB_FINISHED, aiocb_ops::store_aiocb, aiocb_ops::store_error, aiocb_ops::store_status, ts, and tvtohz().

Referenced by sys_aio_waitcomplete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_lio_listio()

static int kern_lio_listio ( struct thread *  td,
int  mode,
struct aiocb *const *  uacb_list,
struct aiocb **  acb_list,
int  nent,
struct sigevent *  sig,
struct aiocb_ops ops 
)
static

◆ MALLOC_DEFINE() [1/2]

static MALLOC_DEFINE ( M_AIOS  ,
"aios"  ,
"aio_suspend aio control block list"   
)
static

◆ MALLOC_DEFINE() [2/2]

static MALLOC_DEFINE ( M_LIO  ,
"lio"  ,
"listio aio control block list"   
)
static

◆ MODULE_VERSION()

MODULE_VERSION ( aio  ,
 
)

◆ sys_aio_cancel()

int sys_aio_cancel ( struct thread *  td,
struct aio_cancel_args *  uap 
)

Definition at line 2050 of file vfs_aio.c.

References aio_cancel_job(), AIO_LOCK, AIO_UNLOCK, cap_no_rights, fget(), and vn_isdisk().

Here is the call graph for this function:

◆ sys_aio_error()

int sys_aio_error ( struct thread *  td,
struct aio_error_args *  uap 
)

Definition at line 2167 of file vfs_aio.c.

References kern_aio_error().

Here is the call graph for this function:

◆ sys_aio_fsync()

int sys_aio_fsync ( struct thread *  td,
struct aio_fsync_args *  uap 
)

Definition at line 2621 of file vfs_aio.c.

References kern_aio_fsync().

Here is the call graph for this function:

◆ sys_aio_mlock()

int sys_aio_mlock ( struct thread *  td,
struct aio_mlock_args *  uap 
)

Definition at line 2224 of file vfs_aio.c.

References aio_aqueue().

Here is the call graph for this function:

◆ sys_aio_read()

int sys_aio_read ( struct thread *  td,
struct aio_read_args *  uap 
)

Definition at line 2185 of file vfs_aio.c.

References aio_aqueue().

Here is the call graph for this function:

◆ sys_aio_readv()

int sys_aio_readv ( struct thread *  td,
struct aio_readv_args *  uap 
)

Definition at line 2192 of file vfs_aio.c.

References aio_aqueue().

Here is the call graph for this function:

◆ sys_aio_return()

int sys_aio_return ( struct thread *  td,
struct aio_return_args *  uap 
)

Definition at line 1952 of file vfs_aio.c.

References kern_aio_return().

Here is the call graph for this function:

◆ sys_aio_suspend()

int sys_aio_suspend ( struct thread *  td,
struct aio_suspend_args *  uap 
)

Definition at line 2021 of file vfs_aio.c.

References free(), kern_aio_suspend(), malloc(), max_aio_queue_per_proc, and ts.

Here is the call graph for this function:

◆ sys_aio_waitcomplete()

int sys_aio_waitcomplete ( struct thread *  td,
struct aio_waitcomplete_args *  uap 
)

Definition at line 2583 of file vfs_aio.c.

References kern_aio_waitcomplete(), and ts.

Here is the call graph for this function:

◆ sys_aio_write()

int sys_aio_write ( struct thread *  td,
struct aio_write_args *  uap 
)

Definition at line 2210 of file vfs_aio.c.

References aio_aqueue().

Here is the call graph for this function:

◆ sys_aio_writev()

int sys_aio_writev ( struct thread *  td,
struct aio_writev_args *  uap 
)

Definition at line 2217 of file vfs_aio.c.

References aio_aqueue().

Here is the call graph for this function:

◆ sys_lio_listio()

int sys_lio_listio ( struct thread *  td,
struct lio_listio_args *  uap 
)

Definition at line 2415 of file vfs_aio.c.

References free(), kern_lio_listio(), malloc(), and max_aio_queue_per_proc.

Here is the call graph for this function:

◆ SYSCTL_DECL()

SYSCTL_DECL ( _p1003_1b  )

◆ SYSCTL_INT() [1/13]

SYSCTL_INT ( _p1003_1b  ,
CTL_P1003_1B_AIO_LISTIO_MAX  ,
aio_listio_max  ,
CTLFLAG_RD|  CTLFLAG_CAPRD,
max_aio_queue_per_proc,
,
"Maximum aio requests for a single lio_listio call"   
)

◆ SYSCTL_INT() [2/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
aiod_lifetime  ,
CTLFLAG_RW  ,
aiod_lifetime,
,
"Maximum lifetime for idle aiod"   
)

◆ SYSCTL_INT() [3/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
enable_unsafe  ,
CTLFLAG_RW  ,
enable_aio_unsafe,
,
"Permit asynchronous IO on all file  types,
not just known-safe types"   
)

◆ SYSCTL_INT() [4/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
max_aio_per_proc  ,
CTLFLAG_RW  ,
max_aio_per_proc,
,
"Maximum active aio requests per process"   
)

◆ SYSCTL_INT() [5/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
max_aio_procs  ,
CTLFLAG_RW  ,
max_aio_procs,
,
"Maximum number of kernel processes to use for handling async IO "   
)

◆ SYSCTL_INT() [6/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
max_aio_queue  ,
CTLFLAG_RW  ,
max_queue_count,
,
"Maximum number of aio requests to  queue,
globally"   
)

◆ SYSCTL_INT() [7/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
max_aio_queue_per_proc  ,
CTLFLAG_RW  ,
max_aio_queue_per_proc,
,
"Maximum queued aio requests per process"   
)

◆ SYSCTL_INT() [8/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
max_buf_aio  ,
CTLFLAG_RW  ,
max_buf_aio,
,
"Maximum buf aio requests per process"   
)

◆ SYSCTL_INT() [9/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
num_aio_procs  ,
CTLFLAG_RD  ,
num_aio_procs,
,
"Number of presently active kernel processes for async IO"   
)

◆ SYSCTL_INT() [10/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
num_buf_aio  ,
CTLFLAG_RD  ,
num_buf_aio,
,
"Number of aio requests presently handled by the buf subsystem"   
)

◆ SYSCTL_INT() [11/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
num_queue_count  ,
CTLFLAG_RD  ,
num_queue_count,
,
"Number of queued aio requests"   
)

◆ SYSCTL_INT() [12/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
num_unmapped_aio  ,
CTLFLAG_RD  ,
num_unmapped_aio,
,
"Number of aio requests presently handled by unmapped I/O buffers"   
)

◆ SYSCTL_INT() [13/13]

SYSCTL_INT ( _vfs_aio  ,
OID_AUTO  ,
target_aio_procs  ,
CTLFLAG_RW  ,
target_aio_procs,
,
"Preferred number of ready kernel processes for async IO"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _vfs  ,
OID_AUTO  ,
aio  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"Async IO management"   
)
static

◆ SYSCTL_UINT()

SYSCTL_UINT ( _vfs_aio  ,
OID_AUTO  ,
unsafe_warningcnt  ,
CTLFLAG_RW  ,
unsafe_warningcnt,
,
"Warnings that will be triggered upon failed IO requests on unsafe files"   
)

◆ TAILQ_HEAD()

static TAILQ_HEAD ( aioproc  )
static

Definition at line 304 of file vfs_aio.c.

◆ TASKQUEUE_DEFINE_THREAD()

TASKQUEUE_DEFINE_THREAD ( aiod_kick  )

Variable Documentation

◆ aio_mod

moduledata_t aio_mod
static
Initial value:
= {
"aio",
NULL
}
static int aio_modload(struct module *module, int cmd, void *arg)
Definition: vfs_aio.c:371

Definition at line 388 of file vfs_aio.c.

◆ aiocb_ops

struct aiocb_ops aiocb_ops
static
Initial value:
= {
.aio_copyin = aiocb_copyin,
.fetch_status = aiocb_fetch_status,
.fetch_error = aiocb_fetch_error,
.store_status = aiocb_store_status,
.store_error = aiocb_store_error,
.store_kernelinfo = aiocb_store_kernelinfo,
.store_aiocb = aiocb_store_aiocb,
}
static long aiocb_fetch_status(struct aiocb *ujob)
Definition: vfs_aio.c:1438
static int aiocb_store_status(struct aiocb *ujob, long status)
Definition: vfs_aio.c:1452
static int aiocb_store_error(struct aiocb *ujob, long error)
Definition: vfs_aio.c:1459
static int aiocb_store_aiocb(struct aiocb **ujobp, struct aiocb *ujob)
Definition: vfs_aio.c:1473
static long aiocb_fetch_error(struct aiocb *ujob)
Definition: vfs_aio.c:1445
static int aiocb_store_kernelinfo(struct aiocb *ujob, long jobref)
Definition: vfs_aio.c:1466
static int aiocb_copyin(struct aiocb *ujob, struct kaiocb *kjob, int type)
Definition: vfs_aio.c:1418

Definition at line 1479 of file vfs_aio.c.

◆ aiod_lifetime

int aiod_lifetime
static

Definition at line 160 of file vfs_aio.c.

Referenced by aio_daemon(), and aio_onceonly().

◆ enable_aio_unsafe

int enable_aio_unsafe = 0
static

Definition at line 113 of file vfs_aio.c.

Referenced by aio_queue_file().

◆ exec_tag

eventhandler_tag exec_tag
static

Definition at line 363 of file vfs_aio.c.

Referenced by aio_onceonly().

◆ exit_tag

eventhandler_tag exit_tag
static

Definition at line 363 of file vfs_aio.c.

Referenced by aio_onceonly().

◆ jobrefid

u_long jobrefid
static

Definition at line 81 of file vfs_aio.c.

Referenced by aio_aqueue(), and aio_onceonly().

◆ jobseqno

uint64_t jobseqno
static

Definition at line 86 of file vfs_aio.c.

Referenced by aio_aqueue().

◆ lio_filtops

struct filterops lio_filtops
static
Initial value:
= {
.f_isfd = 0,
.f_attach = filt_lioattach,
.f_detach = filt_liodetach,
.f_event = filt_lio
}
static int filt_lio(struct knote *kn, long hint)
Definition: vfs_aio.c:2716
static void filt_liodetach(struct knote *kn)
Definition: vfs_aio.c:2702
static int filt_lioattach(struct knote *kn)
Definition: vfs_aio.c:2679

Definition at line 356 of file vfs_aio.c.

Referenced by aio_onceonly().

◆ max_aio_per_proc

int max_aio_per_proc = MAX_AIO_PER_PROC
static

Definition at line 164 of file vfs_aio.c.

Referenced by aio_kick(), aio_kick_nowait(), and aio_selectjob().

◆ max_aio_procs

int max_aio_procs = MAX_AIO_PROCS
static

Definition at line 122 of file vfs_aio.c.

Referenced by aio_init_aioinfo(), aio_kick(), and aio_kick_nowait().

◆ max_aio_queue_per_proc

int max_aio_queue_per_proc = MAX_AIO_QUEUE_PER_PROC
static

Definition at line 169 of file vfs_aio.c.

Referenced by aio_aqueue(), kern_lio_listio(), sys_aio_suspend(), and sys_lio_listio().

◆ max_buf_aio

int max_buf_aio = MAX_BUF_AIO
static

Definition at line 174 of file vfs_aio.c.

Referenced by aio_qbio().

◆ max_queue_count

int max_queue_count = MAX_AIO_QUEUE
static

Definition at line 139 of file vfs_aio.c.

Referenced by aio_aqueue().

◆ num_aio_procs

int num_aio_procs = 0
static

Definition at line 126 of file vfs_aio.c.

Referenced by aio_daemon(), aio_init_aioinfo(), aio_kick(), aio_kick_nowait(), and aio_newproc().

◆ num_aio_resv_start

int num_aio_resv_start = 0
static

Definition at line 158 of file vfs_aio.c.

Referenced by aio_kick(), and aio_kick_nowait().

◆ num_buf_aio

int num_buf_aio = 0
static

Definition at line 147 of file vfs_aio.c.

Referenced by aio_biocleanup(), and aio_qbio().

◆ num_queue_count

int num_queue_count = 0
static

Definition at line 143 of file vfs_aio.c.

Referenced by aio_aqueue(), and aio_free_entry().

◆ num_unmapped_aio

int num_unmapped_aio = 0
static

Definition at line 151 of file vfs_aio.c.

Referenced by aio_biocleanup(), and aio_qbio().

◆ target_aio_procs

int target_aio_procs = TARGET_AIO_PROCS
static

Definition at line 134 of file vfs_aio.c.

Referenced by aio_daemon(), and aio_init_aioinfo().

◆ unsafe_warningcnt

unsigned int unsafe_warningcnt = 1
static

Definition at line 117 of file vfs_aio.c.

Referenced by aio_queue_file().