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