Commit 48c2b613 authored by Steven Whitehouse's avatar Steven Whitehouse

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: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent a1c0643f
...@@ -418,6 +418,7 @@ struct gfs2_args { ...@@ -418,6 +418,7 @@ struct gfs2_args {
unsigned int ar_data:2; /* ordered/writeback */ unsigned int ar_data:2; /* ordered/writeback */
unsigned int ar_meta:1; /* mount metafs */ unsigned int ar_meta:1; /* mount metafs */
unsigned int ar_discard:1; /* discard requests */ unsigned int ar_discard:1; /* discard requests */
int ar_commit; /* Commit interval */
}; };
struct gfs2_tune { struct gfs2_tune {
......
...@@ -45,6 +45,7 @@ enum { ...@@ -45,6 +45,7 @@ enum {
Opt_meta, Opt_meta,
Opt_discard, Opt_discard,
Opt_nodiscard, Opt_nodiscard,
Opt_commit,
Opt_err, Opt_err,
}; };
...@@ -73,6 +74,7 @@ static const match_table_t tokens = { ...@@ -73,6 +74,7 @@ static const match_table_t tokens = {
{Opt_meta, "meta"}, {Opt_meta, "meta"},
{Opt_discard, "discard"}, {Opt_discard, "discard"},
{Opt_nodiscard, "nodiscard"}, {Opt_nodiscard, "nodiscard"},
{Opt_commit, "commit=%d"},
{Opt_err, NULL} {Opt_err, NULL}
}; };
...@@ -89,6 +91,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options) ...@@ -89,6 +91,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
char *o; char *o;
int token; int token;
substring_t tmp[MAX_OPT_ARGS]; substring_t tmp[MAX_OPT_ARGS];
int rv;
/* Split the options into tokens with the "," character and /* Split the options into tokens with the "," character and
process them */ process them */
...@@ -173,6 +176,13 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options) ...@@ -173,6 +176,13 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
case Opt_nodiscard: case Opt_nodiscard:
args->ar_discard = 0; args->ar_discard = 0;
break; break;
case Opt_commit:
rv = match_int(&tmp[0], &args->ar_commit);
if (rv || args->ar_commit <= 0) {
fs_info(sdp, "commit mount option requires a positive numeric argument\n");
return rv ? rv : -EINVAL;
}
break;
case Opt_err: case Opt_err:
default: default:
fs_info(sdp, "invalid mount option: %s\n", o); fs_info(sdp, "invalid mount option: %s\n", o);
......
...@@ -55,7 +55,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt) ...@@ -55,7 +55,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
spin_lock_init(&gt->gt_spin); spin_lock_init(&gt->gt_spin);
gt->gt_incore_log_blocks = 1024; gt->gt_incore_log_blocks = 1024;
gt->gt_log_flush_secs = 60;
gt->gt_recoverd_secs = 60; gt->gt_recoverd_secs = 60;
gt->gt_logd_secs = 1; gt->gt_logd_secs = 1;
gt->gt_quota_simul_sync = 64; gt->gt_quota_simul_sync = 64;
...@@ -1165,6 +1164,7 @@ static int fill_super(struct super_block *sb, void *data, int silent) ...@@ -1165,6 +1164,7 @@ static int fill_super(struct super_block *sb, void *data, int silent)
sdp->sd_args.ar_quota = GFS2_QUOTA_DEFAULT; sdp->sd_args.ar_quota = GFS2_QUOTA_DEFAULT;
sdp->sd_args.ar_data = GFS2_DATA_DEFAULT; sdp->sd_args.ar_data = GFS2_DATA_DEFAULT;
sdp->sd_args.ar_commit = 60;
error = gfs2_mount_args(sdp, &sdp->sd_args, data); error = gfs2_mount_args(sdp, &sdp->sd_args, data);
if (error) { if (error) {
...@@ -1191,6 +1191,8 @@ static int fill_super(struct super_block *sb, void *data, int silent) ...@@ -1191,6 +1191,8 @@ static int fill_super(struct super_block *sb, void *data, int silent)
GFS2_BASIC_BLOCK_SHIFT; GFS2_BASIC_BLOCK_SHIFT;
sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift; sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
sdp->sd_tune.gt_log_flush_secs = sdp->sd_args.ar_commit;
error = init_names(sdp, silent); error = init_names(sdp, silent);
if (error) if (error)
goto fail; goto fail;
......
...@@ -436,8 +436,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) ...@@ -436,8 +436,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
{ {
struct gfs2_sbd *sdp = sb->s_fs_info; struct gfs2_sbd *sdp = sb->s_fs_info;
struct gfs2_args args = sdp->sd_args; /* Default to current settings */ struct gfs2_args args = sdp->sd_args; /* Default to current settings */
struct gfs2_tune *gt = &sdp->sd_tune;
int error; int error;
spin_lock(&gt->gt_spin);
args.ar_commit = gt->gt_log_flush_secs;
spin_unlock(&gt->gt_spin);
error = gfs2_mount_args(sdp, &args, data); error = gfs2_mount_args(sdp, &args, data);
if (error) if (error)
return error; return error;
...@@ -473,6 +477,10 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) ...@@ -473,6 +477,10 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
sb->s_flags |= MS_POSIXACL; sb->s_flags |= MS_POSIXACL;
else else
sb->s_flags &= ~MS_POSIXACL; sb->s_flags &= ~MS_POSIXACL;
spin_lock(&gt->gt_spin);
gt->gt_log_flush_secs = args.ar_commit;
spin_unlock(&gt->gt_spin);
return 0; return 0;
} }
...@@ -550,6 +558,7 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) ...@@ -550,6 +558,7 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
{ {
struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
struct gfs2_args *args = &sdp->sd_args; struct gfs2_args *args = &sdp->sd_args;
int lfsecs;
if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir)) if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
seq_printf(s, ",meta"); seq_printf(s, ",meta");
...@@ -610,7 +619,9 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) ...@@ -610,7 +619,9 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
} }
if (args->ar_discard) if (args->ar_discard)
seq_printf(s, ",discard"); seq_printf(s, ",discard");
lfsecs = sdp->sd_tune.gt_log_flush_secs;
if (lfsecs != 60)
seq_printf(s, ",commit=%d", lfsecs);
return 0; return 0;
} }
......
...@@ -26,6 +26,36 @@ ...@@ -26,6 +26,36 @@
#include "util.h" #include "util.h"
#include "glops.h" #include "glops.h"
struct gfs2_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *, char *);
ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
};
static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
return a->show ? a->show(sdp, buf) : 0;
}
static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t len)
{
struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
return a->store ? a->store(sdp, buf, len) : len;
}
static struct sysfs_ops gfs2_attr_ops = {
.show = gfs2_attr_show,
.store = gfs2_attr_store,
};
static struct kset *gfs2_kset;
static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
{ {
return snprintf(buf, PAGE_SIZE, "%u:%u\n", 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,11 +242,6 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len
return len; return len;
} }
struct gfs2_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *, char *);
ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
};
#define GFS2_ATTR(name, mode, show, store) \ #define GFS2_ATTR(name, mode, show, store) \
static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
...@@ -246,49 +271,21 @@ static struct attribute *gfs2_attrs[] = { ...@@ -246,49 +271,21 @@ static struct attribute *gfs2_attrs[] = {
NULL, NULL,
}; };
static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
return a->show ? a->show(sdp, buf) : 0;
}
static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t len)
{
struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
return a->store ? a->store(sdp, buf, len) : len;
}
static struct sysfs_ops gfs2_attr_ops = {
.show = gfs2_attr_show,
.store = gfs2_attr_store,
};
static struct kobj_type gfs2_ktype = { static struct kobj_type gfs2_ktype = {
.default_attrs = gfs2_attrs, .default_attrs = gfs2_attrs,
.sysfs_ops = &gfs2_attr_ops, .sysfs_ops = &gfs2_attr_ops,
}; };
static struct kset *gfs2_kset;
/* /*
* display struct lm_lockstruct fields * display struct lm_lockstruct fields
*/ */
struct lockstruct_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *, char *);
};
#define LOCKSTRUCT_ATTR(name, fmt) \ #define LOCKSTRUCT_ATTR(name, fmt) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \ { \
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \ return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \
} \ } \
static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name) static struct gfs2_attr lockstruct_attr_##name = __ATTR_RO(name)
LOCKSTRUCT_ATTR(jid, "%u\n"); LOCKSTRUCT_ATTR(jid, "%u\n");
LOCKSTRUCT_ATTR(first, "%u\n"); LOCKSTRUCT_ATTR(first, "%u\n");
...@@ -401,14 +398,8 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf) ...@@ -401,14 +398,8 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)
return sprintf(buf, "%d\n", ls->ls_recover_jid_status); return sprintf(buf, "%d\n", ls->ls_recover_jid_status);
} }
struct gdlm_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *sdp, char *);
ssize_t (*store)(struct gfs2_sbd *sdp, const char *, size_t);
};
#define GDLM_ATTR(_name,_mode,_show,_store) \ #define GDLM_ATTR(_name,_mode,_show,_store) \
static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
GDLM_ATTR(block, 0644, block_show, block_store); GDLM_ATTR(block, 0644, block_show, block_store);
...@@ -434,21 +425,12 @@ static struct attribute *lock_module_attrs[] = { ...@@ -434,21 +425,12 @@ static struct attribute *lock_module_attrs[] = {
NULL, NULL,
}; };
/*
* display struct gfs2_args fields
*/
struct args_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *, char *);
};
#define ARGS_ATTR(name, fmt) \ #define ARGS_ATTR(name, fmt) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \ { \
return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \ return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \
} \ } \
static struct args_attr args_attr_##name = __ATTR_RO(name) static struct gfs2_attr args_attr_##name = __ATTR_RO(name)
ARGS_ATTR(lockproto, "%s\n"); ARGS_ATTR(lockproto, "%s\n");
ARGS_ATTR(locktable, "%s\n"); ARGS_ATTR(locktable, "%s\n");
...@@ -531,14 +513,8 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field, ...@@ -531,14 +513,8 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
return len; return len;
} }
struct tune_attr {
struct attribute attr;
ssize_t (*show)(struct gfs2_sbd *, char *);
ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
};
#define TUNE_ATTR_3(name, show, store) \ #define TUNE_ATTR_3(name, show, store) \
static struct tune_attr tune_attr_##name = __ATTR(name, 0644, show, store) static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store)
#define TUNE_ATTR_2(name, store) \ #define TUNE_ATTR_2(name, store) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment