]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/dlm.h
ipv6: AF_INET6 link address family
[net-next-2.6.git] / include / linux / dlm.h
CommitLineData
e7fd4179
DT
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
0f8e0d9a 5** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
e7fd4179
DT
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.
10**
11*******************************************************************************
12******************************************************************************/
13
14#ifndef __DLM_DOT_H__
15#define __DLM_DOT_H__
16
17/*
18 * Interface to Distributed Lock Manager (DLM)
19 * routines and structures to use DLM lockspaces
20 */
21
d69a3ad6
JB
22/* Lock levels and flags are here */
23#include <linux/dlmconstants.h>
c1c76743 24#include <linux/types.h>
e7fd4179 25
e7fd4179
DT
26typedef void dlm_lockspace_t;
27
e7fd4179
DT
28/*
29 * Lock status block
30 *
31 * Use this structure to specify the contents of the lock value block. For a
32 * conversion request, this structure is used to specify the lock ID of the
33 * lock. DLM writes the status of the lock request and the lock ID assigned
34 * to the request in the lock status block.
35 *
36 * sb_lkid: the returned lock ID. It is set on new (non-conversion) requests.
37 * It is available when dlm_lock returns.
38 *
39 * sb_lvbptr: saves or returns the contents of the lock's LVB according to rules
40 * shown for the DLM_LKF_VALBLK flag.
41 *
42 * sb_flags: DLM_SBF_DEMOTED is returned if in the process of promoting a lock,
43 * it was first demoted to NL to avoid conversion deadlock.
44 * DLM_SBF_VALNOTVALID is returned if the resource's LVB is marked invalid.
45 *
46 * sb_status: the returned status of the lock request set prior to AST
47 * execution. Possible return values:
48 *
49 * 0 if lock request was successful
50 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
e7fd4179
DT
51 * -DLM_EUNLOCK if unlock request was successful
52 * -DLM_ECANCEL if a cancel completed successfully
269cddd4
SW
53 * -EDEADLK if a deadlock was detected
54 * -ETIMEDOUT if the lock request was canceled due to a timeout
e7fd4179
DT
55 */
56
57#define DLM_SBF_DEMOTED 0x01
58#define DLM_SBF_VALNOTVALID 0x02
59#define DLM_SBF_ALTMODE 0x04
60
61struct dlm_lksb {
62 int sb_status;
c1c76743 63 __u32 sb_lkid;
e7fd4179
DT
64 char sb_flags;
65 char * sb_lvbptr;
66};
67
0f8e0d9a
DT
68/* dlm_new_lockspace() flags */
69
3ae1acf9
DT
70#define DLM_LSFL_NODIR 0x00000001
71#define DLM_LSFL_TIMEWARN 0x00000002
44f487a5 72#define DLM_LSFL_FS 0x00000004
0f8e0d9a 73#define DLM_LSFL_NEWEXCL 0x00000008
e7fd4179
DT
74
75#ifdef __KERNEL__
76
e7fd4179
DT
77/*
78 * dlm_new_lockspace
79 *
80 * Starts a lockspace with the given name. If the named lockspace exists in
81 * the cluster, the calling node joins it.
82 */
83
08ce4c91
GU
84int dlm_new_lockspace(const char *name, int namelen,
85 dlm_lockspace_t **lockspace, uint32_t flags, int lvblen);
e7fd4179
DT
86
87/*
88 * dlm_release_lockspace
89 *
90 * Stop a lockspace.
91 */
92
93int dlm_release_lockspace(dlm_lockspace_t *lockspace, int force);
94
95/*
96 * dlm_lock
97 *
98 * Make an asyncronous request to acquire or convert a lock on a named
99 * resource.
100 *
101 * lockspace: context for the request
102 * mode: the requested mode of the lock (DLM_LOCK_)
103 * lksb: lock status block for input and async return values
104 * flags: input flags (DLM_LKF_)
105 * name: name of the resource to lock, can be binary
106 * namelen: the length in bytes of the resource name (MAX_RESNAME_LEN)
107 * parent: the lock ID of a parent lock or 0 if none
108 * lockast: function DLM executes when it completes processing the request
109 * astarg: argument passed to lockast and bast functions
110 * bast: function DLM executes when this lock later blocks another request
111 *
112 * Returns:
113 * 0 if request is successfully queued for processing
114 * -EINVAL if any input parameters are invalid
115 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
116 * -ENOMEM if there is no memory to process request
117 * -ENOTCONN if there is a communication error
118 *
119 * If the call to dlm_lock returns an error then the operation has failed and
120 * the AST routine will not be called. If dlm_lock returns 0 it is still
121 * possible that the lock operation will fail. The AST routine will be called
122 * when the locking is complete and the status is returned in the lksb.
123 *
124 * If the AST routines or parameter are passed to a conversion operation then
125 * they will overwrite those values that were passed to a previous dlm_lock
126 * call.
127 *
128 * AST routines should not block (at least not for long), but may make
129 * any locking calls they please.
130 */
131
132int dlm_lock(dlm_lockspace_t *lockspace,
133 int mode,
134 struct dlm_lksb *lksb,
135 uint32_t flags,
136 void *name,
137 unsigned int namelen,
138 uint32_t parent_lkid,
139 void (*lockast) (void *astarg),
140 void *astarg,
3bcd3687 141 void (*bast) (void *astarg, int mode));
e7fd4179
DT
142
143/*
144 * dlm_unlock
145 *
146 * Asynchronously release a lock on a resource. The AST routine is called
147 * when the resource is successfully unlocked.
148 *
149 * lockspace: context for the request
150 * lkid: the lock ID as returned in the lksb
151 * flags: input flags (DLM_LKF_)
152 * lksb: if NULL the lksb parameter passed to last lock request is used
153 * astarg: the arg used with the completion ast for the unlock
154 *
155 * Returns:
156 * 0 if request is successfully queued for processing
157 * -EINVAL if any input parameters are invalid
158 * -ENOTEMPTY if the lock still has sublocks
159 * -EBUSY if the lock is waiting for a remote lock operation
160 * -ENOTCONN if there is a communication error
161 */
162
163int dlm_unlock(dlm_lockspace_t *lockspace,
164 uint32_t lkid,
165 uint32_t flags,
166 struct dlm_lksb *lksb,
167 void *astarg);
168
169#endif /* __KERNEL__ */
170
171#endif /* __DLM_DOT_H__ */
172