1
2
3
4
5
6
7
8
9
10
11
12 #ifndef DLMAPI_H
13 #define DLMAPI_H
14
15 struct dlm_lock;
16 struct dlm_ctxt;
17
18
19 enum dlm_status {
20 DLM_NORMAL = 0,
21 DLM_GRANTED,
22 DLM_DENIED,
23 DLM_DENIED_NOLOCKS,
24 DLM_WORKING,
25 DLM_BLOCKED,
26 DLM_BLOCKED_ORPHAN,
27 DLM_DENIED_GRACE_PERIOD,
28 DLM_SYSERR,
29 DLM_NOSUPPORT,
30 DLM_CANCELGRANT,
31 DLM_IVLOCKID,
32 DLM_SYNC,
33 DLM_BADTYPE,
34 DLM_BADRESOURCE,
35 DLM_MAXHANDLES,
36 DLM_NOCLINFO,
37 DLM_NOLOCKMGR,
38 DLM_NOPURGED,
39 DLM_BADARGS,
40 DLM_VOID,
41 DLM_NOTQUEUED,
42 DLM_IVBUFLEN,
43 DLM_CVTUNGRANT,
44 DLM_BADPARAM,
45 DLM_VALNOTVALID,
46 DLM_REJECTED,
47 DLM_ABORT,
48 DLM_CANCEL,
49 DLM_IVRESHANDLE,
50 DLM_DEADLOCK,
51 DLM_DENIED_NOASTS,
52 DLM_FORWARD,
53 DLM_TIMEOUT,
54 DLM_IVGROUPID,
55 DLM_VERS_CONFLICT,
56 DLM_BAD_DEVICE_PATH,
57 DLM_NO_DEVICE_PERMISSION,
58 DLM_NO_CONTROL_DEVICE,
59
60 DLM_RECOVERING,
61
62 DLM_MIGRATING,
63
64 DLM_MAXSTATS,
65 };
66
67
68 const char *dlm_errmsg(enum dlm_status err);
69
70 const char *dlm_errname(enum dlm_status err);
71
72
73
74
75
76 #define dlm_error(st) do { \
77 if ((st) != DLM_RECOVERING && \
78 (st) != DLM_MIGRATING && \
79 (st) != DLM_FORWARD) \
80 mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st))); \
81 } while (0)
82
83 #define DLM_LKSB_UNUSED1 0x01
84 #define DLM_LKSB_PUT_LVB 0x02
85 #define DLM_LKSB_GET_LVB 0x04
86 #define DLM_LKSB_UNUSED2 0x08
87 #define DLM_LKSB_UNUSED3 0x10
88 #define DLM_LKSB_UNUSED4 0x20
89 #define DLM_LKSB_UNUSED5 0x40
90 #define DLM_LKSB_UNUSED6 0x80
91
92 #define DLM_LVB_LEN 64
93
94
95
96 struct dlm_lockstatus {
97 enum dlm_status status;
98 u32 flags;
99 struct dlm_lock *lockid;
100 char lvb[DLM_LVB_LEN];
101 };
102
103
104 #define LKM_IVMODE (-1)
105 #define LKM_NLMODE 0
106 #define LKM_CRMODE 1
107 #define LKM_CWMODE 2
108 #define LKM_PRMODE 3
109 #define LKM_PWMODE 4
110 #define LKM_EXMODE 5
111 #define LKM_MAXMODE 5
112 #define LKM_MODEMASK 0xff
113
114
115
116
117
118 #define LKM_ORPHAN 0x00000010
119 #define LKM_PARENTABLE 0x00000020
120 #define LKM_BLOCK 0x00000040
121 #define LKM_LOCAL 0x00000080
122 #define LKM_VALBLK 0x00000100
123 #define LKM_NOQUEUE 0x00000200
124 #define LKM_CONVERT 0x00000400
125 #define LKM_NODLCKWT 0x00000800
126 #define LKM_UNLOCK 0x00001000
127 #define LKM_CANCEL 0x00002000
128 #define LKM_DEQALL 0x00004000
129 #define LKM_INVVALBLK 0x00008000
130 #define LKM_SYNCSTS 0x00010000
131 #define LKM_TIMEOUT 0x00020000
132 #define LKM_SNGLDLCK 0x00040000
133 #define LKM_FINDLOCAL 0x00080000
134 #define LKM_PROC_OWNED 0x00100000
135 #define LKM_XID 0x00200000
136 #define LKM_XID_CONFLICT 0x00400000
137 #define LKM_FORCE 0x00800000
138 #define LKM_REVVALBLK 0x01000000
139
140
141 #define LKM_UNUSED1 0x00000001
142 #define LKM_UNUSED2 0x00000002
143 #define LKM_UNUSED3 0x00000004
144 #define LKM_UNUSED4 0x00000008
145 #define LKM_UNUSED5 0x02000000
146 #define LKM_UNUSED6 0x04000000
147 #define LKM_UNUSED7 0x08000000
148
149
150
151 #define LKM_MIGRATION 0x10000000
152
153 #define LKM_PUT_LVB 0x20000000
154
155 #define LKM_GET_LVB 0x40000000
156
157 #define LKM_RECOVERY 0x80000000
158
159
160
161 typedef void (dlm_astlockfunc_t)(void *);
162 typedef void (dlm_bastlockfunc_t)(void *, int);
163 typedef void (dlm_astunlockfunc_t)(void *, enum dlm_status);
164
165 enum dlm_status dlmlock(struct dlm_ctxt *dlm,
166 int mode,
167 struct dlm_lockstatus *lksb,
168 int flags,
169 const char *name,
170 int namelen,
171 dlm_astlockfunc_t *ast,
172 void *data,
173 dlm_bastlockfunc_t *bast);
174
175 enum dlm_status dlmunlock(struct dlm_ctxt *dlm,
176 struct dlm_lockstatus *lksb,
177 int flags,
178 dlm_astunlockfunc_t *unlockast,
179 void *data);
180
181 struct dlm_protocol_version {
182 u8 pv_major;
183 u8 pv_minor;
184 };
185 struct dlm_ctxt * dlm_register_domain(const char *domain, u32 key,
186 struct dlm_protocol_version *fs_proto);
187
188 void dlm_unregister_domain(struct dlm_ctxt *dlm);
189
190 void dlm_print_one_lock(struct dlm_lock *lockid);
191
192 typedef void (dlm_eviction_func)(int, void *);
193 struct dlm_eviction_cb {
194 struct list_head ec_item;
195 dlm_eviction_func *ec_func;
196 void *ec_data;
197 };
198 void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb,
199 dlm_eviction_func *f,
200 void *data);
201 void dlm_register_eviction_cb(struct dlm_ctxt *dlm,
202 struct dlm_eviction_cb *cb);
203 void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb);
204
205 #endif