]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - fs/gfs2/locking/dlm/lock_dlm.h
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfashe...
[mirror_ubuntu-hirsute-kernel.git] / fs / gfs2 / locking / dlm / lock_dlm.h
1 /*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 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 LOCK_DLM_DOT_H
11 #define LOCK_DLM_DOT_H
12
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/spinlock.h>
16 #include <linux/types.h>
17 #include <linux/string.h>
18 #include <linux/list.h>
19 #include <linux/socket.h>
20 #include <linux/delay.h>
21 #include <linux/kthread.h>
22 #include <linux/kobject.h>
23 #include <linux/fcntl.h>
24 #include <linux/wait.h>
25 #include <net/sock.h>
26
27 #include <linux/dlm.h>
28 #include <linux/lm_interface.h>
29
30 /*
31 * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
32 * prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module
33 * as "lock_dlm".
34 */
35
36 #define GDLM_STRNAME_BYTES 24
37 #define GDLM_LVB_SIZE 32
38 #define GDLM_DROP_COUNT 0
39 #define GDLM_DROP_PERIOD 60
40 #define GDLM_NAME_LEN 128
41
42 /* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number).
43 We sprintf these numbers into a 24 byte string of hex values to make them
44 human-readable (to make debugging simpler.) */
45
46 struct gdlm_strname {
47 unsigned char name[GDLM_STRNAME_BYTES];
48 unsigned short namelen;
49 };
50
51 enum {
52 DFL_BLOCK_LOCKS = 0,
53 DFL_SPECTATOR = 1,
54 DFL_WITHDRAW = 2,
55 };
56
57 struct gdlm_ls {
58 u32 id;
59 int jid;
60 int first;
61 int first_done;
62 unsigned long flags;
63 struct kobject kobj;
64 char clustername[GDLM_NAME_LEN];
65 char fsname[GDLM_NAME_LEN];
66 int fsflags;
67 dlm_lockspace_t *dlm_lockspace;
68 lm_callback_t fscb;
69 struct gfs2_sbd *sdp;
70 int recover_jid;
71 int recover_jid_done;
72 int recover_jid_status;
73 spinlock_t async_lock;
74 struct list_head complete;
75 struct list_head blocking;
76 struct list_head delayed;
77 struct list_head submit;
78 struct list_head all_locks;
79 u32 all_locks_count;
80 wait_queue_head_t wait_control;
81 struct task_struct *thread1;
82 struct task_struct *thread2;
83 wait_queue_head_t thread_wait;
84 unsigned long drop_time;
85 int drop_locks_count;
86 int drop_locks_period;
87 };
88
89 enum {
90 LFL_NOBLOCK = 0,
91 LFL_NOCACHE = 1,
92 LFL_DLM_UNLOCK = 2,
93 LFL_DLM_CANCEL = 3,
94 LFL_SYNC_LVB = 4,
95 LFL_FORCE_PROMOTE = 5,
96 LFL_REREQUEST = 6,
97 LFL_ACTIVE = 7,
98 LFL_INLOCK = 8,
99 LFL_CANCEL = 9,
100 LFL_NOBAST = 10,
101 LFL_HEADQUE = 11,
102 LFL_UNLOCK_DELETE = 12,
103 LFL_AST_WAIT = 13,
104 };
105
106 struct gdlm_lock {
107 struct gdlm_ls *ls;
108 struct lm_lockname lockname;
109 struct gdlm_strname strname;
110 char *lvb;
111 struct dlm_lksb lksb;
112
113 s16 cur;
114 s16 req;
115 s16 prev_req;
116 u32 lkf; /* dlm flags DLM_LKF_ */
117 unsigned long flags; /* lock_dlm flags LFL_ */
118
119 int bast_mode; /* protected by async_lock */
120
121 struct list_head clist; /* complete */
122 struct list_head blist; /* blocking */
123 struct list_head delay_list; /* delayed */
124 struct list_head all_list; /* all locks for the fs */
125 struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
126 };
127
128 #define gdlm_assert(assertion, fmt, args...) \
129 do { \
130 if (unlikely(!(assertion))) { \
131 printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \
132 "lock_dlm: " fmt "\n", \
133 #assertion, ##args); \
134 BUG(); \
135 } \
136 } while (0)
137
138 #define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg)
139 #define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg)
140 #define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg)
141 #ifdef LOCK_DLM_LOG_DEBUG
142 #define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg)
143 #else
144 #define log_debug(fmt, arg...)
145 #endif
146
147 /* sysfs.c */
148
149 int gdlm_sysfs_init(void);
150 void gdlm_sysfs_exit(void);
151 int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *);
152 void gdlm_kobject_release(struct gdlm_ls *);
153
154 /* thread.c */
155
156 int gdlm_init_threads(struct gdlm_ls *);
157 void gdlm_release_threads(struct gdlm_ls *);
158
159 /* lock.c */
160
161 s16 gdlm_make_lmstate(s16);
162 void gdlm_queue_delayed(struct gdlm_lock *);
163 void gdlm_submit_delayed(struct gdlm_ls *);
164 int gdlm_release_all_locks(struct gdlm_ls *);
165 void gdlm_delete_lp(struct gdlm_lock *);
166 unsigned int gdlm_do_lock(struct gdlm_lock *);
167
168 int gdlm_get_lock(void *, struct lm_lockname *, void **);
169 void gdlm_put_lock(void *);
170 unsigned int gdlm_lock(void *, unsigned int, unsigned int, unsigned int);
171 unsigned int gdlm_unlock(void *, unsigned int);
172 void gdlm_cancel(void *);
173 int gdlm_hold_lvb(void *, char **);
174 void gdlm_unhold_lvb(void *, char *);
175
176 /* plock.c */
177
178 int gdlm_plock_init(void);
179 void gdlm_plock_exit(void);
180 int gdlm_plock(void *, struct lm_lockname *, struct file *, int,
181 struct file_lock *);
182 int gdlm_plock_get(void *, struct lm_lockname *, struct file *,
183 struct file_lock *);
184 int gdlm_punlock(void *, struct lm_lockname *, struct file *,
185 struct file_lock *);
186 #endif
187