aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/locking/dlm/lock_dlm.h
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2006-01-17 03:47:12 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-01-17 03:47:12 -0500
commit869d81df53ad28ce78fc92504b3365b8196a2fa1 (patch)
tree4062f1b13ef32445f1e554d15d59765f88de5ba6 /fs/gfs2/locking/dlm/lock_dlm.h
parenta8f2d64728d8b706392fc1cb0f2fd6852a5e27ae (diff)
[GFS2] An update of the GFS2 lock modules
This brings the lock modules uptodate and removes the stray .mod.c file which accidently got included in the last check in. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/locking/dlm/lock_dlm.h')
-rw-r--r--fs/gfs2/locking/dlm/lock_dlm.h191
1 files changed, 191 insertions, 0 deletions
diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h
new file mode 100644
index 000000000000..fa545f7872e8
--- /dev/null
+++ b/fs/gfs2/locking/dlm/lock_dlm.h
@@ -0,0 +1,191 @@
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 v.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/module.h>
17#include <linux/types.h>
18#include <linux/string.h>
19#include <linux/list.h>
20#include <linux/socket.h>
21#include <linux/delay.h>
22#include <linux/kthread.h>
23#include <linux/kobject.h>
24#include <linux/fcntl.h>
25#include <linux/wait.h>
26#include <net/sock.h>
27
28#include <linux/dlm.h>
29#include "../../lm_interface.h"
30
31/*
32 * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
33 * prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module
34 * as "lock_dlm".
35 */
36
37#define GDLM_STRNAME_BYTES 24
38#define GDLM_LVB_SIZE 32
39#define GDLM_DROP_COUNT 50000
40#define GDLM_DROP_PERIOD 60
41#define GDLM_NAME_LEN 128
42
43/* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number).
44 We sprintf these numbers into a 24 byte string of hex values to make them
45 human-readable (to make debugging simpler.) */
46
47struct gdlm_strname {
48 unsigned char name[GDLM_STRNAME_BYTES];
49 unsigned short namelen;
50};
51
52enum {
53 DFL_BLOCK_LOCKS = 0,
54 DFL_SPECTATOR = 1,
55 DFL_WITHDRAW = 2,
56};
57
58struct gdlm_ls {
59 uint32_t id;
60 int jid;
61 int first;
62 int first_done;
63 unsigned long flags;
64 struct kobject kobj;
65 char clustername[GDLM_NAME_LEN];
66 char fsname[GDLM_NAME_LEN];
67 int fsflags;
68 dlm_lockspace_t *dlm_lockspace;
69 lm_callback_t fscb;
70 lm_fsdata_t *fsdata;
71 int recover_jid;
72 int recover_jid_done;
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 uint32_t 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
89enum {
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};
104
105struct gdlm_lock {
106 struct gdlm_ls *ls;
107 struct lm_lockname lockname;
108 char *lvb;
109 struct dlm_lksb lksb;
110
111 int16_t cur;
112 int16_t req;
113 int16_t prev_req;
114 uint32_t lkf; /* dlm flags DLM_LKF_ */
115 unsigned long flags; /* lock_dlm flags LFL_ */
116
117 int bast_mode; /* protected by async_lock */
118 struct completion ast_wait;
119
120 struct list_head clist; /* complete */
121 struct list_head blist; /* blocking */
122 struct list_head delay_list; /* delayed */
123 struct list_head all_list; /* all locks for the fs */
124 struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
125};
126
127#define gdlm_assert(assertion, fmt, args...) \
128do { \
129 if (unlikely(!(assertion))) { \
130 printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \
131 "lock_dlm: " fmt "\n", \
132 #assertion, ##args); \
133 BUG(); \
134 } \
135} while (0)
136
137#define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg)
138#define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg)
139#define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg)
140#ifdef LOCK_DLM_LOG_DEBUG
141#define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg)
142#else
143#define log_debug(fmt, arg...)
144#endif
145
146/* sysfs.c */
147
148int gdlm_sysfs_init(void);
149void gdlm_sysfs_exit(void);
150int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *);
151void gdlm_kobject_release(struct gdlm_ls *);
152
153/* thread.c */
154
155int gdlm_init_threads(struct gdlm_ls *);
156void gdlm_release_threads(struct gdlm_ls *);
157
158/* lock.c */
159
160int16_t gdlm_make_lmstate(int16_t);
161void gdlm_queue_delayed(struct gdlm_lock *);
162void gdlm_submit_delayed(struct gdlm_ls *);
163int gdlm_release_all_locks(struct gdlm_ls *);
164int gdlm_create_lp(struct gdlm_ls *, struct lm_lockname *, struct gdlm_lock **);
165void gdlm_delete_lp(struct gdlm_lock *);
166int gdlm_add_lvb(struct gdlm_lock *);
167void gdlm_del_lvb(struct gdlm_lock *);
168unsigned int gdlm_do_lock(struct gdlm_lock *, struct dlm_range *);
169unsigned int gdlm_do_unlock(struct gdlm_lock *);
170
171int gdlm_get_lock(lm_lockspace_t *, struct lm_lockname *, lm_lock_t **);
172void gdlm_put_lock(lm_lock_t *);
173unsigned int gdlm_lock(lm_lock_t *, unsigned int, unsigned int, unsigned int);
174unsigned int gdlm_unlock(lm_lock_t *, unsigned int);
175void gdlm_cancel(lm_lock_t *);
176int gdlm_hold_lvb(lm_lock_t *, char **);
177void gdlm_unhold_lvb(lm_lock_t *, char *);
178void gdlm_sync_lvb(lm_lock_t *, char *);
179
180/* plock.c */
181
182int gdlm_plock_init(void);
183void gdlm_plock_exit(void);
184int gdlm_plock(lm_lockspace_t *, struct lm_lockname *, struct file *, int,
185 struct file_lock *);
186int gdlm_plock_get(lm_lockspace_t *, struct lm_lockname *, struct file *,
187 struct file_lock *);
188int gdlm_punlock(lm_lockspace_t *, struct lm_lockname *, struct file *,
189 struct file_lock *);
190#endif
191