FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_debug_lockf.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/hash.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/fcntl.h>
#include <sys/lockf.h>
#include <sys/taskqueue.h>
Go to the source code of this file.
Data Structures | |
struct | lock_owner |
struct | owner_edge |
struct | owner_vertex |
struct | owner_graph |
struct | lockdesc |
Macros | |
#define | NOLOCKF (struct lockf_entry *)0 |
#define | SELF 0x1 |
#define | OTHERS 0x2 |
#define | LOCK_OWNER_HASH_SIZE 256 |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_LOCKF,"lockf","Byte-range locking structures") |
static void | lf_init (void *) |
static int | lf_hash_owner (caddr_t, struct flock *, int) |
static int | lf_owner_matches (struct lock_owner *, caddr_t, struct flock *, int) |
static struct lockf_entry * | lf_alloc_lock (struct lock_owner *) |
static int | lf_free_lock (struct lockf_entry *) |
static int | lf_clearlock (struct lockf *, struct lockf_entry *) |
static int | lf_overlaps (struct lockf_entry *, struct lockf_entry *) |
static int | lf_blocks (struct lockf_entry *, struct lockf_entry *) |
static void | lf_free_edge (struct lockf_edge *) |
static struct lockf_edge * | lf_alloc_edge (void) |
static void | lf_alloc_vertex (struct lockf_entry *) |
static int | lf_add_edge (struct lockf_entry *, struct lockf_entry *) |
static void | lf_remove_edge (struct lockf_edge *) |
static void | lf_remove_outgoing (struct lockf_entry *) |
static void | lf_remove_incoming (struct lockf_entry *) |
static int | lf_add_outgoing (struct lockf *, struct lockf_entry *) |
static int | lf_add_incoming (struct lockf *, struct lockf_entry *) |
static int | lf_findoverlap (struct lockf_entry **, struct lockf_entry *, int) |
static struct lockf_entry * | lf_getblock (struct lockf *, struct lockf_entry *) |
static int | lf_getlock (struct lockf *, struct lockf_entry *, struct flock *) |
static void | lf_insert_lock (struct lockf *, struct lockf_entry *) |
static void | lf_wakeup_lock (struct lockf *, struct lockf_entry *) |
static void | lf_update_dependancies (struct lockf *, struct lockf_entry *, int all, struct lockf_entry_list *) |
static void | lf_set_start (struct lockf *, struct lockf_entry *, off_t, struct lockf_entry_list *) |
static void | lf_set_end (struct lockf *, struct lockf_entry *, off_t, struct lockf_entry_list *) |
static int | lf_setlock (struct lockf *, struct lockf_entry *, struct vnode *, void **cookiep) |
static int | lf_cancel (struct lockf *, struct lockf_entry *, void *) |
static void | lf_split (struct lockf *, struct lockf_entry *, struct lockf_entry *, struct lockf_entry_list *) |
static int | graph_delta_forward (struct owner_graph *g, struct owner_vertex *x, struct owner_vertex *y, struct owner_vertex_list *delta) |
static int | graph_delta_backward (struct owner_graph *g, struct owner_vertex *x, struct owner_vertex *y, struct owner_vertex_list *delta) |
static int | graph_add_indices (int *indices, int n, struct owner_vertex_list *set) |
static int | graph_assign_indices (struct owner_graph *g, int *indices, int nextunused, struct owner_vertex_list *set) |
static int | graph_add_edge (struct owner_graph *g, struct owner_vertex *x, struct owner_vertex *y) |
static void | graph_remove_edge (struct owner_graph *g, struct owner_vertex *x, struct owner_vertex *y) |
static struct owner_vertex * | graph_alloc_vertex (struct owner_graph *g, struct lock_owner *lo) |
static void | graph_free_vertex (struct owner_graph *g, struct owner_vertex *v) |
static struct owner_graph * | graph_init (struct owner_graph *g) |
LIST_HEAD (lock_owner_list, lock_owner) | |
LIST_HEAD (owner_edge_list, owner_edge) | |
TAILQ_HEAD (owner_vertex_list, owner_vertex) | |
SYSINIT (lf_init, SI_SUB_LOCK, SI_ORDER_FIRST, lf_init, NULL) | |
int | lf_advlockasync (struct vop_advlockasync_args *ap, struct lockf **statep, u_quad_t size) |
int | lf_advlock (struct vop_advlock_args *ap, struct lockf **statep, u_quad_t size) |
void | lf_purgelocks (struct vnode *vp, struct lockf **statep) |
static void | lf_activate_lock (struct lockf *state, struct lockf_entry *lock) |
static void | lf_cancel_lock (struct lockf *state, struct lockf_entry *lock) |
STAILQ_HEAD (lockdesclist, lockdesc) | |
int | lf_iteratelocks_sysid (int sysid, lf_iterator *fn, void *arg) |
int | lf_iteratelocks_vnode (struct vnode *vp, lf_iterator *fn, void *arg) |
static int | lf_clearremotesys_iterator (struct vnode *vp, struct flock *fl, void *arg) |
void | lf_clearremotesys (int sysid) |
int | lf_countlocks (int sysid) |
Variables | |
static struct sx | lf_lock_states_lock |
static struct lockf_list | lf_lock_states |
static struct sx | lf_lock_owners_lock |
static struct lock_owner_list | lf_lock_owners [LOCK_OWNER_HASH_SIZE] |
static struct sx | lf_owner_graph_lock |
static struct owner_graph | lf_owner_graph |
#define LOCK_OWNER_HASH_SIZE 256 |
Definition at line 191 of file kern_lockf.c.
Referenced by lf_countlocks(), lf_hash_owner(), and lf_init().
#define NOLOCKF (struct lockf_entry *)0 |
Definition at line 100 of file kern_lockf.c.
Referenced by lf_clearlock(), lf_findoverlap(), and lf_getblock().
#define OTHERS 0x2 |
Definition at line 102 of file kern_lockf.c.
Referenced by lf_findoverlap().
#define SELF 0x1 |
Definition at line 101 of file kern_lockf.c.
Referenced by lf_activate_lock(), and lf_findoverlap().
__FBSDID | ( | "$BSDSUniX$" | ) |
|
static |
Definition at line 2229 of file kern_lockf.c.
References owner_graph::g_gen, owner_graph::g_indexbuf, owner_graph::g_size, owner_graph::g_vertices, graph_add_indices(), graph_assign_indices(), graph_delta_backward(), graph_delta_forward(), lf_owner_graph_lock, malloc(), and printf().
Referenced by lf_add_edge().
|
static |
Definition at line 2189 of file kern_lockf.c.
Referenced by graph_add_edge().
|
static |
Definition at line 2403 of file kern_lockf.c.
References free(), owner_graph::g_gen, owner_graph::g_indexbuf, owner_graph::g_size, owner_graph::g_space, owner_graph::g_vertices, lf_owner_graph_lock, malloc(), and realloc().
Referenced by lf_alloc_vertex().
|
static |
Definition at line 2208 of file kern_lockf.c.
References owner_graph::g_vertices.
Referenced by graph_add_edge().
|
static |
Definition at line 2154 of file kern_lockf.c.
References owner_graph::g_gen.
Referenced by graph_add_edge().
|
static |
Definition at line 2112 of file kern_lockf.c.
References owner_graph::g_gen.
Referenced by graph_add_edge().
|
static |
Definition at line 2432 of file kern_lockf.c.
References free(), owner_graph::g_size, owner_graph::g_vertices, and lf_owner_graph_lock.
Referenced by lf_free_lock().
|
static |
Definition at line 2457 of file kern_lockf.c.
References owner_graph::g_gen, owner_graph::g_indexbuf, owner_graph::g_size, owner_graph::g_space, owner_graph::g_vertices, and malloc().
Referenced by lf_init().
|
static |
Definition at line 2368 of file kern_lockf.c.
References free(), lf_owner_graph_lock, and printf().
Referenced by lf_remove_edge().
|
static |
Definition at line 1212 of file kern_lockf.c.
References lf_findoverlap(), lf_free_lock(), lf_insert_lock(), lf_set_end(), lf_set_start(), lf_split(), lf_update_dependancies(), printf(), and SELF.
Referenced by lf_cancel_lock(), lf_clearlock(), and lf_setlock().
|
static |
Definition at line 911 of file kern_lockf.c.
References graph_add_edge(), lf_alloc_edge(), lf_alloc_vertex(), and lf_owner_graph.
Referenced by lf_add_incoming(), and lf_add_outgoing().
|
static |
Definition at line 1059 of file kern_lockf.c.
References lf_add_edge(), lf_blocks(), and lf_remove_incoming().
Referenced by lf_setlock(), and lf_split().
|
static |
Definition at line 991 of file kern_lockf.c.
References lf_add_edge(), lf_blocks(), and lf_remove_outgoing().
Referenced by lf_setlock().
int lf_advlock | ( | struct vop_advlock_args * | ap, |
struct lockf ** | statep, | ||
u_quad_t | size | ||
) |
Definition at line 759 of file kern_lockf.c.
References lf_advlockasync().
Referenced by vop_stdadvlock().
int lf_advlockasync | ( | struct vop_advlockasync_args * | ap, |
struct lockf ** | statep, | ||
u_quad_t | size | ||
) |
Definition at line 408 of file kern_lockf.c.
References free(), lf_alloc_lock(), lf_blocks(), lf_cancel(), lf_clearlock(), lf_clearremotesys(), lf_free_lock(), lf_getlock(), lf_hash_owner(), lf_lock_owners, lf_lock_owners_lock, lf_lock_states, lf_lock_states_lock, lf_overlaps(), lf_owner_matches(), lf_setlock(), malloc(), printf(), start, sx_destroy(), vref(), and wakeup().
Referenced by lf_advlock(), and vop_stdadvlockasync().
|
static |
Definition at line 875 of file kern_lockf.c.
References malloc().
Referenced by lf_add_edge().
|
static |
Definition at line 330 of file kern_lockf.c.
References lf_lock_owners_lock, malloc(), and printf().
Referenced by lf_advlockasync(), and lf_split().
|
static |
Definition at line 897 of file kern_lockf.c.
References graph_alloc_vertex(), and lf_owner_graph.
Referenced by lf_add_edge().
|
static |
Definition at line 863 of file kern_lockf.c.
References lf_overlaps().
Referenced by lf_add_incoming(), lf_add_outgoing(), lf_advlockasync(), lf_getblock(), and lf_update_dependancies().
|
static |
Definition at line 1602 of file kern_lockf.c.
References lf_cancel_lock().
Referenced by lf_advlockasync().
|
static |
Definition at line 1325 of file kern_lockf.c.
References lf_activate_lock(), lf_free_lock(), lf_owner_graph_lock, lf_remove_outgoing(), and lf_update_dependancies().
Referenced by lf_cancel(), and lf_setlock().
|
static |
Definition at line 1548 of file kern_lockf.c.
References lf_activate_lock(), NOLOCKF, and panic().
Referenced by lf_advlockasync().
void lf_clearremotesys | ( | int | sysid | ) |
Definition at line 2007 of file kern_lockf.c.
References lf_clearremotesys_iterator(), and lf_iteratelocks_sysid().
Referenced by lf_advlockasync().
|
static |
Definition at line 1999 of file kern_lockf.c.
Referenced by lf_clearremotesys().
int lf_countlocks | ( | int | sysid | ) |
Definition at line 2015 of file kern_lockf.c.
References count, lf_lock_owners, lf_lock_owners_lock, and LOCK_OWNER_HASH_SIZE.
|
static |
Definition at line 1699 of file kern_lockf.c.
References NOLOCKF, OTHERS, panic(), printf(), SELF, and start.
Referenced by lf_activate_lock().
|
static |
Definition at line 885 of file kern_lockf.c.
References free().
Referenced by lf_remove_edge().
|
static |
Definition at line 351 of file kern_lockf.c.
References free(), graph_free_vertex(), lf_lock_owners_lock, lf_owner_graph, lf_owner_graph_lock, printf(), and vrele().
Referenced by lf_activate_lock(), lf_advlockasync(), lf_cancel_lock(), lf_purgelocks(), and lf_setlock().
|
static |
Definition at line 1655 of file kern_lockf.c.
References lf_blocks(), and NOLOCKF.
Referenced by lf_getlock(), and lf_setlock().
|
static |
Definition at line 1573 of file kern_lockf.c.
References lf_getblock().
Referenced by lf_advlockasync().
|
static |
Definition at line 295 of file kern_lockf.c.
References LOCK_OWNER_HASH_SIZE.
Referenced by lf_advlockasync().
|
static |
Definition at line 275 of file kern_lockf.c.
References graph_init(), lf_lock_owners, lf_lock_owners_lock, lf_lock_states, lf_lock_states_lock, lf_owner_graph, lf_owner_graph_lock, and LOCK_OWNER_HASH_SIZE.
|
static |
Definition at line 1092 of file kern_lockf.c.
Referenced by lf_activate_lock(), lf_set_start(), and lf_split().
int lf_iteratelocks_sysid | ( | int | sysid, |
lf_iterator * | fn, | ||
void * | arg | ||
) |
Definition at line 1869 of file kern_lockf.c.
References free(), lf_lock_states, lf_lock_states_lock, malloc(), vref(), and vrele().
Referenced by lf_clearremotesys().
int lf_iteratelocks_vnode | ( | struct vnode * | vp, |
lf_iterator * | fn, | ||
void * | arg | ||
) |
|
static |
Definition at line 853 of file kern_lockf.c.
Referenced by lf_advlockasync(), and lf_blocks().
|
static |
Definition at line 318 of file kern_lockf.c.
Referenced by lf_advlockasync().
void lf_purgelocks | ( | struct vnode * | vp, |
struct lockf ** | statep | ||
) |
Definition at line 775 of file kern_lockf.c.
References free(), lf_free_lock(), lf_lock_states_lock, lf_owner_graph_lock, lf_remove_incoming(), lf_remove_outgoing(), sx_destroy(), and wakeup().
Referenced by vop_stdadvlockpurge().
|
static |
Definition at line 946 of file kern_lockf.c.
References graph_remove_edge(), lf_free_edge(), and lf_owner_graph.
Referenced by lf_remove_incoming(), lf_remove_outgoing(), and lf_update_dependancies().
|
static |
Definition at line 977 of file kern_lockf.c.
References lf_remove_edge().
Referenced by lf_add_incoming(), and lf_purgelocks().
|
static |
Definition at line 964 of file kern_lockf.c.
References lf_remove_edge().
Referenced by lf_add_outgoing(), lf_cancel_lock(), and lf_purgelocks().
|
static |
Definition at line 1187 of file kern_lockf.c.
References lf_update_dependancies().
Referenced by lf_activate_lock(), and lf_split().
|
static |
Definition at line 1171 of file kern_lockf.c.
References lf_insert_lock(), and lf_update_dependancies().
Referenced by lf_activate_lock(), and lf_split().
|
static |
Definition at line 1376 of file kern_lockf.c.
References lf_activate_lock(), lf_add_incoming(), lf_add_outgoing(), lf_cancel_lock(), lf_free_lock(), lf_getblock(), lf_owner_graph_lock, and priority.
Referenced by lf_advlockasync().
|
static |
Definition at line 1807 of file kern_lockf.c.
References lf_add_incoming(), lf_alloc_lock(), lf_insert_lock(), lf_owner_graph_lock, lf_set_end(), lf_set_start(), and vref().
Referenced by lf_activate_lock().
|
static |
Definition at line 1146 of file kern_lockf.c.
References lf_blocks(), lf_owner_graph_lock, lf_remove_edge(), and lf_wakeup_lock().
Referenced by lf_activate_lock(), lf_cancel_lock(), lf_set_end(), and lf_set_start().
|
static |
Definition at line 1119 of file kern_lockf.c.
References taskqueue_enqueue(), and wakeup().
Referenced by lf_update_dependancies().
LIST_HEAD | ( | lock_owner_list | , |
lock_owner | |||
) |
LIST_HEAD | ( | owner_edge_list | , |
owner_edge | |||
) |
|
static |
STAILQ_HEAD | ( | lockdesclist | , |
lockdesc | |||
) |
TAILQ_HEAD | ( | owner_vertex_list | , |
owner_vertex | |||
) |
|
static |
Definition at line 208 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_countlocks(), and lf_init().
|
static |
Definition at line 207 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_alloc_lock(), lf_countlocks(), lf_free_lock(), and lf_init().
|
static |
Definition at line 206 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_init(), and lf_iteratelocks_sysid().
|
static |
Definition at line 205 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_init(), lf_iteratelocks_sysid(), and lf_purgelocks().
|
static |
Definition at line 269 of file kern_lockf.c.
Referenced by lf_add_edge(), lf_alloc_vertex(), lf_free_lock(), lf_init(), and lf_remove_edge().
|
static |
Definition at line 268 of file kern_lockf.c.
Referenced by graph_add_edge(), graph_alloc_vertex(), graph_free_vertex(), graph_remove_edge(), lf_cancel_lock(), lf_free_lock(), lf_init(), lf_purgelocks(), lf_setlock(), lf_split(), and lf_update_dependancies().