]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - fs/gfs2/lm_interface.h
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
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 v.2.
10 #ifndef __LM_INTERFACE_DOT_H__
11 #define __LM_INTERFACE_DOT_H__
14 * Opaque handles represent the lock module's lockspace structure, the lock
15 * module's lock structures, and GFS's file system (superblock) structure.
18 typedef void lm_lockspace_t
;
19 typedef void lm_lock_t
;
20 typedef void lm_fsdata_t
;
22 typedef void (*lm_callback_t
) (lm_fsdata_t
*fsdata
, unsigned int type
,
29 * GFS is asking to join the filesystem's lockspace, but it doesn't want to
30 * modify the filesystem. The lock module shouldn't assign a journal to the FS
31 * mount. It shouldn't send recovery callbacks to the FS mount. If the node
32 * dies or withdraws, all locks can be wiped immediately.
35 #define LM_MFLAG_SPECTATOR 0x00000001
41 * The lock_nolock module returns LM_LSFLAG_LOCAL to GFS, indicating that GFS
42 * can make single-node optimizations.
45 #define LM_LSFLAG_LOCAL 0x00000001
51 #define LM_TYPE_RESERVED 0x00
52 #define LM_TYPE_NONDISK 0x01
53 #define LM_TYPE_INODE 0x02
54 #define LM_TYPE_RGRP 0x03
55 #define LM_TYPE_META 0x04
56 #define LM_TYPE_IOPEN 0x05
57 #define LM_TYPE_FLOCK 0x06
58 #define LM_TYPE_PLOCK 0x07
59 #define LM_TYPE_QUOTA 0x08
60 #define LM_TYPE_JOURNAL 0x09
65 * SHARED is compatible with SHARED, not with DEFERRED or EX.
66 * DEFERRED is compatible with DEFERRED, not with SHARED or EX.
69 #define LM_ST_UNLOCKED 0
70 #define LM_ST_EXCLUSIVE 1
71 #define LM_ST_DEFERRED 2
72 #define LM_ST_SHARED 3
78 * Don't wait to acquire the lock if it can't be granted immediately.
81 * Send one blocking callback if TRY is set and the lock is not granted.
84 * GFS sets this flag on lock requests it makes while doing journal recovery.
85 * These special requests should not be blocked due to the recovery like
86 * ordinary locks would be.
89 * A SHARED request may also be granted in DEFERRED, or a DEFERRED request may
90 * also be granted in SHARED. The preferred state is whichever is compatible
91 * with other granted locks, or the specified state if no other locks exist.
94 * Override fairness considerations. Suppose a lock is held in a shared state
95 * and there is a pending request for the deferred state. A shared lock
96 * request with the priority flag would be allowed to bypass the deferred
97 * request and directly join the other shared lock. A shared lock request
98 * without the priority flag might be forced to wait until the deferred
99 * requested had acquired and released the lock.
102 #define LM_FLAG_TRY 0x00000001
103 #define LM_FLAG_TRY_1CB 0x00000002
104 #define LM_FLAG_NOEXP 0x00000004
105 #define LM_FLAG_ANY 0x00000008
106 #define LM_FLAG_PRIORITY 0x00000010
109 * lm_lock() and lm_async_cb return flags
112 * Masks the lower two bits of lock state in the returned value.
115 * The lock hasn't been released so GFS can continue to cache data for it.
118 * The lock request was canceled.
121 * The result of the request will be returned in an LM_CB_ASYNC callback.
124 #define LM_OUT_ST_MASK 0x00000003
125 #define LM_OUT_CACHEABLE 0x00000004
126 #define LM_OUT_CANCELED 0x00000008
127 #define LM_OUT_ASYNC 0x00000080
128 #define LM_OUT_ERROR 0x00000100
131 * lm_callback_t types
133 * LM_CB_NEED_E LM_CB_NEED_D LM_CB_NEED_S
134 * Blocking callback, a remote node is requesting the given lock in
135 * EXCLUSIVE, DEFERRED, or SHARED.
137 * LM_CB_NEED_RECOVERY
138 * The given journal needs to be recovered.
141 * Reduce the number of cached locks.
144 * The given lock has been granted.
147 #define LM_CB_NEED_E 257
148 #define LM_CB_NEED_D 258
149 #define LM_CB_NEED_S 259
150 #define LM_CB_NEED_RECOVERY 260
151 #define LM_CB_DROPLOCKS 261
152 #define LM_CB_ASYNC 262
155 * lm_recovery_done() messages
158 #define LM_RD_GAVEUP 308
159 #define LM_RD_SUCCESS 309
164 unsigned int ln_type
;
167 #define lm_name_equal(name1, name2) \
168 (((name1)->ln_number == (name2)->ln_number) && \
169 ((name1)->ln_type == (name2)->ln_type)) \
172 struct lm_lockname lc_name
;
176 struct lm_lockstruct
;
179 char lm_proto_name
[256];
185 int (*lm_mount
) (char *table_name
, char *host_data
,
186 lm_callback_t cb
, lm_fsdata_t
*fsdata
,
187 unsigned int min_lvb_size
, int flags
,
188 struct lm_lockstruct
*lockstruct
,
189 struct kobject
*fskobj
);
191 void (*lm_others_may_mount
) (lm_lockspace_t
*lockspace
);
193 void (*lm_unmount
) (lm_lockspace_t
*lockspace
);
195 void (*lm_withdraw
) (lm_lockspace_t
*lockspace
);
198 * Lock oriented operations
201 int (*lm_get_lock
) (lm_lockspace_t
*lockspace
,
202 struct lm_lockname
*name
, lm_lock_t
**lockp
);
204 void (*lm_put_lock
) (lm_lock_t
*lock
);
206 unsigned int (*lm_lock
) (lm_lock_t
*lock
, unsigned int cur_state
,
207 unsigned int req_state
, unsigned int flags
);
209 unsigned int (*lm_unlock
) (lm_lock_t
*lock
, unsigned int cur_state
);
211 void (*lm_cancel
) (lm_lock_t
*lock
);
213 int (*lm_hold_lvb
) (lm_lock_t
*lock
, char **lvbp
);
214 void (*lm_unhold_lvb
) (lm_lock_t
*lock
, char *lvb
);
215 void (*lm_sync_lvb
) (lm_lock_t
*lock
, char *lvb
);
218 * Posix Lock oriented operations
221 int (*lm_plock_get
) (lm_lockspace_t
*lockspace
,
222 struct lm_lockname
*name
,
223 struct file
*file
, struct file_lock
*fl
);
225 int (*lm_plock
) (lm_lockspace_t
*lockspace
,
226 struct lm_lockname
*name
,
227 struct file
*file
, int cmd
, struct file_lock
*fl
);
229 int (*lm_punlock
) (lm_lockspace_t
*lockspace
,
230 struct lm_lockname
*name
,
231 struct file
*file
, struct file_lock
*fl
);
234 * Client oriented operations
237 void (*lm_recovery_done
) (lm_lockspace_t
*lockspace
, unsigned int jid
,
238 unsigned int message
);
240 struct module
*lm_owner
;
244 * lm_mount() return values
246 * ls_jid - the journal ID this node should use
247 * ls_first - this node is the first to mount the file system
248 * ls_lvb_size - size in bytes of lock value blocks
249 * ls_lockspace - lock module's context for this file system
250 * ls_ops - lock module's functions
251 * ls_flags - lock module features
254 struct lm_lockstruct
{
256 unsigned int ls_first
;
257 unsigned int ls_lvb_size
;
258 lm_lockspace_t
*ls_lockspace
;
259 struct lm_lockops
*ls_ops
;
263 void __init
gfs2_init_lmh(void);
266 * Lock module bottom interface. A lock module makes itself available to GFS
267 * with these functions.
269 * For the time being, we copy the gfs1 lock module bottom interface so the
270 * same lock modules can be used with both gfs1 and gfs2 (it won't be possible
271 * to load both gfs1 and gfs2 at once.) Eventually the lock modules will fork
272 * for gfs1/gfs2 and this API can change to the gfs2_ prefix.
275 int gfs_register_lockproto(struct lm_lockops
*proto
);
277 void gfs_unregister_lockproto(struct lm_lockops
*proto
);
280 * Lock module top interface. GFS calls these functions when mounting or
281 * unmounting a file system.
284 int gfs2_mount_lockproto(char *proto_name
, char *table_name
, char *host_data
,
285 lm_callback_t cb
, lm_fsdata_t
*fsdata
,
286 unsigned int min_lvb_size
, int flags
,
287 struct lm_lockstruct
*lockstruct
,
288 struct kobject
*fskobj
);
290 void gfs2_unmount_lockproto(struct lm_lockstruct
*lockstruct
);
292 void gfs2_withdraw_lockproto(struct lm_lockstruct
*lockstruct
);
294 #endif /* __LM_INTERFACE_DOT_H__ */