aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/locking/dlm/sysfs.c
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/sysfs.c
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/sysfs.c')
-rw-r--r--fs/gfs2/locking/dlm/sysfs.c203
1 files changed, 53 insertions, 150 deletions
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 8964733f55e4..e1e5186c97c9 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -1,21 +1,25 @@
1/****************************************************************************** 1/*
2******************************************************************************* 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3** 3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
4** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 4 *
5** 5 * This copyrighted material is made available to anyone wishing to use,
6** This copyrighted material is made available to anyone wishing to use, 6 * modify, copy, or redistribute it subject to the terms and conditions
7** modify, copy, or redistribute it subject to the terms and conditions 7 * of the GNU General Public License v.2.
8** of the GNU General Public License v.2. 8 */
9**
10*******************************************************************************
11******************************************************************************/
12 9
13#include <linux/ctype.h> 10#include <linux/ctype.h>
14#include <linux/stat.h> 11#include <linux/stat.h>
15 12
16#include "lock_dlm.h" 13#include "lock_dlm.h"
17 14
18static ssize_t gdlm_block_show(struct gdlm_ls *ls, char *buf) 15extern struct lm_lockops gdlm_ops;
16
17static ssize_t proto_name_show(struct gdlm_ls *ls, char *buf)
18{
19 return sprintf(buf, "%s\n", gdlm_ops.lm_proto_name);
20}
21
22static ssize_t block_show(struct gdlm_ls *ls, char *buf)
19{ 23{
20 ssize_t ret; 24 ssize_t ret;
21 int val = 0; 25 int val = 0;
@@ -26,7 +30,7 @@ static ssize_t gdlm_block_show(struct gdlm_ls *ls, char *buf)
26 return ret; 30 return ret;
27} 31}
28 32
29static ssize_t gdlm_block_store(struct gdlm_ls *ls, const char *buf, size_t len) 33static ssize_t block_store(struct gdlm_ls *ls, const char *buf, size_t len)
30{ 34{
31 ssize_t ret = len; 35 ssize_t ret = len;
32 int val; 36 int val;
@@ -43,43 +47,7 @@ static ssize_t gdlm_block_store(struct gdlm_ls *ls, const char *buf, size_t len)
43 return ret; 47 return ret;
44} 48}
45 49
46static ssize_t gdlm_mounted_show(struct gdlm_ls *ls, char *buf) 50static ssize_t withdraw_show(struct gdlm_ls *ls, char *buf)
47{
48 ssize_t ret;
49 int val = -2;
50
51 if (test_bit(DFL_TERMINATE, &ls->flags))
52 val = -1;
53 else if (test_bit(DFL_LEAVE_DONE, &ls->flags))
54 val = 0;
55 else if (test_bit(DFL_JOIN_DONE, &ls->flags))
56 val = 1;
57 ret = sprintf(buf, "%d\n", val);
58 return ret;
59}
60
61static ssize_t gdlm_mounted_store(struct gdlm_ls *ls, const char *buf, size_t len)
62{
63 ssize_t ret = len;
64 int val;
65
66 val = simple_strtol(buf, NULL, 0);
67
68 if (val == 1)
69 set_bit(DFL_JOIN_DONE, &ls->flags);
70 else if (val == 0)
71 set_bit(DFL_LEAVE_DONE, &ls->flags);
72 else if (val == -1) {
73 set_bit(DFL_TERMINATE, &ls->flags);
74 set_bit(DFL_JOIN_DONE, &ls->flags);
75 set_bit(DFL_LEAVE_DONE, &ls->flags);
76 } else
77 ret = -EINVAL;
78 wake_up(&ls->wait_control);
79 return ret;
80}
81
82static ssize_t gdlm_withdraw_show(struct gdlm_ls *ls, char *buf)
83{ 51{
84 ssize_t ret; 52 ssize_t ret;
85 int val = 0; 53 int val = 0;
@@ -90,7 +58,7 @@ static ssize_t gdlm_withdraw_show(struct gdlm_ls *ls, char *buf)
90 return ret; 58 return ret;
91} 59}
92 60
93static ssize_t gdlm_withdraw_store(struct gdlm_ls *ls, const char *buf, size_t len) 61static ssize_t withdraw_store(struct gdlm_ls *ls, const char *buf, size_t len)
94{ 62{
95 ssize_t ret = len; 63 ssize_t ret = len;
96 int val; 64 int val;
@@ -105,67 +73,41 @@ static ssize_t gdlm_withdraw_store(struct gdlm_ls *ls, const char *buf, size_t l
105 return ret; 73 return ret;
106} 74}
107 75
108static ssize_t gdlm_jid_show(struct gdlm_ls *ls, char *buf) 76static ssize_t id_show(struct gdlm_ls *ls, char *buf)
109{
110 return sprintf(buf, "%u\n", ls->jid);
111}
112
113static ssize_t gdlm_jid_store(struct gdlm_ls *ls, const char *buf, size_t len)
114{ 77{
115 ls->jid = simple_strtol(buf, NULL, 0); 78 return sprintf(buf, "%u\n", ls->id);
116 return len;
117} 79}
118 80
119static ssize_t gdlm_first_show(struct gdlm_ls *ls, char *buf) 81static ssize_t jid_show(struct gdlm_ls *ls, char *buf)
120{ 82{
121 return sprintf(buf, "%u\n", ls->first); 83 return sprintf(buf, "%d\n", ls->jid);
122} 84}
123 85
124static ssize_t gdlm_first_store(struct gdlm_ls *ls, const char *buf, size_t len) 86static ssize_t first_show(struct gdlm_ls *ls, char *buf)
125{ 87{
126 ls->first = simple_strtol(buf, NULL, 0); 88 return sprintf(buf, "%d\n", ls->first);
127 return len;
128} 89}
129 90
130static ssize_t gdlm_first_done_show(struct gdlm_ls *ls, char *buf) 91static ssize_t first_done_show(struct gdlm_ls *ls, char *buf)
131{ 92{
132 return sprintf(buf, "%d\n", ls->first_done); 93 return sprintf(buf, "%d\n", ls->first_done);
133} 94}
134 95
135static ssize_t gdlm_recover_show(struct gdlm_ls *ls, char *buf) 96static ssize_t recover_show(struct gdlm_ls *ls, char *buf)
136{ 97{
137 return sprintf(buf, "%u\n", ls->recover_jid); 98 return sprintf(buf, "%d\n", ls->recover_jid);
138} 99}
139 100
140static ssize_t gdlm_recover_store(struct gdlm_ls *ls, const char *buf, size_t len) 101static ssize_t recover_store(struct gdlm_ls *ls, const char *buf, size_t len)
141{ 102{
142 ls->recover_jid = simple_strtol(buf, NULL, 0); 103 ls->recover_jid = simple_strtol(buf, NULL, 0);
143 ls->fscb(ls->fsdata, LM_CB_NEED_RECOVERY, &ls->recover_jid); 104 ls->fscb(ls->fsdata, LM_CB_NEED_RECOVERY, &ls->recover_jid);
144 return len; 105 return len;
145} 106}
146 107
147static ssize_t gdlm_recover_done_show(struct gdlm_ls *ls, char *buf) 108static ssize_t recover_done_show(struct gdlm_ls *ls, char *buf)
148{
149 ssize_t ret;
150 ret = sprintf(buf, "%d\n", ls->recover_done);
151 return ret;
152}
153
154static ssize_t gdlm_cluster_show(struct gdlm_ls *ls, char *buf)
155{
156 ssize_t ret;
157 ret = sprintf(buf, "%s\n", ls->clustername);
158 return ret;
159}
160
161static ssize_t gdlm_options_show(struct gdlm_ls *ls, char *buf)
162{ 109{
163 ssize_t ret = 0; 110 return sprintf(buf, "%d\n", ls->recover_jid_done);
164
165 if (ls->fsflags & LM_MFLAG_SPECTATOR)
166 ret += sprintf(buf, "spectator ");
167
168 return ret;
169} 111}
170 112
171struct gdlm_attr { 113struct gdlm_attr {
@@ -174,73 +116,29 @@ struct gdlm_attr {
174 ssize_t (*store)(struct gdlm_ls *, const char *, size_t); 116 ssize_t (*store)(struct gdlm_ls *, const char *, size_t);
175}; 117};
176 118
177static struct gdlm_attr gdlm_attr_block = { 119#define GDLM_ATTR(_name,_mode,_show,_store) \
178 .attr = {.name = "block", .mode = S_IRUGO | S_IWUSR}, 120static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
179 .show = gdlm_block_show,
180 .store = gdlm_block_store
181};
182
183static struct gdlm_attr gdlm_attr_mounted = {
184 .attr = {.name = "mounted", .mode = S_IRUGO | S_IWUSR},
185 .show = gdlm_mounted_show,
186 .store = gdlm_mounted_store
187};
188
189static struct gdlm_attr gdlm_attr_withdraw = {
190 .attr = {.name = "withdraw", .mode = S_IRUGO | S_IWUSR},
191 .show = gdlm_withdraw_show,
192 .store = gdlm_withdraw_store
193};
194
195static struct gdlm_attr gdlm_attr_jid = {
196 .attr = {.name = "jid", .mode = S_IRUGO | S_IWUSR},
197 .show = gdlm_jid_show,
198 .store = gdlm_jid_store
199};
200
201static struct gdlm_attr gdlm_attr_first = {
202 .attr = {.name = "first", .mode = S_IRUGO | S_IWUSR},
203 .show = gdlm_first_show,
204 .store = gdlm_first_store
205};
206
207static struct gdlm_attr gdlm_attr_first_done = {
208 .attr = {.name = "first_done", .mode = S_IRUGO},
209 .show = gdlm_first_done_show,
210};
211
212static struct gdlm_attr gdlm_attr_recover = {
213 .attr = {.name = "recover", .mode = S_IRUGO | S_IWUSR},
214 .show = gdlm_recover_show,
215 .store = gdlm_recover_store
216};
217
218static struct gdlm_attr gdlm_attr_recover_done = {
219 .attr = {.name = "recover_done", .mode = S_IRUGO | S_IWUSR},
220 .show = gdlm_recover_done_show,
221};
222
223static struct gdlm_attr gdlm_attr_cluster = {
224 .attr = {.name = "cluster", .mode = S_IRUGO | S_IWUSR},
225 .show = gdlm_cluster_show,
226};
227 121
228static struct gdlm_attr gdlm_attr_options = { 122GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
229 .attr = {.name = "options", .mode = S_IRUGO | S_IWUSR}, 123GDLM_ATTR(block, 0644, block_show, block_store);
230 .show = gdlm_options_show, 124GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
231}; 125GDLM_ATTR(id, 0444, id_show, NULL);
126GDLM_ATTR(jid, 0444, jid_show, NULL);
127GDLM_ATTR(first, 0444, first_show, NULL);
128GDLM_ATTR(first_done, 0444, first_done_show, NULL);
129GDLM_ATTR(recover, 0644, recover_show, recover_store);
130GDLM_ATTR(recover_done, 0444, recover_done_show, NULL);
232 131
233static struct attribute *gdlm_attrs[] = { 132static struct attribute *gdlm_attrs[] = {
133 &gdlm_attr_proto_name.attr,
234 &gdlm_attr_block.attr, 134 &gdlm_attr_block.attr,
235 &gdlm_attr_mounted.attr,
236 &gdlm_attr_withdraw.attr, 135 &gdlm_attr_withdraw.attr,
136 &gdlm_attr_id.attr,
237 &gdlm_attr_jid.attr, 137 &gdlm_attr_jid.attr,
238 &gdlm_attr_first.attr, 138 &gdlm_attr_first.attr,
239 &gdlm_attr_first_done.attr, 139 &gdlm_attr_first_done.attr,
240 &gdlm_attr_recover.attr, 140 &gdlm_attr_recover.attr,
241 &gdlm_attr_recover_done.attr, 141 &gdlm_attr_recover_done.attr,
242 &gdlm_attr_cluster.attr,
243 &gdlm_attr_options.attr,
244 NULL, 142 NULL,
245}; 143};
246 144
@@ -276,20 +174,25 @@ static struct kset gdlm_kset = {
276 .ktype = &gdlm_ktype, 174 .ktype = &gdlm_ktype,
277}; 175};
278 176
279int gdlm_kobject_setup(struct gdlm_ls *ls) 177int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
280{ 178{
281 int error; 179 int error;
282 180
283 error = kobject_set_name(&ls->kobj, "%s", ls->fsname); 181 error = kobject_set_name(&ls->kobj, "%s", "lock_module");
284 if (error) 182 if (error) {
183 log_error("can't set kobj name %d", error);
285 return error; 184 return error;
185 }
286 186
287 ls->kobj.kset = &gdlm_kset; 187 ls->kobj.kset = &gdlm_kset;
288 ls->kobj.ktype = &gdlm_ktype; 188 ls->kobj.ktype = &gdlm_ktype;
189 ls->kobj.parent = fskobj;
289 190
290 error = kobject_register(&ls->kobj); 191 error = kobject_register(&ls->kobj);
192 if (error)
193 log_error("can't register kobj %d", error);
291 194
292 return 0; 195 return error;
293} 196}
294 197
295void gdlm_kobject_release(struct gdlm_ls *ls) 198void gdlm_kobject_release(struct gdlm_ls *ls)