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>
47 static match_table_t tokens
= {
48 {Opt_lockproto
, "lockproto=%s"},
49 {Opt_locktable
, "locktable=%s"},
50 {Opt_hostdata
, "hostdata=%s"},
51 {Opt_spectator
, "spectator"},
52 {Opt_ignore_local_fs
, "ignore_local_fs"},
53 {Opt_localflocks
, "localflocks"},
54 {Opt_localcaching
, "localcaching"},
56 {Opt_nodebug
, "nodebug"},
57 {Opt_upgrade
, "upgrade"},
58 {Opt_num_glockd
, "num_glockd=%d"},
61 {Opt_quota_off
, "quota=off"},
62 {Opt_quota_account
, "quota=account"},
63 {Opt_quota_on
, "quota=on"},
64 {Opt_suiddir
, "suiddir"},
65 {Opt_nosuiddir
, "nosuiddir"},
66 {Opt_data_writeback
, "data=writeback"},
67 {Opt_data_ordered
, "data=ordered"}
71 * gfs2_mount_args - Parse mount options
78 int gfs2_mount_args(struct gfs2_sbd
*sdp
, char *data_arg
, int remount
)
80 struct gfs2_args
*args
= &sdp
->sd_args
;
81 char *data
= data_arg
;
82 char *options
, *o
, *v
;
86 /* If someone preloaded options, use those instead */
87 spin_lock(&gfs2_sys_margs_lock
);
89 data
= gfs2_sys_margs
;
90 gfs2_sys_margs
= NULL
;
92 spin_unlock(&gfs2_sys_margs_lock
);
94 /* Set some defaults */
95 args
->ar_num_glockd
= GFS2_GLOCKD_DEFAULT
;
96 args
->ar_quota
= GFS2_QUOTA_DEFAULT
;
97 args
->ar_data
= GFS2_DATA_DEFAULT
;
100 /* Split the options into tokens with the "," character and
103 for (options
= data
; (o
= strsep(&options
, ",")); ) {
105 substring_t tmp
[MAX_OPT_ARGS
];
110 token
= match_token(o
, tokens
, tmp
);
113 v
= match_strdup(&tmp
[0]);
115 fs_info(sdp
, "no memory for lockproto\n");
120 if (remount
&& strcmp(v
, args
->ar_lockproto
)) {
125 strncpy(args
->ar_lockproto
, v
, GFS2_LOCKNAME_LEN
);
126 args
->ar_lockproto
[GFS2_LOCKNAME_LEN
- 1] = 0;
130 v
= match_strdup(&tmp
[0]);
132 fs_info(sdp
, "no memory for locktable\n");
137 if (remount
&& strcmp(v
, args
->ar_locktable
)) {
142 strncpy(args
->ar_locktable
, v
, GFS2_LOCKNAME_LEN
);
143 args
->ar_locktable
[GFS2_LOCKNAME_LEN
- 1] = 0;
147 v
= match_strdup(&tmp
[0]);
149 fs_info(sdp
, "no memory for hostdata\n");
154 if (remount
&& strcmp(v
, args
->ar_hostdata
)) {
159 strncpy(args
->ar_hostdata
, v
, GFS2_LOCKNAME_LEN
);
160 args
->ar_hostdata
[GFS2_LOCKNAME_LEN
- 1] = 0;
164 if (remount
&& !args
->ar_spectator
)
166 args
->ar_spectator
= 1;
167 sdp
->sd_vfs
->s_flags
|= MS_RDONLY
;
169 case Opt_ignore_local_fs
:
170 if (remount
&& !args
->ar_ignore_local_fs
)
172 args
->ar_ignore_local_fs
= 1;
174 case Opt_localflocks
:
175 if (remount
&& !args
->ar_localflocks
)
177 args
->ar_localflocks
= 1;
179 case Opt_localcaching
:
180 if (remount
&& !args
->ar_localcaching
)
182 args
->ar_localcaching
= 1;
191 if (remount
&& !args
->ar_upgrade
)
193 args
->ar_upgrade
= 1;
196 if ((error
= match_int(&tmp
[0], &option
))) {
197 fs_info(sdp
, "problem getting num_glockd\n");
201 if (remount
&& option
!= args
->ar_num_glockd
)
203 if (!option
|| option
> GFS2_GLOCKD_MAX
) {
204 fs_info(sdp
, "0 < num_glockd <= %u (not %u)\n",
205 GFS2_GLOCKD_MAX
, option
);
209 args
->ar_num_glockd
= option
;
212 args
->ar_posix_acl
= 1;
213 sdp
->sd_vfs
->s_flags
|= MS_POSIXACL
;
216 args
->ar_posix_acl
= 0;
217 sdp
->sd_vfs
->s_flags
&= ~MS_POSIXACL
;
220 args
->ar_quota
= GFS2_QUOTA_OFF
;
222 case Opt_quota_account
:
223 args
->ar_quota
= GFS2_QUOTA_ACCOUNT
;
226 args
->ar_quota
= GFS2_QUOTA_ON
;
229 args
->ar_suiddir
= 1;
232 args
->ar_suiddir
= 0;
234 case Opt_data_writeback
:
235 args
->ar_data
= GFS2_DATA_WRITEBACK
;
237 case Opt_data_ordered
:
238 args
->ar_data
= GFS2_DATA_ORDERED
;
241 fs_info(sdp
, "unknown option: %s\n", o
);
249 fs_info(sdp
, "invalid mount option(s)\n");
251 if (data
!= data_arg
)
257 fs_info(sdp
, "can't remount with option %s\n", o
);