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 ("$FreeBSD$")
 
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_LAST, 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

◆ ALD_LOCK

#define ALD_LOCK ( )    mtx_lock(&ald_mtx)

◆ ALD_UNLOCK

#define ALD_UNLOCK ( )    mtx_unlock(&ald_mtx)

◆ ALQ_LOCK

#define ALQ_LOCK (   alq)    mtx_lock_spin(&(alq)->aq_mtx)

Definition at line 88 of file kern_alq.c.

◆ ALQ_UNLOCK

#define ALQ_UNLOCK (   alq)    mtx_unlock_spin(&(alq)->aq_mtx)

Definition at line 89 of file kern_alq.c.

◆ AQ_ACTIVE

#define AQ_ACTIVE   0x0002 /* on the active list */

Definition at line 82 of file kern_alq.c.

◆ AQ_FLUSHING

#define AQ_FLUSHING   0x0004 /* doing IO */

Definition at line 83 of file kern_alq.c.

◆ AQ_LEGACY

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

Definition at line 86 of file kern_alq.c.

◆ AQ_ORDERED

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

Definition at line 85 of file kern_alq.c.

◆ AQ_SHUTDOWN

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

Definition at line 84 of file kern_alq.c.

◆ AQ_WANTED

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

Definition at line 81 of file kern_alq.c.

◆ HAS_PENDING_DATA

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

Definition at line 91 of file kern_alq.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ ald_activate()

static void ald_activate ( struct alq alq)
static

Definition at line 170 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:

◆ ald_daemon()

static void ald_daemon ( void  )
static

Definition at line 192 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:

◆ ald_deactivate()

static void ald_deactivate ( struct alq alq)
static

Definition at line 177 of file kern_alq.c.

References alq::aq_flags.

Referenced by ald_daemon(), and alq_flush().

Here is the caller graph for this function:

◆ ald_rem()

static int ald_rem ( struct alq alq)
static

Definition at line 149 of file kern_alq.c.

References ALD_LOCK, and ALD_UNLOCK.

Referenced by alq_close().

Here is the caller graph for this function:

◆ ald_shutdown()

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

Definition at line 229 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:

◆ ald_startup()

static void ald_startup ( void *  unused)
static

Definition at line 184 of file kern_alq.c.

References ald_mtx.

◆ alq_close()

void alq_close ( struct alq alq)

Definition at line 913 of file kern_alq.c.

References ald_rem(), and alq_destroy().

Here is the call graph for this function:

◆ alq_destroy()

void alq_destroy ( struct alq alq)

Definition at line 295 of file kern_alq.c.

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

Referenced by alq_close(), and alq_open_flags().

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

◆ alq_doio()

static int alq_doio ( struct alq alq)
static

Definition at line 309 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:

◆ alq_flush()

void alq_flush ( struct alq alq)

Definition at line 883 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:

◆ alq_get()

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

Definition at line 816 of file kern_alq.c.

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

Referenced by ktr_tracepoint().

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

◆ alq_getn()

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

Definition at line 672 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, flags, HAS_PENDING_DATA, wakeup(), and wakeup_one().

Referenced by alq_get().

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

◆ alq_load_handler()

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

Definition at line 921 of file kern_alq.c.

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

Here is the call graph for this function:

◆ alq_open()

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

Definition at line 481 of file kern_alq.c.

References alq_open_flags(), AQ_LEGACY, and count.

Here is the call graph for this function:

◆ alq_open_flags()

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

Definition at line 431 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(), flags, malloc(), 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:

◆ alq_post_flags()

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

◆ alq_shutdown()

static void alq_shutdown ( struct alq alq)
static

Definition at line 261 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, 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:

◆ alq_write()

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

Definition at line 660 of file kern_alq.c.

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

Here is the call graph for this function:

◆ alq_writen()

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

Definition at line 506 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, data, flags, HAS_PENDING_DATA, 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()

DECLARE_MODULE ( alq  ,
alq_mod  ,
SI_SUB_LAST  ,
SI_ORDER_ANY   
)

◆ LIST_HEAD()

static LIST_HEAD ( alq  )
static

Definition at line 99 of file kern_alq.c.

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

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_ALD  ,
"ALD"  ,
"ALD"   
)
static

◆ MODULE_VERSION()

MODULE_VERSION ( alq  ,
 
)

◆ SYSINIT() [1/2]

SYSINIT ( ald  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
ald_startup  ,
NULL   
)

◆ SYSINIT() [2/2]

SYSINIT ( aldthread  ,
SI_SUB_KTHREAD_IDLE  ,
SI_ORDER_ANY  ,
kproc_start  ,
ald_kp 
)

Variable Documentation

◆ ald_kp

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

Definition at line 415 of file kern_alq.c.

◆ ald_mtx

struct mtx ald_mtx
static

Definition at line 98 of file kern_alq.c.

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

◆ alq_mod

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:921

Definition at line 962 of file kern_alq.c.