FreeBSD kernel kern code
kern_alq.c File Reference
#include <sys/cdefs.h>
#include "opt_mac.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/lock.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/alq.h>
#include <sys/malloc.h>
#include <sys/unistd.h>
#include <sys/fcntl.h>
#include <sys/eventhandler.h>
#include <security/mac/mac_framework.h>
Include dependency graph for kern_alq.c:

Go to the source code of this file.

Data Structures

struct  alq
 

Macros

#define AQ_WANTED   0x0001 /* Wakeup sleeper when io is done */
 
#define AQ_ACTIVE   0x0002 /* on the active list */
 
#define AQ_FLUSHING   0x0004 /* doing IO */
 
#define AQ_SHUTDOWN   0x0008 /* Queue no longer valid */
 
#define AQ_ORDERED   0x0010 /* Queue enforces ordered writes */
 
#define AQ_LEGACY   0x0020 /* Legacy queue (fixed length writes) */
 
#define ALQ_LOCK(alq)   mtx_lock_spin(&(alq)->aq_mtx)
 
#define ALQ_UNLOCK(alq)   mtx_unlock_spin(&(alq)->aq_mtx)
 
#define HAS_PENDING_DATA(alq)   ((alq)->aq_freebytes != (alq)->aq_buflen)
 
#define ALD_LOCK()   mtx_lock(&ald_mtx)
 
#define ALD_UNLOCK()   mtx_unlock(&ald_mtx)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_ALD,"ALD","ALD")
 
static LIST_HEAD (alq)
 
static int ald_rem (struct alq *alq)
 
static void ald_activate (struct alq *alq)
 
static void ald_deactivate (struct alq *alq)
 
static void ald_startup (void *unused)
 
static void ald_daemon (void)
 
static void ald_shutdown (void *arg, int howto)
 
static void alq_shutdown (struct alq *alq)
 
void alq_destroy (struct alq *alq)
 
static int alq_doio (struct alq *alq)
 
 SYSINIT (aldthread, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, kproc_start,&ald_kp)
 
 SYSINIT (ald, SI_SUB_LOCK, SI_ORDER_ANY, ald_startup, NULL)
 
int alq_open_flags (struct alq **alqp, const char *file, struct ucred *cred, int cmode, int size, int flags)
 
int alq_open (struct alq **alqp, const char *file, struct ucred *cred, int cmode, int size, int count)
 
int alq_writen (struct alq *alq, void *data, int len, int flags)
 
int alq_write (struct alq *alq, void *data, int flags)
 
struct ale * alq_getn (struct alq *alq, int len, int flags)
 
struct ale * alq_get (struct alq *alq, int flags)
 
void alq_post_flags (struct alq *alq, struct ale *ale, int flags)
 
void alq_flush (struct alq *alq)
 
void alq_close (struct alq *alq)
 
static int alq_load_handler (module_t mod, int what, void *arg)
 
 DECLARE_MODULE (alq, alq_mod, SI_SUB_SMP, SI_ORDER_ANY)
 
 MODULE_VERSION (alq, 1)
 

Variables

static struct mtx ald_mtx
 
static struct kproc_desc ald_kp
 
static moduledata_t alq_mod
 

Macro Definition Documentation

#define ALD_UNLOCK ( )    mtx_unlock(&ald_mtx)
#define ALQ_LOCK (   alq)    mtx_lock_spin(&(alq)->aq_mtx)

Definition at line 86 of file kern_alq.c.

Referenced by ald_daemon(), alq_doio(), alq_flush(), alq_getn(), alq_shutdown(), and alq_writen().

#define ALQ_UNLOCK (   alq)    mtx_unlock_spin(&(alq)->aq_mtx)
#define AQ_ACTIVE   0x0002 /* on the active list */

Definition at line 80 of file kern_alq.c.

Referenced by ald_deactivate(), alq_flush(), alq_getn(), alq_post_flags(), alq_shutdown(), and alq_writen().

#define AQ_FLUSHING   0x0004 /* doing IO */

Definition at line 81 of file kern_alq.c.

Referenced by alq_doio(), and alq_flush().

#define AQ_LEGACY   0x0020 /* Legacy queue (fixed length writes) */

Definition at line 84 of file kern_alq.c.

Referenced by alq_get(), alq_open(), and alq_write().

#define AQ_ORDERED   0x0010 /* Queue enforces ordered writes */

Definition at line 83 of file kern_alq.c.

Referenced by alq_getn(), alq_open_flags(), alq_post_flags(), and alq_writen().

#define AQ_SHUTDOWN   0x0008 /* Queue no longer valid */

Definition at line 82 of file kern_alq.c.

Referenced by alq_getn(), alq_shutdown(), and alq_writen().

#define AQ_WANTED   0x0001 /* Wakeup sleeper when io is done */

Definition at line 79 of file kern_alq.c.

Referenced by alq_doio(), alq_getn(), alq_shutdown(), and alq_writen().

#define HAS_PENDING_DATA (   alq)    ((alq)->aq_freebytes != (alq)->aq_buflen)

Definition at line 89 of file kern_alq.c.

Referenced by alq_doio(), alq_flush(), alq_getn(), alq_post_flags(), alq_shutdown(), and alq_writen().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static void ald_activate ( struct alq alq)
static

Definition at line 169 of file kern_alq.c.

References wakeup().

Referenced by alq_post_flags(), alq_shutdown(), and alq_writen().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ald_daemon ( void  )
static

Definition at line 191 of file kern_alq.c.

References ald_deactivate(), ALD_LOCK, ald_mtx, ald_shutdown(), ALD_UNLOCK, alq_doio(), ALQ_LOCK, ALQ_UNLOCK, kproc_exit(), and wakeup_one().

Here is the call graph for this function:

static void ald_deactivate ( struct alq alq)
static

Definition at line 176 of file kern_alq.c.

References AQ_ACTIVE, and alq::aq_flags.

Referenced by ald_daemon(), and alq_flush().

Here is the caller graph for this function:

static int ald_rem ( struct alq alq)
static

Definition at line 148 of file kern_alq.c.

References ALD_LOCK, and ALD_UNLOCK.

Referenced by alq_close().

Here is the caller graph for this function:

static void ald_shutdown ( void *  arg,
int  howto 
)
static

Definition at line 228 of file kern_alq.c.

References ALD_LOCK, ald_mtx, ALD_UNLOCK, alq_shutdown(), and wakeup().

Referenced by ald_daemon(), and alq_load_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ald_startup ( void *  unused)
static

Definition at line 183 of file kern_alq.c.

References ald_mtx, and mtx_init().

Here is the call graph for this function:

void alq_close ( struct alq alq)

Definition at line 922 of file kern_alq.c.

References ald_rem(), and alq_destroy().

Here is the call graph for this function:

void alq_destroy ( struct alq alq)

Definition at line 294 of file kern_alq.c.

References alq_shutdown(), alq::aq_entbuf, alq::aq_mtx, free(), and mtx_destroy().

Referenced by alq_close(), and alq_open_flags().

Here is the call graph for this function:

Here is the caller graph for this function:

static int alq_doio ( struct alq alq)
static

Definition at line 308 of file kern_alq.c.

References ALQ_LOCK, ALQ_UNLOCK, alq::aq_buflen, alq::aq_cred, alq::aq_entbuf, alq::aq_flags, AQ_FLUSHING, alq::aq_freebytes, alq::aq_vp, AQ_WANTED, alq::aq_wrapearly, alq::aq_writehead, alq::aq_writetail, HAS_PENDING_DATA, vn_finished_write(), and vn_start_write().

Referenced by ald_daemon(), and alq_flush().

Here is the call graph for this function:

Here is the caller graph for this function:

void alq_flush ( struct alq alq)

Definition at line 892 of file kern_alq.c.

References ald_deactivate(), ALD_LOCK, ALD_UNLOCK, alq_doio(), ALQ_LOCK, ALQ_UNLOCK, AQ_ACTIVE, alq::aq_flags, AQ_FLUSHING, HAS_PENDING_DATA, and wakeup_one().

Here is the call graph for this function:

struct ale* alq_get ( struct alq alq,
int  flags 
)

Definition at line 825 of file kern_alq.c.

References alq_getn(), alq::aq_entlen, alq::aq_flags, and AQ_LEGACY.

Referenced by ktr_tracepoint().

Here is the call graph for this function:

Here is the caller graph for this function:

struct ale* alq_getn ( struct alq alq,
int  len,
int  flags 
)

Definition at line 681 of file kern_alq.c.

References ALQ_LOCK, ALQ_UNLOCK, AQ_ACTIVE, alq::aq_buflen, alq::aq_entbuf, alq::aq_flags, alq::aq_freebytes, alq::aq_getpost, alq::aq_mtx, AQ_ORDERED, AQ_SHUTDOWN, alq::aq_waiters, AQ_WANTED, alq::aq_wrapearly, alq::aq_writehead, alq::aq_writetail, HAS_PENDING_DATA, msleep_spin(), wakeup(), and wakeup_one().

Referenced by alq_get().

Here is the call graph for this function:

Here is the caller graph for this function:

static int alq_load_handler ( module_t  mod,
int  what,
void *  arg 
)
static

Definition at line 930 of file kern_alq.c.

References ALD_LOCK, ald_mtx, ald_shutdown(), ALD_UNLOCK, and mtx_destroy().

Here is the call graph for this function:

int alq_open ( struct alq **  alqp,
const char *  file,
struct ucred *  cred,
int  cmode,
int  size,
int  count 
)

Definition at line 489 of file kern_alq.c.

References alq_open_flags(), AQ_LEGACY, and count.

Here is the call graph for this function:

int alq_open_flags ( struct alq **  alqp,
const char *  file,
struct ucred *  cred,
int  cmode,
int  size,
int  flags 
)

Definition at line 434 of file kern_alq.c.

References alq_destroy(), alq::aq_buflen, alq::aq_cred, alq::aq_entbuf, alq::aq_entlen, alq::aq_entmax, alq::aq_flags, alq::aq_freebytes, alq::aq_mtx, AQ_ORDERED, alq::aq_vp, alq::aq_writehead, alq::aq_writetail, crhold(), malloc(), mtx_init(), NDFREE(), and vn_open_cred().

Referenced by alq_open().

Here is the call graph for this function:

Here is the caller graph for this function:

void alq_post_flags ( struct alq alq,
struct ale *  ale,
int  flags 
)
static void alq_shutdown ( struct alq alq)
static

Definition at line 260 of file kern_alq.c.

References ald_activate(), ALD_LOCK, ALD_UNLOCK, ALQ_LOCK, ALQ_UNLOCK, AQ_ACTIVE, alq::aq_cred, alq::aq_flags, alq::aq_mtx, AQ_SHUTDOWN, alq::aq_vp, AQ_WANTED, crfree(), HAS_PENDING_DATA, msleep_spin(), and vn_close().

Referenced by ald_shutdown(), and alq_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

int alq_write ( struct alq alq,
void *  data,
int  flags 
)

Definition at line 669 of file kern_alq.c.

References alq_writen(), alq::aq_entlen, alq::aq_flags, and AQ_LEGACY.

Here is the call graph for this function:

int alq_writen ( struct alq alq,
void *  data,
int  len,
int  flags 
)

Definition at line 515 of file kern_alq.c.

References ald_activate(), ALD_LOCK, ALD_UNLOCK, ALQ_LOCK, ALQ_UNLOCK, AQ_ACTIVE, alq::aq_buflen, alq::aq_entbuf, alq::aq_flags, alq::aq_freebytes, alq::aq_mtx, AQ_ORDERED, AQ_SHUTDOWN, alq::aq_waiters, AQ_WANTED, alq::aq_writehead, HAS_PENDING_DATA, msleep_spin(), wakeup(), and wakeup_one().

Referenced by alq_write().

Here is the call graph for this function:

Here is the caller graph for this function:

DECLARE_MODULE ( alq  ,
alq_mod  ,
SI_SUB_SMP  ,
SI_ORDER_ANY   
)
static LIST_HEAD ( alq  )
static

Definition at line 97 of file kern_alq.c.

Referenced by hashdestroy(), hashinit_flags(), and phashinit().

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_ALD  ,
"ALD"  ,
"ALD"   
)
static
MODULE_VERSION ( alq  ,
 
)
SYSINIT ( aldthread  ,
SI_SUB_KTHREAD_IDLE  ,
SI_ORDER_ANY  ,
kproc_start  ,
ald_kp 
)
SYSINIT ( ald  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
ald_startup  ,
NULL   
)

Variable Documentation

struct kproc_desc ald_kp
static
Initial value:
= {
"ALQ Daemon",
&ald_proc
}
static void ald_daemon(void)
Definition: kern_alq.c:191

Definition at line 417 of file kern_alq.c.

struct mtx ald_mtx
static

Definition at line 96 of file kern_alq.c.

Referenced by ald_daemon(), ald_shutdown(), ald_startup(), and alq_load_handler().

moduledata_t alq_mod
static
Initial value:
=
{
"alq",
NULL
}
static int alq_load_handler(module_t mod, int what, void *arg)
Definition: kern_alq.c:930

Definition at line 971 of file kern_alq.c.