nfsd4: make recall callback an asynchronous rpc
[safe/jmp/linux-2.6] / fs / gfs2 / mount.c
index ef3092e..f7e8527 100644 (file)
@@ -7,20 +7,75 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
-#include <linux/lm_interface.h>
+#include <linux/parser.h>
 
 #include "gfs2.h"
 #include "incore.h"
-#include "mount.h"
+#include "super.h"
 #include "sys.h"
 #include "util.h"
 
+enum {
+       Opt_lockproto,
+       Opt_locktable,
+       Opt_hostdata,
+       Opt_spectator,
+       Opt_ignore_local_fs,
+       Opt_localflocks,
+       Opt_localcaching,
+       Opt_debug,
+       Opt_nodebug,
+       Opt_upgrade,
+       Opt_acl,
+       Opt_noacl,
+       Opt_quota_off,
+       Opt_quota_account,
+       Opt_quota_on,
+       Opt_quota,
+       Opt_noquota,
+       Opt_suiddir,
+       Opt_nosuiddir,
+       Opt_data_writeback,
+       Opt_data_ordered,
+       Opt_meta,
+       Opt_discard,
+       Opt_nodiscard,
+       Opt_err,
+};
+
+static const match_table_t tokens = {
+       {Opt_lockproto, "lockproto=%s"},
+       {Opt_locktable, "locktable=%s"},
+       {Opt_hostdata, "hostdata=%s"},
+       {Opt_spectator, "spectator"},
+       {Opt_ignore_local_fs, "ignore_local_fs"},
+       {Opt_localflocks, "localflocks"},
+       {Opt_localcaching, "localcaching"},
+       {Opt_debug, "debug"},
+       {Opt_nodebug, "nodebug"},
+       {Opt_upgrade, "upgrade"},
+       {Opt_acl, "acl"},
+       {Opt_noacl, "noacl"},
+       {Opt_quota_off, "quota=off"},
+       {Opt_quota_account, "quota=account"},
+       {Opt_quota_on, "quota=on"},
+       {Opt_quota, "quota"},
+       {Opt_noquota, "noquota"},
+       {Opt_suiddir, "suiddir"},
+       {Opt_nosuiddir, "nosuiddir"},
+       {Opt_data_writeback, "data=writeback"},
+       {Opt_data_ordered, "data=ordered"},
+       {Opt_meta, "meta"},
+       {Opt_discard, "discard"},
+       {Opt_nodiscard, "nodiscard"},
+       {Opt_err, NULL}
+};
+
 /**
  * gfs2_mount_args - Parse mount options
  * @sdp:
  * Return: errno
  */
 
-int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
+int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
 {
-       struct gfs2_args *args = &sdp->sd_args;
-       char *data = data_arg;
-       char *options, *o, *v;
-       int error = 0;
-
-       if (!remount) {
-               /*  If someone preloaded options, use those instead  */
-               spin_lock(&gfs2_sys_margs_lock);
-               if (gfs2_sys_margs) {
-                       data = gfs2_sys_margs;
-                       gfs2_sys_margs = NULL;
-               }
-               spin_unlock(&gfs2_sys_margs_lock);
-
-               /*  Set some defaults  */
-               args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
-               args->ar_quota = GFS2_QUOTA_DEFAULT;
-               args->ar_data = GFS2_DATA_DEFAULT;
-       }
+       char *o;
+       int token;
+       substring_t tmp[MAX_OPT_ARGS];
 
        /* Split the options into tokens with the "," character and
           process them */
 
-       for (options = data; (o = strsep(&options, ",")); ) {
-               if (!*o)
+       while (1) {
+               o = strsep(&options, ",");
+               if (o == NULL)
+                       break;
+               if (*o == '\0')
                        continue;
 
-               v = strchr(o, '=');
-               if (v)
-                       *v++ = 0;
-
-               if (!strcmp(o, "lockproto")) {
-                       if (!v)
-                               goto need_value;
-                       if (remount && strcmp(v, args->ar_lockproto))
-                               goto cant_remount;
-                       strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
-                       args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
-               }
-
-               else if (!strcmp(o, "locktable")) {
-                       if (!v)
-                               goto need_value;
-                       if (remount && strcmp(v, args->ar_locktable))
-                               goto cant_remount;
-                       strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
-                       args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
-               }
-
-               else if (!strcmp(o, "hostdata")) {
-                       if (!v)
-                               goto need_value;
-                       if (remount && strcmp(v, args->ar_hostdata))
-                               goto cant_remount;
-                       strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
-                       args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
-               }
-
-               else if (!strcmp(o, "spectator")) {
-                       if (remount && !args->ar_spectator)
-                               goto cant_remount;
+               token = match_token(o, tokens, tmp);
+               switch (token) {
+               case Opt_lockproto:
+                       match_strlcpy(args->ar_lockproto, &tmp[0],
+                                     GFS2_LOCKNAME_LEN);
+                       break;
+               case Opt_locktable:
+                       match_strlcpy(args->ar_locktable, &tmp[0],
+                                     GFS2_LOCKNAME_LEN);
+                       break;
+               case Opt_hostdata:
+                       match_strlcpy(args->ar_hostdata, &tmp[0],
+                                     GFS2_LOCKNAME_LEN);
+                       break;
+               case Opt_spectator:
                        args->ar_spectator = 1;
-                       sdp->sd_vfs->s_flags |= MS_RDONLY;
-               }
-
-               else if (!strcmp(o, "ignore_local_fs")) {
-                       if (remount && !args->ar_ignore_local_fs)
-                               goto cant_remount;
+                       break;
+               case Opt_ignore_local_fs:
                        args->ar_ignore_local_fs = 1;
-               }
-
-               else if (!strcmp(o, "localflocks")) {
-                       if (remount && !args->ar_localflocks)
-                               goto cant_remount;
+                       break;
+               case Opt_localflocks:
                        args->ar_localflocks = 1;
-               }
-
-               else if (!strcmp(o, "localcaching")) {
-                       if (remount && !args->ar_localcaching)
-                               goto cant_remount;
+                       break;
+               case Opt_localcaching:
                        args->ar_localcaching = 1;
-               }
-
-               else if (!strcmp(o, "debug"))
+                       break;
+               case Opt_debug:
                        args->ar_debug = 1;
-
-               else if (!strcmp(o, "nodebug"))
+                       break;
+               case Opt_nodebug:
                        args->ar_debug = 0;
-
-               else if (!strcmp(o, "upgrade")) {
-                       if (remount && !args->ar_upgrade)
-                               goto cant_remount;
+                       break;
+               case Opt_upgrade:
                        args->ar_upgrade = 1;
-               }
-
-               else if (!strcmp(o, "num_glockd")) {
-                       unsigned int x;
-                       if (!v)
-                               goto need_value;
-                       sscanf(v, "%u", &x);
-                       if (remount && x != args->ar_num_glockd)
-                               goto cant_remount;
-                       if (!x || x > GFS2_GLOCKD_MAX) {
-                               fs_info(sdp, "0 < num_glockd <= %u  (not %u)\n",
-                                       GFS2_GLOCKD_MAX, x);
-                               error = -EINVAL;
-                               break;
-                       }
-                       args->ar_num_glockd = x;
-               }
-
-               else if (!strcmp(o, "acl")) {
+                       break;
+               case Opt_acl:
                        args->ar_posix_acl = 1;
-                       sdp->sd_vfs->s_flags |= MS_POSIXACL;
-               }
-
-               else if (!strcmp(o, "noacl")) {
+                       break;
+               case Opt_noacl:
                        args->ar_posix_acl = 0;
-                       sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
-               }
-
-               else if (!strcmp(o, "quota")) {
-                       if (!v)
-                               goto need_value;
-                       if (!strcmp(v, "off"))
-                               args->ar_quota = GFS2_QUOTA_OFF;
-                       else if (!strcmp(v, "account"))
-                               args->ar_quota = GFS2_QUOTA_ACCOUNT;
-                       else if (!strcmp(v, "on"))
-                               args->ar_quota = GFS2_QUOTA_ON;
-                       else {
-                               fs_info(sdp, "invalid value for quota\n");
-                               error = -EINVAL;
-                               break;
-                       }
-               }
-
-               else if (!strcmp(o, "suiddir"))
+                       break;
+               case Opt_quota_off:
+               case Opt_noquota:
+                       args->ar_quota = GFS2_QUOTA_OFF;
+                       break;
+               case Opt_quota_account:
+                       args->ar_quota = GFS2_QUOTA_ACCOUNT;
+                       break;
+               case Opt_quota_on:
+               case Opt_quota:
+                       args->ar_quota = GFS2_QUOTA_ON;
+                       break;
+               case Opt_suiddir:
                        args->ar_suiddir = 1;
-
-               else if (!strcmp(o, "nosuiddir"))
+                       break;
+               case Opt_nosuiddir:
                        args->ar_suiddir = 0;
-
-               else if (!strcmp(o, "data")) {
-                       if (!v)
-                               goto need_value;
-                       if (!strcmp(v, "writeback"))
-                               args->ar_data = GFS2_DATA_WRITEBACK;
-                       else if (!strcmp(v, "ordered"))
-                               args->ar_data = GFS2_DATA_ORDERED;
-                       else {
-                               fs_info(sdp, "invalid value for data\n");
-                               error = -EINVAL;
-                               break;
-                       }
-               }
-
-               else {
-                       fs_info(sdp, "unknown option: %s\n", o);
-                       error = -EINVAL;
                        break;
+               case Opt_data_writeback:
+                       args->ar_data = GFS2_DATA_WRITEBACK;
+                       break;
+               case Opt_data_ordered:
+                       args->ar_data = GFS2_DATA_ORDERED;
+                       break;
+               case Opt_meta:
+                       args->ar_meta = 1;
+                       break;
+               case Opt_discard:
+                       args->ar_discard = 1;
+                       break;
+               case Opt_nodiscard:
+                       args->ar_discard = 0;
+                       break;
+               case Opt_err:
+               default:
+                       fs_info(sdp, "invalid mount option: %s\n", o);
+                       return -EINVAL;
                }
        }
 
-       if (error)
-               fs_info(sdp, "invalid mount option(s)\n");
-
-       if (data != data_arg)
-               kfree(data);
-
-       return error;
-
-need_value:
-       fs_info(sdp, "need value for option %s\n", o);
-       return -EINVAL;
-
-cant_remount:
-       fs_info(sdp, "can't remount with option %s\n", o);
-       return -EINVAL;
+       return 0;
 }