aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2009-05-13 09:49:48 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2009-05-13 09:49:48 -0400
commit48c2b613616235d7c97fda5982f50100a6c79166 (patch)
tree7c735f22b3908ec4bdebd27f5b51a8e4631485a6 /fs
parenta1c0643ff9f360a30644f6e3cd643ca2a5083aea (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')
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/mount.c10
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/gfs2/ops_super.c13
-rw-r--r--fs/gfs2/sys.c92
5 files changed, 60 insertions, 60 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 399d1b978049..65f438e9537a 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -418,6 +418,7 @@ struct gfs2_args {
418 unsigned int ar_data:2; /* ordered/writeback */ 418 unsigned int ar_data:2; /* ordered/writeback */
419 unsigned int ar_meta:1; /* mount metafs */ 419 unsigned int ar_meta:1; /* mount metafs */
420 unsigned int ar_discard:1; /* discard requests */ 420 unsigned int ar_discard:1; /* discard requests */
421 int ar_commit; /* Commit interval */
421}; 422};
422 423
423struct gfs2_tune { 424struct gfs2_tune {
diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c
index f7e8527a21e0..947af151fa24 100644
--- a/fs/gfs2/mount.c
+++ b/fs/gfs2/mount.c
@@ -45,6 +45,7 @@ enum {
45 Opt_meta, 45 Opt_meta,
46 Opt_discard, 46 Opt_discard,
47 Opt_nodiscard, 47 Opt_nodiscard,
48 Opt_commit,
48 Opt_err, 49 Opt_err,
49}; 50};
50 51
@@ -73,6 +74,7 @@ static const match_table_t tokens = {
73 {Opt_meta, "meta"}, 74 {Opt_meta, "meta"},
74 {Opt_discard, "discard"}, 75 {Opt_discard, "discard"},
75 {Opt_nodiscard, "nodiscard"}, 76 {Opt_nodiscard, "nodiscard"},
77 {Opt_commit, "commit=%d"},
76 {Opt_err, NULL} 78 {Opt_err, NULL}
77}; 79};
78 80
@@ -89,6 +91,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
89 char *o; 91 char *o;
90 int token; 92 int token;
91 substring_t tmp[MAX_OPT_ARGS]; 93 substring_t tmp[MAX_OPT_ARGS];
94 int rv;
92 95
93 /* Split the options into tokens with the "," character and 96 /* Split the options into tokens with the "," character and
94 process them */ 97 process them */
@@ -173,6 +176,13 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
173 case Opt_nodiscard: 176 case Opt_nodiscard:
174 args->ar_discard = 0; 177 args->ar_discard = 0;
175 break; 178 break;
179 case Opt_commit:
180 rv = match_int(&tmp[0], &args->ar_commit);
181 if (rv || args->ar_commit <= 0) {
182 fs_info(sdp, "commit mount option requires a positive numeric argument\n");
183 return rv ? rv : -EINVAL;
184 }
185 break;
176 case Opt_err: 186 case Opt_err:
177 default: 187 default:
178 fs_info(sdp, "invalid mount option: %s\n", o); 188 fs_info(sdp, "invalid mount option: %s\n", o);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 1ff9473ea753..7981fbc9fc3b 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -55,7 +55,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
55 spin_lock_init(&gt->gt_spin); 55 spin_lock_init(&gt->gt_spin);
56 56
57 gt->gt_incore_log_blocks = 1024; 57 gt->gt_incore_log_blocks = 1024;
58 gt->gt_log_flush_secs = 60;
59 gt->gt_recoverd_secs = 60; 58 gt->gt_recoverd_secs = 60;
60 gt->gt_logd_secs = 1; 59 gt->gt_logd_secs = 1;
61 gt->gt_quota_simul_sync = 64; 60 gt->gt_quota_simul_sync = 64;
@@ -1165,6 +1164,7 @@ static int fill_super(struct super_block *sb, void *data, int silent)
1165 1164
1166 sdp->sd_args.ar_quota = GFS2_QUOTA_DEFAULT; 1165 sdp->sd_args.ar_quota = GFS2_QUOTA_DEFAULT;
1167 sdp->sd_args.ar_data = GFS2_DATA_DEFAULT; 1166 sdp->sd_args.ar_data = GFS2_DATA_DEFAULT;
1167 sdp->sd_args.ar_commit = 60;
1168 1168
1169 error = gfs2_mount_args(sdp, &sdp->sd_args, data); 1169 error = gfs2_mount_args(sdp, &sdp->sd_args, data);
1170 if (error) { 1170 if (error) {
@@ -1191,6 +1191,8 @@ static int fill_super(struct super_block *sb, void *data, int silent)
1191 GFS2_BASIC_BLOCK_SHIFT; 1191 GFS2_BASIC_BLOCK_SHIFT;
1192 sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift; 1192 sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
1193 1193
1194 sdp->sd_tune.gt_log_flush_secs = sdp->sd_args.ar_commit;
1195
1194 error = init_names(sdp, silent); 1196 error = init_names(sdp, silent);
1195 if (error) 1197 if (error)
1196 goto fail; 1198 goto fail;
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index 458019569dcb..0677a8378560 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -436,8 +436,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
436{ 436{
437 struct gfs2_sbd *sdp = sb->s_fs_info; 437 struct gfs2_sbd *sdp = sb->s_fs_info;
438 struct gfs2_args args = sdp->sd_args; /* Default to current settings */ 438 struct gfs2_args args = sdp->sd_args; /* Default to current settings */
439 struct gfs2_tune *gt = &sdp->sd_tune;
439 int error; 440 int error;
440 441
442 spin_lock(&gt->gt_spin);
443 args.ar_commit = gt->gt_log_flush_secs;
444 spin_unlock(&gt->gt_spin);
441 error = gfs2_mount_args(sdp, &args, data); 445 error = gfs2_mount_args(sdp, &args, data);
442 if (error) 446 if (error)
443 return error; 447 return error;
@@ -473,6 +477,10 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
473 sb->s_flags |= MS_POSIXACL; 477 sb->s_flags |= MS_POSIXACL;
474 else 478 else
475 sb->s_flags &= ~MS_POSIXACL; 479 sb->s_flags &= ~MS_POSIXACL;
480 spin_lock(&gt->gt_spin);
481 gt->gt_log_flush_secs = args.ar_commit;
482 spin_unlock(&gt->gt_spin);
483
476 return 0; 484 return 0;
477} 485}
478 486
@@ -550,6 +558,7 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
550{ 558{
551 struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; 559 struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
552 struct gfs2_args *args = &sdp->sd_args; 560 struct gfs2_args *args = &sdp->sd_args;
561 int lfsecs;
553 562
554 if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir)) 563 if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
555 seq_printf(s, ",meta"); 564 seq_printf(s, ",meta");
@@ -610,7 +619,9 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
610 } 619 }
611 if (args->ar_discard) 620 if (args->ar_discard)
612 seq_printf(s, ",discard"); 621 seq_printf(s, ",discard");
613 622 lfsecs = sdp->sd_tune.gt_log_flush_secs;
623 if (lfsecs != 60)
624 seq_printf(s, ",commit=%d", lfsecs);
614 return 0; 625 return 0;
615} 626}
616 627
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
29struct 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
35static 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
43static 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
51static struct sysfs_ops gfs2_attr_ops = {
52 .show = gfs2_attr_show,
53 .store = gfs2_attr_store,
54};
55
56
57static struct kset *gfs2_kset;
58
29static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) 59static 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
215struct 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) \
222static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) 247static 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
249static 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
257static 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
265static struct sysfs_ops gfs2_attr_ops = {
266 .show = gfs2_attr_show,
267 .store = gfs2_attr_store,
268};
269
270static struct kobj_type gfs2_ktype = { 274static 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
275static struct kset *gfs2_kset;
276
277/* 279/*
278 * display struct lm_lockstruct fields 280 * display struct lm_lockstruct fields
279 */ 281 */
280 282
281struct 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) \
287static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ 284static 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} \
291static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name) 288static struct gfs2_attr lockstruct_attr_##name = __ATTR_RO(name)
292 289
293LOCKSTRUCT_ATTR(jid, "%u\n"); 290LOCKSTRUCT_ATTR(jid, "%u\n");
294LOCKSTRUCT_ATTR(first, "%u\n"); 291LOCKSTRUCT_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
404struct 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) \
411static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) 402static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
412 403
413GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); 404GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
414GDLM_ATTR(block, 0644, block_show, block_store); 405GDLM_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
441struct 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) \
447static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ 429static 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} \
451static struct args_attr args_attr_##name = __ATTR_RO(name) 433static struct gfs2_attr args_attr_##name = __ATTR_RO(name)
452 434
453ARGS_ATTR(lockproto, "%s\n"); 435ARGS_ATTR(lockproto, "%s\n");
454ARGS_ATTR(locktable, "%s\n"); 436ARGS_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
534struct 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) \
541static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store) 517static 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) \
544static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ 520static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \