FreeBSD kernel kern code
kern_rangelock.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/rangelock.h>
#include <sys/systm.h>
#include <vm/uma.h>
Include dependency graph for kern_rangelock.c:

Go to the source code of this file.

Data Structures

struct  rl_q_entry
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void rangelock_sys_init (void)
 
 SYSINIT (vfs, SI_SUB_LOCK, SI_ORDER_ANY, rangelock_sys_init, NULL)
 
static struct rl_q_entryrlqentry_alloc (void)
 
void rlqentry_free (struct rl_q_entry *rleq)
 
void rangelock_init (struct rangelock *lock)
 
void rangelock_destroy (struct rangelock *lock)
 
static int ranges_overlap (const struct rl_q_entry *e1, const struct rl_q_entry *e2)
 
static void rangelock_calc_block (struct rangelock *lock)
 
static void rangelock_unlock_locked (struct rangelock *lock, struct rl_q_entry *entry, struct mtx *ilk, bool do_calc_block)
 
void rangelock_unlock (struct rangelock *lock, void *cookie, struct mtx *ilk)
 
void * rangelock_unlock_range (struct rangelock *lock, void *cookie, off_t start, off_t end, struct mtx *ilk)
 
static void * rangelock_enqueue (struct rangelock *lock, off_t start, off_t end, int mode, struct mtx *ilk, bool trylock)
 
void * rangelock_rlock (struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
 
void * rangelock_tryrlock (struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
 
void * rangelock_wlock (struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
 
void * rangelock_trywlock (struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
 

Variables

static uma_zone_t rl_entry_zone
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ rangelock_calc_block()

static void rangelock_calc_block ( struct rangelock *  lock)
static

Definition at line 106 of file kern_rangelock.c.

References ranges_overlap(), and wakeup().

Referenced by rangelock_enqueue(), rangelock_unlock_locked(), and rangelock_unlock_range().

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

◆ rangelock_destroy()

void rangelock_destroy ( struct rangelock *  lock)

Definition at line 82 of file kern_rangelock.c.

Referenced by shm_drop(), and vnode_fini().

Here is the caller graph for this function:

◆ rangelock_enqueue()

static void * rangelock_enqueue ( struct rangelock *  lock,
off_t  start,
off_t  end,
int  mode,
struct mtx ilk,
bool  trylock 
)
static

Definition at line 220 of file kern_rangelock.c.

References mode, rangelock_calc_block(), rangelock_unlock_locked(), rlqentry_alloc(), and start.

Referenced by rangelock_rlock(), rangelock_tryrlock(), rangelock_trywlock(), and rangelock_wlock().

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

◆ rangelock_init()

void rangelock_init ( struct rangelock *  lock)

Definition at line 74 of file kern_rangelock.c.

Referenced by shm_alloc(), and vnode_init().

Here is the caller graph for this function:

◆ rangelock_rlock()

void * rangelock_rlock ( struct rangelock *  lock,
off_t  start,
off_t  end,
struct mtx ilk 
)

Definition at line 274 of file kern_rangelock.c.

References rangelock_enqueue(), and start.

Referenced by shm_ioctl(), shm_mmap(), and shm_read().

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

◆ rangelock_sys_init()

static void rangelock_sys_init ( void  )
static

Definition at line 51 of file kern_rangelock.c.

References rl_entry_zone.

◆ rangelock_tryrlock()

void * rangelock_tryrlock ( struct rangelock *  lock,
off_t  start,
off_t  end,
struct mtx ilk 
)

Definition at line 281 of file kern_rangelock.c.

References rangelock_enqueue(), and start.

Here is the call graph for this function:

◆ rangelock_trywlock()

void * rangelock_trywlock ( struct rangelock *  lock,
off_t  start,
off_t  end,
struct mtx ilk 
)

Definition at line 296 of file kern_rangelock.c.

References rangelock_enqueue(), and start.

Here is the call graph for this function:

◆ rangelock_unlock()

void rangelock_unlock ( struct rangelock *  lock,
void *  cookie,
struct mtx ilk 
)

Definition at line 179 of file kern_rangelock.c.

References rangelock_unlock_locked().

Referenced by kern_shm_open2(), shm_add_seals(), shm_dotruncate(), shm_fallocate(), shm_fspacectl(), shm_ioctl(), shm_mmap(), shm_read(), and shm_write().

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

◆ rangelock_unlock_locked()

static void rangelock_unlock_locked ( struct rangelock *  lock,
struct rl_q_entry entry,
struct mtx ilk,
bool  do_calc_block 
)
static

Definition at line 143 of file kern_rangelock.c.

References rangelock_calc_block(), and rlqentry_free().

Referenced by rangelock_enqueue(), rangelock_unlock(), and rangelock_unlock_range().

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

◆ rangelock_unlock_range()

void * rangelock_unlock_range ( struct rangelock *  lock,
void *  cookie,
off_t  start,
off_t  end,
struct mtx ilk 
)

Definition at line 192 of file kern_rangelock.c.

References rangelock_calc_block(), rangelock_unlock_locked(), and start.

Here is the call graph for this function:

◆ rangelock_wlock()

void * rangelock_wlock ( struct rangelock *  lock,
off_t  start,
off_t  end,
struct mtx ilk 
)

Definition at line 289 of file kern_rangelock.c.

References rangelock_enqueue(), and start.

Referenced by kern_shm_open2(), shm_add_seals(), shm_dotruncate(), shm_fallocate(), shm_fspacectl(), shm_ioctl(), and shm_write().

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

◆ ranges_overlap()

static int ranges_overlap ( const struct rl_q_entry e1,
const struct rl_q_entry e2 
)
static

Definition at line 93 of file kern_rangelock.c.

Referenced by rangelock_calc_block().

Here is the caller graph for this function:

◆ rlqentry_alloc()

static struct rl_q_entry * rlqentry_alloc ( void  )
static

Definition at line 60 of file kern_rangelock.c.

References rl_entry_zone.

Referenced by rangelock_enqueue().

Here is the caller graph for this function:

◆ rlqentry_free()

void rlqentry_free ( struct rl_q_entry rleq)

Definition at line 67 of file kern_rangelock.c.

References rl_entry_zone.

Referenced by rangelock_unlock_locked(), and thread_fini().

Here is the caller graph for this function:

◆ SYSINIT()

SYSINIT ( vfs  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
rangelock_sys_init  ,
NULL   
)

Variable Documentation

◆ rl_entry_zone

uma_zone_t rl_entry_zone
static

Definition at line 48 of file kern_rangelock.c.

Referenced by rangelock_sys_init(), rlqentry_alloc(), and rlqentry_free().