[GFS2] Remove unused sync_lvb code from lock modules
[pandora-kernel.git] / fs / gfs2 / lm_interface.h
1 /*
2  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
3  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
4  *
5  * This copyrighted material is made available to anyone wishing to use,
6  * modify, copy, or redistribute it subject to the terms and conditions
7  * of the GNU General Public License version 2.
8  */
9
10 #ifndef __LM_INTERFACE_DOT_H__
11 #define __LM_INTERFACE_DOT_H__
12
13 /*
14  * Opaque handles represent the lock module's lockspace structure, the lock
15  * module's lock structures, and GFS's file system (superblock) structure.
16  */
17
18 typedef void lm_lockspace_t;
19 typedef void lm_lock_t;
20 struct gfs2_sbd;
21
22 typedef void (*lm_callback_t) (struct gfs2_sbd *sdp, unsigned int type, void *data);
23
24 /*
25  * lm_mount() flags
26  *
27  * LM_MFLAG_SPECTATOR
28  * GFS is asking to join the filesystem's lockspace, but it doesn't want to
29  * modify the filesystem.  The lock module shouldn't assign a journal to the FS
30  * mount.  It shouldn't send recovery callbacks to the FS mount.  If the node
31  * dies or withdraws, all locks can be wiped immediately.
32  */
33
34 #define LM_MFLAG_SPECTATOR      0x00000001
35
36 /*
37  * lm_lockstruct flags
38  *
39  * LM_LSFLAG_LOCAL
40  * The lock_nolock module returns LM_LSFLAG_LOCAL to GFS, indicating that GFS
41  * can make single-node optimizations.
42  */
43
44 #define LM_LSFLAG_LOCAL         0x00000001
45
46 /*
47  * lm_lockname types
48  */
49
50 #define LM_TYPE_RESERVED        0x00
51 #define LM_TYPE_NONDISK         0x01
52 #define LM_TYPE_INODE           0x02
53 #define LM_TYPE_RGRP            0x03
54 #define LM_TYPE_META            0x04
55 #define LM_TYPE_IOPEN           0x05
56 #define LM_TYPE_FLOCK           0x06
57 #define LM_TYPE_PLOCK           0x07
58 #define LM_TYPE_QUOTA           0x08
59 #define LM_TYPE_JOURNAL         0x09
60
61 /*
62  * lm_lock() states
63  *
64  * SHARED is compatible with SHARED, not with DEFERRED or EX.
65  * DEFERRED is compatible with DEFERRED, not with SHARED or EX.
66  */
67
68 #define LM_ST_UNLOCKED          0
69 #define LM_ST_EXCLUSIVE         1
70 #define LM_ST_DEFERRED          2
71 #define LM_ST_SHARED            3
72
73 /*
74  * lm_lock() flags
75  *
76  * LM_FLAG_TRY
77  * Don't wait to acquire the lock if it can't be granted immediately.
78  *
79  * LM_FLAG_TRY_1CB
80  * Send one blocking callback if TRY is set and the lock is not granted.
81  *
82  * LM_FLAG_NOEXP
83  * GFS sets this flag on lock requests it makes while doing journal recovery.
84  * These special requests should not be blocked due to the recovery like
85  * ordinary locks would be.
86  *
87  * LM_FLAG_ANY
88  * A SHARED request may also be granted in DEFERRED, or a DEFERRED request may
89  * also be granted in SHARED.  The preferred state is whichever is compatible
90  * with other granted locks, or the specified state if no other locks exist.
91  *
92  * LM_FLAG_PRIORITY
93  * Override fairness considerations.  Suppose a lock is held in a shared state
94  * and there is a pending request for the deferred state.  A shared lock
95  * request with the priority flag would be allowed to bypass the deferred
96  * request and directly join the other shared lock.  A shared lock request
97  * without the priority flag might be forced to wait until the deferred
98  * requested had acquired and released the lock.
99  */
100
101 #define LM_FLAG_TRY             0x00000001
102 #define LM_FLAG_TRY_1CB         0x00000002
103 #define LM_FLAG_NOEXP           0x00000004
104 #define LM_FLAG_ANY             0x00000008
105 #define LM_FLAG_PRIORITY        0x00000010
106
107 /*
108  * lm_lock() and lm_async_cb return flags
109  *
110  * LM_OUT_ST_MASK
111  * Masks the lower two bits of lock state in the returned value.
112  *
113  * LM_OUT_CACHEABLE
114  * The lock hasn't been released so GFS can continue to cache data for it.
115  *
116  * LM_OUT_CANCELED
117  * The lock request was canceled.
118  *
119  * LM_OUT_ASYNC
120  * The result of the request will be returned in an LM_CB_ASYNC callback.
121  */
122
123 #define LM_OUT_ST_MASK          0x00000003
124 #define LM_OUT_CACHEABLE        0x00000004
125 #define LM_OUT_CANCELED         0x00000008
126 #define LM_OUT_ASYNC            0x00000080
127 #define LM_OUT_ERROR            0x00000100
128
129 /*
130  * lm_callback_t types
131  *
132  * LM_CB_NEED_E LM_CB_NEED_D LM_CB_NEED_S
133  * Blocking callback, a remote node is requesting the given lock in
134  * EXCLUSIVE, DEFERRED, or SHARED.
135  *
136  * LM_CB_NEED_RECOVERY
137  * The given journal needs to be recovered.
138  *
139  * LM_CB_DROPLOCKS
140  * Reduce the number of cached locks.
141  *
142  * LM_CB_ASYNC
143  * The given lock has been granted.
144  */
145
146 #define LM_CB_NEED_E            257
147 #define LM_CB_NEED_D            258
148 #define LM_CB_NEED_S            259
149 #define LM_CB_NEED_RECOVERY     260
150 #define LM_CB_DROPLOCKS         261
151 #define LM_CB_ASYNC             262
152
153 /*
154  * lm_recovery_done() messages
155  */
156
157 #define LM_RD_GAVEUP            308
158 #define LM_RD_SUCCESS           309
159
160
161 struct lm_lockname {
162         u64 ln_number;
163         unsigned int ln_type;
164 };
165
166 #define lm_name_equal(name1, name2) \
167         (((name1)->ln_number == (name2)->ln_number) && \
168          ((name1)->ln_type == (name2)->ln_type)) \
169
170 struct lm_async_cb {
171         struct lm_lockname lc_name;
172         int lc_ret;
173 };
174
175 struct lm_lockstruct;
176
177 struct lm_lockops {
178         char lm_proto_name[256];
179
180         /*
181          * Mount/Unmount
182          */
183
184         int (*lm_mount) (char *table_name, char *host_data,
185                          lm_callback_t cb, struct gfs2_sbd *sdp,
186                          unsigned int min_lvb_size, int flags,
187                          struct lm_lockstruct *lockstruct,
188                          struct kobject *fskobj);
189
190         void (*lm_others_may_mount) (lm_lockspace_t *lockspace);
191
192         void (*lm_unmount) (lm_lockspace_t *lockspace);
193
194         void (*lm_withdraw) (lm_lockspace_t *lockspace);
195
196         /*
197          * Lock oriented operations
198          */
199
200         int (*lm_get_lock) (lm_lockspace_t *lockspace,
201                             struct lm_lockname *name, lm_lock_t **lockp);
202
203         void (*lm_put_lock) (lm_lock_t *lock);
204
205         unsigned int (*lm_lock) (lm_lock_t *lock, unsigned int cur_state,
206                                  unsigned int req_state, unsigned int flags);
207
208         unsigned int (*lm_unlock) (lm_lock_t *lock, unsigned int cur_state);
209
210         void (*lm_cancel) (lm_lock_t *lock);
211
212         int (*lm_hold_lvb) (lm_lock_t *lock, char **lvbp);
213         void (*lm_unhold_lvb) (lm_lock_t *lock, char *lvb);
214
215         /*
216          * Posix Lock oriented operations
217          */
218
219         int (*lm_plock_get) (lm_lockspace_t *lockspace,
220                              struct lm_lockname *name,
221                              struct file *file, struct file_lock *fl);
222
223         int (*lm_plock) (lm_lockspace_t *lockspace,
224                          struct lm_lockname *name,
225                          struct file *file, int cmd, struct file_lock *fl);
226
227         int (*lm_punlock) (lm_lockspace_t *lockspace,
228                            struct lm_lockname *name,
229                            struct file *file, struct file_lock *fl);
230
231         /*
232          * Client oriented operations
233          */
234
235         void (*lm_recovery_done) (lm_lockspace_t *lockspace, unsigned int jid,
236                                   unsigned int message);
237
238         struct module *lm_owner;
239 };
240
241 /*
242  * lm_mount() return values
243  *
244  * ls_jid - the journal ID this node should use
245  * ls_first - this node is the first to mount the file system
246  * ls_lvb_size - size in bytes of lock value blocks
247  * ls_lockspace - lock module's context for this file system
248  * ls_ops - lock module's functions
249  * ls_flags - lock module features
250  */
251
252 struct lm_lockstruct {
253         unsigned int ls_jid;
254         unsigned int ls_first;
255         unsigned int ls_lvb_size;
256         lm_lockspace_t *ls_lockspace;
257         struct lm_lockops *ls_ops;
258         int ls_flags;
259 };
260
261 /*
262  * Lock module bottom interface.  A lock module makes itself available to GFS
263  * with these functions.
264  */
265
266 int gfs2_register_lockproto(struct lm_lockops *proto);
267
268 void gfs2_unregister_lockproto(struct lm_lockops *proto);
269
270 /*
271  * Lock module top interface.  GFS calls these functions when mounting or
272  * unmounting a file system.
273  */
274
275 int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
276                          lm_callback_t cb, struct gfs2_sbd *sdp,
277                          unsigned int min_lvb_size, int flags,
278                          struct lm_lockstruct *lockstruct,
279                          struct kobject *fskobj);
280
281 void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct);
282
283 void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct);
284
285 #endif /* __LM_INTERFACE_DOT_H__ */
286