FreeBSD/sys/kern/kern_lockf.c
/*
 * Attempt to record an edge from lock x to lock y. Return EDEADLK if
 * the new edge would cause a cycle in the owner graph.
 */
Attempt to record an edge from lock x to lock y. Return EDEADLK if
the new edge would cause a cycle in the owner graph.
Attempt to record an edge from lock x to lock y . Return EDEADLK if the new edge would cause a cycle in the owner graph .
static int
lf_add_edge(struct lockf_entry *x, struct lockf_entry *y)
{
	struct owner_graph *g = &lf_owner_graph;
	struct lockf_edge *e;
	int error;
#ifdef INVARIANTS
	LIST_FOREACH(e, &x->lf_outedges, le_outlink)
		KASSERT(e->le_to != y, ("adding lock edge twice"));
#endif
	lf_alloc_vertex(x);
	lf_alloc_vertex(y);
	error = graph_add_edge(g, x->lf_owner->lo_vertex,
	    y->lf_owner->lo_vertex);
	if (error)
		return (error);
	e = lf_alloc_edge();
	LIST_INSERT_HEAD(&x->lf_outedges, e, le_outlink);
	LIST_INSERT_HEAD(&y->lf_inedges, e, le_inlink);
	e->le_from = x;
	e->le_to = y;
	return (0);
}
static int lf_add_edge ( struct lockf_entry * x , struct lockf_entry * y ) { struct owner_graph * g = & lf_owner_graph ; struct lockf_edge * e ; int error ; #ifdef INVARIANTS LIST_FOREACH ( e , & x -> lf_outedges , le_outlink ) KASSERT ( e -> le_to != y , ( " " ) ) ; #endif lf_alloc_vertex ( x ) ; lf_alloc_vertex ( y ) ; error = graph_add_edge ( g , x -> lf_owner -> lo_vertex , y -> lf_owner -> lo_vertex ) ; if ( error ) return ( error ) ; e = lf_alloc_edge ( ) ; LIST_INSERT_HEAD ( & x -> lf_outedges , e , le_outlink ) ; LIST_INSERT_HEAD ( & y -> lf_inedges , e , le_inlink ) ; e -> le_from = x ; e -> le_to = y ; return ( 0 ) ; }
Attempt to record an edge from lock x to lock y.
Attempt to record an edge from lock x to lock y .
/*
	 * Make sure the two owners have entries in the owner graph.
	 */