diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2009-05-13 09:49:48 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2009-05-13 09:49:48 -0400 |
commit | 48c2b613616235d7c97fda5982f50100a6c79166 (patch) | |
tree | 7c735f22b3908ec4bdebd27f5b51a8e4631485a6 /fs/gfs2/sys.c | |
parent | a1c0643ff9f360a30644f6e3cd643ca2a5083aea (diff) |
GFS2: Add commit= mount option
It has always been possible to adjust the gfs2 log commit
interval, but only from the sysfs interface. This adds a
mount option, commit=<nn>, which will be familar to ext3
users.
The sysfs interface continues to be available as well, although
this might be removed in the future.
Also this patch cleans up some duplicated structures in the GFS2
sysfs code.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/sys.c')
-rw-r--r-- | fs/gfs2/sys.c | 92 |
1 files changed, 34 insertions, 58 deletions
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 7655f5025fec..d53b22edc980 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -26,6 +26,36 @@ | |||
26 | #include "util.h" | 26 | #include "util.h" |
27 | #include "glops.h" | 27 | #include "glops.h" |
28 | 28 | ||
29 | struct gfs2_attr { | ||
30 | struct attribute attr; | ||
31 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
32 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
33 | }; | ||
34 | |||
35 | static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr, | ||
36 | char *buf) | ||
37 | { | ||
38 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
39 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
40 | return a->show ? a->show(sdp, buf) : 0; | ||
41 | } | ||
42 | |||
43 | static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr, | ||
44 | const char *buf, size_t len) | ||
45 | { | ||
46 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
47 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
48 | return a->store ? a->store(sdp, buf, len) : len; | ||
49 | } | ||
50 | |||
51 | static struct sysfs_ops gfs2_attr_ops = { | ||
52 | .show = gfs2_attr_show, | ||
53 | .store = gfs2_attr_store, | ||
54 | }; | ||
55 | |||
56 | |||
57 | static struct kset *gfs2_kset; | ||
58 | |||
29 | static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) | 59 | static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) |
30 | { | 60 | { |
31 | return snprintf(buf, PAGE_SIZE, "%u:%u\n", | 61 | return snprintf(buf, PAGE_SIZE, "%u:%u\n", |
@@ -212,11 +242,6 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len | |||
212 | return len; | 242 | return len; |
213 | } | 243 | } |
214 | 244 | ||
215 | struct gfs2_attr { | ||
216 | struct attribute attr; | ||
217 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
218 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
219 | }; | ||
220 | 245 | ||
221 | #define GFS2_ATTR(name, mode, show, store) \ | 246 | #define GFS2_ATTR(name, mode, show, store) \ |
222 | static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) | 247 | static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) |
@@ -246,49 +271,21 @@ static struct attribute *gfs2_attrs[] = { | |||
246 | NULL, | 271 | NULL, |
247 | }; | 272 | }; |
248 | 273 | ||
249 | static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr, | ||
250 | char *buf) | ||
251 | { | ||
252 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
253 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
254 | return a->show ? a->show(sdp, buf) : 0; | ||
255 | } | ||
256 | |||
257 | static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr, | ||
258 | const char *buf, size_t len) | ||
259 | { | ||
260 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | ||
261 | struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr); | ||
262 | return a->store ? a->store(sdp, buf, len) : len; | ||
263 | } | ||
264 | |||
265 | static struct sysfs_ops gfs2_attr_ops = { | ||
266 | .show = gfs2_attr_show, | ||
267 | .store = gfs2_attr_store, | ||
268 | }; | ||
269 | |||
270 | static struct kobj_type gfs2_ktype = { | 274 | static struct kobj_type gfs2_ktype = { |
271 | .default_attrs = gfs2_attrs, | 275 | .default_attrs = gfs2_attrs, |
272 | .sysfs_ops = &gfs2_attr_ops, | 276 | .sysfs_ops = &gfs2_attr_ops, |
273 | }; | 277 | }; |
274 | 278 | ||
275 | static struct kset *gfs2_kset; | ||
276 | |||
277 | /* | 279 | /* |
278 | * display struct lm_lockstruct fields | 280 | * display struct lm_lockstruct fields |
279 | */ | 281 | */ |
280 | 282 | ||
281 | struct lockstruct_attr { | ||
282 | struct attribute attr; | ||
283 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
284 | }; | ||
285 | |||
286 | #define LOCKSTRUCT_ATTR(name, fmt) \ | 283 | #define LOCKSTRUCT_ATTR(name, fmt) \ |
287 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | 284 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ |
288 | { \ | 285 | { \ |
289 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \ | 286 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \ |
290 | } \ | 287 | } \ |
291 | static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name) | 288 | static struct gfs2_attr lockstruct_attr_##name = __ATTR_RO(name) |
292 | 289 | ||
293 | LOCKSTRUCT_ATTR(jid, "%u\n"); | 290 | LOCKSTRUCT_ATTR(jid, "%u\n"); |
294 | LOCKSTRUCT_ATTR(first, "%u\n"); | 291 | LOCKSTRUCT_ATTR(first, "%u\n"); |
@@ -401,14 +398,8 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf) | |||
401 | return sprintf(buf, "%d\n", ls->ls_recover_jid_status); | 398 | return sprintf(buf, "%d\n", ls->ls_recover_jid_status); |
402 | } | 399 | } |
403 | 400 | ||
404 | struct gdlm_attr { | ||
405 | struct attribute attr; | ||
406 | ssize_t (*show)(struct gfs2_sbd *sdp, char *); | ||
407 | ssize_t (*store)(struct gfs2_sbd *sdp, const char *, size_t); | ||
408 | }; | ||
409 | |||
410 | #define GDLM_ATTR(_name,_mode,_show,_store) \ | 401 | #define GDLM_ATTR(_name,_mode,_show,_store) \ |
411 | static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) | 402 | static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) |
412 | 403 | ||
413 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); | 404 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); |
414 | GDLM_ATTR(block, 0644, block_show, block_store); | 405 | GDLM_ATTR(block, 0644, block_show, block_store); |
@@ -434,21 +425,12 @@ static struct attribute *lock_module_attrs[] = { | |||
434 | NULL, | 425 | NULL, |
435 | }; | 426 | }; |
436 | 427 | ||
437 | /* | ||
438 | * display struct gfs2_args fields | ||
439 | */ | ||
440 | |||
441 | struct args_attr { | ||
442 | struct attribute attr; | ||
443 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
444 | }; | ||
445 | |||
446 | #define ARGS_ATTR(name, fmt) \ | 428 | #define ARGS_ATTR(name, fmt) \ |
447 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | 429 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ |
448 | { \ | 430 | { \ |
449 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \ | 431 | return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \ |
450 | } \ | 432 | } \ |
451 | static struct args_attr args_attr_##name = __ATTR_RO(name) | 433 | static struct gfs2_attr args_attr_##name = __ATTR_RO(name) |
452 | 434 | ||
453 | ARGS_ATTR(lockproto, "%s\n"); | 435 | ARGS_ATTR(lockproto, "%s\n"); |
454 | ARGS_ATTR(locktable, "%s\n"); | 436 | ARGS_ATTR(locktable, "%s\n"); |
@@ -531,14 +513,8 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field, | |||
531 | return len; | 513 | return len; |
532 | } | 514 | } |
533 | 515 | ||
534 | struct tune_attr { | ||
535 | struct attribute attr; | ||
536 | ssize_t (*show)(struct gfs2_sbd *, char *); | ||
537 | ssize_t (*store)(struct gfs2_sbd *, const char *, size_t); | ||
538 | }; | ||
539 | |||
540 | #define TUNE_ATTR_3(name, show, store) \ | 516 | #define TUNE_ATTR_3(name, show, store) \ |
541 | static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store) | 517 | static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store) |
542 | 518 | ||
543 | #define TUNE_ATTR_2(name, store) \ | 519 | #define TUNE_ATTR_2(name, store) \ |
544 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ | 520 | static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ |