blob: f7e8527a21e07438e3ab7e8b759d276853acb587 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
David Teiglandb3b94fa2006-01-16 16:50:04 +000010#include <linux/slab.h>
11#include <linux/spinlock.h>
12#include <linux/completion.h>
13#include <linux/buffer_head.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050014#include <linux/gfs2_ondisk.h>
Josef Bacik476c0062007-04-23 11:55:39 -040015#include <linux/parser.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000016
17#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050018#include "incore.h"
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000019#include "super.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000020#include "sys.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050021#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000022
Josef Bacik476c0062007-04-23 11:55:39 -040023enum {
24 Opt_lockproto,
25 Opt_locktable,
26 Opt_hostdata,
27 Opt_spectator,
28 Opt_ignore_local_fs,
29 Opt_localflocks,
30 Opt_localcaching,
31 Opt_debug,
32 Opt_nodebug,
33 Opt_upgrade,
Josef Bacik476c0062007-04-23 11:55:39 -040034 Opt_acl,
35 Opt_noacl,
36 Opt_quota_off,
37 Opt_quota_account,
38 Opt_quota_on,
Steven Whitehouseb9a96942009-02-19 10:32:35 +000039 Opt_quota,
40 Opt_noquota,
Josef Bacik476c0062007-04-23 11:55:39 -040041 Opt_suiddir,
42 Opt_nosuiddir,
43 Opt_data_writeback,
44 Opt_data_ordered,
Steven Whitehouse9b8df982008-08-08 13:45:13 +010045 Opt_meta,
Steven Whitehousef15ab562009-02-09 09:25:01 +000046 Opt_discard,
47 Opt_nodiscard,
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050048 Opt_err,
Josef Bacik476c0062007-04-23 11:55:39 -040049};
50
Steven Whitehousea447c092008-10-13 10:46:57 +010051static const match_table_t tokens = {
Josef Bacik476c0062007-04-23 11:55:39 -040052 {Opt_lockproto, "lockproto=%s"},
53 {Opt_locktable, "locktable=%s"},
54 {Opt_hostdata, "hostdata=%s"},
55 {Opt_spectator, "spectator"},
56 {Opt_ignore_local_fs, "ignore_local_fs"},
57 {Opt_localflocks, "localflocks"},
58 {Opt_localcaching, "localcaching"},
59 {Opt_debug, "debug"},
60 {Opt_nodebug, "nodebug"},
61 {Opt_upgrade, "upgrade"},
Josef Bacik476c0062007-04-23 11:55:39 -040062 {Opt_acl, "acl"},
63 {Opt_noacl, "noacl"},
64 {Opt_quota_off, "quota=off"},
65 {Opt_quota_account, "quota=account"},
66 {Opt_quota_on, "quota=on"},
Steven Whitehouseb9a96942009-02-19 10:32:35 +000067 {Opt_quota, "quota"},
68 {Opt_noquota, "noquota"},
Josef Bacik476c0062007-04-23 11:55:39 -040069 {Opt_suiddir, "suiddir"},
70 {Opt_nosuiddir, "nosuiddir"},
71 {Opt_data_writeback, "data=writeback"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050072 {Opt_data_ordered, "data=ordered"},
Steven Whitehouse9b8df982008-08-08 13:45:13 +010073 {Opt_meta, "meta"},
Steven Whitehousef15ab562009-02-09 09:25:01 +000074 {Opt_discard, "discard"},
75 {Opt_nodiscard, "nodiscard"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050076 {Opt_err, NULL}
Josef Bacik476c0062007-04-23 11:55:39 -040077};
78
David Teiglandb3b94fa2006-01-16 16:50:04 +000079/**
80 * gfs2_mount_args - Parse mount options
81 * @sdp:
82 * @data:
83 *
84 * Return: errno
85 */
86
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000087int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
David Teiglandb3b94fa2006-01-16 16:50:04 +000088{
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000089 char *o;
90 int token;
91 substring_t tmp[MAX_OPT_ARGS];
David Teiglandb3b94fa2006-01-16 16:50:04 +000092
93 /* Split the options into tokens with the "," character and
94 process them */
95
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000096 while (1) {
97 o = strsep(&options, ",");
98 if (o == NULL)
99 break;
100 if (*o == '\0')
David Teiglandb3b94fa2006-01-16 16:50:04 +0000101 continue;
102
Josef Bacik476c0062007-04-23 11:55:39 -0400103 token = match_token(o, tokens, tmp);
104 switch (token) {
105 case Opt_lockproto:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000106 match_strlcpy(args->ar_lockproto, &tmp[0],
107 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400108 break;
109 case Opt_locktable:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000110 match_strlcpy(args->ar_locktable, &tmp[0],
111 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400112 break;
113 case Opt_hostdata:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000114 match_strlcpy(args->ar_hostdata, &tmp[0],
115 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400116 break;
117 case Opt_spectator:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000118 args->ar_spectator = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400119 break;
120 case Opt_ignore_local_fs:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000121 args->ar_ignore_local_fs = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400122 break;
123 case Opt_localflocks:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000124 args->ar_localflocks = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400125 break;
126 case Opt_localcaching:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000127 args->ar_localcaching = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400128 break;
129 case Opt_debug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000130 args->ar_debug = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400131 break;
132 case Opt_nodebug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000133 args->ar_debug = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400134 break;
135 case Opt_upgrade:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000136 args->ar_upgrade = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400137 break;
Josef Bacik476c0062007-04-23 11:55:39 -0400138 case Opt_acl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000139 args->ar_posix_acl = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400140 break;
141 case Opt_noacl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000142 args->ar_posix_acl = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400143 break;
144 case Opt_quota_off:
Steven Whitehouseb9a96942009-02-19 10:32:35 +0000145 case Opt_noquota:
Josef Bacik476c0062007-04-23 11:55:39 -0400146 args->ar_quota = GFS2_QUOTA_OFF;
147 break;
148 case Opt_quota_account:
149 args->ar_quota = GFS2_QUOTA_ACCOUNT;
150 break;
151 case Opt_quota_on:
Steven Whitehouseb9a96942009-02-19 10:32:35 +0000152 case Opt_quota:
Josef Bacik476c0062007-04-23 11:55:39 -0400153 args->ar_quota = GFS2_QUOTA_ON;
154 break;
155 case Opt_suiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000156 args->ar_suiddir = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400157 break;
158 case Opt_nosuiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000159 args->ar_suiddir = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400160 break;
161 case Opt_data_writeback:
162 args->ar_data = GFS2_DATA_WRITEBACK;
163 break;
164 case Opt_data_ordered:
165 args->ar_data = GFS2_DATA_ORDERED;
166 break;
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100167 case Opt_meta:
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100168 args->ar_meta = 1;
169 break;
Steven Whitehousef15ab562009-02-09 09:25:01 +0000170 case Opt_discard:
171 args->ar_discard = 1;
172 break;
173 case Opt_nodiscard:
174 args->ar_discard = 0;
175 break;
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -0500176 case Opt_err:
Josef Bacik476c0062007-04-23 11:55:39 -0400177 default:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000178 fs_info(sdp, "invalid mount option: %s\n", o);
179 return -EINVAL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000180 }
181 }
182
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000183 return 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000184}
185