132
138
{ Opt_nosharecache, "nosharecache" },
133
139
{ Opt_resvport, "resvport" },
134
140
{ Opt_noresvport, "noresvport" },
141
{ Opt_fscache, "fsc" },
142
{ Opt_fscache_uniq, "fsc=%s" },
143
{ Opt_nofscache, "nofsc" },
136
{ Opt_port, "port=%u" },
137
{ Opt_rsize, "rsize=%u" },
138
{ Opt_wsize, "wsize=%u" },
139
{ Opt_bsize, "bsize=%u" },
140
{ Opt_timeo, "timeo=%u" },
141
{ Opt_retrans, "retrans=%u" },
142
{ Opt_acregmin, "acregmin=%u" },
143
{ Opt_acregmax, "acregmax=%u" },
144
{ Opt_acdirmin, "acdirmin=%u" },
145
{ Opt_acdirmax, "acdirmax=%u" },
146
{ Opt_actimeo, "actimeo=%u" },
147
{ Opt_namelen, "namlen=%u" },
148
{ Opt_mountport, "mountport=%u" },
149
{ Opt_mountvers, "mountvers=%u" },
150
{ Opt_nfsvers, "nfsvers=%u" },
151
{ Opt_nfsvers, "vers=%u" },
145
{ Opt_port, "port=%s" },
146
{ Opt_rsize, "rsize=%s" },
147
{ Opt_wsize, "wsize=%s" },
148
{ Opt_bsize, "bsize=%s" },
149
{ Opt_timeo, "timeo=%s" },
150
{ Opt_retrans, "retrans=%s" },
151
{ Opt_acregmin, "acregmin=%s" },
152
{ Opt_acregmax, "acregmax=%s" },
153
{ Opt_acdirmin, "acdirmin=%s" },
154
{ Opt_acdirmax, "acdirmax=%s" },
155
{ Opt_actimeo, "actimeo=%s" },
156
{ Opt_namelen, "namlen=%s" },
157
{ Opt_mountport, "mountport=%s" },
158
{ Opt_mountvers, "mountvers=%s" },
159
{ Opt_nfsvers, "nfsvers=%s" },
160
{ Opt_nfsvers, "vers=%s" },
161
{ Opt_minorversion, "minorversion=%u" },
153
163
{ Opt_sec, "sec=%s" },
154
164
{ Opt_proto, "proto=%s" },
264
274
#ifdef CONFIG_NFS_V4
265
275
static int nfs4_get_sb(struct file_system_type *fs_type,
266
276
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
277
static int nfs4_remote_get_sb(struct file_system_type *fs_type,
278
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
267
279
static int nfs4_xdev_get_sb(struct file_system_type *fs_type,
268
280
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
269
281
static int nfs4_referral_get_sb(struct file_system_type *fs_type,
270
282
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
283
static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
284
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
271
285
static void nfs4_kill_super(struct super_block *sb);
273
287
static struct file_system_type nfs4_fs_type = {
1043
1088
case Opt_noresvport:
1044
1089
mnt->flags |= NFS_MOUNT_NORESVPORT;
1092
mnt->options |= NFS_OPTION_FSCACHE;
1093
kfree(mnt->fscache_uniq);
1094
mnt->fscache_uniq = NULL;
1097
mnt->options &= ~NFS_OPTION_FSCACHE;
1098
kfree(mnt->fscache_uniq);
1099
mnt->fscache_uniq = NULL;
1101
case Opt_fscache_uniq:
1102
string = match_strdup(args);
1105
kfree(mnt->fscache_uniq);
1106
mnt->fscache_uniq = string;
1107
mnt->options |= NFS_OPTION_FSCACHE;
1048
1111
* options that take numeric values
1051
if (match_int(args, &option) ||
1052
option < 0 || option > USHORT_MAX) {
1054
nfs_parse_invalid_value("port");
1056
mnt->nfs_server.port = option;
1114
string = match_strdup(args);
1117
rc = strict_strtoul(string, 10, &option);
1119
if (rc != 0 || option > USHORT_MAX)
1120
goto out_invalid_value;
1121
mnt->nfs_server.port = option;
1058
1123
case Opt_rsize:
1059
if (match_int(args, &option) || option < 0) {
1061
nfs_parse_invalid_value("rsize");
1063
mnt->rsize = option;
1124
string = match_strdup(args);
1127
rc = strict_strtoul(string, 10, &option);
1130
goto out_invalid_value;
1131
mnt->rsize = option;
1065
1133
case Opt_wsize:
1066
if (match_int(args, &option) || option < 0) {
1068
nfs_parse_invalid_value("wsize");
1070
mnt->wsize = option;
1134
string = match_strdup(args);
1137
rc = strict_strtoul(string, 10, &option);
1140
goto out_invalid_value;
1141
mnt->wsize = option;
1072
1143
case Opt_bsize:
1073
if (match_int(args, &option) || option < 0) {
1075
nfs_parse_invalid_value("bsize");
1077
mnt->bsize = option;
1144
string = match_strdup(args);
1147
rc = strict_strtoul(string, 10, &option);
1150
goto out_invalid_value;
1151
mnt->bsize = option;
1079
1153
case Opt_timeo:
1080
if (match_int(args, &option) || option <= 0) {
1082
nfs_parse_invalid_value("timeo");
1084
mnt->timeo = option;
1154
string = match_strdup(args);
1157
rc = strict_strtoul(string, 10, &option);
1159
if (rc != 0 || option == 0)
1160
goto out_invalid_value;
1161
mnt->timeo = option;
1086
1163
case Opt_retrans:
1087
if (match_int(args, &option) || option <= 0) {
1089
nfs_parse_invalid_value("retrans");
1091
mnt->retrans = option;
1164
string = match_strdup(args);
1167
rc = strict_strtoul(string, 10, &option);
1169
if (rc != 0 || option == 0)
1170
goto out_invalid_value;
1171
mnt->retrans = option;
1093
1173
case Opt_acregmin:
1094
if (match_int(args, &option) || option < 0) {
1096
nfs_parse_invalid_value("acregmin");
1098
mnt->acregmin = option;
1174
string = match_strdup(args);
1177
rc = strict_strtoul(string, 10, &option);
1180
goto out_invalid_value;
1181
mnt->acregmin = option;
1100
1183
case Opt_acregmax:
1101
if (match_int(args, &option) || option < 0) {
1103
nfs_parse_invalid_value("acregmax");
1105
mnt->acregmax = option;
1184
string = match_strdup(args);
1187
rc = strict_strtoul(string, 10, &option);
1190
goto out_invalid_value;
1191
mnt->acregmax = option;
1107
1193
case Opt_acdirmin:
1108
if (match_int(args, &option) || option < 0) {
1110
nfs_parse_invalid_value("acdirmin");
1112
mnt->acdirmin = option;
1194
string = match_strdup(args);
1197
rc = strict_strtoul(string, 10, &option);
1200
goto out_invalid_value;
1201
mnt->acdirmin = option;
1114
1203
case Opt_acdirmax:
1115
if (match_int(args, &option) || option < 0) {
1117
nfs_parse_invalid_value("acdirmax");
1119
mnt->acdirmax = option;
1204
string = match_strdup(args);
1207
rc = strict_strtoul(string, 10, &option);
1210
goto out_invalid_value;
1211
mnt->acdirmax = option;
1121
1213
case Opt_actimeo:
1122
if (match_int(args, &option) || option < 0) {
1124
nfs_parse_invalid_value("actimeo");
1126
mnt->acregmin = mnt->acregmax =
1127
mnt->acdirmin = mnt->acdirmax = option;
1214
string = match_strdup(args);
1217
rc = strict_strtoul(string, 10, &option);
1220
goto out_invalid_value;
1221
mnt->acregmin = mnt->acregmax =
1222
mnt->acdirmin = mnt->acdirmax = option;
1129
1224
case Opt_namelen:
1130
if (match_int(args, &option) || option < 0) {
1132
nfs_parse_invalid_value("namlen");
1134
mnt->namlen = option;
1225
string = match_strdup(args);
1228
rc = strict_strtoul(string, 10, &option);
1231
goto out_invalid_value;
1232
mnt->namlen = option;
1136
1234
case Opt_mountport:
1137
if (match_int(args, &option) ||
1138
option < 0 || option > USHORT_MAX) {
1140
nfs_parse_invalid_value("mountport");
1142
mnt->mount_server.port = option;
1235
string = match_strdup(args);
1238
rc = strict_strtoul(string, 10, &option);
1240
if (rc != 0 || option > USHORT_MAX)
1241
goto out_invalid_value;
1242
mnt->mount_server.port = option;
1144
1244
case Opt_mountvers:
1145
if (match_int(args, &option) ||
1245
string = match_strdup(args);
1248
rc = strict_strtoul(string, 10, &option);
1146
1251
option < NFS_MNT_VERSION ||
1147
option > NFS_MNT3_VERSION) {
1149
nfs_parse_invalid_value("mountvers");
1151
mnt->mount_server.version = option;
1252
option > NFS_MNT3_VERSION)
1253
goto out_invalid_value;
1254
mnt->mount_server.version = option;
1153
1256
case Opt_nfsvers:
1154
if (match_int(args, &option)) {
1156
nfs_parse_invalid_value("nfsvers");
1257
string = match_strdup(args);
1260
rc = strict_strtoul(string, 10, &option);
1263
goto out_invalid_value;
1159
1264
switch (option) {
1160
1265
case NFS2_VERSION:
1161
1266
mnt->flags &= ~NFS_MOUNT_VER3;
2529
security_free_mnt_opts(&data->lsm_opts);
2535
nfs_free_server(server);
2541
deactivate_locked_super(s);
2545
static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
2546
int flags, void *data, const char *hostname)
2548
struct vfsmount *root_mnt;
2552
len = strlen(hostname) + 3;
2553
root_devname = kmalloc(len, GFP_KERNEL);
2554
if (root_devname == NULL)
2555
return ERR_PTR(-ENOMEM);
2556
snprintf(root_devname, len, "%s:/", hostname);
2557
root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
2558
kfree(root_devname);
2562
static void nfs_fix_devname(const struct path *path, struct vfsmount *mnt)
2564
char *page = (char *) __get_free_page(GFP_KERNEL);
2565
char *devname, *tmp;
2569
devname = nfs_path(path->mnt->mnt_devname,
2570
path->mnt->mnt_root, path->dentry,
2572
if (devname == NULL)
2574
tmp = kstrdup(devname, GFP_KERNEL);
2577
kfree(mnt->mnt_devname);
2578
mnt->mnt_devname = tmp;
2580
free_page((unsigned long)page);
2583
static int nfs_follow_remote_path(struct vfsmount *root_mnt,
2584
const char *export_path, struct vfsmount *mnt_target)
2586
struct mnt_namespace *ns_private;
2587
struct nameidata nd;
2588
struct super_block *s;
2591
ns_private = create_mnt_ns(root_mnt);
2592
ret = PTR_ERR(ns_private);
2593
if (IS_ERR(ns_private))
2596
ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
2597
export_path, LOOKUP_FOLLOW, &nd);
2599
put_mnt_ns(ns_private);
2604
s = nd.path.mnt->mnt_sb;
2605
atomic_inc(&s->s_active);
2606
mnt_target->mnt_sb = s;
2607
mnt_target->mnt_root = dget(nd.path.dentry);
2609
/* Correct the device pathname */
2610
nfs_fix_devname(&nd.path, mnt_target);
2613
down_write(&s->s_umount);
2622
* Get the superblock for an NFS4 mountpoint
2624
static int nfs4_get_sb(struct file_system_type *fs_type,
2625
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
2627
struct nfs_parsed_mount_data *data;
2629
struct vfsmount *root_mnt;
2630
int error = -ENOMEM;
2632
data = kzalloc(sizeof(*data), GFP_KERNEL);
2636
/* Validate the mount data */
2637
error = nfs4_validate_mount_data(raw_data, data, dev_name);
2641
export_path = data->nfs_server.export_path;
2642
data->nfs_server.export_path = "/";
2643
root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, data,
2644
data->nfs_server.hostname);
2645
data->nfs_server.export_path = export_path;
2647
error = PTR_ERR(root_mnt);
2648
if (IS_ERR(root_mnt))
2651
error = nfs_follow_remote_path(root_mnt, export_path, mnt);
2409
2654
kfree(data->client_address);
2410
2655
kfree(data->nfs_server.export_path);
2411
2656
kfree(data->nfs_server.hostname);
2412
security_free_mnt_opts(&data->lsm_opts);
2657
kfree(data->fscache_uniq);
2660
dprintk("<-- nfs4_get_sb() = %d%s\n", error,
2661
error != 0 ? " [error]" : "");
2419
nfs_free_server(server);
2425
up_write(&s->s_umount);
2426
deactivate_super(s);
2430
2665
static void nfs4_kill_super(struct super_block *sb)
2432
2667
struct nfs_server *server = NFS_SB(sb);
2669
dprintk("--> %s\n", __func__);
2434
2670
nfs_super_return_all_delegations(sb);
2435
2671
kill_anon_super(sb);
2437
2672
nfs4_renewd_prepare_shutdown(server);
2673
nfs_fscache_release_super_cookie(sb);
2438
2674
nfs_free_server(server);
2675
dprintk("<-- %s\n", __func__);
2603
2836
error_splat_super:
2604
up_write(&s->s_umount);
2605
deactivate_super(s);
2837
deactivate_locked_super(s);
2606
2838
dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
2843
* Create an NFS4 server record on referral traversal
2845
static int nfs4_referral_get_sb(struct file_system_type *fs_type,
2846
int flags, const char *dev_name, void *raw_data,
2847
struct vfsmount *mnt)
2849
struct nfs_clone_mount *data = raw_data;
2851
struct vfsmount *root_mnt;
2854
dprintk("--> nfs4_referral_get_sb()\n");
2856
export_path = data->mnt_path;
2857
data->mnt_path = "/";
2859
root_mnt = nfs_do_root_mount(&nfs4_remote_referral_fs_type,
2860
flags, data, data->hostname);
2861
data->mnt_path = export_path;
2863
error = PTR_ERR(root_mnt);
2864
if (IS_ERR(root_mnt))
2867
error = nfs_follow_remote_path(root_mnt, export_path, mnt);
2869
dprintk("<-- nfs4_referral_get_sb() = %d%s\n", error,
2870
error != 0 ? " [error]" : "");
2610
2874
#endif /* CONFIG_NFS_V4 */