GFS2: Add commit= mount option
[cascardo/linux.git] / fs / gfs2 / ops_super.c
index 320323d..0677a83 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/delay.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
-#include <linux/lm_interface.h>
 #include <linux/time.h>
 
 #include "gfs2.h"
@@ -27,7 +26,6 @@
 #include "glock.h"
 #include "inode.h"
 #include "log.h"
-#include "mount.h"
 #include "quota.h"
 #include "recovery.h"
 #include "rgrp.h"
@@ -40,6 +38,8 @@
 #include "bmap.h"
 #include "meta_io.h"
 
+#define args_neq(a1, a2, x) ((a1)->ar_##x != (a2)->ar_##x)
+
 /**
  * gfs2_write_inode - Make sure the inode is stable on the disk
  * @inode: The inode
@@ -435,25 +435,53 @@ static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
 {
        struct gfs2_sbd *sdp = sb->s_fs_info;
+       struct gfs2_args args = sdp->sd_args; /* Default to current settings */
+       struct gfs2_tune *gt = &sdp->sd_tune;
        int error;
 
-       error = gfs2_mount_args(sdp, data, 1);
+       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);
        if (error)
                return error;
 
+       /* Not allowed to change locking details */
+       if (strcmp(args.ar_lockproto, sdp->sd_args.ar_lockproto) ||
+           strcmp(args.ar_locktable, sdp->sd_args.ar_locktable) ||
+           strcmp(args.ar_hostdata, sdp->sd_args.ar_hostdata))
+               return -EINVAL;
+
+       /* Some flags must not be changed */
+       if (args_neq(&args, &sdp->sd_args, spectator) ||
+           args_neq(&args, &sdp->sd_args, ignore_local_fs) ||
+           args_neq(&args, &sdp->sd_args, localflocks) ||
+           args_neq(&args, &sdp->sd_args, localcaching) ||
+           args_neq(&args, &sdp->sd_args, meta))
+               return -EINVAL;
+
        if (sdp->sd_args.ar_spectator)
                *flags |= MS_RDONLY;
-       else {
-               if (*flags & MS_RDONLY) {
-                       if (!(sb->s_flags & MS_RDONLY))
-                               error = gfs2_make_fs_ro(sdp);
-               } else if (!(*flags & MS_RDONLY) &&
-                          (sb->s_flags & MS_RDONLY)) {
+
+       if ((sb->s_flags ^ *flags) & MS_RDONLY) {
+               if (*flags & MS_RDONLY)
+                       error = gfs2_make_fs_ro(sdp);
+               else
                        error = gfs2_make_fs_rw(sdp);
-               }
+               if (error)
+                       return error;
        }
 
-       return error;
+       sdp->sd_args = args;
+       if (sdp->sd_args.ar_posix_acl)
+               sb->s_flags |= MS_POSIXACL;
+       else
+               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;
 }
 
 /**
@@ -530,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_args *args = &sdp->sd_args;
+       int lfsecs;
 
        if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
                seq_printf(s, ",meta");
@@ -588,7 +617,11 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
                }
                seq_printf(s, ",data=%s", state);
        }
-
+       if (args->ar_discard)
+               seq_printf(s, ",discard");
+       lfsecs = sdp->sd_tune.gt_log_flush_secs;
+       if (lfsecs != 60)
+               seq_printf(s, ",commit=%d", lfsecs);
        return 0;
 }