aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/locking
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-05-23 09:46:04 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2008-06-27 04:39:28 -0400
commit048bca223739368aa5b9ce7cfb1d576c32d66cc7 (patch)
tree66d4f1c0e90eb6429755cb4529f8c7f609026e89 /fs/gfs2/locking
parentf3c9d38a26be32abf9b8897e9e0afc7166c712dd (diff)
[GFS2] No lock_nolock
This patch merges the lock_nolock module into GFS2 itself. As well as removing some of the overhead of the module, it also means that its now impossible to build GFS2 without a lock module (which would be a pointless thing to do anyway). We also plan to merge lock_dlm into GFS2 in the future, but that is a more tricky task, and will therefore be a separate patch. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/gfs2/locking')
-rw-r--r--fs/gfs2/locking/nolock/Makefile3
-rw-r--r--fs/gfs2/locking/nolock/main.c240
2 files changed, 0 insertions, 243 deletions
diff --git a/fs/gfs2/locking/nolock/Makefile b/fs/gfs2/locking/nolock/Makefile
deleted file mode 100644
index 35e9730bc3a8..000000000000
--- a/fs/gfs2/locking/nolock/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += lock_nolock.o
2lock_nolock-y := main.o
3
diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c
deleted file mode 100644
index 627bfb79bc8c..000000000000
--- a/fs/gfs2/locking/nolock/main.c
+++ /dev/null
@@ -1,240 +0,0 @@
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#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/init.h>
13#include <linux/types.h>
14#include <linux/fs.h>
15#include <linux/lm_interface.h>
16
17struct nolock_lockspace {
18 unsigned int nl_lvb_size;
19};
20
21static const struct lm_lockops nolock_ops;
22
23static int nolock_mount(char *table_name, char *host_data,
24 lm_callback_t cb, void *cb_data,
25 unsigned int min_lvb_size, int flags,
26 struct lm_lockstruct *lockstruct,
27 struct kobject *fskobj)
28{
29 char *c;
30 unsigned int jid;
31 struct nolock_lockspace *nl;
32
33 c = strstr(host_data, "jid=");
34 if (!c)
35 jid = 0;
36 else {
37 c += 4;
38 sscanf(c, "%u", &jid);
39 }
40
41 nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
42 if (!nl)
43 return -ENOMEM;
44
45 nl->nl_lvb_size = min_lvb_size;
46
47 lockstruct->ls_jid = jid;
48 lockstruct->ls_first = 1;
49 lockstruct->ls_lvb_size = min_lvb_size;
50 lockstruct->ls_lockspace = nl;
51 lockstruct->ls_ops = &nolock_ops;
52 lockstruct->ls_flags = LM_LSFLAG_LOCAL;
53
54 return 0;
55}
56
57static void nolock_others_may_mount(void *lockspace)
58{
59}
60
61static void nolock_unmount(void *lockspace)
62{
63 struct nolock_lockspace *nl = lockspace;
64 kfree(nl);
65}
66
67static void nolock_withdraw(void *lockspace)
68{
69}
70
71/**
72 * nolock_get_lock - get a lm_lock_t given a descripton of the lock
73 * @lockspace: the lockspace the lock lives in
74 * @name: the name of the lock
75 * @lockp: return the lm_lock_t here
76 *
77 * Returns: 0 on success, -EXXX on failure
78 */
79
80static int nolock_get_lock(void *lockspace, struct lm_lockname *name,
81 void **lockp)
82{
83 *lockp = lockspace;
84 return 0;
85}
86
87/**
88 * nolock_put_lock - get rid of a lock structure
89 * @lock: the lock to throw away
90 *
91 */
92
93static void nolock_put_lock(void *lock)
94{
95}
96
97/**
98 * nolock_lock - acquire a lock
99 * @lock: the lock to manipulate
100 * @cur_state: the current state
101 * @req_state: the requested state
102 * @flags: modifier flags
103 *
104 * Returns: A bitmap of LM_OUT_*
105 */
106
107static unsigned int nolock_lock(void *lock, unsigned int cur_state,
108 unsigned int req_state, unsigned int flags)
109{
110 if (req_state == LM_ST_UNLOCKED)
111 return 0;
112 return req_state | LM_OUT_CACHEABLE;
113}
114
115/**
116 * nolock_unlock - unlock a lock
117 * @lock: the lock to manipulate
118 * @cur_state: the current state
119 *
120 * Returns: 0
121 */
122
123static unsigned int nolock_unlock(void *lock, unsigned int cur_state)
124{
125 return 0;
126}
127
128static void nolock_cancel(void *lock)
129{
130}
131
132/**
133 * nolock_hold_lvb - hold on to a lock value block
134 * @lock: the lock the LVB is associated with
135 * @lvbp: return the lm_lvb_t here
136 *
137 * Returns: 0 on success, -EXXX on failure
138 */
139
140static int nolock_hold_lvb(void *lock, char **lvbp)
141{
142 struct nolock_lockspace *nl = lock;
143 int error = 0;
144
145 *lvbp = kzalloc(nl->nl_lvb_size, GFP_NOFS);
146 if (!*lvbp)
147 error = -ENOMEM;
148
149 return error;
150}
151
152/**
153 * nolock_unhold_lvb - release a LVB
154 * @lock: the lock the LVB is associated with
155 * @lvb: the lock value block
156 *
157 */
158
159static void nolock_unhold_lvb(void *lock, char *lvb)
160{
161 kfree(lvb);
162}
163
164static int nolock_plock_get(void *lockspace, struct lm_lockname *name,
165 struct file *file, struct file_lock *fl)
166{
167 posix_test_lock(file, fl);
168
169 return 0;
170}
171
172static int nolock_plock(void *lockspace, struct lm_lockname *name,
173 struct file *file, int cmd, struct file_lock *fl)
174{
175 int error;
176 error = posix_lock_file_wait(file, fl);
177 return error;
178}
179
180static int nolock_punlock(void *lockspace, struct lm_lockname *name,
181 struct file *file, struct file_lock *fl)
182{
183 int error;
184 error = posix_lock_file_wait(file, fl);
185 return error;
186}
187
188static void nolock_recovery_done(void *lockspace, unsigned int jid,
189 unsigned int message)
190{
191}
192
193static const struct lm_lockops nolock_ops = {
194 .lm_proto_name = "lock_nolock",
195 .lm_mount = nolock_mount,
196 .lm_others_may_mount = nolock_others_may_mount,
197 .lm_unmount = nolock_unmount,
198 .lm_withdraw = nolock_withdraw,
199 .lm_get_lock = nolock_get_lock,
200 .lm_put_lock = nolock_put_lock,
201 .lm_lock = nolock_lock,
202 .lm_unlock = nolock_unlock,
203 .lm_cancel = nolock_cancel,
204 .lm_hold_lvb = nolock_hold_lvb,
205 .lm_unhold_lvb = nolock_unhold_lvb,
206 .lm_plock_get = nolock_plock_get,
207 .lm_plock = nolock_plock,
208 .lm_punlock = nolock_punlock,
209 .lm_recovery_done = nolock_recovery_done,
210 .lm_owner = THIS_MODULE,
211};
212
213static int __init init_nolock(void)
214{
215 int error;
216
217 error = gfs2_register_lockproto(&nolock_ops);
218 if (error) {
219 printk(KERN_WARNING
220 "lock_nolock: can't register protocol: %d\n", error);
221 return error;
222 }
223
224 printk(KERN_INFO
225 "Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__);
226 return 0;
227}
228
229static void __exit exit_nolock(void)
230{
231 gfs2_unregister_lockproto(&nolock_ops);
232}
233
234module_init(init_nolock);
235module_exit(exit_nolock);
236
237MODULE_DESCRIPTION("GFS Nolock Locking Module");
238MODULE_AUTHOR("Red Hat, Inc.");
239MODULE_LICENSE("GPL");
240