flock_impl.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FLOCK_IMPL_H
#define _SYS_FLOCK_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
struct edge {
};
struct lock_descriptor {
int l_index; /* used for barrier count */
int l_type; /* type of lock */
int l_state; /* state described below */
int l_color; /* color used for graph alg */
int pvertex; /* index to proc vertex */
int l_status; /* status described below */
};
typedef struct lock_descriptor lock_descriptor_t;
/*
* Each graph holds locking information for some number of vnodes. The
* active and sleeping lists are circular, with a dummy head element.
*/
struct graph {
struct lock_descriptor active_locks;
struct lock_descriptor sleeping_locks;
int index; /* index of this graph into the hash table */
int mark; /* used for coloring the graph */
};
/*
* The possible states a lock can be in. These states are stored in the
* 'l_status' member of the 'lock_descriptor_t' structure. All locks start
* life in the INITIAL state, and end up in the DEAD state. Possible state
* transitions are :
*
* INITIAL--> START --> ACTIVE --> DEAD
*
* --> DEAD
*
* --> ACTIVE --> DEAD (new locks from flk_relation)
*
* --> SLEEPING --> GRANTED --> START --> ACTIVE --> DEAD
*
* --> INTR --> DEAD
*
* --> CANCELLED --> DEAD
*
* --> INTR --> DEAD
*
* --> INTR --> DEAD
*
* --> CANCELLED --> DEAD
*
* --> INTR --> DEAD
*
* Lock transitions are done in the following functions:
* --> INITIAL flk_get_lock(), reclock()
* --> START flk_execute_request()
* --> ACTIVE flk_insert_active_lock()
* --> SLEEPING flk_insert_sleeping_lock()
* --> GRANTED GRANT_WAKEUP
* --> INTERRUPTED INTERRUPT_WAKEUP
* --> CANCELLED CANCEL_WAKEUP
* --> DEAD reclock(), flk_delete_active_lock(), and
* flk_cancel_sleeping_lock()
*/
/* flags defining state of locks */
/*
* The LLM design has been modified so that lock states are now stored
* in the l_status field of lock_descriptor_t. The l_state field is
* currently preserved for binary compatibility, but may be modified or
* removed in a minor release of Solaris. Note that both of these
* fields (and the rest of the lock_descriptor_t structure) are private
* to the implementation of the lock manager and should not be used
* externally.
*/
/* Clustering: flag for PXFS locks */
#define HASH_SIZE 32
/* extern definitions */
extern struct kmem_cache *flk_edge_cache;
/* Clustering: functions called by PXFS */
int flk_execute_request(lock_descriptor_t *);
void flk_cancel_sleeping_lock(lock_descriptor_t *, int);
void flk_set_state(lock_descriptor_t *, int);
/* flags used for readability in flock.c */
#define FLK_USE_GRAPH 0 /* don't initialize the lock_graph */
#define NO_COLOR 0 /* vertex is not colored */
#define NO_CHECK_CYCLE 0 /* don't mark vertex's in flk_add_edge */
/*
* stack data structure and operations
*/
{ \
}
{ \
; \
}
#define IS_WILLING_TO_SLEEP(lock) \
/* Clustering: Macro for PXFS locks */
/*
* "local" requests don't involve the NFS lock manager in any way.
* "remote" requests can be on the server (requests from a remote client),
* in which case they should be associated with a local vnode (UFS, tmpfs,
* etc.). These requests are flagged with LOCKMGR_LOCK and are made using
* kernel service threads. Remote requests can also be on an NFS client,
* because the NFS lock manager uses local locking for some of its
* bookkeeping. These requests are made by regular user processes.
*/
/* Clustering: Return value for blocking PXFS locks */
/*
* For PXFS locks, reclock() will return this error code for requests that
* need to block
*/
#define PXFS_LOCK_BLOCKED -1
/* Clustering: PXFS callback function */
/*
* This function is a callback from the LLM into the PXFS server module. It
* is initialized as a weak stub, and is functional when the pxfs server module
* is loaded.
*/
#define IN_LIST_REMOVE(ep) \
{ \
}
#define ADJ_LIST_REMOVE(ep) \
{ \
}
#define NOT_BLOCKED(lock) \
#define GRANT_WAKEUP(lock) \
{ \
/* \
* Clustering: PXFS locks do not sleep in the LLM, \
* so there is no need to signal them \
*/ \
} \
}
#define CANCEL_WAKEUP(lock) \
{ \
/* \
* Clustering: PXFS locks do not sleep in the LLM, \
* so there is no need to signal them \
*/ \
} \
}
#define INTERRUPT_WAKEUP(lock) \
{ \
/* \
* Clustering: PXFS locks do not sleep in the LLM, \
* so there is no need to signal them \
*/ \
} \
}
#define REMOVE_SLEEP_QUEUE(lock) \
{ \
}
#define NO_DEPENDENTS(lock) \
{ \
}
#define IN_ADJ_INIT(lock) \
{ \
}
{ \
}
/*
* Clustering
*/
/* Routines to set and get the NLM state in a lock request */
/*
* NLM registry abstraction:
* Abstraction overview:
* This registry keeps track of the NLM servers via their nlmids
* that have requested locks at the LLM this registry is associated
* with.
*/
/* Routines to manipulate the NLM registry object state */
/* Indicates the effect of executing a request on the existing locks */
/* proc graph definitions */
/*
* Proc graph is the global process graph that maintains information
* about the dependencies between processes. An edge is added between two
* processes represented by proc_vertex's A and B, iff there exists l1
* owned by process A in any of the lock_graph's dependent on l2
* (thus having an edge to l2) owned by process B.
*/
struct proc_vertex {
long sysid; /* sysid of the process */
int incount; /* Number of inedges to this process */
int atime; /* used for cycle detection algorithm */
int dtime; /* used for cycle detection algorithm */
int index; /* index into the array of proc_graph vertices */
};
typedef struct proc_vertex proc_vertex_t;
struct proc_edge {
int refcount; /* reference count of this edge */
};
typedef struct proc_edge proc_edge_t;
#define PROC_CHUNK 100
struct proc_graph {
int gcount; /* list size */
int free; /* number of free slots in the list */
int mark; /* used for graph coloring */
};
typedef struct proc_graph proc_graph_t;
extern struct proc_graph pgraph;
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FLOCK_IMPL_H */