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 | lock_owner_chain |
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 ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_LOCKF, "lockf", "Byte-range locking structures") |
static void | lf_init (void *) |
static int | lf_hash_owner (caddr_t, struct vnode *, 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 lock_owner_chain | 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 194 of file kern_lockf.c.
#define NOLOCKF (struct lockf_entry *)0 |
Definition at line 104 of file kern_lockf.c.
#define OTHERS 0x2 |
Definition at line 106 of file kern_lockf.c.
#define SELF 0x1 |
Definition at line 105 of file kern_lockf.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 2232 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(), path, printf(), and set.
Referenced by lf_add_edge().
|
static |
Definition at line 2192 of file kern_lockf.c.
References set.
Referenced by graph_add_edge().
|
static |
Definition at line 2407 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 2211 of file kern_lockf.c.
References owner_graph::g_vertices, and set.
Referenced by graph_add_edge().
|
static |
Definition at line 2157 of file kern_lockf.c.
References owner_graph::g_gen.
Referenced by graph_add_edge().
|
static |
Definition at line 2115 of file kern_lockf.c.
References owner_graph::g_gen.
Referenced by graph_add_edge().
|
static |
Definition at line 2436 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 2461 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 2372 of file kern_lockf.c.
References free(), lf_owner_graph_lock, and printf().
Referenced by lf_remove_edge().
|
static |
Definition at line 1214 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 906 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 1054 of file kern_lockf.c.
References lf_add_edge(), lf_blocks(), lf_owner_graph_lock, and lf_remove_incoming().
Referenced by lf_setlock(), and lf_split().
|
static |
Definition at line 986 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 747 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 417 of file kern_lockf.c.
References flags, 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_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 871 of file kern_lockf.c.
References malloc().
Referenced by lf_add_edge().
|
static |
Definition at line 337 of file kern_lockf.c.
References lf_lock_owners, lock_owner_chain::lock, malloc(), and printf().
Referenced by lf_advlockasync(), and lf_split().
|
static |
Definition at line 892 of file kern_lockf.c.
References graph_alloc_vertex(), and lf_owner_graph.
Referenced by lf_add_edge().
|
static |
Definition at line 859 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 1604 of file kern_lockf.c.
References lf_cancel_lock().
Referenced by lf_advlockasync().
|
static |
Definition at line 1327 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 1550 of file kern_lockf.c.
References lf_activate_lock(), NOLOCKF, and panic().
Referenced by lf_advlockasync().
void lf_clearremotesys | ( | int | sysid | ) |
Definition at line 2009 of file kern_lockf.c.
References lf_clearremotesys_iterator(), and lf_iteratelocks_sysid().
Referenced by lf_advlockasync().
|
static |
Definition at line 2001 of file kern_lockf.c.
Referenced by lf_clearremotesys().
int lf_countlocks | ( | int | sysid | ) |
Definition at line 2017 of file kern_lockf.c.
References count, lf_lock_owners, and LOCK_OWNER_HASH_SIZE.
|
static |
|
static |
Definition at line 881 of file kern_lockf.c.
References free().
Referenced by lf_remove_edge().
|
static |
Definition at line 358 of file kern_lockf.c.
References free(), graph_free_vertex(), lf_lock_owners, lf_owner_graph, lf_owner_graph_lock, lock_owner_chain::lock, printf(), and vrele().
Referenced by lf_activate_lock(), lf_advlockasync(), lf_cancel_lock(), lf_purgelocks(), and lf_setlock().
|
static |
Definition at line 1657 of file kern_lockf.c.
References lf_blocks(), and NOLOCKF.
Referenced by lf_getlock(), and lf_setlock().
|
static |
Definition at line 1575 of file kern_lockf.c.
References lf_getblock().
Referenced by lf_advlockasync().
|
static |
Definition at line 304 of file kern_lockf.c.
References flags, and LOCK_OWNER_HASH_SIZE.
Referenced by lf_advlockasync().
|
static |
Definition at line 283 of file kern_lockf.c.
References graph_init(), lf_lock_owners, lf_lock_states, lf_lock_states_lock, lf_owner_graph, lf_owner_graph_lock, and LOCK_OWNER_HASH_SIZE.
|
static |
Definition at line 1094 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 849 of file kern_lockf.c.
Referenced by lf_advlockasync(), and lf_blocks().
|
static |
Definition at line 325 of file kern_lockf.c.
References flags.
Referenced by lf_advlockasync().
void lf_purgelocks | ( | struct vnode * | vp, |
struct lockf ** | statep | ||
) |
Definition at line 763 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 941 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 972 of file kern_lockf.c.
References lf_remove_edge().
Referenced by lf_add_incoming(), and lf_purgelocks().
|
static |
Definition at line 959 of file kern_lockf.c.
References lf_remove_edge().
Referenced by lf_add_outgoing(), lf_cancel_lock(), and lf_purgelocks().
|
static |
Definition at line 1189 of file kern_lockf.c.
References lf_update_dependancies().
Referenced by lf_activate_lock(), and lf_split().
|
static |
Definition at line 1173 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 1378 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 1809 of file kern_lockf.c.
References lf_add_incoming(), lf_alloc_lock(), lf_insert_lock(), lf_set_end(), lf_set_start(), and vref().
Referenced by lf_activate_lock().
|
static |
Definition at line 1148 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 1121 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 216 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_alloc_lock(), lf_countlocks(), lf_free_lock(), and lf_init().
|
static |
Definition at line 215 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_init(), and lf_iteratelocks_sysid().
|
static |
Definition at line 214 of file kern_lockf.c.
Referenced by lf_advlockasync(), lf_init(), lf_iteratelocks_sysid(), and lf_purgelocks().
|
static |
Definition at line 277 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 276 of file kern_lockf.c.
Referenced by graph_add_edge(), graph_alloc_vertex(), graph_free_vertex(), graph_remove_edge(), lf_add_incoming(), lf_cancel_lock(), lf_free_lock(), lf_init(), lf_purgelocks(), lf_setlock(), and lf_update_dependancies().