2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
10 #include <linux/slab.h>
11 #include <linux/spinlock.h>
12 #include <linux/completion.h>
13 #include <linux/buffer_head.h>
14 #include <linux/gfs2_ondisk.h>
15 #include <linux/lm_interface.h>
16 #include <linux/parser.h>
49 static match_table_t tokens = {
50 {Opt_lockproto, "lockproto=%s"},
51 {Opt_locktable, "locktable=%s"},
52 {Opt_hostdata, "hostdata=%s"},
53 {Opt_spectator, "spectator"},
54 {Opt_ignore_local_fs, "ignore_local_fs"},
55 {Opt_localflocks, "localflocks"},
56 {Opt_localcaching, "localcaching"},
58 {Opt_nodebug, "nodebug"},
59 {Opt_upgrade, "upgrade"},
60 {Opt_num_glockd, "num_glockd=%d"},
63 {Opt_quota_off, "quota=off"},
64 {Opt_quota_account, "quota=account"},
65 {Opt_quota_on, "quota=on"},
66 {Opt_suiddir, "suiddir"},
67 {Opt_nosuiddir, "nosuiddir"},
68 {Opt_data_writeback, "data=writeback"},
69 {Opt_data_ordered, "data=ordered"},
75 * gfs2_mount_args - Parse mount options
82 int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
84 struct gfs2_args *args = &sdp->sd_args;
85 char *data = data_arg;
86 char *options, *o, *v;
90 /* If someone preloaded options, use those instead */
91 spin_lock(&gfs2_sys_margs_lock);
93 data = gfs2_sys_margs;
94 gfs2_sys_margs = NULL;
96 spin_unlock(&gfs2_sys_margs_lock);
98 /* Set some defaults */
99 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
100 args->ar_quota = GFS2_QUOTA_DEFAULT;
101 args->ar_data = GFS2_DATA_DEFAULT;
104 /* Split the options into tokens with the "," character and
107 for (options = data; (o = strsep(&options, ",")); ) {
109 substring_t tmp[MAX_OPT_ARGS];
114 token = match_token(o, tokens, tmp);
117 v = match_strdup(&tmp[0]);
119 fs_info(sdp, "no memory for lockproto\n");
124 if (remount && strcmp(v, args->ar_lockproto)) {
129 strncpy(args->ar_lockproto, v, GFS2_LOCKNAME_LEN);
130 args->ar_lockproto[GFS2_LOCKNAME_LEN - 1] = 0;
134 v = match_strdup(&tmp[0]);
136 fs_info(sdp, "no memory for locktable\n");
141 if (remount && strcmp(v, args->ar_locktable)) {
146 strncpy(args->ar_locktable, v, GFS2_LOCKNAME_LEN);
147 args->ar_locktable[GFS2_LOCKNAME_LEN - 1] = 0;
151 v = match_strdup(&tmp[0]);
153 fs_info(sdp, "no memory for hostdata\n");
158 if (remount && strcmp(v, args->ar_hostdata)) {
163 strncpy(args->ar_hostdata, v, GFS2_LOCKNAME_LEN);
164 args->ar_hostdata[GFS2_LOCKNAME_LEN - 1] = 0;
168 if (remount && !args->ar_spectator)
170 args->ar_spectator = 1;
171 sdp->sd_vfs->s_flags |= MS_RDONLY;
173 case Opt_ignore_local_fs:
174 if (remount && !args->ar_ignore_local_fs)
176 args->ar_ignore_local_fs = 1;
178 case Opt_localflocks:
179 if (remount && !args->ar_localflocks)
181 args->ar_localflocks = 1;
183 case Opt_localcaching:
184 if (remount && !args->ar_localcaching)
186 args->ar_localcaching = 1;
195 if (remount && !args->ar_upgrade)
197 args->ar_upgrade = 1;
200 if ((error = match_int(&tmp[0], &option))) {
201 fs_info(sdp, "problem getting num_glockd\n");
205 if (remount && option != args->ar_num_glockd)
207 if (!option || option > GFS2_GLOCKD_MAX) {
208 fs_info(sdp, "0 < num_glockd <= %u (not %u)\n",
209 GFS2_GLOCKD_MAX, option);
213 args->ar_num_glockd = option;
216 args->ar_posix_acl = 1;
217 sdp->sd_vfs->s_flags |= MS_POSIXACL;
220 args->ar_posix_acl = 0;
221 sdp->sd_vfs->s_flags &= ~MS_POSIXACL;
224 args->ar_quota = GFS2_QUOTA_OFF;
226 case Opt_quota_account:
227 args->ar_quota = GFS2_QUOTA_ACCOUNT;
230 args->ar_quota = GFS2_QUOTA_ON;
233 args->ar_suiddir = 1;
236 args->ar_suiddir = 0;
238 case Opt_data_writeback:
239 args->ar_data = GFS2_DATA_WRITEBACK;
241 case Opt_data_ordered:
242 args->ar_data = GFS2_DATA_ORDERED;
245 if (remount && args->ar_meta != 1)
251 fs_info(sdp, "unknown option: %s\n", o);
259 fs_info(sdp, "invalid mount option(s)\n");
261 if (data != data_arg)
267 fs_info(sdp, "can't remount with option %s\n", o);