blob: ee69701a777745e2ef6bda5a152d216459634cd5 [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,
39 Opt_suiddir,
40 Opt_nosuiddir,
41 Opt_data_writeback,
42 Opt_data_ordered,
Steven Whitehouse9b8df982008-08-08 13:45:13 +010043 Opt_meta,
Steven Whitehousef15ab562009-02-09 09:25:01 +000044 Opt_discard,
45 Opt_nodiscard,
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050046 Opt_err,
Josef Bacik476c0062007-04-23 11:55:39 -040047};
48
Steven Whitehousea447c092008-10-13 10:46:57 +010049static const match_table_t tokens = {
Josef Bacik476c0062007-04-23 11:55:39 -040050 {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"},
57 {Opt_debug, "debug"},
58 {Opt_nodebug, "nodebug"},
59 {Opt_upgrade, "upgrade"},
Josef Bacik476c0062007-04-23 11:55:39 -040060 {Opt_acl, "acl"},
61 {Opt_noacl, "noacl"},
62 {Opt_quota_off, "quota=off"},
63 {Opt_quota_account, "quota=account"},
64 {Opt_quota_on, "quota=on"},
65 {Opt_suiddir, "suiddir"},
66 {Opt_nosuiddir, "nosuiddir"},
67 {Opt_data_writeback, "data=writeback"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050068 {Opt_data_ordered, "data=ordered"},
Steven Whitehouse9b8df982008-08-08 13:45:13 +010069 {Opt_meta, "meta"},
Steven Whitehousef15ab562009-02-09 09:25:01 +000070 {Opt_discard, "discard"},
71 {Opt_nodiscard, "nodiscard"},
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -050072 {Opt_err, NULL}
Josef Bacik476c0062007-04-23 11:55:39 -040073};
74
David Teiglandb3b94fa2006-01-16 16:50:04 +000075/**
76 * gfs2_mount_args - Parse mount options
77 * @sdp:
78 * @data:
79 *
80 * Return: errno
81 */
82
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000083int gfs2_mount_args(struct gfs2_sbd *sdp, struct gfs2_args *args, char *options)
David Teiglandb3b94fa2006-01-16 16:50:04 +000084{
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000085 char *o;
86 int token;
87 substring_t tmp[MAX_OPT_ARGS];
David Teiglandb3b94fa2006-01-16 16:50:04 +000088
89 /* Split the options into tokens with the "," character and
90 process them */
91
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +000092 while (1) {
93 o = strsep(&options, ",");
94 if (o == NULL)
95 break;
96 if (*o == '\0')
David Teiglandb3b94fa2006-01-16 16:50:04 +000097 continue;
98
Josef Bacik476c0062007-04-23 11:55:39 -040099 token = match_token(o, tokens, tmp);
100 switch (token) {
101 case Opt_lockproto:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000102 match_strlcpy(args->ar_lockproto, &tmp[0],
103 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400104 break;
105 case Opt_locktable:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000106 match_strlcpy(args->ar_locktable, &tmp[0],
107 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400108 break;
109 case Opt_hostdata:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000110 match_strlcpy(args->ar_hostdata, &tmp[0],
111 GFS2_LOCKNAME_LEN);
Josef Bacik476c0062007-04-23 11:55:39 -0400112 break;
113 case Opt_spectator:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000114 args->ar_spectator = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400115 break;
116 case Opt_ignore_local_fs:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000117 args->ar_ignore_local_fs = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400118 break;
119 case Opt_localflocks:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000120 args->ar_localflocks = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400121 break;
122 case Opt_localcaching:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000123 args->ar_localcaching = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400124 break;
125 case Opt_debug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000126 args->ar_debug = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400127 break;
128 case Opt_nodebug:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000129 args->ar_debug = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400130 break;
131 case Opt_upgrade:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000132 args->ar_upgrade = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400133 break;
Josef Bacik476c0062007-04-23 11:55:39 -0400134 case Opt_acl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000135 args->ar_posix_acl = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400136 break;
137 case Opt_noacl:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000138 args->ar_posix_acl = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400139 break;
140 case Opt_quota_off:
141 args->ar_quota = GFS2_QUOTA_OFF;
142 break;
143 case Opt_quota_account:
144 args->ar_quota = GFS2_QUOTA_ACCOUNT;
145 break;
146 case Opt_quota_on:
147 args->ar_quota = GFS2_QUOTA_ON;
148 break;
149 case Opt_suiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000150 args->ar_suiddir = 1;
Josef Bacik476c0062007-04-23 11:55:39 -0400151 break;
152 case Opt_nosuiddir:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000153 args->ar_suiddir = 0;
Josef Bacik476c0062007-04-23 11:55:39 -0400154 break;
155 case Opt_data_writeback:
156 args->ar_data = GFS2_DATA_WRITEBACK;
157 break;
158 case Opt_data_ordered:
159 args->ar_data = GFS2_DATA_ORDERED;
160 break;
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100161 case Opt_meta:
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100162 args->ar_meta = 1;
163 break;
Steven Whitehousef15ab562009-02-09 09:25:01 +0000164 case Opt_discard:
165 args->ar_discard = 1;
166 break;
167 case Opt_nodiscard:
168 args->ar_discard = 0;
169 break;
Benjamin Marzinski9a5ad132007-08-17 20:22:07 -0500170 case Opt_err:
Josef Bacik476c0062007-04-23 11:55:39 -0400171 default:
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000172 fs_info(sdp, "invalid mount option: %s\n", o);
173 return -EINVAL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000174 }
175 }
176
Steven Whitehouse6f04c1c2009-01-06 11:52:25 +0000177 return 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000178}
179