[ALSA] Clean up duplicate includes in sound/core/
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / dlm.h
blobbe9d278761e0ed5ddbb87653d64f34e9108956cb
1 /******************************************************************************
2 *******************************************************************************
3 **
4 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5 ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
6 **
7 ** This copyrighted material is made available to anyone wishing to use,
8 ** modify, copy, or redistribute it subject to the terms and conditions
9 ** of the GNU General Public License v.2.
11 *******************************************************************************
12 ******************************************************************************/
14 #ifndef __DLM_DOT_H__
15 #define __DLM_DOT_H__
18 * Interface to Distributed Lock Manager (DLM)
19 * routines and structures to use DLM lockspaces
23 * Lock Modes
26 #define DLM_LOCK_IV -1 /* invalid */
27 #define DLM_LOCK_NL 0 /* null */
28 #define DLM_LOCK_CR 1 /* concurrent read */
29 #define DLM_LOCK_CW 2 /* concurrent write */
30 #define DLM_LOCK_PR 3 /* protected read */
31 #define DLM_LOCK_PW 4 /* protected write */
32 #define DLM_LOCK_EX 5 /* exclusive */
35 * Maximum size in bytes of a dlm_lock name
38 #define DLM_RESNAME_MAXLEN 64
41 * Flags to dlm_lock
43 * DLM_LKF_NOQUEUE
45 * Do not queue the lock request on the wait queue if it cannot be granted
46 * immediately. If the lock cannot be granted because of this flag, DLM will
47 * either return -EAGAIN from the dlm_lock call or will return 0 from
48 * dlm_lock and -EAGAIN in the lock status block when the AST is executed.
50 * DLM_LKF_CANCEL
52 * Used to cancel a pending lock request or conversion. A converting lock is
53 * returned to its previously granted mode.
55 * DLM_LKF_CONVERT
57 * Indicates a lock conversion request. For conversions the name and namelen
58 * are ignored and the lock ID in the LKSB is used to identify the lock.
60 * DLM_LKF_VALBLK
62 * Requests DLM to return the current contents of the lock value block in the
63 * lock status block. When this flag is set in a lock conversion from PW or EX
64 * modes, DLM assigns the value specified in the lock status block to the lock
65 * value block of the lock resource. The LVB is a DLM_LVB_LEN size array
66 * containing application-specific information.
68 * DLM_LKF_QUECVT
70 * Force a conversion request to be queued, even if it is compatible with
71 * the granted modes of other locks on the same resource.
73 * DLM_LKF_IVVALBLK
75 * Invalidate the lock value block.
77 * DLM_LKF_CONVDEADLK
79 * Allows the dlm to resolve conversion deadlocks internally by demoting the
80 * granted mode of a converting lock to NL. The DLM_SBF_DEMOTED flag is
81 * returned for a conversion that's been effected by this.
83 * DLM_LKF_PERSISTENT
85 * Only relevant to locks originating in userspace. A persistent lock will not
86 * be removed if the process holding the lock exits.
88 * DLM_LKF_NODLCKWT
90 * Do not cancel the lock if it gets into conversion deadlock.
91 * Exclude this lock from being monitored due to DLM_LSFL_TIMEWARN.
93 * DLM_LKF_NODLCKBLK
95 * net yet implemented
97 * DLM_LKF_EXPEDITE
99 * Used only with new requests for NL mode locks. Tells the lock manager
100 * to grant the lock, ignoring other locks in convert and wait queues.
102 * DLM_LKF_NOQUEUEBAST
104 * Send blocking AST's before returning -EAGAIN to the caller. It is only
105 * used along with the NOQUEUE flag. Blocking AST's are not sent for failed
106 * NOQUEUE requests otherwise.
108 * DLM_LKF_HEADQUE
110 * Add a lock to the head of the convert or wait queue rather than the tail.
112 * DLM_LKF_NOORDER
114 * Disregard the standard grant order rules and grant a lock as soon as it
115 * is compatible with other granted locks.
117 * DLM_LKF_ORPHAN
119 * not yet implemented
121 * DLM_LKF_ALTPR
123 * If the requested mode cannot be granted immediately, try to grant the lock
124 * in PR mode instead. If this alternate mode is granted instead of the
125 * requested mode, DLM_SBF_ALTMODE is returned in the lksb.
127 * DLM_LKF_ALTCW
129 * The same as ALTPR, but the alternate mode is CW.
131 * DLM_LKF_FORCEUNLOCK
133 * Unlock the lock even if it is converting or waiting or has sublocks.
134 * Only really for use by the userland device.c code.
138 #define DLM_LKF_NOQUEUE 0x00000001
139 #define DLM_LKF_CANCEL 0x00000002
140 #define DLM_LKF_CONVERT 0x00000004
141 #define DLM_LKF_VALBLK 0x00000008
142 #define DLM_LKF_QUECVT 0x00000010
143 #define DLM_LKF_IVVALBLK 0x00000020
144 #define DLM_LKF_CONVDEADLK 0x00000040
145 #define DLM_LKF_PERSISTENT 0x00000080
146 #define DLM_LKF_NODLCKWT 0x00000100
147 #define DLM_LKF_NODLCKBLK 0x00000200
148 #define DLM_LKF_EXPEDITE 0x00000400
149 #define DLM_LKF_NOQUEUEBAST 0x00000800
150 #define DLM_LKF_HEADQUE 0x00001000
151 #define DLM_LKF_NOORDER 0x00002000
152 #define DLM_LKF_ORPHAN 0x00004000
153 #define DLM_LKF_ALTPR 0x00008000
154 #define DLM_LKF_ALTCW 0x00010000
155 #define DLM_LKF_FORCEUNLOCK 0x00020000
156 #define DLM_LKF_TIMEOUT 0x00040000
159 * Some return codes that are not in errno.h
162 #define DLM_ECANCEL 0x10001
163 #define DLM_EUNLOCK 0x10002
165 typedef void dlm_lockspace_t;
168 * Lock status block
170 * Use this structure to specify the contents of the lock value block. For a
171 * conversion request, this structure is used to specify the lock ID of the
172 * lock. DLM writes the status of the lock request and the lock ID assigned
173 * to the request in the lock status block.
175 * sb_lkid: the returned lock ID. It is set on new (non-conversion) requests.
176 * It is available when dlm_lock returns.
178 * sb_lvbptr: saves or returns the contents of the lock's LVB according to rules
179 * shown for the DLM_LKF_VALBLK flag.
181 * sb_flags: DLM_SBF_DEMOTED is returned if in the process of promoting a lock,
182 * it was first demoted to NL to avoid conversion deadlock.
183 * DLM_SBF_VALNOTVALID is returned if the resource's LVB is marked invalid.
185 * sb_status: the returned status of the lock request set prior to AST
186 * execution. Possible return values:
188 * 0 if lock request was successful
189 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
190 * -ENOMEM if there is no memory to process request
191 * -EINVAL if there are invalid parameters
192 * -DLM_EUNLOCK if unlock request was successful
193 * -DLM_ECANCEL if a cancel completed successfully
196 #define DLM_SBF_DEMOTED 0x01
197 #define DLM_SBF_VALNOTVALID 0x02
198 #define DLM_SBF_ALTMODE 0x04
200 struct dlm_lksb {
201 int sb_status;
202 uint32_t sb_lkid;
203 char sb_flags;
204 char * sb_lvbptr;
207 #define DLM_LSFL_NODIR 0x00000001
208 #define DLM_LSFL_TIMEWARN 0x00000002
209 #define DLM_LSFL_FS 0x00000004
211 #ifdef __KERNEL__
214 * dlm_new_lockspace
216 * Starts a lockspace with the given name. If the named lockspace exists in
217 * the cluster, the calling node joins it.
220 int dlm_new_lockspace(char *name, int namelen, dlm_lockspace_t **lockspace,
221 uint32_t flags, int lvblen);
224 * dlm_release_lockspace
226 * Stop a lockspace.
229 int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
232 * dlm_lock
234 * Make an asyncronous request to acquire or convert a lock on a named
235 * resource.
237 * lockspace: context for the request
238 * mode: the requested mode of the lock (DLM_LOCK_)
239 * lksb: lock status block for input and async return values
240 * flags: input flags (DLM_LKF_)
241 * name: name of the resource to lock, can be binary
242 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
243 * parent: the lock ID of a parent lock or 0 if none
244 * lockast: function DLM executes when it completes processing the request
245 * astarg: argument passed to lockast and bast functions
246 * bast: function DLM executes when this lock later blocks another request
248 * Returns:
249 * 0 if request is successfully queued for processing
250 * -EINVAL if any input parameters are invalid
251 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
252 * -ENOMEM if there is no memory to process request
253 * -ENOTCONN if there is a communication error
255 * If the call to dlm_lock returns an error then the operation has failed and
256 * the AST routine will not be called. If dlm_lock returns 0 it is still
257 * possible that the lock operation will fail. The AST routine will be called
258 * when the locking is complete and the status is returned in the lksb.
260 * If the AST routines or parameter are passed to a conversion operation then
261 * they will overwrite those values that were passed to a previous dlm_lock
262 * call.
264 * AST routines should not block (at least not for long), but may make
265 * any locking calls they please.
268 int dlm_lock(dlm_lockspace_t *lockspace,
269 int mode,
270 struct dlm_lksb *lksb,
271 uint32_t flags,
272 void *name,
273 unsigned int namelen,
274 uint32_t parent_lkid,
275 void (*lockast) (void *astarg),
276 void *astarg,
277 void (*bast) (void *astarg, int mode));
280 * dlm_unlock
282 * Asynchronously release a lock on a resource. The AST routine is called
283 * when the resource is successfully unlocked.
285 * lockspace: context for the request
286 * lkid: the lock ID as returned in the lksb
287 * flags: input flags (DLM_LKF_)
288 * lksb: if NULL the lksb parameter passed to last lock request is used
289 * astarg: the arg used with the completion ast for the unlock
291 * Returns:
292 * 0 if request is successfully queued for processing
293 * -EINVAL if any input parameters are invalid
294 * -ENOTEMPTY if the lock still has sublocks
295 * -EBUSY if the lock is waiting for a remote lock operation
296 * -ENOTCONN if there is a communication error
299 int dlm_unlock(dlm_lockspace_t *lockspace,
300 uint32_t lkid,
301 uint32_t flags,
302 struct dlm_lksb *lksb,
303 void *astarg);
305 #endif /* __KERNEL__ */
307 #endif /* __DLM_DOT_H__ */