blob: c26c21b53c19a2ccb26d1e75ee81569634f943b3 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/module.h>
16#include <linux/kobject.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050017#include <linux/gfs2_ondisk.h>
Fabio Massimo Di Nitto7d308592006-09-19 07:56:29 +020018#include <linux/lm_interface.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000019#include <asm/uaccess.h>
20
21#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050022#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000023#include "lm.h"
24#include "sys.h"
25#include "super.h"
26#include "glock.h"
27#include "quota.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050028#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000029
30char *gfs2_sys_margs;
31spinlock_t gfs2_sys_margs_lock;
32
33static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
34{
David Teigland3204a6c2006-09-06 16:57:06 -050035 return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_vfs->s_id);
David Teiglandb3b94fa2006-01-16 16:50:04 +000036}
37
38static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
39{
David Teigland3204a6c2006-09-06 16:57:06 -050040 return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
David Teiglandb3b94fa2006-01-16 16:50:04 +000041}
42
43static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
44{
45 unsigned int count;
46
Steven Whitehousef55ab262006-02-21 12:51:39 +000047 mutex_lock(&sdp->sd_freeze_lock);
David Teiglandb3b94fa2006-01-16 16:50:04 +000048 count = sdp->sd_freeze_count;
Steven Whitehousef55ab262006-02-21 12:51:39 +000049 mutex_unlock(&sdp->sd_freeze_lock);
David Teiglandb3b94fa2006-01-16 16:50:04 +000050
David Teigland3204a6c2006-09-06 16:57:06 -050051 return snprintf(buf, PAGE_SIZE, "%u\n", count);
David Teiglandb3b94fa2006-01-16 16:50:04 +000052}
53
54static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
55{
56 ssize_t ret = len;
57 int error = 0;
58 int n = simple_strtol(buf, NULL, 0);
59
60 if (!capable(CAP_SYS_ADMIN))
61 return -EACCES;
62
63 switch (n) {
64 case 0:
65 gfs2_unfreeze_fs(sdp);
66 break;
67 case 1:
68 error = gfs2_freeze_fs(sdp);
69 break;
70 default:
71 ret = -EINVAL;
72 }
73
74 if (error)
75 fs_warn(sdp, "freeze %d error %d", n, error);
76
77 return ret;
78}
79
80static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
81{
82 unsigned int b = test_bit(SDF_SHUTDOWN, &sdp->sd_flags);
David Teigland3204a6c2006-09-06 16:57:06 -050083 return snprintf(buf, PAGE_SIZE, "%u\n", b);
David Teiglandb3b94fa2006-01-16 16:50:04 +000084}
85
86static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
87{
88 if (!capable(CAP_SYS_ADMIN))
89 return -EACCES;
90
91 if (simple_strtol(buf, NULL, 0) != 1)
92 return -EINVAL;
93
94 gfs2_lm_withdraw(sdp,
95 "GFS2: fsid=%s: withdrawing from cluster at user's request\n",
96 sdp->sd_fsname);
97 return len;
98}
99
100static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
101 size_t len)
102{
103 if (!capable(CAP_SYS_ADMIN))
104 return -EACCES;
105
106 if (simple_strtol(buf, NULL, 0) != 1)
107 return -EINVAL;
108
109 gfs2_statfs_sync(sdp);
110 return len;
111}
112
113static ssize_t shrink_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
114{
115 if (!capable(CAP_SYS_ADMIN))
116 return -EACCES;
117
118 if (simple_strtol(buf, NULL, 0) != 1)
119 return -EINVAL;
120
121 gfs2_gl_hash_clear(sdp, NO_WAIT);
122 return len;
123}
124
125static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
126 size_t len)
127{
128 if (!capable(CAP_SYS_ADMIN))
129 return -EACCES;
130
131 if (simple_strtol(buf, NULL, 0) != 1)
132 return -EINVAL;
133
134 gfs2_quota_sync(sdp);
135 return len;
136}
137
138static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
139 size_t len)
140{
Steven Whitehousecd915492006-09-04 12:49:07 -0400141 u32 id;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000142
143 if (!capable(CAP_SYS_ADMIN))
144 return -EACCES;
145
146 id = simple_strtoul(buf, NULL, 0);
147
148 gfs2_quota_refresh(sdp, 1, id);
149 return len;
150}
151
152static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
153 size_t len)
154{
Steven Whitehousecd915492006-09-04 12:49:07 -0400155 u32 id;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000156
157 if (!capable(CAP_SYS_ADMIN))
158 return -EACCES;
159
160 id = simple_strtoul(buf, NULL, 0);
161
162 gfs2_quota_refresh(sdp, 0, id);
163 return len;
164}
165
166struct gfs2_attr {
167 struct attribute attr;
168 ssize_t (*show)(struct gfs2_sbd *, char *);
169 ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
170};
171
172#define GFS2_ATTR(name, mode, show, store) \
173static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
174
175GFS2_ATTR(id, 0444, id_show, NULL);
176GFS2_ATTR(fsname, 0444, fsname_show, NULL);
177GFS2_ATTR(freeze, 0644, freeze_show, freeze_store);
178GFS2_ATTR(shrink, 0200, NULL, shrink_store);
179GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
180GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store);
181GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);
182GFS2_ATTR(quota_refresh_user, 0200, NULL, quota_refresh_user_store);
183GFS2_ATTR(quota_refresh_group, 0200, NULL, quota_refresh_group_store);
184
185static struct attribute *gfs2_attrs[] = {
186 &gfs2_attr_id.attr,
187 &gfs2_attr_fsname.attr,
188 &gfs2_attr_freeze.attr,
189 &gfs2_attr_shrink.attr,
190 &gfs2_attr_withdraw.attr,
191 &gfs2_attr_statfs_sync.attr,
192 &gfs2_attr_quota_sync.attr,
193 &gfs2_attr_quota_refresh_user.attr,
194 &gfs2_attr_quota_refresh_group.attr,
195 NULL,
196};
197
198static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
199 char *buf)
200{
201 struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
202 struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
203 return a->show ? a->show(sdp, buf) : 0;
204}
205
206static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
207 const char *buf, size_t len)
208{
209 struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
210 struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
211 return a->store ? a->store(sdp, buf, len) : len;
212}
213
214static struct sysfs_ops gfs2_attr_ops = {
215 .show = gfs2_attr_show,
216 .store = gfs2_attr_store,
217};
218
219static struct kobj_type gfs2_ktype = {
220 .default_attrs = gfs2_attrs,
221 .sysfs_ops = &gfs2_attr_ops,
222};
223
224static struct kset gfs2_kset = {
Steven Whitehouse2c1e52a2006-09-05 15:41:57 -0400225 .kobj = {.name = "gfs2"},
David Teiglandb3b94fa2006-01-16 16:50:04 +0000226 .ktype = &gfs2_ktype,
227};
228
229/*
230 * display struct lm_lockstruct fields
231 */
232
233struct lockstruct_attr {
234 struct attribute attr;
235 ssize_t (*show)(struct gfs2_sbd *, char *);
236};
237
238#define LOCKSTRUCT_ATTR(name, fmt) \
239static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
240{ \
David Teigland3204a6c2006-09-06 16:57:06 -0500241 return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \
David Teiglandb3b94fa2006-01-16 16:50:04 +0000242} \
243static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name)
244
245LOCKSTRUCT_ATTR(jid, "%u\n");
246LOCKSTRUCT_ATTR(first, "%u\n");
247LOCKSTRUCT_ATTR(lvb_size, "%u\n");
248LOCKSTRUCT_ATTR(flags, "%d\n");
249
250static struct attribute *lockstruct_attrs[] = {
251 &lockstruct_attr_jid.attr,
252 &lockstruct_attr_first.attr,
253 &lockstruct_attr_lvb_size.attr,
254 &lockstruct_attr_flags.attr,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400255 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000256};
257
258/*
259 * display struct gfs2_args fields
260 */
261
262struct args_attr {
263 struct attribute attr;
264 ssize_t (*show)(struct gfs2_sbd *, char *);
265};
266
267#define ARGS_ATTR(name, fmt) \
268static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
269{ \
David Teigland3204a6c2006-09-06 16:57:06 -0500270 return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \
David Teiglandb3b94fa2006-01-16 16:50:04 +0000271} \
272static struct args_attr args_attr_##name = __ATTR_RO(name)
273
274ARGS_ATTR(lockproto, "%s\n");
275ARGS_ATTR(locktable, "%s\n");
276ARGS_ATTR(hostdata, "%s\n");
277ARGS_ATTR(spectator, "%d\n");
278ARGS_ATTR(ignore_local_fs, "%d\n");
279ARGS_ATTR(localcaching, "%d\n");
280ARGS_ATTR(localflocks, "%d\n");
281ARGS_ATTR(debug, "%d\n");
282ARGS_ATTR(upgrade, "%d\n");
283ARGS_ATTR(num_glockd, "%u\n");
284ARGS_ATTR(posix_acl, "%d\n");
285ARGS_ATTR(quota, "%u\n");
286ARGS_ATTR(suiddir, "%d\n");
287ARGS_ATTR(data, "%d\n");
288
289/* one oddball doesn't fit the macro mold */
290static ssize_t noatime_show(struct gfs2_sbd *sdp, char *buf)
291{
David Teigland3204a6c2006-09-06 16:57:06 -0500292 return snprintf(buf, PAGE_SIZE, "%d\n",
293 !!test_bit(SDF_NOATIME, &sdp->sd_flags));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000294}
295static struct args_attr args_attr_noatime = __ATTR_RO(noatime);
296
297static struct attribute *args_attrs[] = {
298 &args_attr_lockproto.attr,
299 &args_attr_locktable.attr,
300 &args_attr_hostdata.attr,
301 &args_attr_spectator.attr,
302 &args_attr_ignore_local_fs.attr,
303 &args_attr_localcaching.attr,
304 &args_attr_localflocks.attr,
305 &args_attr_debug.attr,
306 &args_attr_upgrade.attr,
307 &args_attr_num_glockd.attr,
308 &args_attr_posix_acl.attr,
309 &args_attr_quota.attr,
310 &args_attr_suiddir.attr,
311 &args_attr_data.attr,
312 &args_attr_noatime.attr,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400313 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000314};
315
316/*
317 * display counters from superblock
318 */
319
320struct counters_attr {
321 struct attribute attr;
322 ssize_t (*show)(struct gfs2_sbd *, char *);
323};
324
David Teigland6a6b3d02006-02-23 10:11:47 +0000325#define COUNTERS_ATTR(name, fmt) \
David Teiglandb3b94fa2006-01-16 16:50:04 +0000326static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
327{ \
David Teigland3204a6c2006-09-06 16:57:06 -0500328 return snprintf(buf, PAGE_SIZE, fmt, \
329 (unsigned int)atomic_read(&sdp->sd_##name)); \
David Teiglandb3b94fa2006-01-16 16:50:04 +0000330} \
331static struct counters_attr counters_attr_##name = __ATTR_RO(name)
332
David Teigland6a6b3d02006-02-23 10:11:47 +0000333COUNTERS_ATTR(glock_count, "%u\n");
334COUNTERS_ATTR(glock_held_count, "%u\n");
335COUNTERS_ATTR(inode_count, "%u\n");
336COUNTERS_ATTR(reclaimed, "%u\n");
David Teiglandb3b94fa2006-01-16 16:50:04 +0000337
338static struct attribute *counters_attrs[] = {
339 &counters_attr_glock_count.attr,
340 &counters_attr_glock_held_count.attr,
341 &counters_attr_inode_count.attr,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000342 &counters_attr_reclaimed.attr,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400343 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000344};
345
346/*
347 * get and set struct gfs2_tune fields
348 */
349
350static ssize_t quota_scale_show(struct gfs2_sbd *sdp, char *buf)
351{
David Teigland3204a6c2006-09-06 16:57:06 -0500352 return snprintf(buf, PAGE_SIZE, "%u %u\n",
353 sdp->sd_tune.gt_quota_scale_num,
354 sdp->sd_tune.gt_quota_scale_den);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000355}
356
357static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,
358 size_t len)
359{
360 struct gfs2_tune *gt = &sdp->sd_tune;
361 unsigned int x, y;
362
363 if (!capable(CAP_SYS_ADMIN))
364 return -EACCES;
365
366 if (sscanf(buf, "%u %u", &x, &y) != 2 || !y)
367 return -EINVAL;
368
369 spin_lock(&gt->gt_spin);
370 gt->gt_quota_scale_num = x;
371 gt->gt_quota_scale_den = y;
372 spin_unlock(&gt->gt_spin);
373 return len;
374}
375
376static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
377 int check_zero, const char *buf, size_t len)
378{
379 struct gfs2_tune *gt = &sdp->sd_tune;
380 unsigned int x;
381
382 if (!capable(CAP_SYS_ADMIN))
383 return -EACCES;
384
385 x = simple_strtoul(buf, NULL, 0);
386
387 if (check_zero && !x)
388 return -EINVAL;
389
390 spin_lock(&gt->gt_spin);
391 *field = x;
392 spin_unlock(&gt->gt_spin);
393 return len;
394}
395
396struct tune_attr {
397 struct attribute attr;
398 ssize_t (*show)(struct gfs2_sbd *, char *);
399 ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
400};
401
402#define TUNE_ATTR_3(name, show, store) \
403static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store)
404
405#define TUNE_ATTR_2(name, store) \
406static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
407{ \
David Teigland3204a6c2006-09-06 16:57:06 -0500408 return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
David Teiglandb3b94fa2006-01-16 16:50:04 +0000409} \
410TUNE_ATTR_3(name, name##_show, store)
411
412#define TUNE_ATTR(name, check_zero) \
413static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
414{ \
415 return tune_set(sdp, &sdp->sd_tune.gt_##name, check_zero, buf, len); \
416} \
417TUNE_ATTR_2(name, name##_store)
418
419#define TUNE_ATTR_DAEMON(name, process) \
420static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
421{ \
422 ssize_t r = tune_set(sdp, &sdp->sd_tune.gt_##name, 1, buf, len); \
423 wake_up_process(sdp->sd_##process); \
424 return r; \
425} \
426TUNE_ATTR_2(name, name##_store)
427
David Teiglandb3b94fa2006-01-16 16:50:04 +0000428TUNE_ATTR(demote_secs, 0);
429TUNE_ATTR(incore_log_blocks, 0);
430TUNE_ATTR(log_flush_secs, 0);
431TUNE_ATTR(jindex_refresh_secs, 0);
432TUNE_ATTR(quota_warn_period, 0);
433TUNE_ATTR(quota_quantum, 0);
434TUNE_ATTR(atime_quantum, 0);
435TUNE_ATTR(max_readahead, 0);
436TUNE_ATTR(complain_secs, 0);
437TUNE_ATTR(reclaim_limit, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000438TUNE_ATTR(statfs_slow, 0);
439TUNE_ATTR(new_files_jdata, 0);
440TUNE_ATTR(new_files_directio, 0);
441TUNE_ATTR(quota_simul_sync, 1);
442TUNE_ATTR(quota_cache_secs, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000443TUNE_ATTR(stall_secs, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000444TUNE_ATTR(statfs_quantum, 1);
445TUNE_ATTR_DAEMON(scand_secs, scand_process);
446TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process);
447TUNE_ATTR_DAEMON(logd_secs, logd_process);
448TUNE_ATTR_DAEMON(quotad_secs, quotad_process);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000449TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
450
451static struct attribute *tune_attrs[] = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000452 &tune_attr_demote_secs.attr,
453 &tune_attr_incore_log_blocks.attr,
454 &tune_attr_log_flush_secs.attr,
455 &tune_attr_jindex_refresh_secs.attr,
456 &tune_attr_quota_warn_period.attr,
457 &tune_attr_quota_quantum.attr,
458 &tune_attr_atime_quantum.attr,
459 &tune_attr_max_readahead.attr,
460 &tune_attr_complain_secs.attr,
461 &tune_attr_reclaim_limit.attr,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000462 &tune_attr_statfs_slow.attr,
463 &tune_attr_quota_simul_sync.attr,
464 &tune_attr_quota_cache_secs.attr,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000465 &tune_attr_stall_secs.attr,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000466 &tune_attr_statfs_quantum.attr,
467 &tune_attr_scand_secs.attr,
468 &tune_attr_recoverd_secs.attr,
469 &tune_attr_logd_secs.attr,
470 &tune_attr_quotad_secs.attr,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000471 &tune_attr_quota_scale.attr,
472 &tune_attr_new_files_jdata.attr,
473 &tune_attr_new_files_directio.attr,
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400474 NULL,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000475};
476
477static struct attribute_group lockstruct_group = {
478 .name = "lockstruct",
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400479 .attrs = lockstruct_attrs,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000480};
481
482static struct attribute_group counters_group = {
483 .name = "counters",
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400484 .attrs = counters_attrs,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000485};
486
487static struct attribute_group args_group = {
488 .name = "args",
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400489 .attrs = args_attrs,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000490};
491
492static struct attribute_group tune_group = {
493 .name = "tune",
Steven Whitehouseea67eed2006-09-05 10:53:09 -0400494 .attrs = tune_attrs,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000495};
496
497int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
498{
499 int error;
500
501 sdp->sd_kobj.kset = &gfs2_kset;
502 sdp->sd_kobj.ktype = &gfs2_ktype;
503
504 error = kobject_set_name(&sdp->sd_kobj, "%s", sdp->sd_table_name);
505 if (error)
506 goto fail;
507
508 error = kobject_register(&sdp->sd_kobj);
509 if (error)
510 goto fail;
511
512 error = sysfs_create_group(&sdp->sd_kobj, &lockstruct_group);
513 if (error)
514 goto fail_reg;
515
516 error = sysfs_create_group(&sdp->sd_kobj, &counters_group);
517 if (error)
518 goto fail_lockstruct;
519
520 error = sysfs_create_group(&sdp->sd_kobj, &args_group);
521 if (error)
522 goto fail_counters;
523
524 error = sysfs_create_group(&sdp->sd_kobj, &tune_group);
525 if (error)
526 goto fail_args;
527
528 return 0;
529
Steven Whitehousea91ea692006-09-04 12:04:26 -0400530fail_args:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000531 sysfs_remove_group(&sdp->sd_kobj, &args_group);
Steven Whitehousea91ea692006-09-04 12:04:26 -0400532fail_counters:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000533 sysfs_remove_group(&sdp->sd_kobj, &counters_group);
Steven Whitehousea91ea692006-09-04 12:04:26 -0400534fail_lockstruct:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000535 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group);
Steven Whitehousea91ea692006-09-04 12:04:26 -0400536fail_reg:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000537 kobject_unregister(&sdp->sd_kobj);
Steven Whitehousea91ea692006-09-04 12:04:26 -0400538fail:
David Teigland65952fb2006-09-15 13:09:11 -0500539 fs_err(sdp, "error %d adding sysfs files", error);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000540 return error;
541}
542
543void gfs2_sys_fs_del(struct gfs2_sbd *sdp)
544{
545 sysfs_remove_group(&sdp->sd_kobj, &tune_group);
546 sysfs_remove_group(&sdp->sd_kobj, &args_group);
547 sysfs_remove_group(&sdp->sd_kobj, &counters_group);
548 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group);
549 kobject_unregister(&sdp->sd_kobj);
550}
551
552int gfs2_sys_init(void)
553{
554 gfs2_sys_margs = NULL;
555 spin_lock_init(&gfs2_sys_margs_lock);
Greg Kroah-Hartman823bccf2007-04-13 13:15:19 -0700556 kobj_set_kset_s(&gfs2_kset, fs_subsys);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000557 return kset_register(&gfs2_kset);
558}
559
560void gfs2_sys_uninit(void)
561{
562 kfree(gfs2_sys_margs);
563 kset_unregister(&gfs2_kset);
564}
565