Commit 9423a08ad5773d0a7612d434700561dc8346b6d6
Committed by
Trond Myklebust
1 parent
61d0a8e6a8
Exists in
master
and in
39 other branches
NFS: Add nfs_alloc_parsed_mount_data
Allocating nfs_parsed_mount_data and setting up the defaults is nearly the same for both nfs and nfs4 mounts. Both paths seem to use nfs_validate_transport_protocol(), so setting a default value for nfs_server.protocol ought to be unnecessary. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 1 changed file with 23 additions and 27 deletions Inline Diff
fs/nfs/super.c
1 | /* | 1 | /* |
2 | * linux/fs/nfs/super.c | 2 | * linux/fs/nfs/super.c |
3 | * | 3 | * |
4 | * Copyright (C) 1992 Rick Sladkey | 4 | * Copyright (C) 1992 Rick Sladkey |
5 | * | 5 | * |
6 | * nfs superblock handling functions | 6 | * nfs superblock handling functions |
7 | * | 7 | * |
8 | * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some | 8 | * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some |
9 | * experimental NFS changes. Modularisation taken straight from SYS5 fs. | 9 | * experimental NFS changes. Modularisation taken straight from SYS5 fs. |
10 | * | 10 | * |
11 | * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts. | 11 | * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts. |
12 | * J.S.Peatfield@damtp.cam.ac.uk | 12 | * J.S.Peatfield@damtp.cam.ac.uk |
13 | * | 13 | * |
14 | * Split from inode.c by David Howells <dhowells@redhat.com> | 14 | * Split from inode.c by David Howells <dhowells@redhat.com> |
15 | * | 15 | * |
16 | * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a | 16 | * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a |
17 | * particular server are held in the same superblock | 17 | * particular server are held in the same superblock |
18 | * - NFS superblocks can have several effective roots to the dentry tree | 18 | * - NFS superblocks can have several effective roots to the dentry tree |
19 | * - directory type roots are spliced into the tree when a path from one root reaches the root | 19 | * - directory type roots are spliced into the tree when a path from one root reaches the root |
20 | * of another (see nfs_lookup()) | 20 | * of another (see nfs_lookup()) |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | 25 | ||
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/stat.h> | 30 | #include <linux/stat.h> |
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | #include <linux/unistd.h> | 32 | #include <linux/unistd.h> |
33 | #include <linux/sunrpc/clnt.h> | 33 | #include <linux/sunrpc/clnt.h> |
34 | #include <linux/sunrpc/stats.h> | 34 | #include <linux/sunrpc/stats.h> |
35 | #include <linux/sunrpc/metrics.h> | 35 | #include <linux/sunrpc/metrics.h> |
36 | #include <linux/sunrpc/xprtsock.h> | 36 | #include <linux/sunrpc/xprtsock.h> |
37 | #include <linux/sunrpc/xprtrdma.h> | 37 | #include <linux/sunrpc/xprtrdma.h> |
38 | #include <linux/nfs_fs.h> | 38 | #include <linux/nfs_fs.h> |
39 | #include <linux/nfs_mount.h> | 39 | #include <linux/nfs_mount.h> |
40 | #include <linux/nfs4_mount.h> | 40 | #include <linux/nfs4_mount.h> |
41 | #include <linux/lockd/bind.h> | 41 | #include <linux/lockd/bind.h> |
42 | #include <linux/smp_lock.h> | 42 | #include <linux/smp_lock.h> |
43 | #include <linux/seq_file.h> | 43 | #include <linux/seq_file.h> |
44 | #include <linux/mount.h> | 44 | #include <linux/mount.h> |
45 | #include <linux/mnt_namespace.h> | 45 | #include <linux/mnt_namespace.h> |
46 | #include <linux/namei.h> | 46 | #include <linux/namei.h> |
47 | #include <linux/nfs_idmap.h> | 47 | #include <linux/nfs_idmap.h> |
48 | #include <linux/vfs.h> | 48 | #include <linux/vfs.h> |
49 | #include <linux/inet.h> | 49 | #include <linux/inet.h> |
50 | #include <linux/in6.h> | 50 | #include <linux/in6.h> |
51 | #include <net/ipv6.h> | 51 | #include <net/ipv6.h> |
52 | #include <linux/netdevice.h> | 52 | #include <linux/netdevice.h> |
53 | #include <linux/nfs_xdr.h> | 53 | #include <linux/nfs_xdr.h> |
54 | #include <linux/magic.h> | 54 | #include <linux/magic.h> |
55 | #include <linux/parser.h> | 55 | #include <linux/parser.h> |
56 | 56 | ||
57 | #include <asm/system.h> | 57 | #include <asm/system.h> |
58 | #include <asm/uaccess.h> | 58 | #include <asm/uaccess.h> |
59 | 59 | ||
60 | #include "nfs4_fs.h" | 60 | #include "nfs4_fs.h" |
61 | #include "callback.h" | 61 | #include "callback.h" |
62 | #include "delegation.h" | 62 | #include "delegation.h" |
63 | #include "iostat.h" | 63 | #include "iostat.h" |
64 | #include "internal.h" | 64 | #include "internal.h" |
65 | #include "fscache.h" | 65 | #include "fscache.h" |
66 | 66 | ||
67 | #define NFSDBG_FACILITY NFSDBG_VFS | 67 | #define NFSDBG_FACILITY NFSDBG_VFS |
68 | 68 | ||
69 | enum { | 69 | enum { |
70 | /* Mount options that take no arguments */ | 70 | /* Mount options that take no arguments */ |
71 | Opt_soft, Opt_hard, | 71 | Opt_soft, Opt_hard, |
72 | Opt_posix, Opt_noposix, | 72 | Opt_posix, Opt_noposix, |
73 | Opt_cto, Opt_nocto, | 73 | Opt_cto, Opt_nocto, |
74 | Opt_ac, Opt_noac, | 74 | Opt_ac, Opt_noac, |
75 | Opt_lock, Opt_nolock, | 75 | Opt_lock, Opt_nolock, |
76 | Opt_v2, Opt_v3, Opt_v4, | 76 | Opt_v2, Opt_v3, Opt_v4, |
77 | Opt_udp, Opt_tcp, Opt_rdma, | 77 | Opt_udp, Opt_tcp, Opt_rdma, |
78 | Opt_acl, Opt_noacl, | 78 | Opt_acl, Opt_noacl, |
79 | Opt_rdirplus, Opt_nordirplus, | 79 | Opt_rdirplus, Opt_nordirplus, |
80 | Opt_sharecache, Opt_nosharecache, | 80 | Opt_sharecache, Opt_nosharecache, |
81 | Opt_resvport, Opt_noresvport, | 81 | Opt_resvport, Opt_noresvport, |
82 | Opt_fscache, Opt_nofscache, | 82 | Opt_fscache, Opt_nofscache, |
83 | 83 | ||
84 | /* Mount options that take integer arguments */ | 84 | /* Mount options that take integer arguments */ |
85 | Opt_port, | 85 | Opt_port, |
86 | Opt_rsize, Opt_wsize, Opt_bsize, | 86 | Opt_rsize, Opt_wsize, Opt_bsize, |
87 | Opt_timeo, Opt_retrans, | 87 | Opt_timeo, Opt_retrans, |
88 | Opt_acregmin, Opt_acregmax, | 88 | Opt_acregmin, Opt_acregmax, |
89 | Opt_acdirmin, Opt_acdirmax, | 89 | Opt_acdirmin, Opt_acdirmax, |
90 | Opt_actimeo, | 90 | Opt_actimeo, |
91 | Opt_namelen, | 91 | Opt_namelen, |
92 | Opt_mountport, | 92 | Opt_mountport, |
93 | Opt_mountvers, | 93 | Opt_mountvers, |
94 | Opt_nfsvers, | 94 | Opt_nfsvers, |
95 | Opt_minorversion, | 95 | Opt_minorversion, |
96 | 96 | ||
97 | /* Mount options that take string arguments */ | 97 | /* Mount options that take string arguments */ |
98 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, | 98 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, |
99 | Opt_addr, Opt_mountaddr, Opt_clientaddr, | 99 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
100 | Opt_lookupcache, | 100 | Opt_lookupcache, |
101 | Opt_fscache_uniq, | 101 | Opt_fscache_uniq, |
102 | 102 | ||
103 | /* Special mount options */ | 103 | /* Special mount options */ |
104 | Opt_userspace, Opt_deprecated, Opt_sloppy, | 104 | Opt_userspace, Opt_deprecated, Opt_sloppy, |
105 | 105 | ||
106 | Opt_err | 106 | Opt_err |
107 | }; | 107 | }; |
108 | 108 | ||
109 | static const match_table_t nfs_mount_option_tokens = { | 109 | static const match_table_t nfs_mount_option_tokens = { |
110 | { Opt_userspace, "bg" }, | 110 | { Opt_userspace, "bg" }, |
111 | { Opt_userspace, "fg" }, | 111 | { Opt_userspace, "fg" }, |
112 | { Opt_userspace, "retry=%s" }, | 112 | { Opt_userspace, "retry=%s" }, |
113 | 113 | ||
114 | { Opt_sloppy, "sloppy" }, | 114 | { Opt_sloppy, "sloppy" }, |
115 | 115 | ||
116 | { Opt_soft, "soft" }, | 116 | { Opt_soft, "soft" }, |
117 | { Opt_hard, "hard" }, | 117 | { Opt_hard, "hard" }, |
118 | { Opt_deprecated, "intr" }, | 118 | { Opt_deprecated, "intr" }, |
119 | { Opt_deprecated, "nointr" }, | 119 | { Opt_deprecated, "nointr" }, |
120 | { Opt_posix, "posix" }, | 120 | { Opt_posix, "posix" }, |
121 | { Opt_noposix, "noposix" }, | 121 | { Opt_noposix, "noposix" }, |
122 | { Opt_cto, "cto" }, | 122 | { Opt_cto, "cto" }, |
123 | { Opt_nocto, "nocto" }, | 123 | { Opt_nocto, "nocto" }, |
124 | { Opt_ac, "ac" }, | 124 | { Opt_ac, "ac" }, |
125 | { Opt_noac, "noac" }, | 125 | { Opt_noac, "noac" }, |
126 | { Opt_lock, "lock" }, | 126 | { Opt_lock, "lock" }, |
127 | { Opt_nolock, "nolock" }, | 127 | { Opt_nolock, "nolock" }, |
128 | { Opt_v2, "v2" }, | 128 | { Opt_v2, "v2" }, |
129 | { Opt_v3, "v3" }, | 129 | { Opt_v3, "v3" }, |
130 | { Opt_v4, "v4" }, | 130 | { Opt_v4, "v4" }, |
131 | { Opt_udp, "udp" }, | 131 | { Opt_udp, "udp" }, |
132 | { Opt_tcp, "tcp" }, | 132 | { Opt_tcp, "tcp" }, |
133 | { Opt_rdma, "rdma" }, | 133 | { Opt_rdma, "rdma" }, |
134 | { Opt_acl, "acl" }, | 134 | { Opt_acl, "acl" }, |
135 | { Opt_noacl, "noacl" }, | 135 | { Opt_noacl, "noacl" }, |
136 | { Opt_rdirplus, "rdirplus" }, | 136 | { Opt_rdirplus, "rdirplus" }, |
137 | { Opt_nordirplus, "nordirplus" }, | 137 | { Opt_nordirplus, "nordirplus" }, |
138 | { Opt_sharecache, "sharecache" }, | 138 | { Opt_sharecache, "sharecache" }, |
139 | { Opt_nosharecache, "nosharecache" }, | 139 | { Opt_nosharecache, "nosharecache" }, |
140 | { Opt_resvport, "resvport" }, | 140 | { Opt_resvport, "resvport" }, |
141 | { Opt_noresvport, "noresvport" }, | 141 | { Opt_noresvport, "noresvport" }, |
142 | { Opt_fscache, "fsc" }, | 142 | { Opt_fscache, "fsc" }, |
143 | { Opt_fscache_uniq, "fsc=%s" }, | 143 | { Opt_fscache_uniq, "fsc=%s" }, |
144 | { Opt_nofscache, "nofsc" }, | 144 | { Opt_nofscache, "nofsc" }, |
145 | 145 | ||
146 | { Opt_port, "port=%s" }, | 146 | { Opt_port, "port=%s" }, |
147 | { Opt_rsize, "rsize=%s" }, | 147 | { Opt_rsize, "rsize=%s" }, |
148 | { Opt_wsize, "wsize=%s" }, | 148 | { Opt_wsize, "wsize=%s" }, |
149 | { Opt_bsize, "bsize=%s" }, | 149 | { Opt_bsize, "bsize=%s" }, |
150 | { Opt_timeo, "timeo=%s" }, | 150 | { Opt_timeo, "timeo=%s" }, |
151 | { Opt_retrans, "retrans=%s" }, | 151 | { Opt_retrans, "retrans=%s" }, |
152 | { Opt_acregmin, "acregmin=%s" }, | 152 | { Opt_acregmin, "acregmin=%s" }, |
153 | { Opt_acregmax, "acregmax=%s" }, | 153 | { Opt_acregmax, "acregmax=%s" }, |
154 | { Opt_acdirmin, "acdirmin=%s" }, | 154 | { Opt_acdirmin, "acdirmin=%s" }, |
155 | { Opt_acdirmax, "acdirmax=%s" }, | 155 | { Opt_acdirmax, "acdirmax=%s" }, |
156 | { Opt_actimeo, "actimeo=%s" }, | 156 | { Opt_actimeo, "actimeo=%s" }, |
157 | { Opt_namelen, "namlen=%s" }, | 157 | { Opt_namelen, "namlen=%s" }, |
158 | { Opt_mountport, "mountport=%s" }, | 158 | { Opt_mountport, "mountport=%s" }, |
159 | { Opt_mountvers, "mountvers=%s" }, | 159 | { Opt_mountvers, "mountvers=%s" }, |
160 | { Opt_nfsvers, "nfsvers=%s" }, | 160 | { Opt_nfsvers, "nfsvers=%s" }, |
161 | { Opt_nfsvers, "vers=%s" }, | 161 | { Opt_nfsvers, "vers=%s" }, |
162 | { Opt_minorversion, "minorversion=%s" }, | 162 | { Opt_minorversion, "minorversion=%s" }, |
163 | 163 | ||
164 | { Opt_sec, "sec=%s" }, | 164 | { Opt_sec, "sec=%s" }, |
165 | { Opt_proto, "proto=%s" }, | 165 | { Opt_proto, "proto=%s" }, |
166 | { Opt_mountproto, "mountproto=%s" }, | 166 | { Opt_mountproto, "mountproto=%s" }, |
167 | { Opt_addr, "addr=%s" }, | 167 | { Opt_addr, "addr=%s" }, |
168 | { Opt_clientaddr, "clientaddr=%s" }, | 168 | { Opt_clientaddr, "clientaddr=%s" }, |
169 | { Opt_mounthost, "mounthost=%s" }, | 169 | { Opt_mounthost, "mounthost=%s" }, |
170 | { Opt_mountaddr, "mountaddr=%s" }, | 170 | { Opt_mountaddr, "mountaddr=%s" }, |
171 | 171 | ||
172 | { Opt_lookupcache, "lookupcache=%s" }, | 172 | { Opt_lookupcache, "lookupcache=%s" }, |
173 | 173 | ||
174 | { Opt_err, NULL } | 174 | { Opt_err, NULL } |
175 | }; | 175 | }; |
176 | 176 | ||
177 | enum { | 177 | enum { |
178 | Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, | 178 | Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, |
179 | 179 | ||
180 | Opt_xprt_err | 180 | Opt_xprt_err |
181 | }; | 181 | }; |
182 | 182 | ||
183 | static const match_table_t nfs_xprt_protocol_tokens = { | 183 | static const match_table_t nfs_xprt_protocol_tokens = { |
184 | { Opt_xprt_udp, "udp" }, | 184 | { Opt_xprt_udp, "udp" }, |
185 | { Opt_xprt_tcp, "tcp" }, | 185 | { Opt_xprt_tcp, "tcp" }, |
186 | { Opt_xprt_rdma, "rdma" }, | 186 | { Opt_xprt_rdma, "rdma" }, |
187 | 187 | ||
188 | { Opt_xprt_err, NULL } | 188 | { Opt_xprt_err, NULL } |
189 | }; | 189 | }; |
190 | 190 | ||
191 | enum { | 191 | enum { |
192 | Opt_sec_none, Opt_sec_sys, | 192 | Opt_sec_none, Opt_sec_sys, |
193 | Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p, | 193 | Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p, |
194 | Opt_sec_lkey, Opt_sec_lkeyi, Opt_sec_lkeyp, | 194 | Opt_sec_lkey, Opt_sec_lkeyi, Opt_sec_lkeyp, |
195 | Opt_sec_spkm, Opt_sec_spkmi, Opt_sec_spkmp, | 195 | Opt_sec_spkm, Opt_sec_spkmi, Opt_sec_spkmp, |
196 | 196 | ||
197 | Opt_sec_err | 197 | Opt_sec_err |
198 | }; | 198 | }; |
199 | 199 | ||
200 | static const match_table_t nfs_secflavor_tokens = { | 200 | static const match_table_t nfs_secflavor_tokens = { |
201 | { Opt_sec_none, "none" }, | 201 | { Opt_sec_none, "none" }, |
202 | { Opt_sec_none, "null" }, | 202 | { Opt_sec_none, "null" }, |
203 | { Opt_sec_sys, "sys" }, | 203 | { Opt_sec_sys, "sys" }, |
204 | 204 | ||
205 | { Opt_sec_krb5, "krb5" }, | 205 | { Opt_sec_krb5, "krb5" }, |
206 | { Opt_sec_krb5i, "krb5i" }, | 206 | { Opt_sec_krb5i, "krb5i" }, |
207 | { Opt_sec_krb5p, "krb5p" }, | 207 | { Opt_sec_krb5p, "krb5p" }, |
208 | 208 | ||
209 | { Opt_sec_lkey, "lkey" }, | 209 | { Opt_sec_lkey, "lkey" }, |
210 | { Opt_sec_lkeyi, "lkeyi" }, | 210 | { Opt_sec_lkeyi, "lkeyi" }, |
211 | { Opt_sec_lkeyp, "lkeyp" }, | 211 | { Opt_sec_lkeyp, "lkeyp" }, |
212 | 212 | ||
213 | { Opt_sec_spkm, "spkm3" }, | 213 | { Opt_sec_spkm, "spkm3" }, |
214 | { Opt_sec_spkmi, "spkm3i" }, | 214 | { Opt_sec_spkmi, "spkm3i" }, |
215 | { Opt_sec_spkmp, "spkm3p" }, | 215 | { Opt_sec_spkmp, "spkm3p" }, |
216 | 216 | ||
217 | { Opt_sec_err, NULL } | 217 | { Opt_sec_err, NULL } |
218 | }; | 218 | }; |
219 | 219 | ||
220 | enum { | 220 | enum { |
221 | Opt_lookupcache_all, Opt_lookupcache_positive, | 221 | Opt_lookupcache_all, Opt_lookupcache_positive, |
222 | Opt_lookupcache_none, | 222 | Opt_lookupcache_none, |
223 | 223 | ||
224 | Opt_lookupcache_err | 224 | Opt_lookupcache_err |
225 | }; | 225 | }; |
226 | 226 | ||
227 | static match_table_t nfs_lookupcache_tokens = { | 227 | static match_table_t nfs_lookupcache_tokens = { |
228 | { Opt_lookupcache_all, "all" }, | 228 | { Opt_lookupcache_all, "all" }, |
229 | { Opt_lookupcache_positive, "pos" }, | 229 | { Opt_lookupcache_positive, "pos" }, |
230 | { Opt_lookupcache_positive, "positive" }, | 230 | { Opt_lookupcache_positive, "positive" }, |
231 | { Opt_lookupcache_none, "none" }, | 231 | { Opt_lookupcache_none, "none" }, |
232 | 232 | ||
233 | { Opt_lookupcache_err, NULL } | 233 | { Opt_lookupcache_err, NULL } |
234 | }; | 234 | }; |
235 | 235 | ||
236 | 236 | ||
237 | static void nfs_umount_begin(struct super_block *); | 237 | static void nfs_umount_begin(struct super_block *); |
238 | static int nfs_statfs(struct dentry *, struct kstatfs *); | 238 | static int nfs_statfs(struct dentry *, struct kstatfs *); |
239 | static int nfs_show_options(struct seq_file *, struct vfsmount *); | 239 | static int nfs_show_options(struct seq_file *, struct vfsmount *); |
240 | static int nfs_show_stats(struct seq_file *, struct vfsmount *); | 240 | static int nfs_show_stats(struct seq_file *, struct vfsmount *); |
241 | static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); | 241 | static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); |
242 | static int nfs_xdev_get_sb(struct file_system_type *fs_type, | 242 | static int nfs_xdev_get_sb(struct file_system_type *fs_type, |
243 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 243 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
244 | static void nfs_kill_super(struct super_block *); | 244 | static void nfs_kill_super(struct super_block *); |
245 | static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); | 245 | static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); |
246 | 246 | ||
247 | static struct file_system_type nfs_fs_type = { | 247 | static struct file_system_type nfs_fs_type = { |
248 | .owner = THIS_MODULE, | 248 | .owner = THIS_MODULE, |
249 | .name = "nfs", | 249 | .name = "nfs", |
250 | .get_sb = nfs_get_sb, | 250 | .get_sb = nfs_get_sb, |
251 | .kill_sb = nfs_kill_super, | 251 | .kill_sb = nfs_kill_super, |
252 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 252 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
253 | }; | 253 | }; |
254 | 254 | ||
255 | struct file_system_type nfs_xdev_fs_type = { | 255 | struct file_system_type nfs_xdev_fs_type = { |
256 | .owner = THIS_MODULE, | 256 | .owner = THIS_MODULE, |
257 | .name = "nfs", | 257 | .name = "nfs", |
258 | .get_sb = nfs_xdev_get_sb, | 258 | .get_sb = nfs_xdev_get_sb, |
259 | .kill_sb = nfs_kill_super, | 259 | .kill_sb = nfs_kill_super, |
260 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 260 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
261 | }; | 261 | }; |
262 | 262 | ||
263 | static const struct super_operations nfs_sops = { | 263 | static const struct super_operations nfs_sops = { |
264 | .alloc_inode = nfs_alloc_inode, | 264 | .alloc_inode = nfs_alloc_inode, |
265 | .destroy_inode = nfs_destroy_inode, | 265 | .destroy_inode = nfs_destroy_inode, |
266 | .write_inode = nfs_write_inode, | 266 | .write_inode = nfs_write_inode, |
267 | .statfs = nfs_statfs, | 267 | .statfs = nfs_statfs, |
268 | .clear_inode = nfs_clear_inode, | 268 | .clear_inode = nfs_clear_inode, |
269 | .umount_begin = nfs_umount_begin, | 269 | .umount_begin = nfs_umount_begin, |
270 | .show_options = nfs_show_options, | 270 | .show_options = nfs_show_options, |
271 | .show_stats = nfs_show_stats, | 271 | .show_stats = nfs_show_stats, |
272 | .remount_fs = nfs_remount, | 272 | .remount_fs = nfs_remount, |
273 | }; | 273 | }; |
274 | 274 | ||
275 | #ifdef CONFIG_NFS_V4 | 275 | #ifdef CONFIG_NFS_V4 |
276 | static int nfs4_validate_text_mount_data(void *options, | 276 | static int nfs4_validate_text_mount_data(void *options, |
277 | struct nfs_parsed_mount_data *args, const char *dev_name); | 277 | struct nfs_parsed_mount_data *args, const char *dev_name); |
278 | static int nfs4_try_mount(int flags, const char *dev_name, | 278 | static int nfs4_try_mount(int flags, const char *dev_name, |
279 | struct nfs_parsed_mount_data *data, struct vfsmount *mnt); | 279 | struct nfs_parsed_mount_data *data, struct vfsmount *mnt); |
280 | static int nfs4_get_sb(struct file_system_type *fs_type, | 280 | static int nfs4_get_sb(struct file_system_type *fs_type, |
281 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 281 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
282 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, | 282 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, |
283 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 283 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
284 | static int nfs4_xdev_get_sb(struct file_system_type *fs_type, | 284 | static int nfs4_xdev_get_sb(struct file_system_type *fs_type, |
285 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 285 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
286 | static int nfs4_referral_get_sb(struct file_system_type *fs_type, | 286 | static int nfs4_referral_get_sb(struct file_system_type *fs_type, |
287 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 287 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
288 | static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | 288 | static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, |
289 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 289 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
290 | static void nfs4_kill_super(struct super_block *sb); | 290 | static void nfs4_kill_super(struct super_block *sb); |
291 | 291 | ||
292 | static struct file_system_type nfs4_fs_type = { | 292 | static struct file_system_type nfs4_fs_type = { |
293 | .owner = THIS_MODULE, | 293 | .owner = THIS_MODULE, |
294 | .name = "nfs4", | 294 | .name = "nfs4", |
295 | .get_sb = nfs4_get_sb, | 295 | .get_sb = nfs4_get_sb, |
296 | .kill_sb = nfs4_kill_super, | 296 | .kill_sb = nfs4_kill_super, |
297 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 297 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
298 | }; | 298 | }; |
299 | 299 | ||
300 | static struct file_system_type nfs4_remote_fs_type = { | 300 | static struct file_system_type nfs4_remote_fs_type = { |
301 | .owner = THIS_MODULE, | 301 | .owner = THIS_MODULE, |
302 | .name = "nfs4", | 302 | .name = "nfs4", |
303 | .get_sb = nfs4_remote_get_sb, | 303 | .get_sb = nfs4_remote_get_sb, |
304 | .kill_sb = nfs4_kill_super, | 304 | .kill_sb = nfs4_kill_super, |
305 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 305 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
306 | }; | 306 | }; |
307 | 307 | ||
308 | struct file_system_type nfs4_xdev_fs_type = { | 308 | struct file_system_type nfs4_xdev_fs_type = { |
309 | .owner = THIS_MODULE, | 309 | .owner = THIS_MODULE, |
310 | .name = "nfs4", | 310 | .name = "nfs4", |
311 | .get_sb = nfs4_xdev_get_sb, | 311 | .get_sb = nfs4_xdev_get_sb, |
312 | .kill_sb = nfs4_kill_super, | 312 | .kill_sb = nfs4_kill_super, |
313 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 313 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
314 | }; | 314 | }; |
315 | 315 | ||
316 | static struct file_system_type nfs4_remote_referral_fs_type = { | 316 | static struct file_system_type nfs4_remote_referral_fs_type = { |
317 | .owner = THIS_MODULE, | 317 | .owner = THIS_MODULE, |
318 | .name = "nfs4", | 318 | .name = "nfs4", |
319 | .get_sb = nfs4_remote_referral_get_sb, | 319 | .get_sb = nfs4_remote_referral_get_sb, |
320 | .kill_sb = nfs4_kill_super, | 320 | .kill_sb = nfs4_kill_super, |
321 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 321 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
322 | }; | 322 | }; |
323 | 323 | ||
324 | struct file_system_type nfs4_referral_fs_type = { | 324 | struct file_system_type nfs4_referral_fs_type = { |
325 | .owner = THIS_MODULE, | 325 | .owner = THIS_MODULE, |
326 | .name = "nfs4", | 326 | .name = "nfs4", |
327 | .get_sb = nfs4_referral_get_sb, | 327 | .get_sb = nfs4_referral_get_sb, |
328 | .kill_sb = nfs4_kill_super, | 328 | .kill_sb = nfs4_kill_super, |
329 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 329 | .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
330 | }; | 330 | }; |
331 | 331 | ||
332 | static const struct super_operations nfs4_sops = { | 332 | static const struct super_operations nfs4_sops = { |
333 | .alloc_inode = nfs_alloc_inode, | 333 | .alloc_inode = nfs_alloc_inode, |
334 | .destroy_inode = nfs_destroy_inode, | 334 | .destroy_inode = nfs_destroy_inode, |
335 | .write_inode = nfs_write_inode, | 335 | .write_inode = nfs_write_inode, |
336 | .statfs = nfs_statfs, | 336 | .statfs = nfs_statfs, |
337 | .clear_inode = nfs4_clear_inode, | 337 | .clear_inode = nfs4_clear_inode, |
338 | .umount_begin = nfs_umount_begin, | 338 | .umount_begin = nfs_umount_begin, |
339 | .show_options = nfs_show_options, | 339 | .show_options = nfs_show_options, |
340 | .show_stats = nfs_show_stats, | 340 | .show_stats = nfs_show_stats, |
341 | .remount_fs = nfs_remount, | 341 | .remount_fs = nfs_remount, |
342 | }; | 342 | }; |
343 | #endif | 343 | #endif |
344 | 344 | ||
345 | static struct shrinker acl_shrinker = { | 345 | static struct shrinker acl_shrinker = { |
346 | .shrink = nfs_access_cache_shrinker, | 346 | .shrink = nfs_access_cache_shrinker, |
347 | .seeks = DEFAULT_SEEKS, | 347 | .seeks = DEFAULT_SEEKS, |
348 | }; | 348 | }; |
349 | 349 | ||
350 | /* | 350 | /* |
351 | * Register the NFS filesystems | 351 | * Register the NFS filesystems |
352 | */ | 352 | */ |
353 | int __init register_nfs_fs(void) | 353 | int __init register_nfs_fs(void) |
354 | { | 354 | { |
355 | int ret; | 355 | int ret; |
356 | 356 | ||
357 | ret = register_filesystem(&nfs_fs_type); | 357 | ret = register_filesystem(&nfs_fs_type); |
358 | if (ret < 0) | 358 | if (ret < 0) |
359 | goto error_0; | 359 | goto error_0; |
360 | 360 | ||
361 | ret = nfs_register_sysctl(); | 361 | ret = nfs_register_sysctl(); |
362 | if (ret < 0) | 362 | if (ret < 0) |
363 | goto error_1; | 363 | goto error_1; |
364 | #ifdef CONFIG_NFS_V4 | 364 | #ifdef CONFIG_NFS_V4 |
365 | ret = register_filesystem(&nfs4_fs_type); | 365 | ret = register_filesystem(&nfs4_fs_type); |
366 | if (ret < 0) | 366 | if (ret < 0) |
367 | goto error_2; | 367 | goto error_2; |
368 | #endif | 368 | #endif |
369 | register_shrinker(&acl_shrinker); | 369 | register_shrinker(&acl_shrinker); |
370 | return 0; | 370 | return 0; |
371 | 371 | ||
372 | #ifdef CONFIG_NFS_V4 | 372 | #ifdef CONFIG_NFS_V4 |
373 | error_2: | 373 | error_2: |
374 | nfs_unregister_sysctl(); | 374 | nfs_unregister_sysctl(); |
375 | #endif | 375 | #endif |
376 | error_1: | 376 | error_1: |
377 | unregister_filesystem(&nfs_fs_type); | 377 | unregister_filesystem(&nfs_fs_type); |
378 | error_0: | 378 | error_0: |
379 | return ret; | 379 | return ret; |
380 | } | 380 | } |
381 | 381 | ||
382 | /* | 382 | /* |
383 | * Unregister the NFS filesystems | 383 | * Unregister the NFS filesystems |
384 | */ | 384 | */ |
385 | void __exit unregister_nfs_fs(void) | 385 | void __exit unregister_nfs_fs(void) |
386 | { | 386 | { |
387 | unregister_shrinker(&acl_shrinker); | 387 | unregister_shrinker(&acl_shrinker); |
388 | #ifdef CONFIG_NFS_V4 | 388 | #ifdef CONFIG_NFS_V4 |
389 | unregister_filesystem(&nfs4_fs_type); | 389 | unregister_filesystem(&nfs4_fs_type); |
390 | #endif | 390 | #endif |
391 | nfs_unregister_sysctl(); | 391 | nfs_unregister_sysctl(); |
392 | unregister_filesystem(&nfs_fs_type); | 392 | unregister_filesystem(&nfs_fs_type); |
393 | } | 393 | } |
394 | 394 | ||
395 | void nfs_sb_active(struct super_block *sb) | 395 | void nfs_sb_active(struct super_block *sb) |
396 | { | 396 | { |
397 | struct nfs_server *server = NFS_SB(sb); | 397 | struct nfs_server *server = NFS_SB(sb); |
398 | 398 | ||
399 | if (atomic_inc_return(&server->active) == 1) | 399 | if (atomic_inc_return(&server->active) == 1) |
400 | atomic_inc(&sb->s_active); | 400 | atomic_inc(&sb->s_active); |
401 | } | 401 | } |
402 | 402 | ||
403 | void nfs_sb_deactive(struct super_block *sb) | 403 | void nfs_sb_deactive(struct super_block *sb) |
404 | { | 404 | { |
405 | struct nfs_server *server = NFS_SB(sb); | 405 | struct nfs_server *server = NFS_SB(sb); |
406 | 406 | ||
407 | if (atomic_dec_and_test(&server->active)) | 407 | if (atomic_dec_and_test(&server->active)) |
408 | deactivate_super(sb); | 408 | deactivate_super(sb); |
409 | } | 409 | } |
410 | 410 | ||
411 | /* | 411 | /* |
412 | * Deliver file system statistics to userspace | 412 | * Deliver file system statistics to userspace |
413 | */ | 413 | */ |
414 | static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 414 | static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
415 | { | 415 | { |
416 | struct nfs_server *server = NFS_SB(dentry->d_sb); | 416 | struct nfs_server *server = NFS_SB(dentry->d_sb); |
417 | unsigned char blockbits; | 417 | unsigned char blockbits; |
418 | unsigned long blockres; | 418 | unsigned long blockres; |
419 | struct nfs_fh *fh = NFS_FH(dentry->d_inode); | 419 | struct nfs_fh *fh = NFS_FH(dentry->d_inode); |
420 | struct nfs_fattr fattr; | 420 | struct nfs_fattr fattr; |
421 | struct nfs_fsstat res = { | 421 | struct nfs_fsstat res = { |
422 | .fattr = &fattr, | 422 | .fattr = &fattr, |
423 | }; | 423 | }; |
424 | int error; | 424 | int error; |
425 | 425 | ||
426 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); | 426 | error = server->nfs_client->rpc_ops->statfs(server, fh, &res); |
427 | if (error < 0) | 427 | if (error < 0) |
428 | goto out_err; | 428 | goto out_err; |
429 | buf->f_type = NFS_SUPER_MAGIC; | 429 | buf->f_type = NFS_SUPER_MAGIC; |
430 | 430 | ||
431 | /* | 431 | /* |
432 | * Current versions of glibc do not correctly handle the | 432 | * Current versions of glibc do not correctly handle the |
433 | * case where f_frsize != f_bsize. Eventually we want to | 433 | * case where f_frsize != f_bsize. Eventually we want to |
434 | * report the value of wtmult in this field. | 434 | * report the value of wtmult in this field. |
435 | */ | 435 | */ |
436 | buf->f_frsize = dentry->d_sb->s_blocksize; | 436 | buf->f_frsize = dentry->d_sb->s_blocksize; |
437 | 437 | ||
438 | /* | 438 | /* |
439 | * On most *nix systems, f_blocks, f_bfree, and f_bavail | 439 | * On most *nix systems, f_blocks, f_bfree, and f_bavail |
440 | * are reported in units of f_frsize. Linux hasn't had | 440 | * are reported in units of f_frsize. Linux hasn't had |
441 | * an f_frsize field in its statfs struct until recently, | 441 | * an f_frsize field in its statfs struct until recently, |
442 | * thus historically Linux's sys_statfs reports these | 442 | * thus historically Linux's sys_statfs reports these |
443 | * fields in units of f_bsize. | 443 | * fields in units of f_bsize. |
444 | */ | 444 | */ |
445 | buf->f_bsize = dentry->d_sb->s_blocksize; | 445 | buf->f_bsize = dentry->d_sb->s_blocksize; |
446 | blockbits = dentry->d_sb->s_blocksize_bits; | 446 | blockbits = dentry->d_sb->s_blocksize_bits; |
447 | blockres = (1 << blockbits) - 1; | 447 | blockres = (1 << blockbits) - 1; |
448 | buf->f_blocks = (res.tbytes + blockres) >> blockbits; | 448 | buf->f_blocks = (res.tbytes + blockres) >> blockbits; |
449 | buf->f_bfree = (res.fbytes + blockres) >> blockbits; | 449 | buf->f_bfree = (res.fbytes + blockres) >> blockbits; |
450 | buf->f_bavail = (res.abytes + blockres) >> blockbits; | 450 | buf->f_bavail = (res.abytes + blockres) >> blockbits; |
451 | 451 | ||
452 | buf->f_files = res.tfiles; | 452 | buf->f_files = res.tfiles; |
453 | buf->f_ffree = res.afiles; | 453 | buf->f_ffree = res.afiles; |
454 | 454 | ||
455 | buf->f_namelen = server->namelen; | 455 | buf->f_namelen = server->namelen; |
456 | 456 | ||
457 | return 0; | 457 | return 0; |
458 | 458 | ||
459 | out_err: | 459 | out_err: |
460 | dprintk("%s: statfs error = %d\n", __func__, -error); | 460 | dprintk("%s: statfs error = %d\n", __func__, -error); |
461 | return error; | 461 | return error; |
462 | } | 462 | } |
463 | 463 | ||
464 | /* | 464 | /* |
465 | * Map the security flavour number to a name | 465 | * Map the security flavour number to a name |
466 | */ | 466 | */ |
467 | static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) | 467 | static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) |
468 | { | 468 | { |
469 | static const struct { | 469 | static const struct { |
470 | rpc_authflavor_t flavour; | 470 | rpc_authflavor_t flavour; |
471 | const char *str; | 471 | const char *str; |
472 | } sec_flavours[] = { | 472 | } sec_flavours[] = { |
473 | { RPC_AUTH_NULL, "null" }, | 473 | { RPC_AUTH_NULL, "null" }, |
474 | { RPC_AUTH_UNIX, "sys" }, | 474 | { RPC_AUTH_UNIX, "sys" }, |
475 | { RPC_AUTH_GSS_KRB5, "krb5" }, | 475 | { RPC_AUTH_GSS_KRB5, "krb5" }, |
476 | { RPC_AUTH_GSS_KRB5I, "krb5i" }, | 476 | { RPC_AUTH_GSS_KRB5I, "krb5i" }, |
477 | { RPC_AUTH_GSS_KRB5P, "krb5p" }, | 477 | { RPC_AUTH_GSS_KRB5P, "krb5p" }, |
478 | { RPC_AUTH_GSS_LKEY, "lkey" }, | 478 | { RPC_AUTH_GSS_LKEY, "lkey" }, |
479 | { RPC_AUTH_GSS_LKEYI, "lkeyi" }, | 479 | { RPC_AUTH_GSS_LKEYI, "lkeyi" }, |
480 | { RPC_AUTH_GSS_LKEYP, "lkeyp" }, | 480 | { RPC_AUTH_GSS_LKEYP, "lkeyp" }, |
481 | { RPC_AUTH_GSS_SPKM, "spkm" }, | 481 | { RPC_AUTH_GSS_SPKM, "spkm" }, |
482 | { RPC_AUTH_GSS_SPKMI, "spkmi" }, | 482 | { RPC_AUTH_GSS_SPKMI, "spkmi" }, |
483 | { RPC_AUTH_GSS_SPKMP, "spkmp" }, | 483 | { RPC_AUTH_GSS_SPKMP, "spkmp" }, |
484 | { UINT_MAX, "unknown" } | 484 | { UINT_MAX, "unknown" } |
485 | }; | 485 | }; |
486 | int i; | 486 | int i; |
487 | 487 | ||
488 | for (i = 0; sec_flavours[i].flavour != UINT_MAX; i++) { | 488 | for (i = 0; sec_flavours[i].flavour != UINT_MAX; i++) { |
489 | if (sec_flavours[i].flavour == flavour) | 489 | if (sec_flavours[i].flavour == flavour) |
490 | break; | 490 | break; |
491 | } | 491 | } |
492 | return sec_flavours[i].str; | 492 | return sec_flavours[i].str; |
493 | } | 493 | } |
494 | 494 | ||
495 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | 495 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, |
496 | int showdefaults) | 496 | int showdefaults) |
497 | { | 497 | { |
498 | struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address; | 498 | struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address; |
499 | 499 | ||
500 | switch (sap->sa_family) { | 500 | switch (sap->sa_family) { |
501 | case AF_INET: { | 501 | case AF_INET: { |
502 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; | 502 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; |
503 | seq_printf(m, ",mountaddr=%pI4", &sin->sin_addr.s_addr); | 503 | seq_printf(m, ",mountaddr=%pI4", &sin->sin_addr.s_addr); |
504 | break; | 504 | break; |
505 | } | 505 | } |
506 | case AF_INET6: { | 506 | case AF_INET6: { |
507 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | 507 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; |
508 | seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr); | 508 | seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr); |
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | default: | 511 | default: |
512 | if (showdefaults) | 512 | if (showdefaults) |
513 | seq_printf(m, ",mountaddr=unspecified"); | 513 | seq_printf(m, ",mountaddr=unspecified"); |
514 | } | 514 | } |
515 | 515 | ||
516 | if (nfss->mountd_version || showdefaults) | 516 | if (nfss->mountd_version || showdefaults) |
517 | seq_printf(m, ",mountvers=%u", nfss->mountd_version); | 517 | seq_printf(m, ",mountvers=%u", nfss->mountd_version); |
518 | if (nfss->mountd_port || showdefaults) | 518 | if (nfss->mountd_port || showdefaults) |
519 | seq_printf(m, ",mountport=%u", nfss->mountd_port); | 519 | seq_printf(m, ",mountport=%u", nfss->mountd_port); |
520 | 520 | ||
521 | switch (nfss->mountd_protocol) { | 521 | switch (nfss->mountd_protocol) { |
522 | case IPPROTO_UDP: | 522 | case IPPROTO_UDP: |
523 | seq_printf(m, ",mountproto=udp"); | 523 | seq_printf(m, ",mountproto=udp"); |
524 | break; | 524 | break; |
525 | case IPPROTO_TCP: | 525 | case IPPROTO_TCP: |
526 | seq_printf(m, ",mountproto=tcp"); | 526 | seq_printf(m, ",mountproto=tcp"); |
527 | break; | 527 | break; |
528 | default: | 528 | default: |
529 | if (showdefaults) | 529 | if (showdefaults) |
530 | seq_printf(m, ",mountproto=auto"); | 530 | seq_printf(m, ",mountproto=auto"); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | /* | 534 | /* |
535 | * Describe the mount options in force on this server representation | 535 | * Describe the mount options in force on this server representation |
536 | */ | 536 | */ |
537 | static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | 537 | static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, |
538 | int showdefaults) | 538 | int showdefaults) |
539 | { | 539 | { |
540 | static const struct proc_nfs_info { | 540 | static const struct proc_nfs_info { |
541 | int flag; | 541 | int flag; |
542 | const char *str; | 542 | const char *str; |
543 | const char *nostr; | 543 | const char *nostr; |
544 | } nfs_info[] = { | 544 | } nfs_info[] = { |
545 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, | 545 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, |
546 | { NFS_MOUNT_POSIX, ",posix", "" }, | 546 | { NFS_MOUNT_POSIX, ",posix", "" }, |
547 | { NFS_MOUNT_NOCTO, ",nocto", "" }, | 547 | { NFS_MOUNT_NOCTO, ",nocto", "" }, |
548 | { NFS_MOUNT_NOAC, ",noac", "" }, | 548 | { NFS_MOUNT_NOAC, ",noac", "" }, |
549 | { NFS_MOUNT_NONLM, ",nolock", "" }, | 549 | { NFS_MOUNT_NONLM, ",nolock", "" }, |
550 | { NFS_MOUNT_NOACL, ",noacl", "" }, | 550 | { NFS_MOUNT_NOACL, ",noacl", "" }, |
551 | { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" }, | 551 | { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" }, |
552 | { NFS_MOUNT_UNSHARED, ",nosharecache", "" }, | 552 | { NFS_MOUNT_UNSHARED, ",nosharecache", "" }, |
553 | { NFS_MOUNT_NORESVPORT, ",noresvport", "" }, | 553 | { NFS_MOUNT_NORESVPORT, ",noresvport", "" }, |
554 | { 0, NULL, NULL } | 554 | { 0, NULL, NULL } |
555 | }; | 555 | }; |
556 | const struct proc_nfs_info *nfs_infop; | 556 | const struct proc_nfs_info *nfs_infop; |
557 | struct nfs_client *clp = nfss->nfs_client; | 557 | struct nfs_client *clp = nfss->nfs_client; |
558 | u32 version = clp->rpc_ops->version; | 558 | u32 version = clp->rpc_ops->version; |
559 | 559 | ||
560 | seq_printf(m, ",vers=%u", version); | 560 | seq_printf(m, ",vers=%u", version); |
561 | seq_printf(m, ",rsize=%u", nfss->rsize); | 561 | seq_printf(m, ",rsize=%u", nfss->rsize); |
562 | seq_printf(m, ",wsize=%u", nfss->wsize); | 562 | seq_printf(m, ",wsize=%u", nfss->wsize); |
563 | if (nfss->bsize != 0) | 563 | if (nfss->bsize != 0) |
564 | seq_printf(m, ",bsize=%u", nfss->bsize); | 564 | seq_printf(m, ",bsize=%u", nfss->bsize); |
565 | seq_printf(m, ",namlen=%u", nfss->namelen); | 565 | seq_printf(m, ",namlen=%u", nfss->namelen); |
566 | if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults) | 566 | if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults) |
567 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); | 567 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); |
568 | if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults) | 568 | if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults) |
569 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); | 569 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); |
570 | if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults) | 570 | if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults) |
571 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); | 571 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); |
572 | if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults) | 572 | if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults) |
573 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); | 573 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); |
574 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | 574 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { |
575 | if (nfss->flags & nfs_infop->flag) | 575 | if (nfss->flags & nfs_infop->flag) |
576 | seq_puts(m, nfs_infop->str); | 576 | seq_puts(m, nfs_infop->str); |
577 | else | 577 | else |
578 | seq_puts(m, nfs_infop->nostr); | 578 | seq_puts(m, nfs_infop->nostr); |
579 | } | 579 | } |
580 | seq_printf(m, ",proto=%s", | 580 | seq_printf(m, ",proto=%s", |
581 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); | 581 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); |
582 | if (version == 4) { | 582 | if (version == 4) { |
583 | if (nfss->port != NFS_PORT) | 583 | if (nfss->port != NFS_PORT) |
584 | seq_printf(m, ",port=%u", nfss->port); | 584 | seq_printf(m, ",port=%u", nfss->port); |
585 | } else | 585 | } else |
586 | if (nfss->port) | 586 | if (nfss->port) |
587 | seq_printf(m, ",port=%u", nfss->port); | 587 | seq_printf(m, ",port=%u", nfss->port); |
588 | 588 | ||
589 | seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ); | 589 | seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ); |
590 | seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries); | 590 | seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries); |
591 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); | 591 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); |
592 | 592 | ||
593 | if (version != 4) | 593 | if (version != 4) |
594 | nfs_show_mountd_options(m, nfss, showdefaults); | 594 | nfs_show_mountd_options(m, nfss, showdefaults); |
595 | 595 | ||
596 | #ifdef CONFIG_NFS_V4 | 596 | #ifdef CONFIG_NFS_V4 |
597 | if (clp->rpc_ops->version == 4) | 597 | if (clp->rpc_ops->version == 4) |
598 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); | 598 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); |
599 | #endif | 599 | #endif |
600 | if (nfss->options & NFS_OPTION_FSCACHE) | 600 | if (nfss->options & NFS_OPTION_FSCACHE) |
601 | seq_printf(m, ",fsc"); | 601 | seq_printf(m, ",fsc"); |
602 | } | 602 | } |
603 | 603 | ||
604 | /* | 604 | /* |
605 | * Describe the mount options on this VFS mountpoint | 605 | * Describe the mount options on this VFS mountpoint |
606 | */ | 606 | */ |
607 | static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) | 607 | static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) |
608 | { | 608 | { |
609 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | 609 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); |
610 | 610 | ||
611 | nfs_show_mount_options(m, nfss, 0); | 611 | nfs_show_mount_options(m, nfss, 0); |
612 | 612 | ||
613 | seq_printf(m, ",addr=%s", | 613 | seq_printf(m, ",addr=%s", |
614 | rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient, | 614 | rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient, |
615 | RPC_DISPLAY_ADDR)); | 615 | RPC_DISPLAY_ADDR)); |
616 | 616 | ||
617 | return 0; | 617 | return 0; |
618 | } | 618 | } |
619 | 619 | ||
620 | /* | 620 | /* |
621 | * Present statistical information for this VFS mountpoint | 621 | * Present statistical information for this VFS mountpoint |
622 | */ | 622 | */ |
623 | static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) | 623 | static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) |
624 | { | 624 | { |
625 | int i, cpu; | 625 | int i, cpu; |
626 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | 626 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); |
627 | struct rpc_auth *auth = nfss->client->cl_auth; | 627 | struct rpc_auth *auth = nfss->client->cl_auth; |
628 | struct nfs_iostats totals = { }; | 628 | struct nfs_iostats totals = { }; |
629 | 629 | ||
630 | seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS); | 630 | seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS); |
631 | 631 | ||
632 | /* | 632 | /* |
633 | * Display all mount option settings | 633 | * Display all mount option settings |
634 | */ | 634 | */ |
635 | seq_printf(m, "\n\topts:\t"); | 635 | seq_printf(m, "\n\topts:\t"); |
636 | seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); | 636 | seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); |
637 | seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); | 637 | seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); |
638 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); | 638 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); |
639 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); | 639 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); |
640 | nfs_show_mount_options(m, nfss, 1); | 640 | nfs_show_mount_options(m, nfss, 1); |
641 | 641 | ||
642 | seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); | 642 | seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); |
643 | 643 | ||
644 | seq_printf(m, "\n\tcaps:\t"); | 644 | seq_printf(m, "\n\tcaps:\t"); |
645 | seq_printf(m, "caps=0x%x", nfss->caps); | 645 | seq_printf(m, "caps=0x%x", nfss->caps); |
646 | seq_printf(m, ",wtmult=%u", nfss->wtmult); | 646 | seq_printf(m, ",wtmult=%u", nfss->wtmult); |
647 | seq_printf(m, ",dtsize=%u", nfss->dtsize); | 647 | seq_printf(m, ",dtsize=%u", nfss->dtsize); |
648 | seq_printf(m, ",bsize=%u", nfss->bsize); | 648 | seq_printf(m, ",bsize=%u", nfss->bsize); |
649 | seq_printf(m, ",namlen=%u", nfss->namelen); | 649 | seq_printf(m, ",namlen=%u", nfss->namelen); |
650 | 650 | ||
651 | #ifdef CONFIG_NFS_V4 | 651 | #ifdef CONFIG_NFS_V4 |
652 | if (nfss->nfs_client->rpc_ops->version == 4) { | 652 | if (nfss->nfs_client->rpc_ops->version == 4) { |
653 | seq_printf(m, "\n\tnfsv4:\t"); | 653 | seq_printf(m, "\n\tnfsv4:\t"); |
654 | seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); | 654 | seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); |
655 | seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); | 655 | seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); |
656 | seq_printf(m, ",acl=0x%x", nfss->acl_bitmask); | 656 | seq_printf(m, ",acl=0x%x", nfss->acl_bitmask); |
657 | } | 657 | } |
658 | #endif | 658 | #endif |
659 | 659 | ||
660 | /* | 660 | /* |
661 | * Display security flavor in effect for this mount | 661 | * Display security flavor in effect for this mount |
662 | */ | 662 | */ |
663 | seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor); | 663 | seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor); |
664 | if (auth->au_flavor) | 664 | if (auth->au_flavor) |
665 | seq_printf(m, ",pseudoflavor=%u", auth->au_flavor); | 665 | seq_printf(m, ",pseudoflavor=%u", auth->au_flavor); |
666 | 666 | ||
667 | /* | 667 | /* |
668 | * Display superblock I/O counters | 668 | * Display superblock I/O counters |
669 | */ | 669 | */ |
670 | for_each_possible_cpu(cpu) { | 670 | for_each_possible_cpu(cpu) { |
671 | struct nfs_iostats *stats; | 671 | struct nfs_iostats *stats; |
672 | 672 | ||
673 | preempt_disable(); | 673 | preempt_disable(); |
674 | stats = per_cpu_ptr(nfss->io_stats, cpu); | 674 | stats = per_cpu_ptr(nfss->io_stats, cpu); |
675 | 675 | ||
676 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | 676 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) |
677 | totals.events[i] += stats->events[i]; | 677 | totals.events[i] += stats->events[i]; |
678 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | 678 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) |
679 | totals.bytes[i] += stats->bytes[i]; | 679 | totals.bytes[i] += stats->bytes[i]; |
680 | #ifdef CONFIG_NFS_FSCACHE | 680 | #ifdef CONFIG_NFS_FSCACHE |
681 | for (i = 0; i < __NFSIOS_FSCACHEMAX; i++) | 681 | for (i = 0; i < __NFSIOS_FSCACHEMAX; i++) |
682 | totals.fscache[i] += stats->fscache[i]; | 682 | totals.fscache[i] += stats->fscache[i]; |
683 | #endif | 683 | #endif |
684 | 684 | ||
685 | preempt_enable(); | 685 | preempt_enable(); |
686 | } | 686 | } |
687 | 687 | ||
688 | seq_printf(m, "\n\tevents:\t"); | 688 | seq_printf(m, "\n\tevents:\t"); |
689 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | 689 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) |
690 | seq_printf(m, "%lu ", totals.events[i]); | 690 | seq_printf(m, "%lu ", totals.events[i]); |
691 | seq_printf(m, "\n\tbytes:\t"); | 691 | seq_printf(m, "\n\tbytes:\t"); |
692 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | 692 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) |
693 | seq_printf(m, "%Lu ", totals.bytes[i]); | 693 | seq_printf(m, "%Lu ", totals.bytes[i]); |
694 | #ifdef CONFIG_NFS_FSCACHE | 694 | #ifdef CONFIG_NFS_FSCACHE |
695 | if (nfss->options & NFS_OPTION_FSCACHE) { | 695 | if (nfss->options & NFS_OPTION_FSCACHE) { |
696 | seq_printf(m, "\n\tfsc:\t"); | 696 | seq_printf(m, "\n\tfsc:\t"); |
697 | for (i = 0; i < __NFSIOS_FSCACHEMAX; i++) | 697 | for (i = 0; i < __NFSIOS_FSCACHEMAX; i++) |
698 | seq_printf(m, "%Lu ", totals.bytes[i]); | 698 | seq_printf(m, "%Lu ", totals.bytes[i]); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | seq_printf(m, "\n"); | 701 | seq_printf(m, "\n"); |
702 | 702 | ||
703 | rpc_print_iostats(m, nfss->client); | 703 | rpc_print_iostats(m, nfss->client); |
704 | 704 | ||
705 | return 0; | 705 | return 0; |
706 | } | 706 | } |
707 | 707 | ||
708 | /* | 708 | /* |
709 | * Begin unmount by attempting to remove all automounted mountpoints we added | 709 | * Begin unmount by attempting to remove all automounted mountpoints we added |
710 | * in response to xdev traversals and referrals | 710 | * in response to xdev traversals and referrals |
711 | */ | 711 | */ |
712 | static void nfs_umount_begin(struct super_block *sb) | 712 | static void nfs_umount_begin(struct super_block *sb) |
713 | { | 713 | { |
714 | struct nfs_server *server; | 714 | struct nfs_server *server; |
715 | struct rpc_clnt *rpc; | 715 | struct rpc_clnt *rpc; |
716 | 716 | ||
717 | lock_kernel(); | 717 | lock_kernel(); |
718 | 718 | ||
719 | server = NFS_SB(sb); | 719 | server = NFS_SB(sb); |
720 | /* -EIO all pending I/O */ | 720 | /* -EIO all pending I/O */ |
721 | rpc = server->client_acl; | 721 | rpc = server->client_acl; |
722 | if (!IS_ERR(rpc)) | 722 | if (!IS_ERR(rpc)) |
723 | rpc_killall_tasks(rpc); | 723 | rpc_killall_tasks(rpc); |
724 | rpc = server->client; | 724 | rpc = server->client; |
725 | if (!IS_ERR(rpc)) | 725 | if (!IS_ERR(rpc)) |
726 | rpc_killall_tasks(rpc); | 726 | rpc_killall_tasks(rpc); |
727 | 727 | ||
728 | unlock_kernel(); | 728 | unlock_kernel(); |
729 | } | 729 | } |
730 | 730 | ||
731 | static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(int flags) | ||
732 | { | ||
733 | struct nfs_parsed_mount_data *data; | ||
734 | |||
735 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
736 | if (data) { | ||
737 | data->flags = flags; | ||
738 | data->rsize = NFS_MAX_FILE_IO_SIZE; | ||
739 | data->wsize = NFS_MAX_FILE_IO_SIZE; | ||
740 | data->acregmin = NFS_DEF_ACREGMIN; | ||
741 | data->acregmax = NFS_DEF_ACREGMAX; | ||
742 | data->acdirmin = NFS_DEF_ACDIRMIN; | ||
743 | data->acdirmax = NFS_DEF_ACDIRMAX; | ||
744 | data->nfs_server.port = NFS_UNSPEC_PORT; | ||
745 | data->auth_flavors[0] = RPC_AUTH_UNIX; | ||
746 | data->auth_flavor_len = 1; | ||
747 | data->minorversion = 0; | ||
748 | } | ||
749 | return data; | ||
750 | } | ||
751 | |||
731 | /* | 752 | /* |
732 | * Sanity-check a server address provided by the mount command. | 753 | * Sanity-check a server address provided by the mount command. |
733 | * | 754 | * |
734 | * Address family must be initialized, and address must not be | 755 | * Address family must be initialized, and address must not be |
735 | * the ANY address for that family. | 756 | * the ANY address for that family. |
736 | */ | 757 | */ |
737 | static int nfs_verify_server_address(struct sockaddr *addr) | 758 | static int nfs_verify_server_address(struct sockaddr *addr) |
738 | { | 759 | { |
739 | switch (addr->sa_family) { | 760 | switch (addr->sa_family) { |
740 | case AF_INET: { | 761 | case AF_INET: { |
741 | struct sockaddr_in *sa = (struct sockaddr_in *)addr; | 762 | struct sockaddr_in *sa = (struct sockaddr_in *)addr; |
742 | return sa->sin_addr.s_addr != htonl(INADDR_ANY); | 763 | return sa->sin_addr.s_addr != htonl(INADDR_ANY); |
743 | } | 764 | } |
744 | case AF_INET6: { | 765 | case AF_INET6: { |
745 | struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr; | 766 | struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr; |
746 | return !ipv6_addr_any(sa); | 767 | return !ipv6_addr_any(sa); |
747 | } | 768 | } |
748 | } | 769 | } |
749 | 770 | ||
750 | dfprintk(MOUNT, "NFS: Invalid IP address specified\n"); | 771 | dfprintk(MOUNT, "NFS: Invalid IP address specified\n"); |
751 | return 0; | 772 | return 0; |
752 | } | 773 | } |
753 | 774 | ||
754 | /* | 775 | /* |
755 | * Select between a default port value and a user-specified port value. | 776 | * Select between a default port value and a user-specified port value. |
756 | * If a zero value is set, then autobind will be used. | 777 | * If a zero value is set, then autobind will be used. |
757 | */ | 778 | */ |
758 | static void nfs_set_default_port(struct sockaddr *sap, const int parsed_port, | 779 | static void nfs_set_default_port(struct sockaddr *sap, const int parsed_port, |
759 | const unsigned short default_port) | 780 | const unsigned short default_port) |
760 | { | 781 | { |
761 | unsigned short port = default_port; | 782 | unsigned short port = default_port; |
762 | 783 | ||
763 | if (parsed_port != NFS_UNSPEC_PORT) | 784 | if (parsed_port != NFS_UNSPEC_PORT) |
764 | port = parsed_port; | 785 | port = parsed_port; |
765 | 786 | ||
766 | rpc_set_port(sap, port); | 787 | rpc_set_port(sap, port); |
767 | } | 788 | } |
768 | 789 | ||
769 | /* | 790 | /* |
770 | * Sanity check the NFS transport protocol. | 791 | * Sanity check the NFS transport protocol. |
771 | * | 792 | * |
772 | */ | 793 | */ |
773 | static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt) | 794 | static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt) |
774 | { | 795 | { |
775 | switch (mnt->nfs_server.protocol) { | 796 | switch (mnt->nfs_server.protocol) { |
776 | case XPRT_TRANSPORT_UDP: | 797 | case XPRT_TRANSPORT_UDP: |
777 | case XPRT_TRANSPORT_TCP: | 798 | case XPRT_TRANSPORT_TCP: |
778 | case XPRT_TRANSPORT_RDMA: | 799 | case XPRT_TRANSPORT_RDMA: |
779 | break; | 800 | break; |
780 | default: | 801 | default: |
781 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 802 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
782 | } | 803 | } |
783 | } | 804 | } |
784 | 805 | ||
785 | /* | 806 | /* |
786 | * For text based NFSv2/v3 mounts, the mount protocol transport default | 807 | * For text based NFSv2/v3 mounts, the mount protocol transport default |
787 | * settings should depend upon the specified NFS transport. | 808 | * settings should depend upon the specified NFS transport. |
788 | */ | 809 | */ |
789 | static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt) | 810 | static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt) |
790 | { | 811 | { |
791 | nfs_validate_transport_protocol(mnt); | 812 | nfs_validate_transport_protocol(mnt); |
792 | 813 | ||
793 | if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP || | 814 | if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP || |
794 | mnt->mount_server.protocol == XPRT_TRANSPORT_TCP) | 815 | mnt->mount_server.protocol == XPRT_TRANSPORT_TCP) |
795 | return; | 816 | return; |
796 | switch (mnt->nfs_server.protocol) { | 817 | switch (mnt->nfs_server.protocol) { |
797 | case XPRT_TRANSPORT_UDP: | 818 | case XPRT_TRANSPORT_UDP: |
798 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | 819 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; |
799 | break; | 820 | break; |
800 | case XPRT_TRANSPORT_TCP: | 821 | case XPRT_TRANSPORT_TCP: |
801 | case XPRT_TRANSPORT_RDMA: | 822 | case XPRT_TRANSPORT_RDMA: |
802 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | 823 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; |
803 | } | 824 | } |
804 | } | 825 | } |
805 | 826 | ||
806 | /* | 827 | /* |
807 | * Parse the value of the 'sec=' option. | 828 | * Parse the value of the 'sec=' option. |
808 | */ | 829 | */ |
809 | static int nfs_parse_security_flavors(char *value, | 830 | static int nfs_parse_security_flavors(char *value, |
810 | struct nfs_parsed_mount_data *mnt) | 831 | struct nfs_parsed_mount_data *mnt) |
811 | { | 832 | { |
812 | substring_t args[MAX_OPT_ARGS]; | 833 | substring_t args[MAX_OPT_ARGS]; |
813 | 834 | ||
814 | dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value); | 835 | dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value); |
815 | 836 | ||
816 | switch (match_token(value, nfs_secflavor_tokens, args)) { | 837 | switch (match_token(value, nfs_secflavor_tokens, args)) { |
817 | case Opt_sec_none: | 838 | case Opt_sec_none: |
818 | mnt->auth_flavors[0] = RPC_AUTH_NULL; | 839 | mnt->auth_flavors[0] = RPC_AUTH_NULL; |
819 | break; | 840 | break; |
820 | case Opt_sec_sys: | 841 | case Opt_sec_sys: |
821 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; | 842 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; |
822 | break; | 843 | break; |
823 | case Opt_sec_krb5: | 844 | case Opt_sec_krb5: |
824 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; | 845 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; |
825 | break; | 846 | break; |
826 | case Opt_sec_krb5i: | 847 | case Opt_sec_krb5i: |
827 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; | 848 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; |
828 | break; | 849 | break; |
829 | case Opt_sec_krb5p: | 850 | case Opt_sec_krb5p: |
830 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; | 851 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; |
831 | break; | 852 | break; |
832 | case Opt_sec_lkey: | 853 | case Opt_sec_lkey: |
833 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; | 854 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; |
834 | break; | 855 | break; |
835 | case Opt_sec_lkeyi: | 856 | case Opt_sec_lkeyi: |
836 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; | 857 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; |
837 | break; | 858 | break; |
838 | case Opt_sec_lkeyp: | 859 | case Opt_sec_lkeyp: |
839 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; | 860 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; |
840 | break; | 861 | break; |
841 | case Opt_sec_spkm: | 862 | case Opt_sec_spkm: |
842 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; | 863 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; |
843 | break; | 864 | break; |
844 | case Opt_sec_spkmi: | 865 | case Opt_sec_spkmi: |
845 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; | 866 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; |
846 | break; | 867 | break; |
847 | case Opt_sec_spkmp: | 868 | case Opt_sec_spkmp: |
848 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; | 869 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; |
849 | break; | 870 | break; |
850 | default: | 871 | default: |
851 | return 0; | 872 | return 0; |
852 | } | 873 | } |
853 | 874 | ||
854 | mnt->auth_flavor_len = 1; | 875 | mnt->auth_flavor_len = 1; |
855 | return 1; | 876 | return 1; |
856 | } | 877 | } |
857 | 878 | ||
858 | /* | 879 | /* |
859 | * Error-check and convert a string of mount options from user space into | 880 | * Error-check and convert a string of mount options from user space into |
860 | * a data structure. The whole mount string is processed; bad options are | 881 | * a data structure. The whole mount string is processed; bad options are |
861 | * skipped as they are encountered. If there were no errors, return 1; | 882 | * skipped as they are encountered. If there were no errors, return 1; |
862 | * otherwise return 0 (zero). | 883 | * otherwise return 0 (zero). |
863 | */ | 884 | */ |
864 | static int nfs_parse_mount_options(char *raw, | 885 | static int nfs_parse_mount_options(char *raw, |
865 | struct nfs_parsed_mount_data *mnt) | 886 | struct nfs_parsed_mount_data *mnt) |
866 | { | 887 | { |
867 | char *p, *string, *secdata; | 888 | char *p, *string, *secdata; |
868 | int rc, sloppy = 0, invalid_option = 0; | 889 | int rc, sloppy = 0, invalid_option = 0; |
869 | 890 | ||
870 | if (!raw) { | 891 | if (!raw) { |
871 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); | 892 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); |
872 | return 1; | 893 | return 1; |
873 | } | 894 | } |
874 | dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw); | 895 | dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw); |
875 | 896 | ||
876 | secdata = alloc_secdata(); | 897 | secdata = alloc_secdata(); |
877 | if (!secdata) | 898 | if (!secdata) |
878 | goto out_nomem; | 899 | goto out_nomem; |
879 | 900 | ||
880 | rc = security_sb_copy_data(raw, secdata); | 901 | rc = security_sb_copy_data(raw, secdata); |
881 | if (rc) | 902 | if (rc) |
882 | goto out_security_failure; | 903 | goto out_security_failure; |
883 | 904 | ||
884 | rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts); | 905 | rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts); |
885 | if (rc) | 906 | if (rc) |
886 | goto out_security_failure; | 907 | goto out_security_failure; |
887 | 908 | ||
888 | free_secdata(secdata); | 909 | free_secdata(secdata); |
889 | 910 | ||
890 | while ((p = strsep(&raw, ",")) != NULL) { | 911 | while ((p = strsep(&raw, ",")) != NULL) { |
891 | substring_t args[MAX_OPT_ARGS]; | 912 | substring_t args[MAX_OPT_ARGS]; |
892 | unsigned long option; | 913 | unsigned long option; |
893 | int token; | 914 | int token; |
894 | 915 | ||
895 | if (!*p) | 916 | if (!*p) |
896 | continue; | 917 | continue; |
897 | 918 | ||
898 | dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p); | 919 | dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p); |
899 | 920 | ||
900 | token = match_token(p, nfs_mount_option_tokens, args); | 921 | token = match_token(p, nfs_mount_option_tokens, args); |
901 | switch (token) { | 922 | switch (token) { |
902 | 923 | ||
903 | /* | 924 | /* |
904 | * boolean options: foo/nofoo | 925 | * boolean options: foo/nofoo |
905 | */ | 926 | */ |
906 | case Opt_soft: | 927 | case Opt_soft: |
907 | mnt->flags |= NFS_MOUNT_SOFT; | 928 | mnt->flags |= NFS_MOUNT_SOFT; |
908 | break; | 929 | break; |
909 | case Opt_hard: | 930 | case Opt_hard: |
910 | mnt->flags &= ~NFS_MOUNT_SOFT; | 931 | mnt->flags &= ~NFS_MOUNT_SOFT; |
911 | break; | 932 | break; |
912 | case Opt_posix: | 933 | case Opt_posix: |
913 | mnt->flags |= NFS_MOUNT_POSIX; | 934 | mnt->flags |= NFS_MOUNT_POSIX; |
914 | break; | 935 | break; |
915 | case Opt_noposix: | 936 | case Opt_noposix: |
916 | mnt->flags &= ~NFS_MOUNT_POSIX; | 937 | mnt->flags &= ~NFS_MOUNT_POSIX; |
917 | break; | 938 | break; |
918 | case Opt_cto: | 939 | case Opt_cto: |
919 | mnt->flags &= ~NFS_MOUNT_NOCTO; | 940 | mnt->flags &= ~NFS_MOUNT_NOCTO; |
920 | break; | 941 | break; |
921 | case Opt_nocto: | 942 | case Opt_nocto: |
922 | mnt->flags |= NFS_MOUNT_NOCTO; | 943 | mnt->flags |= NFS_MOUNT_NOCTO; |
923 | break; | 944 | break; |
924 | case Opt_ac: | 945 | case Opt_ac: |
925 | mnt->flags &= ~NFS_MOUNT_NOAC; | 946 | mnt->flags &= ~NFS_MOUNT_NOAC; |
926 | break; | 947 | break; |
927 | case Opt_noac: | 948 | case Opt_noac: |
928 | mnt->flags |= NFS_MOUNT_NOAC; | 949 | mnt->flags |= NFS_MOUNT_NOAC; |
929 | break; | 950 | break; |
930 | case Opt_lock: | 951 | case Opt_lock: |
931 | mnt->flags &= ~NFS_MOUNT_NONLM; | 952 | mnt->flags &= ~NFS_MOUNT_NONLM; |
932 | break; | 953 | break; |
933 | case Opt_nolock: | 954 | case Opt_nolock: |
934 | mnt->flags |= NFS_MOUNT_NONLM; | 955 | mnt->flags |= NFS_MOUNT_NONLM; |
935 | break; | 956 | break; |
936 | case Opt_v2: | 957 | case Opt_v2: |
937 | mnt->flags &= ~NFS_MOUNT_VER3; | 958 | mnt->flags &= ~NFS_MOUNT_VER3; |
938 | mnt->version = 2; | 959 | mnt->version = 2; |
939 | break; | 960 | break; |
940 | case Opt_v3: | 961 | case Opt_v3: |
941 | mnt->flags |= NFS_MOUNT_VER3; | 962 | mnt->flags |= NFS_MOUNT_VER3; |
942 | mnt->version = 3; | 963 | mnt->version = 3; |
943 | break; | 964 | break; |
944 | #ifdef CONFIG_NFS_V4 | 965 | #ifdef CONFIG_NFS_V4 |
945 | case Opt_v4: | 966 | case Opt_v4: |
946 | mnt->flags &= ~NFS_MOUNT_VER3; | 967 | mnt->flags &= ~NFS_MOUNT_VER3; |
947 | mnt->version = 4; | 968 | mnt->version = 4; |
948 | break; | 969 | break; |
949 | #endif | 970 | #endif |
950 | case Opt_udp: | 971 | case Opt_udp: |
951 | mnt->flags &= ~NFS_MOUNT_TCP; | 972 | mnt->flags &= ~NFS_MOUNT_TCP; |
952 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 973 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
953 | break; | 974 | break; |
954 | case Opt_tcp: | 975 | case Opt_tcp: |
955 | mnt->flags |= NFS_MOUNT_TCP; | 976 | mnt->flags |= NFS_MOUNT_TCP; |
956 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 977 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
957 | break; | 978 | break; |
958 | case Opt_rdma: | 979 | case Opt_rdma: |
959 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ | 980 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ |
960 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 981 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
961 | xprt_load_transport(p); | 982 | xprt_load_transport(p); |
962 | break; | 983 | break; |
963 | case Opt_acl: | 984 | case Opt_acl: |
964 | mnt->flags &= ~NFS_MOUNT_NOACL; | 985 | mnt->flags &= ~NFS_MOUNT_NOACL; |
965 | break; | 986 | break; |
966 | case Opt_noacl: | 987 | case Opt_noacl: |
967 | mnt->flags |= NFS_MOUNT_NOACL; | 988 | mnt->flags |= NFS_MOUNT_NOACL; |
968 | break; | 989 | break; |
969 | case Opt_rdirplus: | 990 | case Opt_rdirplus: |
970 | mnt->flags &= ~NFS_MOUNT_NORDIRPLUS; | 991 | mnt->flags &= ~NFS_MOUNT_NORDIRPLUS; |
971 | break; | 992 | break; |
972 | case Opt_nordirplus: | 993 | case Opt_nordirplus: |
973 | mnt->flags |= NFS_MOUNT_NORDIRPLUS; | 994 | mnt->flags |= NFS_MOUNT_NORDIRPLUS; |
974 | break; | 995 | break; |
975 | case Opt_sharecache: | 996 | case Opt_sharecache: |
976 | mnt->flags &= ~NFS_MOUNT_UNSHARED; | 997 | mnt->flags &= ~NFS_MOUNT_UNSHARED; |
977 | break; | 998 | break; |
978 | case Opt_nosharecache: | 999 | case Opt_nosharecache: |
979 | mnt->flags |= NFS_MOUNT_UNSHARED; | 1000 | mnt->flags |= NFS_MOUNT_UNSHARED; |
980 | break; | 1001 | break; |
981 | case Opt_resvport: | 1002 | case Opt_resvport: |
982 | mnt->flags &= ~NFS_MOUNT_NORESVPORT; | 1003 | mnt->flags &= ~NFS_MOUNT_NORESVPORT; |
983 | break; | 1004 | break; |
984 | case Opt_noresvport: | 1005 | case Opt_noresvport: |
985 | mnt->flags |= NFS_MOUNT_NORESVPORT; | 1006 | mnt->flags |= NFS_MOUNT_NORESVPORT; |
986 | break; | 1007 | break; |
987 | case Opt_fscache: | 1008 | case Opt_fscache: |
988 | mnt->options |= NFS_OPTION_FSCACHE; | 1009 | mnt->options |= NFS_OPTION_FSCACHE; |
989 | kfree(mnt->fscache_uniq); | 1010 | kfree(mnt->fscache_uniq); |
990 | mnt->fscache_uniq = NULL; | 1011 | mnt->fscache_uniq = NULL; |
991 | break; | 1012 | break; |
992 | case Opt_nofscache: | 1013 | case Opt_nofscache: |
993 | mnt->options &= ~NFS_OPTION_FSCACHE; | 1014 | mnt->options &= ~NFS_OPTION_FSCACHE; |
994 | kfree(mnt->fscache_uniq); | 1015 | kfree(mnt->fscache_uniq); |
995 | mnt->fscache_uniq = NULL; | 1016 | mnt->fscache_uniq = NULL; |
996 | break; | 1017 | break; |
997 | case Opt_fscache_uniq: | 1018 | case Opt_fscache_uniq: |
998 | string = match_strdup(args); | 1019 | string = match_strdup(args); |
999 | if (!string) | 1020 | if (!string) |
1000 | goto out_nomem; | 1021 | goto out_nomem; |
1001 | kfree(mnt->fscache_uniq); | 1022 | kfree(mnt->fscache_uniq); |
1002 | mnt->fscache_uniq = string; | 1023 | mnt->fscache_uniq = string; |
1003 | mnt->options |= NFS_OPTION_FSCACHE; | 1024 | mnt->options |= NFS_OPTION_FSCACHE; |
1004 | break; | 1025 | break; |
1005 | 1026 | ||
1006 | /* | 1027 | /* |
1007 | * options that take numeric values | 1028 | * options that take numeric values |
1008 | */ | 1029 | */ |
1009 | case Opt_port: | 1030 | case Opt_port: |
1010 | string = match_strdup(args); | 1031 | string = match_strdup(args); |
1011 | if (string == NULL) | 1032 | if (string == NULL) |
1012 | goto out_nomem; | 1033 | goto out_nomem; |
1013 | rc = strict_strtoul(string, 10, &option); | 1034 | rc = strict_strtoul(string, 10, &option); |
1014 | kfree(string); | 1035 | kfree(string); |
1015 | if (rc != 0 || option > USHORT_MAX) | 1036 | if (rc != 0 || option > USHORT_MAX) |
1016 | goto out_invalid_value; | 1037 | goto out_invalid_value; |
1017 | mnt->nfs_server.port = option; | 1038 | mnt->nfs_server.port = option; |
1018 | break; | 1039 | break; |
1019 | case Opt_rsize: | 1040 | case Opt_rsize: |
1020 | string = match_strdup(args); | 1041 | string = match_strdup(args); |
1021 | if (string == NULL) | 1042 | if (string == NULL) |
1022 | goto out_nomem; | 1043 | goto out_nomem; |
1023 | rc = strict_strtoul(string, 10, &option); | 1044 | rc = strict_strtoul(string, 10, &option); |
1024 | kfree(string); | 1045 | kfree(string); |
1025 | if (rc != 0) | 1046 | if (rc != 0) |
1026 | goto out_invalid_value; | 1047 | goto out_invalid_value; |
1027 | mnt->rsize = option; | 1048 | mnt->rsize = option; |
1028 | break; | 1049 | break; |
1029 | case Opt_wsize: | 1050 | case Opt_wsize: |
1030 | string = match_strdup(args); | 1051 | string = match_strdup(args); |
1031 | if (string == NULL) | 1052 | if (string == NULL) |
1032 | goto out_nomem; | 1053 | goto out_nomem; |
1033 | rc = strict_strtoul(string, 10, &option); | 1054 | rc = strict_strtoul(string, 10, &option); |
1034 | kfree(string); | 1055 | kfree(string); |
1035 | if (rc != 0) | 1056 | if (rc != 0) |
1036 | goto out_invalid_value; | 1057 | goto out_invalid_value; |
1037 | mnt->wsize = option; | 1058 | mnt->wsize = option; |
1038 | break; | 1059 | break; |
1039 | case Opt_bsize: | 1060 | case Opt_bsize: |
1040 | string = match_strdup(args); | 1061 | string = match_strdup(args); |
1041 | if (string == NULL) | 1062 | if (string == NULL) |
1042 | goto out_nomem; | 1063 | goto out_nomem; |
1043 | rc = strict_strtoul(string, 10, &option); | 1064 | rc = strict_strtoul(string, 10, &option); |
1044 | kfree(string); | 1065 | kfree(string); |
1045 | if (rc != 0) | 1066 | if (rc != 0) |
1046 | goto out_invalid_value; | 1067 | goto out_invalid_value; |
1047 | mnt->bsize = option; | 1068 | mnt->bsize = option; |
1048 | break; | 1069 | break; |
1049 | case Opt_timeo: | 1070 | case Opt_timeo: |
1050 | string = match_strdup(args); | 1071 | string = match_strdup(args); |
1051 | if (string == NULL) | 1072 | if (string == NULL) |
1052 | goto out_nomem; | 1073 | goto out_nomem; |
1053 | rc = strict_strtoul(string, 10, &option); | 1074 | rc = strict_strtoul(string, 10, &option); |
1054 | kfree(string); | 1075 | kfree(string); |
1055 | if (rc != 0 || option == 0) | 1076 | if (rc != 0 || option == 0) |
1056 | goto out_invalid_value; | 1077 | goto out_invalid_value; |
1057 | mnt->timeo = option; | 1078 | mnt->timeo = option; |
1058 | break; | 1079 | break; |
1059 | case Opt_retrans: | 1080 | case Opt_retrans: |
1060 | string = match_strdup(args); | 1081 | string = match_strdup(args); |
1061 | if (string == NULL) | 1082 | if (string == NULL) |
1062 | goto out_nomem; | 1083 | goto out_nomem; |
1063 | rc = strict_strtoul(string, 10, &option); | 1084 | rc = strict_strtoul(string, 10, &option); |
1064 | kfree(string); | 1085 | kfree(string); |
1065 | if (rc != 0 || option == 0) | 1086 | if (rc != 0 || option == 0) |
1066 | goto out_invalid_value; | 1087 | goto out_invalid_value; |
1067 | mnt->retrans = option; | 1088 | mnt->retrans = option; |
1068 | break; | 1089 | break; |
1069 | case Opt_acregmin: | 1090 | case Opt_acregmin: |
1070 | string = match_strdup(args); | 1091 | string = match_strdup(args); |
1071 | if (string == NULL) | 1092 | if (string == NULL) |
1072 | goto out_nomem; | 1093 | goto out_nomem; |
1073 | rc = strict_strtoul(string, 10, &option); | 1094 | rc = strict_strtoul(string, 10, &option); |
1074 | kfree(string); | 1095 | kfree(string); |
1075 | if (rc != 0) | 1096 | if (rc != 0) |
1076 | goto out_invalid_value; | 1097 | goto out_invalid_value; |
1077 | mnt->acregmin = option; | 1098 | mnt->acregmin = option; |
1078 | break; | 1099 | break; |
1079 | case Opt_acregmax: | 1100 | case Opt_acregmax: |
1080 | string = match_strdup(args); | 1101 | string = match_strdup(args); |
1081 | if (string == NULL) | 1102 | if (string == NULL) |
1082 | goto out_nomem; | 1103 | goto out_nomem; |
1083 | rc = strict_strtoul(string, 10, &option); | 1104 | rc = strict_strtoul(string, 10, &option); |
1084 | kfree(string); | 1105 | kfree(string); |
1085 | if (rc != 0) | 1106 | if (rc != 0) |
1086 | goto out_invalid_value; | 1107 | goto out_invalid_value; |
1087 | mnt->acregmax = option; | 1108 | mnt->acregmax = option; |
1088 | break; | 1109 | break; |
1089 | case Opt_acdirmin: | 1110 | case Opt_acdirmin: |
1090 | string = match_strdup(args); | 1111 | string = match_strdup(args); |
1091 | if (string == NULL) | 1112 | if (string == NULL) |
1092 | goto out_nomem; | 1113 | goto out_nomem; |
1093 | rc = strict_strtoul(string, 10, &option); | 1114 | rc = strict_strtoul(string, 10, &option); |
1094 | kfree(string); | 1115 | kfree(string); |
1095 | if (rc != 0) | 1116 | if (rc != 0) |
1096 | goto out_invalid_value; | 1117 | goto out_invalid_value; |
1097 | mnt->acdirmin = option; | 1118 | mnt->acdirmin = option; |
1098 | break; | 1119 | break; |
1099 | case Opt_acdirmax: | 1120 | case Opt_acdirmax: |
1100 | string = match_strdup(args); | 1121 | string = match_strdup(args); |
1101 | if (string == NULL) | 1122 | if (string == NULL) |
1102 | goto out_nomem; | 1123 | goto out_nomem; |
1103 | rc = strict_strtoul(string, 10, &option); | 1124 | rc = strict_strtoul(string, 10, &option); |
1104 | kfree(string); | 1125 | kfree(string); |
1105 | if (rc != 0) | 1126 | if (rc != 0) |
1106 | goto out_invalid_value; | 1127 | goto out_invalid_value; |
1107 | mnt->acdirmax = option; | 1128 | mnt->acdirmax = option; |
1108 | break; | 1129 | break; |
1109 | case Opt_actimeo: | 1130 | case Opt_actimeo: |
1110 | string = match_strdup(args); | 1131 | string = match_strdup(args); |
1111 | if (string == NULL) | 1132 | if (string == NULL) |
1112 | goto out_nomem; | 1133 | goto out_nomem; |
1113 | rc = strict_strtoul(string, 10, &option); | 1134 | rc = strict_strtoul(string, 10, &option); |
1114 | kfree(string); | 1135 | kfree(string); |
1115 | if (rc != 0) | 1136 | if (rc != 0) |
1116 | goto out_invalid_value; | 1137 | goto out_invalid_value; |
1117 | mnt->acregmin = mnt->acregmax = | 1138 | mnt->acregmin = mnt->acregmax = |
1118 | mnt->acdirmin = mnt->acdirmax = option; | 1139 | mnt->acdirmin = mnt->acdirmax = option; |
1119 | break; | 1140 | break; |
1120 | case Opt_namelen: | 1141 | case Opt_namelen: |
1121 | string = match_strdup(args); | 1142 | string = match_strdup(args); |
1122 | if (string == NULL) | 1143 | if (string == NULL) |
1123 | goto out_nomem; | 1144 | goto out_nomem; |
1124 | rc = strict_strtoul(string, 10, &option); | 1145 | rc = strict_strtoul(string, 10, &option); |
1125 | kfree(string); | 1146 | kfree(string); |
1126 | if (rc != 0) | 1147 | if (rc != 0) |
1127 | goto out_invalid_value; | 1148 | goto out_invalid_value; |
1128 | mnt->namlen = option; | 1149 | mnt->namlen = option; |
1129 | break; | 1150 | break; |
1130 | case Opt_mountport: | 1151 | case Opt_mountport: |
1131 | string = match_strdup(args); | 1152 | string = match_strdup(args); |
1132 | if (string == NULL) | 1153 | if (string == NULL) |
1133 | goto out_nomem; | 1154 | goto out_nomem; |
1134 | rc = strict_strtoul(string, 10, &option); | 1155 | rc = strict_strtoul(string, 10, &option); |
1135 | kfree(string); | 1156 | kfree(string); |
1136 | if (rc != 0 || option > USHORT_MAX) | 1157 | if (rc != 0 || option > USHORT_MAX) |
1137 | goto out_invalid_value; | 1158 | goto out_invalid_value; |
1138 | mnt->mount_server.port = option; | 1159 | mnt->mount_server.port = option; |
1139 | break; | 1160 | break; |
1140 | case Opt_mountvers: | 1161 | case Opt_mountvers: |
1141 | string = match_strdup(args); | 1162 | string = match_strdup(args); |
1142 | if (string == NULL) | 1163 | if (string == NULL) |
1143 | goto out_nomem; | 1164 | goto out_nomem; |
1144 | rc = strict_strtoul(string, 10, &option); | 1165 | rc = strict_strtoul(string, 10, &option); |
1145 | kfree(string); | 1166 | kfree(string); |
1146 | if (rc != 0 || | 1167 | if (rc != 0 || |
1147 | option < NFS_MNT_VERSION || | 1168 | option < NFS_MNT_VERSION || |
1148 | option > NFS_MNT3_VERSION) | 1169 | option > NFS_MNT3_VERSION) |
1149 | goto out_invalid_value; | 1170 | goto out_invalid_value; |
1150 | mnt->mount_server.version = option; | 1171 | mnt->mount_server.version = option; |
1151 | break; | 1172 | break; |
1152 | case Opt_nfsvers: | 1173 | case Opt_nfsvers: |
1153 | string = match_strdup(args); | 1174 | string = match_strdup(args); |
1154 | if (string == NULL) | 1175 | if (string == NULL) |
1155 | goto out_nomem; | 1176 | goto out_nomem; |
1156 | rc = strict_strtoul(string, 10, &option); | 1177 | rc = strict_strtoul(string, 10, &option); |
1157 | kfree(string); | 1178 | kfree(string); |
1158 | if (rc != 0) | 1179 | if (rc != 0) |
1159 | goto out_invalid_value; | 1180 | goto out_invalid_value; |
1160 | switch (option) { | 1181 | switch (option) { |
1161 | case NFS2_VERSION: | 1182 | case NFS2_VERSION: |
1162 | mnt->flags &= ~NFS_MOUNT_VER3; | 1183 | mnt->flags &= ~NFS_MOUNT_VER3; |
1163 | mnt->version = 2; | 1184 | mnt->version = 2; |
1164 | break; | 1185 | break; |
1165 | case NFS3_VERSION: | 1186 | case NFS3_VERSION: |
1166 | mnt->flags |= NFS_MOUNT_VER3; | 1187 | mnt->flags |= NFS_MOUNT_VER3; |
1167 | mnt->version = 3; | 1188 | mnt->version = 3; |
1168 | break; | 1189 | break; |
1169 | #ifdef CONFIG_NFS_V4 | 1190 | #ifdef CONFIG_NFS_V4 |
1170 | case NFS4_VERSION: | 1191 | case NFS4_VERSION: |
1171 | mnt->flags &= ~NFS_MOUNT_VER3; | 1192 | mnt->flags &= ~NFS_MOUNT_VER3; |
1172 | mnt->version = 4; | 1193 | mnt->version = 4; |
1173 | break; | 1194 | break; |
1174 | #endif | 1195 | #endif |
1175 | default: | 1196 | default: |
1176 | goto out_invalid_value; | 1197 | goto out_invalid_value; |
1177 | } | 1198 | } |
1178 | break; | 1199 | break; |
1179 | case Opt_minorversion: | 1200 | case Opt_minorversion: |
1180 | string = match_strdup(args); | 1201 | string = match_strdup(args); |
1181 | if (string == NULL) | 1202 | if (string == NULL) |
1182 | goto out_nomem; | 1203 | goto out_nomem; |
1183 | rc = strict_strtoul(string, 10, &option); | 1204 | rc = strict_strtoul(string, 10, &option); |
1184 | kfree(string); | 1205 | kfree(string); |
1185 | if (rc != 0) | 1206 | if (rc != 0) |
1186 | goto out_invalid_value; | 1207 | goto out_invalid_value; |
1187 | if (option > NFS4_MAX_MINOR_VERSION) | 1208 | if (option > NFS4_MAX_MINOR_VERSION) |
1188 | goto out_invalid_value; | 1209 | goto out_invalid_value; |
1189 | mnt->minorversion = option; | 1210 | mnt->minorversion = option; |
1190 | break; | 1211 | break; |
1191 | 1212 | ||
1192 | /* | 1213 | /* |
1193 | * options that take text values | 1214 | * options that take text values |
1194 | */ | 1215 | */ |
1195 | case Opt_sec: | 1216 | case Opt_sec: |
1196 | string = match_strdup(args); | 1217 | string = match_strdup(args); |
1197 | if (string == NULL) | 1218 | if (string == NULL) |
1198 | goto out_nomem; | 1219 | goto out_nomem; |
1199 | rc = nfs_parse_security_flavors(string, mnt); | 1220 | rc = nfs_parse_security_flavors(string, mnt); |
1200 | kfree(string); | 1221 | kfree(string); |
1201 | if (!rc) { | 1222 | if (!rc) { |
1202 | dfprintk(MOUNT, "NFS: unrecognized " | 1223 | dfprintk(MOUNT, "NFS: unrecognized " |
1203 | "security flavor\n"); | 1224 | "security flavor\n"); |
1204 | return 0; | 1225 | return 0; |
1205 | } | 1226 | } |
1206 | break; | 1227 | break; |
1207 | case Opt_proto: | 1228 | case Opt_proto: |
1208 | string = match_strdup(args); | 1229 | string = match_strdup(args); |
1209 | if (string == NULL) | 1230 | if (string == NULL) |
1210 | goto out_nomem; | 1231 | goto out_nomem; |
1211 | token = match_token(string, | 1232 | token = match_token(string, |
1212 | nfs_xprt_protocol_tokens, args); | 1233 | nfs_xprt_protocol_tokens, args); |
1213 | 1234 | ||
1214 | switch (token) { | 1235 | switch (token) { |
1215 | case Opt_xprt_udp: | 1236 | case Opt_xprt_udp: |
1216 | mnt->flags &= ~NFS_MOUNT_TCP; | 1237 | mnt->flags &= ~NFS_MOUNT_TCP; |
1217 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1238 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
1218 | kfree(string); | 1239 | kfree(string); |
1219 | break; | 1240 | break; |
1220 | case Opt_xprt_tcp: | 1241 | case Opt_xprt_tcp: |
1221 | mnt->flags |= NFS_MOUNT_TCP; | 1242 | mnt->flags |= NFS_MOUNT_TCP; |
1222 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1243 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1223 | kfree(string); | 1244 | kfree(string); |
1224 | break; | 1245 | break; |
1225 | case Opt_xprt_rdma: | 1246 | case Opt_xprt_rdma: |
1226 | /* vector side protocols to TCP */ | 1247 | /* vector side protocols to TCP */ |
1227 | mnt->flags |= NFS_MOUNT_TCP; | 1248 | mnt->flags |= NFS_MOUNT_TCP; |
1228 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 1249 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
1229 | xprt_load_transport(string); | 1250 | xprt_load_transport(string); |
1230 | kfree(string); | 1251 | kfree(string); |
1231 | break; | 1252 | break; |
1232 | default: | 1253 | default: |
1233 | dfprintk(MOUNT, "NFS: unrecognized " | 1254 | dfprintk(MOUNT, "NFS: unrecognized " |
1234 | "transport protocol\n"); | 1255 | "transport protocol\n"); |
1235 | return 0; | 1256 | return 0; |
1236 | } | 1257 | } |
1237 | break; | 1258 | break; |
1238 | case Opt_mountproto: | 1259 | case Opt_mountproto: |
1239 | string = match_strdup(args); | 1260 | string = match_strdup(args); |
1240 | if (string == NULL) | 1261 | if (string == NULL) |
1241 | goto out_nomem; | 1262 | goto out_nomem; |
1242 | token = match_token(string, | 1263 | token = match_token(string, |
1243 | nfs_xprt_protocol_tokens, args); | 1264 | nfs_xprt_protocol_tokens, args); |
1244 | kfree(string); | 1265 | kfree(string); |
1245 | 1266 | ||
1246 | switch (token) { | 1267 | switch (token) { |
1247 | case Opt_xprt_udp: | 1268 | case Opt_xprt_udp: |
1248 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | 1269 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; |
1249 | break; | 1270 | break; |
1250 | case Opt_xprt_tcp: | 1271 | case Opt_xprt_tcp: |
1251 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | 1272 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; |
1252 | break; | 1273 | break; |
1253 | case Opt_xprt_rdma: /* not used for side protocols */ | 1274 | case Opt_xprt_rdma: /* not used for side protocols */ |
1254 | default: | 1275 | default: |
1255 | dfprintk(MOUNT, "NFS: unrecognized " | 1276 | dfprintk(MOUNT, "NFS: unrecognized " |
1256 | "transport protocol\n"); | 1277 | "transport protocol\n"); |
1257 | return 0; | 1278 | return 0; |
1258 | } | 1279 | } |
1259 | break; | 1280 | break; |
1260 | case Opt_addr: | 1281 | case Opt_addr: |
1261 | string = match_strdup(args); | 1282 | string = match_strdup(args); |
1262 | if (string == NULL) | 1283 | if (string == NULL) |
1263 | goto out_nomem; | 1284 | goto out_nomem; |
1264 | mnt->nfs_server.addrlen = | 1285 | mnt->nfs_server.addrlen = |
1265 | rpc_pton(string, strlen(string), | 1286 | rpc_pton(string, strlen(string), |
1266 | (struct sockaddr *) | 1287 | (struct sockaddr *) |
1267 | &mnt->nfs_server.address, | 1288 | &mnt->nfs_server.address, |
1268 | sizeof(mnt->nfs_server.address)); | 1289 | sizeof(mnt->nfs_server.address)); |
1269 | kfree(string); | 1290 | kfree(string); |
1270 | if (mnt->nfs_server.addrlen == 0) | 1291 | if (mnt->nfs_server.addrlen == 0) |
1271 | goto out_invalid_address; | 1292 | goto out_invalid_address; |
1272 | break; | 1293 | break; |
1273 | case Opt_clientaddr: | 1294 | case Opt_clientaddr: |
1274 | string = match_strdup(args); | 1295 | string = match_strdup(args); |
1275 | if (string == NULL) | 1296 | if (string == NULL) |
1276 | goto out_nomem; | 1297 | goto out_nomem; |
1277 | kfree(mnt->client_address); | 1298 | kfree(mnt->client_address); |
1278 | mnt->client_address = string; | 1299 | mnt->client_address = string; |
1279 | break; | 1300 | break; |
1280 | case Opt_mounthost: | 1301 | case Opt_mounthost: |
1281 | string = match_strdup(args); | 1302 | string = match_strdup(args); |
1282 | if (string == NULL) | 1303 | if (string == NULL) |
1283 | goto out_nomem; | 1304 | goto out_nomem; |
1284 | kfree(mnt->mount_server.hostname); | 1305 | kfree(mnt->mount_server.hostname); |
1285 | mnt->mount_server.hostname = string; | 1306 | mnt->mount_server.hostname = string; |
1286 | break; | 1307 | break; |
1287 | case Opt_mountaddr: | 1308 | case Opt_mountaddr: |
1288 | string = match_strdup(args); | 1309 | string = match_strdup(args); |
1289 | if (string == NULL) | 1310 | if (string == NULL) |
1290 | goto out_nomem; | 1311 | goto out_nomem; |
1291 | mnt->mount_server.addrlen = | 1312 | mnt->mount_server.addrlen = |
1292 | rpc_pton(string, strlen(string), | 1313 | rpc_pton(string, strlen(string), |
1293 | (struct sockaddr *) | 1314 | (struct sockaddr *) |
1294 | &mnt->mount_server.address, | 1315 | &mnt->mount_server.address, |
1295 | sizeof(mnt->mount_server.address)); | 1316 | sizeof(mnt->mount_server.address)); |
1296 | kfree(string); | 1317 | kfree(string); |
1297 | if (mnt->mount_server.addrlen == 0) | 1318 | if (mnt->mount_server.addrlen == 0) |
1298 | goto out_invalid_address; | 1319 | goto out_invalid_address; |
1299 | break; | 1320 | break; |
1300 | case Opt_lookupcache: | 1321 | case Opt_lookupcache: |
1301 | string = match_strdup(args); | 1322 | string = match_strdup(args); |
1302 | if (string == NULL) | 1323 | if (string == NULL) |
1303 | goto out_nomem; | 1324 | goto out_nomem; |
1304 | token = match_token(string, | 1325 | token = match_token(string, |
1305 | nfs_lookupcache_tokens, args); | 1326 | nfs_lookupcache_tokens, args); |
1306 | kfree(string); | 1327 | kfree(string); |
1307 | switch (token) { | 1328 | switch (token) { |
1308 | case Opt_lookupcache_all: | 1329 | case Opt_lookupcache_all: |
1309 | mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE); | 1330 | mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE); |
1310 | break; | 1331 | break; |
1311 | case Opt_lookupcache_positive: | 1332 | case Opt_lookupcache_positive: |
1312 | mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE; | 1333 | mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE; |
1313 | mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG; | 1334 | mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG; |
1314 | break; | 1335 | break; |
1315 | case Opt_lookupcache_none: | 1336 | case Opt_lookupcache_none: |
1316 | mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE; | 1337 | mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE; |
1317 | break; | 1338 | break; |
1318 | default: | 1339 | default: |
1319 | dfprintk(MOUNT, "NFS: invalid " | 1340 | dfprintk(MOUNT, "NFS: invalid " |
1320 | "lookupcache argument\n"); | 1341 | "lookupcache argument\n"); |
1321 | return 0; | 1342 | return 0; |
1322 | }; | 1343 | }; |
1323 | break; | 1344 | break; |
1324 | 1345 | ||
1325 | /* | 1346 | /* |
1326 | * Special options | 1347 | * Special options |
1327 | */ | 1348 | */ |
1328 | case Opt_sloppy: | 1349 | case Opt_sloppy: |
1329 | sloppy = 1; | 1350 | sloppy = 1; |
1330 | dfprintk(MOUNT, "NFS: relaxing parsing rules\n"); | 1351 | dfprintk(MOUNT, "NFS: relaxing parsing rules\n"); |
1331 | break; | 1352 | break; |
1332 | case Opt_userspace: | 1353 | case Opt_userspace: |
1333 | case Opt_deprecated: | 1354 | case Opt_deprecated: |
1334 | dfprintk(MOUNT, "NFS: ignoring mount option " | 1355 | dfprintk(MOUNT, "NFS: ignoring mount option " |
1335 | "'%s'\n", p); | 1356 | "'%s'\n", p); |
1336 | break; | 1357 | break; |
1337 | 1358 | ||
1338 | default: | 1359 | default: |
1339 | invalid_option = 1; | 1360 | invalid_option = 1; |
1340 | dfprintk(MOUNT, "NFS: unrecognized mount option " | 1361 | dfprintk(MOUNT, "NFS: unrecognized mount option " |
1341 | "'%s'\n", p); | 1362 | "'%s'\n", p); |
1342 | } | 1363 | } |
1343 | } | 1364 | } |
1344 | 1365 | ||
1345 | if (!sloppy && invalid_option) | 1366 | if (!sloppy && invalid_option) |
1346 | return 0; | 1367 | return 0; |
1347 | 1368 | ||
1348 | return 1; | 1369 | return 1; |
1349 | 1370 | ||
1350 | out_invalid_address: | 1371 | out_invalid_address: |
1351 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); | 1372 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); |
1352 | return 0; | 1373 | return 0; |
1353 | out_invalid_value: | 1374 | out_invalid_value: |
1354 | printk(KERN_INFO "NFS: bad mount option value specified: %s\n", p); | 1375 | printk(KERN_INFO "NFS: bad mount option value specified: %s\n", p); |
1355 | return 0; | 1376 | return 0; |
1356 | out_nomem: | 1377 | out_nomem: |
1357 | printk(KERN_INFO "NFS: not enough memory to parse option\n"); | 1378 | printk(KERN_INFO "NFS: not enough memory to parse option\n"); |
1358 | return 0; | 1379 | return 0; |
1359 | out_security_failure: | 1380 | out_security_failure: |
1360 | free_secdata(secdata); | 1381 | free_secdata(secdata); |
1361 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); | 1382 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); |
1362 | return 0; | 1383 | return 0; |
1363 | } | 1384 | } |
1364 | 1385 | ||
1365 | /* | 1386 | /* |
1366 | * Match the requested auth flavors with the list returned by | 1387 | * Match the requested auth flavors with the list returned by |
1367 | * the server. Returns zero and sets the mount's authentication | 1388 | * the server. Returns zero and sets the mount's authentication |
1368 | * flavor on success; returns -EACCES if server does not support | 1389 | * flavor on success; returns -EACCES if server does not support |
1369 | * the requested flavor. | 1390 | * the requested flavor. |
1370 | */ | 1391 | */ |
1371 | static int nfs_walk_authlist(struct nfs_parsed_mount_data *args, | 1392 | static int nfs_walk_authlist(struct nfs_parsed_mount_data *args, |
1372 | struct nfs_mount_request *request) | 1393 | struct nfs_mount_request *request) |
1373 | { | 1394 | { |
1374 | unsigned int i, j, server_authlist_len = *(request->auth_flav_len); | 1395 | unsigned int i, j, server_authlist_len = *(request->auth_flav_len); |
1375 | 1396 | ||
1376 | /* | 1397 | /* |
1377 | * Certain releases of Linux's mountd return an empty | 1398 | * Certain releases of Linux's mountd return an empty |
1378 | * flavor list. To prevent behavioral regression with | 1399 | * flavor list. To prevent behavioral regression with |
1379 | * these servers (ie. rejecting mounts that used to | 1400 | * these servers (ie. rejecting mounts that used to |
1380 | * succeed), revert to pre-2.6.32 behavior (no checking) | 1401 | * succeed), revert to pre-2.6.32 behavior (no checking) |
1381 | * if the returned flavor list is empty. | 1402 | * if the returned flavor list is empty. |
1382 | */ | 1403 | */ |
1383 | if (server_authlist_len == 0) | 1404 | if (server_authlist_len == 0) |
1384 | return 0; | 1405 | return 0; |
1385 | 1406 | ||
1386 | /* | 1407 | /* |
1387 | * We avoid sophisticated negotiating here, as there are | 1408 | * We avoid sophisticated negotiating here, as there are |
1388 | * plenty of cases where we can get it wrong, providing | 1409 | * plenty of cases where we can get it wrong, providing |
1389 | * either too little or too much security. | 1410 | * either too little or too much security. |
1390 | * | 1411 | * |
1391 | * RFC 2623, section 2.7 suggests we SHOULD prefer the | 1412 | * RFC 2623, section 2.7 suggests we SHOULD prefer the |
1392 | * flavor listed first. However, some servers list | 1413 | * flavor listed first. However, some servers list |
1393 | * AUTH_NULL first. Our caller plants AUTH_SYS, the | 1414 | * AUTH_NULL first. Our caller plants AUTH_SYS, the |
1394 | * preferred default, in args->auth_flavors[0] if user | 1415 | * preferred default, in args->auth_flavors[0] if user |
1395 | * didn't specify sec= mount option. | 1416 | * didn't specify sec= mount option. |
1396 | */ | 1417 | */ |
1397 | for (i = 0; i < args->auth_flavor_len; i++) | 1418 | for (i = 0; i < args->auth_flavor_len; i++) |
1398 | for (j = 0; j < server_authlist_len; j++) | 1419 | for (j = 0; j < server_authlist_len; j++) |
1399 | if (args->auth_flavors[i] == request->auth_flavs[j]) { | 1420 | if (args->auth_flavors[i] == request->auth_flavs[j]) { |
1400 | dfprintk(MOUNT, "NFS: using auth flavor %d\n", | 1421 | dfprintk(MOUNT, "NFS: using auth flavor %d\n", |
1401 | request->auth_flavs[j]); | 1422 | request->auth_flavs[j]); |
1402 | args->auth_flavors[0] = request->auth_flavs[j]; | 1423 | args->auth_flavors[0] = request->auth_flavs[j]; |
1403 | return 0; | 1424 | return 0; |
1404 | } | 1425 | } |
1405 | 1426 | ||
1406 | dfprintk(MOUNT, "NFS: server does not support requested auth flavor\n"); | 1427 | dfprintk(MOUNT, "NFS: server does not support requested auth flavor\n"); |
1407 | nfs_umount(request); | 1428 | nfs_umount(request); |
1408 | return -EACCES; | 1429 | return -EACCES; |
1409 | } | 1430 | } |
1410 | 1431 | ||
1411 | /* | 1432 | /* |
1412 | * Use the remote server's MOUNT service to request the NFS file handle | 1433 | * Use the remote server's MOUNT service to request the NFS file handle |
1413 | * corresponding to the provided path. | 1434 | * corresponding to the provided path. |
1414 | */ | 1435 | */ |
1415 | static int nfs_try_mount(struct nfs_parsed_mount_data *args, | 1436 | static int nfs_try_mount(struct nfs_parsed_mount_data *args, |
1416 | struct nfs_fh *root_fh) | 1437 | struct nfs_fh *root_fh) |
1417 | { | 1438 | { |
1418 | rpc_authflavor_t server_authlist[NFS_MAX_SECFLAVORS]; | 1439 | rpc_authflavor_t server_authlist[NFS_MAX_SECFLAVORS]; |
1419 | unsigned int server_authlist_len = ARRAY_SIZE(server_authlist); | 1440 | unsigned int server_authlist_len = ARRAY_SIZE(server_authlist); |
1420 | struct nfs_mount_request request = { | 1441 | struct nfs_mount_request request = { |
1421 | .sap = (struct sockaddr *) | 1442 | .sap = (struct sockaddr *) |
1422 | &args->mount_server.address, | 1443 | &args->mount_server.address, |
1423 | .dirpath = args->nfs_server.export_path, | 1444 | .dirpath = args->nfs_server.export_path, |
1424 | .protocol = args->mount_server.protocol, | 1445 | .protocol = args->mount_server.protocol, |
1425 | .fh = root_fh, | 1446 | .fh = root_fh, |
1426 | .noresvport = args->flags & NFS_MOUNT_NORESVPORT, | 1447 | .noresvport = args->flags & NFS_MOUNT_NORESVPORT, |
1427 | .auth_flav_len = &server_authlist_len, | 1448 | .auth_flav_len = &server_authlist_len, |
1428 | .auth_flavs = server_authlist, | 1449 | .auth_flavs = server_authlist, |
1429 | }; | 1450 | }; |
1430 | int status; | 1451 | int status; |
1431 | 1452 | ||
1432 | if (args->mount_server.version == 0) { | 1453 | if (args->mount_server.version == 0) { |
1433 | switch (args->version) { | 1454 | switch (args->version) { |
1434 | default: | 1455 | default: |
1435 | args->mount_server.version = NFS_MNT3_VERSION; | 1456 | args->mount_server.version = NFS_MNT3_VERSION; |
1436 | break; | 1457 | break; |
1437 | case 2: | 1458 | case 2: |
1438 | args->mount_server.version = NFS_MNT_VERSION; | 1459 | args->mount_server.version = NFS_MNT_VERSION; |
1439 | } | 1460 | } |
1440 | } | 1461 | } |
1441 | request.version = args->mount_server.version; | 1462 | request.version = args->mount_server.version; |
1442 | 1463 | ||
1443 | if (args->mount_server.hostname) | 1464 | if (args->mount_server.hostname) |
1444 | request.hostname = args->mount_server.hostname; | 1465 | request.hostname = args->mount_server.hostname; |
1445 | else | 1466 | else |
1446 | request.hostname = args->nfs_server.hostname; | 1467 | request.hostname = args->nfs_server.hostname; |
1447 | 1468 | ||
1448 | /* | 1469 | /* |
1449 | * Construct the mount server's address. | 1470 | * Construct the mount server's address. |
1450 | */ | 1471 | */ |
1451 | if (args->mount_server.address.ss_family == AF_UNSPEC) { | 1472 | if (args->mount_server.address.ss_family == AF_UNSPEC) { |
1452 | memcpy(request.sap, &args->nfs_server.address, | 1473 | memcpy(request.sap, &args->nfs_server.address, |
1453 | args->nfs_server.addrlen); | 1474 | args->nfs_server.addrlen); |
1454 | args->mount_server.addrlen = args->nfs_server.addrlen; | 1475 | args->mount_server.addrlen = args->nfs_server.addrlen; |
1455 | } | 1476 | } |
1456 | request.salen = args->mount_server.addrlen; | 1477 | request.salen = args->mount_server.addrlen; |
1457 | nfs_set_default_port(request.sap, args->mount_server.port, 0); | 1478 | nfs_set_default_port(request.sap, args->mount_server.port, 0); |
1458 | 1479 | ||
1459 | /* | 1480 | /* |
1460 | * Now ask the mount server to map our export path | 1481 | * Now ask the mount server to map our export path |
1461 | * to a file handle. | 1482 | * to a file handle. |
1462 | */ | 1483 | */ |
1463 | status = nfs_mount(&request); | 1484 | status = nfs_mount(&request); |
1464 | if (status != 0) { | 1485 | if (status != 0) { |
1465 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", | 1486 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", |
1466 | request.hostname, status); | 1487 | request.hostname, status); |
1467 | return status; | 1488 | return status; |
1468 | } | 1489 | } |
1469 | 1490 | ||
1470 | /* | 1491 | /* |
1471 | * MNTv1 (NFSv2) does not support auth flavor negotiation. | 1492 | * MNTv1 (NFSv2) does not support auth flavor negotiation. |
1472 | */ | 1493 | */ |
1473 | if (args->mount_server.version != NFS_MNT3_VERSION) | 1494 | if (args->mount_server.version != NFS_MNT3_VERSION) |
1474 | return 0; | 1495 | return 0; |
1475 | return nfs_walk_authlist(args, &request); | 1496 | return nfs_walk_authlist(args, &request); |
1476 | } | 1497 | } |
1477 | 1498 | ||
1478 | static int nfs_parse_simple_hostname(const char *dev_name, | 1499 | static int nfs_parse_simple_hostname(const char *dev_name, |
1479 | char **hostname, size_t maxnamlen, | 1500 | char **hostname, size_t maxnamlen, |
1480 | char **export_path, size_t maxpathlen) | 1501 | char **export_path, size_t maxpathlen) |
1481 | { | 1502 | { |
1482 | size_t len; | 1503 | size_t len; |
1483 | char *colon, *comma; | 1504 | char *colon, *comma; |
1484 | 1505 | ||
1485 | colon = strchr(dev_name, ':'); | 1506 | colon = strchr(dev_name, ':'); |
1486 | if (colon == NULL) | 1507 | if (colon == NULL) |
1487 | goto out_bad_devname; | 1508 | goto out_bad_devname; |
1488 | 1509 | ||
1489 | len = colon - dev_name; | 1510 | len = colon - dev_name; |
1490 | if (len > maxnamlen) | 1511 | if (len > maxnamlen) |
1491 | goto out_hostname; | 1512 | goto out_hostname; |
1492 | 1513 | ||
1493 | /* N.B. caller will free nfs_server.hostname in all cases */ | 1514 | /* N.B. caller will free nfs_server.hostname in all cases */ |
1494 | *hostname = kstrndup(dev_name, len, GFP_KERNEL); | 1515 | *hostname = kstrndup(dev_name, len, GFP_KERNEL); |
1495 | if (!*hostname) | 1516 | if (!*hostname) |
1496 | goto out_nomem; | 1517 | goto out_nomem; |
1497 | 1518 | ||
1498 | /* kill possible hostname list: not supported */ | 1519 | /* kill possible hostname list: not supported */ |
1499 | comma = strchr(*hostname, ','); | 1520 | comma = strchr(*hostname, ','); |
1500 | if (comma != NULL) { | 1521 | if (comma != NULL) { |
1501 | if (comma == *hostname) | 1522 | if (comma == *hostname) |
1502 | goto out_bad_devname; | 1523 | goto out_bad_devname; |
1503 | *comma = '\0'; | 1524 | *comma = '\0'; |
1504 | } | 1525 | } |
1505 | 1526 | ||
1506 | colon++; | 1527 | colon++; |
1507 | len = strlen(colon); | 1528 | len = strlen(colon); |
1508 | if (len > maxpathlen) | 1529 | if (len > maxpathlen) |
1509 | goto out_path; | 1530 | goto out_path; |
1510 | *export_path = kstrndup(colon, len, GFP_KERNEL); | 1531 | *export_path = kstrndup(colon, len, GFP_KERNEL); |
1511 | if (!*export_path) | 1532 | if (!*export_path) |
1512 | goto out_nomem; | 1533 | goto out_nomem; |
1513 | 1534 | ||
1514 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path); | 1535 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path); |
1515 | return 0; | 1536 | return 0; |
1516 | 1537 | ||
1517 | out_bad_devname: | 1538 | out_bad_devname: |
1518 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | 1539 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); |
1519 | return -EINVAL; | 1540 | return -EINVAL; |
1520 | 1541 | ||
1521 | out_nomem: | 1542 | out_nomem: |
1522 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | 1543 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); |
1523 | return -ENOMEM; | 1544 | return -ENOMEM; |
1524 | 1545 | ||
1525 | out_hostname: | 1546 | out_hostname: |
1526 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | 1547 | dfprintk(MOUNT, "NFS: server hostname too long\n"); |
1527 | return -ENAMETOOLONG; | 1548 | return -ENAMETOOLONG; |
1528 | 1549 | ||
1529 | out_path: | 1550 | out_path: |
1530 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | 1551 | dfprintk(MOUNT, "NFS: export pathname too long\n"); |
1531 | return -ENAMETOOLONG; | 1552 | return -ENAMETOOLONG; |
1532 | } | 1553 | } |
1533 | 1554 | ||
1534 | /* | 1555 | /* |
1535 | * Hostname has square brackets around it because it contains one or | 1556 | * Hostname has square brackets around it because it contains one or |
1536 | * more colons. We look for the first closing square bracket, and a | 1557 | * more colons. We look for the first closing square bracket, and a |
1537 | * colon must follow it. | 1558 | * colon must follow it. |
1538 | */ | 1559 | */ |
1539 | static int nfs_parse_protected_hostname(const char *dev_name, | 1560 | static int nfs_parse_protected_hostname(const char *dev_name, |
1540 | char **hostname, size_t maxnamlen, | 1561 | char **hostname, size_t maxnamlen, |
1541 | char **export_path, size_t maxpathlen) | 1562 | char **export_path, size_t maxpathlen) |
1542 | { | 1563 | { |
1543 | size_t len; | 1564 | size_t len; |
1544 | char *start, *end; | 1565 | char *start, *end; |
1545 | 1566 | ||
1546 | start = (char *)(dev_name + 1); | 1567 | start = (char *)(dev_name + 1); |
1547 | 1568 | ||
1548 | end = strchr(start, ']'); | 1569 | end = strchr(start, ']'); |
1549 | if (end == NULL) | 1570 | if (end == NULL) |
1550 | goto out_bad_devname; | 1571 | goto out_bad_devname; |
1551 | if (*(end + 1) != ':') | 1572 | if (*(end + 1) != ':') |
1552 | goto out_bad_devname; | 1573 | goto out_bad_devname; |
1553 | 1574 | ||
1554 | len = end - start; | 1575 | len = end - start; |
1555 | if (len > maxnamlen) | 1576 | if (len > maxnamlen) |
1556 | goto out_hostname; | 1577 | goto out_hostname; |
1557 | 1578 | ||
1558 | /* N.B. caller will free nfs_server.hostname in all cases */ | 1579 | /* N.B. caller will free nfs_server.hostname in all cases */ |
1559 | *hostname = kstrndup(start, len, GFP_KERNEL); | 1580 | *hostname = kstrndup(start, len, GFP_KERNEL); |
1560 | if (*hostname == NULL) | 1581 | if (*hostname == NULL) |
1561 | goto out_nomem; | 1582 | goto out_nomem; |
1562 | 1583 | ||
1563 | end += 2; | 1584 | end += 2; |
1564 | len = strlen(end); | 1585 | len = strlen(end); |
1565 | if (len > maxpathlen) | 1586 | if (len > maxpathlen) |
1566 | goto out_path; | 1587 | goto out_path; |
1567 | *export_path = kstrndup(end, len, GFP_KERNEL); | 1588 | *export_path = kstrndup(end, len, GFP_KERNEL); |
1568 | if (!*export_path) | 1589 | if (!*export_path) |
1569 | goto out_nomem; | 1590 | goto out_nomem; |
1570 | 1591 | ||
1571 | return 0; | 1592 | return 0; |
1572 | 1593 | ||
1573 | out_bad_devname: | 1594 | out_bad_devname: |
1574 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | 1595 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); |
1575 | return -EINVAL; | 1596 | return -EINVAL; |
1576 | 1597 | ||
1577 | out_nomem: | 1598 | out_nomem: |
1578 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | 1599 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); |
1579 | return -ENOMEM; | 1600 | return -ENOMEM; |
1580 | 1601 | ||
1581 | out_hostname: | 1602 | out_hostname: |
1582 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | 1603 | dfprintk(MOUNT, "NFS: server hostname too long\n"); |
1583 | return -ENAMETOOLONG; | 1604 | return -ENAMETOOLONG; |
1584 | 1605 | ||
1585 | out_path: | 1606 | out_path: |
1586 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | 1607 | dfprintk(MOUNT, "NFS: export pathname too long\n"); |
1587 | return -ENAMETOOLONG; | 1608 | return -ENAMETOOLONG; |
1588 | } | 1609 | } |
1589 | 1610 | ||
1590 | /* | 1611 | /* |
1591 | * Split "dev_name" into "hostname:export_path". | 1612 | * Split "dev_name" into "hostname:export_path". |
1592 | * | 1613 | * |
1593 | * The leftmost colon demarks the split between the server's hostname | 1614 | * The leftmost colon demarks the split between the server's hostname |
1594 | * and the export path. If the hostname starts with a left square | 1615 | * and the export path. If the hostname starts with a left square |
1595 | * bracket, then it may contain colons. | 1616 | * bracket, then it may contain colons. |
1596 | * | 1617 | * |
1597 | * Note: caller frees hostname and export path, even on error. | 1618 | * Note: caller frees hostname and export path, even on error. |
1598 | */ | 1619 | */ |
1599 | static int nfs_parse_devname(const char *dev_name, | 1620 | static int nfs_parse_devname(const char *dev_name, |
1600 | char **hostname, size_t maxnamlen, | 1621 | char **hostname, size_t maxnamlen, |
1601 | char **export_path, size_t maxpathlen) | 1622 | char **export_path, size_t maxpathlen) |
1602 | { | 1623 | { |
1603 | if (*dev_name == '[') | 1624 | if (*dev_name == '[') |
1604 | return nfs_parse_protected_hostname(dev_name, | 1625 | return nfs_parse_protected_hostname(dev_name, |
1605 | hostname, maxnamlen, | 1626 | hostname, maxnamlen, |
1606 | export_path, maxpathlen); | 1627 | export_path, maxpathlen); |
1607 | 1628 | ||
1608 | return nfs_parse_simple_hostname(dev_name, | 1629 | return nfs_parse_simple_hostname(dev_name, |
1609 | hostname, maxnamlen, | 1630 | hostname, maxnamlen, |
1610 | export_path, maxpathlen); | 1631 | export_path, maxpathlen); |
1611 | } | 1632 | } |
1612 | 1633 | ||
1613 | /* | 1634 | /* |
1614 | * Validate the NFS2/NFS3 mount data | 1635 | * Validate the NFS2/NFS3 mount data |
1615 | * - fills in the mount root filehandle | 1636 | * - fills in the mount root filehandle |
1616 | * | 1637 | * |
1617 | * For option strings, user space handles the following behaviors: | 1638 | * For option strings, user space handles the following behaviors: |
1618 | * | 1639 | * |
1619 | * + DNS: mapping server host name to IP address ("addr=" option) | 1640 | * + DNS: mapping server host name to IP address ("addr=" option) |
1620 | * | 1641 | * |
1621 | * + failure mode: how to behave if a mount request can't be handled | 1642 | * + failure mode: how to behave if a mount request can't be handled |
1622 | * immediately ("fg/bg" option) | 1643 | * immediately ("fg/bg" option) |
1623 | * | 1644 | * |
1624 | * + retry: how often to retry a mount request ("retry=" option) | 1645 | * + retry: how often to retry a mount request ("retry=" option) |
1625 | * | 1646 | * |
1626 | * + breaking back: trying proto=udp after proto=tcp, v2 after v3, | 1647 | * + breaking back: trying proto=udp after proto=tcp, v2 after v3, |
1627 | * mountproto=tcp after mountproto=udp, and so on | 1648 | * mountproto=tcp after mountproto=udp, and so on |
1628 | */ | 1649 | */ |
1629 | static int nfs_validate_mount_data(void *options, | 1650 | static int nfs_validate_mount_data(void *options, |
1630 | struct nfs_parsed_mount_data *args, | 1651 | struct nfs_parsed_mount_data *args, |
1631 | struct nfs_fh *mntfh, | 1652 | struct nfs_fh *mntfh, |
1632 | const char *dev_name) | 1653 | const char *dev_name) |
1633 | { | 1654 | { |
1634 | struct nfs_mount_data *data = (struct nfs_mount_data *)options; | 1655 | struct nfs_mount_data *data = (struct nfs_mount_data *)options; |
1635 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; | 1656 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; |
1636 | 1657 | ||
1637 | if (data == NULL) | 1658 | if (data == NULL) |
1638 | goto out_no_data; | 1659 | goto out_no_data; |
1639 | 1660 | ||
1640 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); | ||
1641 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
1642 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
1643 | args->acregmin = NFS_DEF_ACREGMIN; | ||
1644 | args->acregmax = NFS_DEF_ACREGMAX; | ||
1645 | args->acdirmin = NFS_DEF_ACDIRMIN; | ||
1646 | args->acdirmax = NFS_DEF_ACDIRMAX; | ||
1647 | args->mount_server.port = NFS_UNSPEC_PORT; | ||
1648 | args->nfs_server.port = NFS_UNSPEC_PORT; | ||
1649 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
1650 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1651 | args->auth_flavor_len = 1; | ||
1652 | args->minorversion = 0; | ||
1653 | |||
1654 | switch (data->version) { | 1661 | switch (data->version) { |
1655 | case 1: | 1662 | case 1: |
1656 | data->namlen = 0; | 1663 | data->namlen = 0; |
1657 | case 2: | 1664 | case 2: |
1658 | data->bsize = 0; | 1665 | data->bsize = 0; |
1659 | case 3: | 1666 | case 3: |
1660 | if (data->flags & NFS_MOUNT_VER3) | 1667 | if (data->flags & NFS_MOUNT_VER3) |
1661 | goto out_no_v3; | 1668 | goto out_no_v3; |
1662 | data->root.size = NFS2_FHSIZE; | 1669 | data->root.size = NFS2_FHSIZE; |
1663 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); | 1670 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); |
1664 | case 4: | 1671 | case 4: |
1665 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | 1672 | if (data->flags & NFS_MOUNT_SECFLAVOUR) |
1666 | goto out_no_sec; | 1673 | goto out_no_sec; |
1667 | case 5: | 1674 | case 5: |
1668 | memset(data->context, 0, sizeof(data->context)); | 1675 | memset(data->context, 0, sizeof(data->context)); |
1669 | case 6: | 1676 | case 6: |
1670 | if (data->flags & NFS_MOUNT_VER3) { | 1677 | if (data->flags & NFS_MOUNT_VER3) { |
1671 | if (data->root.size > NFS3_FHSIZE || data->root.size == 0) | 1678 | if (data->root.size > NFS3_FHSIZE || data->root.size == 0) |
1672 | goto out_invalid_fh; | 1679 | goto out_invalid_fh; |
1673 | mntfh->size = data->root.size; | 1680 | mntfh->size = data->root.size; |
1674 | args->version = 3; | 1681 | args->version = 3; |
1675 | } else { | 1682 | } else { |
1676 | mntfh->size = NFS2_FHSIZE; | 1683 | mntfh->size = NFS2_FHSIZE; |
1677 | args->version = 2; | 1684 | args->version = 2; |
1678 | } | 1685 | } |
1679 | 1686 | ||
1680 | 1687 | ||
1681 | memcpy(mntfh->data, data->root.data, mntfh->size); | 1688 | memcpy(mntfh->data, data->root.data, mntfh->size); |
1682 | if (mntfh->size < sizeof(mntfh->data)) | 1689 | if (mntfh->size < sizeof(mntfh->data)) |
1683 | memset(mntfh->data + mntfh->size, 0, | 1690 | memset(mntfh->data + mntfh->size, 0, |
1684 | sizeof(mntfh->data) - mntfh->size); | 1691 | sizeof(mntfh->data) - mntfh->size); |
1685 | 1692 | ||
1686 | /* | 1693 | /* |
1687 | * Translate to nfs_parsed_mount_data, which nfs_fill_super | 1694 | * Translate to nfs_parsed_mount_data, which nfs_fill_super |
1688 | * can deal with. | 1695 | * can deal with. |
1689 | */ | 1696 | */ |
1690 | args->flags = data->flags & NFS_MOUNT_FLAGMASK; | 1697 | args->flags = data->flags & NFS_MOUNT_FLAGMASK; |
1691 | args->rsize = data->rsize; | 1698 | args->rsize = data->rsize; |
1692 | args->wsize = data->wsize; | 1699 | args->wsize = data->wsize; |
1693 | args->timeo = data->timeo; | 1700 | args->timeo = data->timeo; |
1694 | args->retrans = data->retrans; | 1701 | args->retrans = data->retrans; |
1695 | args->acregmin = data->acregmin; | 1702 | args->acregmin = data->acregmin; |
1696 | args->acregmax = data->acregmax; | 1703 | args->acregmax = data->acregmax; |
1697 | args->acdirmin = data->acdirmin; | 1704 | args->acdirmin = data->acdirmin; |
1698 | args->acdirmax = data->acdirmax; | 1705 | args->acdirmax = data->acdirmax; |
1699 | 1706 | ||
1700 | memcpy(sap, &data->addr, sizeof(data->addr)); | 1707 | memcpy(sap, &data->addr, sizeof(data->addr)); |
1701 | args->nfs_server.addrlen = sizeof(data->addr); | 1708 | args->nfs_server.addrlen = sizeof(data->addr); |
1702 | if (!nfs_verify_server_address(sap)) | 1709 | if (!nfs_verify_server_address(sap)) |
1703 | goto out_no_address; | 1710 | goto out_no_address; |
1704 | 1711 | ||
1705 | if (!(data->flags & NFS_MOUNT_TCP)) | 1712 | if (!(data->flags & NFS_MOUNT_TCP)) |
1706 | args->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1713 | args->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
1707 | /* N.B. caller will free nfs_server.hostname in all cases */ | 1714 | /* N.B. caller will free nfs_server.hostname in all cases */ |
1708 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); | 1715 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); |
1709 | args->namlen = data->namlen; | 1716 | args->namlen = data->namlen; |
1710 | args->bsize = data->bsize; | 1717 | args->bsize = data->bsize; |
1711 | 1718 | ||
1712 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | 1719 | if (data->flags & NFS_MOUNT_SECFLAVOUR) |
1713 | args->auth_flavors[0] = data->pseudoflavor; | 1720 | args->auth_flavors[0] = data->pseudoflavor; |
1714 | if (!args->nfs_server.hostname) | 1721 | if (!args->nfs_server.hostname) |
1715 | goto out_nomem; | 1722 | goto out_nomem; |
1716 | 1723 | ||
1717 | /* | 1724 | /* |
1718 | * The legacy version 6 binary mount data from userspace has a | 1725 | * The legacy version 6 binary mount data from userspace has a |
1719 | * field used only to transport selinux information into the | 1726 | * field used only to transport selinux information into the |
1720 | * the kernel. To continue to support that functionality we | 1727 | * the kernel. To continue to support that functionality we |
1721 | * have a touch of selinux knowledge here in the NFS code. The | 1728 | * have a touch of selinux knowledge here in the NFS code. The |
1722 | * userspace code converted context=blah to just blah so we are | 1729 | * userspace code converted context=blah to just blah so we are |
1723 | * converting back to the full string selinux understands. | 1730 | * converting back to the full string selinux understands. |
1724 | */ | 1731 | */ |
1725 | if (data->context[0]){ | 1732 | if (data->context[0]){ |
1726 | #ifdef CONFIG_SECURITY_SELINUX | 1733 | #ifdef CONFIG_SECURITY_SELINUX |
1727 | int rc; | 1734 | int rc; |
1728 | char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL); | 1735 | char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL); |
1729 | if (!opts_str) | 1736 | if (!opts_str) |
1730 | return -ENOMEM; | 1737 | return -ENOMEM; |
1731 | strcpy(opts_str, "context="); | 1738 | strcpy(opts_str, "context="); |
1732 | data->context[NFS_MAX_CONTEXT_LEN] = '\0'; | 1739 | data->context[NFS_MAX_CONTEXT_LEN] = '\0'; |
1733 | strcat(opts_str, &data->context[0]); | 1740 | strcat(opts_str, &data->context[0]); |
1734 | rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts); | 1741 | rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts); |
1735 | kfree(opts_str); | 1742 | kfree(opts_str); |
1736 | if (rc) | 1743 | if (rc) |
1737 | return rc; | 1744 | return rc; |
1738 | #else | 1745 | #else |
1739 | return -EINVAL; | 1746 | return -EINVAL; |
1740 | #endif | 1747 | #endif |
1741 | } | 1748 | } |
1742 | 1749 | ||
1743 | break; | 1750 | break; |
1744 | default: { | 1751 | default: { |
1745 | int status; | 1752 | int status; |
1746 | 1753 | ||
1747 | if (nfs_parse_mount_options((char *)options, args) == 0) | 1754 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1748 | return -EINVAL; | 1755 | return -EINVAL; |
1749 | 1756 | ||
1750 | if (!nfs_verify_server_address(sap)) | 1757 | if (!nfs_verify_server_address(sap)) |
1751 | goto out_no_address; | 1758 | goto out_no_address; |
1752 | 1759 | ||
1753 | if (args->version == 4) | 1760 | if (args->version == 4) |
1754 | #ifdef CONFIG_NFS_V4 | 1761 | #ifdef CONFIG_NFS_V4 |
1755 | return nfs4_validate_text_mount_data(options, | 1762 | return nfs4_validate_text_mount_data(options, |
1756 | args, dev_name); | 1763 | args, dev_name); |
1757 | #else | 1764 | #else |
1758 | goto out_v4_not_compiled; | 1765 | goto out_v4_not_compiled; |
1759 | #endif | 1766 | #endif |
1760 | 1767 | ||
1761 | nfs_set_default_port(sap, args->nfs_server.port, 0); | 1768 | nfs_set_default_port(sap, args->nfs_server.port, 0); |
1762 | 1769 | ||
1763 | nfs_set_mount_transport_protocol(args); | 1770 | nfs_set_mount_transport_protocol(args); |
1764 | 1771 | ||
1765 | status = nfs_parse_devname(dev_name, | 1772 | status = nfs_parse_devname(dev_name, |
1766 | &args->nfs_server.hostname, | 1773 | &args->nfs_server.hostname, |
1767 | PAGE_SIZE, | 1774 | PAGE_SIZE, |
1768 | &args->nfs_server.export_path, | 1775 | &args->nfs_server.export_path, |
1769 | NFS_MAXPATHLEN); | 1776 | NFS_MAXPATHLEN); |
1770 | if (!status) | 1777 | if (!status) |
1771 | status = nfs_try_mount(args, mntfh); | 1778 | status = nfs_try_mount(args, mntfh); |
1772 | 1779 | ||
1773 | kfree(args->nfs_server.export_path); | 1780 | kfree(args->nfs_server.export_path); |
1774 | args->nfs_server.export_path = NULL; | 1781 | args->nfs_server.export_path = NULL; |
1775 | 1782 | ||
1776 | if (status) | 1783 | if (status) |
1777 | return status; | 1784 | return status; |
1778 | 1785 | ||
1779 | break; | 1786 | break; |
1780 | } | 1787 | } |
1781 | } | 1788 | } |
1782 | 1789 | ||
1783 | #ifndef CONFIG_NFS_V3 | 1790 | #ifndef CONFIG_NFS_V3 |
1784 | if (args->version == 3) | 1791 | if (args->version == 3) |
1785 | goto out_v3_not_compiled; | 1792 | goto out_v3_not_compiled; |
1786 | #endif /* !CONFIG_NFS_V3 */ | 1793 | #endif /* !CONFIG_NFS_V3 */ |
1787 | 1794 | ||
1788 | return 0; | 1795 | return 0; |
1789 | 1796 | ||
1790 | out_no_data: | 1797 | out_no_data: |
1791 | dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n"); | 1798 | dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n"); |
1792 | return -EINVAL; | 1799 | return -EINVAL; |
1793 | 1800 | ||
1794 | out_no_v3: | 1801 | out_no_v3: |
1795 | dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n", | 1802 | dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n", |
1796 | data->version); | 1803 | data->version); |
1797 | return -EINVAL; | 1804 | return -EINVAL; |
1798 | 1805 | ||
1799 | out_no_sec: | 1806 | out_no_sec: |
1800 | dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n"); | 1807 | dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n"); |
1801 | return -EINVAL; | 1808 | return -EINVAL; |
1802 | 1809 | ||
1803 | #ifndef CONFIG_NFS_V3 | 1810 | #ifndef CONFIG_NFS_V3 |
1804 | out_v3_not_compiled: | 1811 | out_v3_not_compiled: |
1805 | dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n"); | 1812 | dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n"); |
1806 | return -EPROTONOSUPPORT; | 1813 | return -EPROTONOSUPPORT; |
1807 | #endif /* !CONFIG_NFS_V3 */ | 1814 | #endif /* !CONFIG_NFS_V3 */ |
1808 | 1815 | ||
1809 | #ifndef CONFIG_NFS_V4 | 1816 | #ifndef CONFIG_NFS_V4 |
1810 | out_v4_not_compiled: | 1817 | out_v4_not_compiled: |
1811 | dfprintk(MOUNT, "NFS: NFSv4 is not compiled into kernel\n"); | 1818 | dfprintk(MOUNT, "NFS: NFSv4 is not compiled into kernel\n"); |
1812 | return -EPROTONOSUPPORT; | 1819 | return -EPROTONOSUPPORT; |
1813 | #endif /* !CONFIG_NFS_V4 */ | 1820 | #endif /* !CONFIG_NFS_V4 */ |
1814 | 1821 | ||
1815 | out_nomem: | 1822 | out_nomem: |
1816 | dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n"); | 1823 | dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n"); |
1817 | return -ENOMEM; | 1824 | return -ENOMEM; |
1818 | 1825 | ||
1819 | out_no_address: | 1826 | out_no_address: |
1820 | dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n"); | 1827 | dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n"); |
1821 | return -EINVAL; | 1828 | return -EINVAL; |
1822 | 1829 | ||
1823 | out_invalid_fh: | 1830 | out_invalid_fh: |
1824 | dfprintk(MOUNT, "NFS: invalid root filehandle\n"); | 1831 | dfprintk(MOUNT, "NFS: invalid root filehandle\n"); |
1825 | return -EINVAL; | 1832 | return -EINVAL; |
1826 | } | 1833 | } |
1827 | 1834 | ||
1828 | static int | 1835 | static int |
1829 | nfs_compare_remount_data(struct nfs_server *nfss, | 1836 | nfs_compare_remount_data(struct nfs_server *nfss, |
1830 | struct nfs_parsed_mount_data *data) | 1837 | struct nfs_parsed_mount_data *data) |
1831 | { | 1838 | { |
1832 | if (data->flags != nfss->flags || | 1839 | if (data->flags != nfss->flags || |
1833 | data->rsize != nfss->rsize || | 1840 | data->rsize != nfss->rsize || |
1834 | data->wsize != nfss->wsize || | 1841 | data->wsize != nfss->wsize || |
1835 | data->retrans != nfss->client->cl_timeout->to_retries || | 1842 | data->retrans != nfss->client->cl_timeout->to_retries || |
1836 | data->auth_flavors[0] != nfss->client->cl_auth->au_flavor || | 1843 | data->auth_flavors[0] != nfss->client->cl_auth->au_flavor || |
1837 | data->acregmin != nfss->acregmin / HZ || | 1844 | data->acregmin != nfss->acregmin / HZ || |
1838 | data->acregmax != nfss->acregmax / HZ || | 1845 | data->acregmax != nfss->acregmax / HZ || |
1839 | data->acdirmin != nfss->acdirmin / HZ || | 1846 | data->acdirmin != nfss->acdirmin / HZ || |
1840 | data->acdirmax != nfss->acdirmax / HZ || | 1847 | data->acdirmax != nfss->acdirmax / HZ || |
1841 | data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) || | 1848 | data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) || |
1842 | data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen || | 1849 | data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen || |
1843 | memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | 1850 | memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr, |
1844 | data->nfs_server.addrlen) != 0) | 1851 | data->nfs_server.addrlen) != 0) |
1845 | return -EINVAL; | 1852 | return -EINVAL; |
1846 | 1853 | ||
1847 | return 0; | 1854 | return 0; |
1848 | } | 1855 | } |
1849 | 1856 | ||
1850 | static int | 1857 | static int |
1851 | nfs_remount(struct super_block *sb, int *flags, char *raw_data) | 1858 | nfs_remount(struct super_block *sb, int *flags, char *raw_data) |
1852 | { | 1859 | { |
1853 | int error; | 1860 | int error; |
1854 | struct nfs_server *nfss = sb->s_fs_info; | 1861 | struct nfs_server *nfss = sb->s_fs_info; |
1855 | struct nfs_parsed_mount_data *data; | 1862 | struct nfs_parsed_mount_data *data; |
1856 | struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data; | 1863 | struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data; |
1857 | struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data; | 1864 | struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data; |
1858 | u32 nfsvers = nfss->nfs_client->rpc_ops->version; | 1865 | u32 nfsvers = nfss->nfs_client->rpc_ops->version; |
1859 | 1866 | ||
1860 | /* | 1867 | /* |
1861 | * Userspace mount programs that send binary options generally send | 1868 | * Userspace mount programs that send binary options generally send |
1862 | * them populated with default values. We have no way to know which | 1869 | * them populated with default values. We have no way to know which |
1863 | * ones were explicitly specified. Fall back to legacy behavior and | 1870 | * ones were explicitly specified. Fall back to legacy behavior and |
1864 | * just return success. | 1871 | * just return success. |
1865 | */ | 1872 | */ |
1866 | if ((nfsvers == 4 && (!options4 || options4->version == 1)) || | 1873 | if ((nfsvers == 4 && (!options4 || options4->version == 1)) || |
1867 | (nfsvers <= 3 && (!options || (options->version >= 1 && | 1874 | (nfsvers <= 3 && (!options || (options->version >= 1 && |
1868 | options->version <= 6)))) | 1875 | options->version <= 6)))) |
1869 | return 0; | 1876 | return 0; |
1870 | 1877 | ||
1871 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 1878 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
1872 | if (data == NULL) | 1879 | if (data == NULL) |
1873 | return -ENOMEM; | 1880 | return -ENOMEM; |
1874 | 1881 | ||
1875 | lock_kernel(); | 1882 | lock_kernel(); |
1876 | /* fill out struct with values from existing mount */ | 1883 | /* fill out struct with values from existing mount */ |
1877 | data->flags = nfss->flags; | 1884 | data->flags = nfss->flags; |
1878 | data->rsize = nfss->rsize; | 1885 | data->rsize = nfss->rsize; |
1879 | data->wsize = nfss->wsize; | 1886 | data->wsize = nfss->wsize; |
1880 | data->retrans = nfss->client->cl_timeout->to_retries; | 1887 | data->retrans = nfss->client->cl_timeout->to_retries; |
1881 | data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; | 1888 | data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; |
1882 | data->acregmin = nfss->acregmin / HZ; | 1889 | data->acregmin = nfss->acregmin / HZ; |
1883 | data->acregmax = nfss->acregmax / HZ; | 1890 | data->acregmax = nfss->acregmax / HZ; |
1884 | data->acdirmin = nfss->acdirmin / HZ; | 1891 | data->acdirmin = nfss->acdirmin / HZ; |
1885 | data->acdirmax = nfss->acdirmax / HZ; | 1892 | data->acdirmax = nfss->acdirmax / HZ; |
1886 | data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; | 1893 | data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; |
1887 | data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; | 1894 | data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; |
1888 | memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | 1895 | memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr, |
1889 | data->nfs_server.addrlen); | 1896 | data->nfs_server.addrlen); |
1890 | 1897 | ||
1891 | /* overwrite those values with any that were specified */ | 1898 | /* overwrite those values with any that were specified */ |
1892 | error = nfs_parse_mount_options((char *)options, data); | 1899 | error = nfs_parse_mount_options((char *)options, data); |
1893 | if (error < 0) | 1900 | if (error < 0) |
1894 | goto out; | 1901 | goto out; |
1895 | 1902 | ||
1896 | /* compare new mount options with old ones */ | 1903 | /* compare new mount options with old ones */ |
1897 | error = nfs_compare_remount_data(nfss, data); | 1904 | error = nfs_compare_remount_data(nfss, data); |
1898 | out: | 1905 | out: |
1899 | kfree(data); | 1906 | kfree(data); |
1900 | unlock_kernel(); | 1907 | unlock_kernel(); |
1901 | return error; | 1908 | return error; |
1902 | } | 1909 | } |
1903 | 1910 | ||
1904 | /* | 1911 | /* |
1905 | * Initialise the common bits of the superblock | 1912 | * Initialise the common bits of the superblock |
1906 | */ | 1913 | */ |
1907 | static inline void nfs_initialise_sb(struct super_block *sb) | 1914 | static inline void nfs_initialise_sb(struct super_block *sb) |
1908 | { | 1915 | { |
1909 | struct nfs_server *server = NFS_SB(sb); | 1916 | struct nfs_server *server = NFS_SB(sb); |
1910 | 1917 | ||
1911 | sb->s_magic = NFS_SUPER_MAGIC; | 1918 | sb->s_magic = NFS_SUPER_MAGIC; |
1912 | 1919 | ||
1913 | /* We probably want something more informative here */ | 1920 | /* We probably want something more informative here */ |
1914 | snprintf(sb->s_id, sizeof(sb->s_id), | 1921 | snprintf(sb->s_id, sizeof(sb->s_id), |
1915 | "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev)); | 1922 | "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev)); |
1916 | 1923 | ||
1917 | if (sb->s_blocksize == 0) | 1924 | if (sb->s_blocksize == 0) |
1918 | sb->s_blocksize = nfs_block_bits(server->wsize, | 1925 | sb->s_blocksize = nfs_block_bits(server->wsize, |
1919 | &sb->s_blocksize_bits); | 1926 | &sb->s_blocksize_bits); |
1920 | 1927 | ||
1921 | if (server->flags & NFS_MOUNT_NOAC) | 1928 | if (server->flags & NFS_MOUNT_NOAC) |
1922 | sb->s_flags |= MS_SYNCHRONOUS; | 1929 | sb->s_flags |= MS_SYNCHRONOUS; |
1923 | 1930 | ||
1924 | sb->s_bdi = &server->backing_dev_info; | 1931 | sb->s_bdi = &server->backing_dev_info; |
1925 | 1932 | ||
1926 | nfs_super_set_maxbytes(sb, server->maxfilesize); | 1933 | nfs_super_set_maxbytes(sb, server->maxfilesize); |
1927 | } | 1934 | } |
1928 | 1935 | ||
1929 | /* | 1936 | /* |
1930 | * Finish setting up an NFS2/3 superblock | 1937 | * Finish setting up an NFS2/3 superblock |
1931 | */ | 1938 | */ |
1932 | static void nfs_fill_super(struct super_block *sb, | 1939 | static void nfs_fill_super(struct super_block *sb, |
1933 | struct nfs_parsed_mount_data *data) | 1940 | struct nfs_parsed_mount_data *data) |
1934 | { | 1941 | { |
1935 | struct nfs_server *server = NFS_SB(sb); | 1942 | struct nfs_server *server = NFS_SB(sb); |
1936 | 1943 | ||
1937 | sb->s_blocksize_bits = 0; | 1944 | sb->s_blocksize_bits = 0; |
1938 | sb->s_blocksize = 0; | 1945 | sb->s_blocksize = 0; |
1939 | if (data->bsize) | 1946 | if (data->bsize) |
1940 | sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); | 1947 | sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); |
1941 | 1948 | ||
1942 | if (server->nfs_client->rpc_ops->version == 3) { | 1949 | if (server->nfs_client->rpc_ops->version == 3) { |
1943 | /* The VFS shouldn't apply the umask to mode bits. We will do | 1950 | /* The VFS shouldn't apply the umask to mode bits. We will do |
1944 | * so ourselves when necessary. | 1951 | * so ourselves when necessary. |
1945 | */ | 1952 | */ |
1946 | sb->s_flags |= MS_POSIXACL; | 1953 | sb->s_flags |= MS_POSIXACL; |
1947 | sb->s_time_gran = 1; | 1954 | sb->s_time_gran = 1; |
1948 | } | 1955 | } |
1949 | 1956 | ||
1950 | sb->s_op = &nfs_sops; | 1957 | sb->s_op = &nfs_sops; |
1951 | nfs_initialise_sb(sb); | 1958 | nfs_initialise_sb(sb); |
1952 | } | 1959 | } |
1953 | 1960 | ||
1954 | /* | 1961 | /* |
1955 | * Finish setting up a cloned NFS2/3 superblock | 1962 | * Finish setting up a cloned NFS2/3 superblock |
1956 | */ | 1963 | */ |
1957 | static void nfs_clone_super(struct super_block *sb, | 1964 | static void nfs_clone_super(struct super_block *sb, |
1958 | const struct super_block *old_sb) | 1965 | const struct super_block *old_sb) |
1959 | { | 1966 | { |
1960 | struct nfs_server *server = NFS_SB(sb); | 1967 | struct nfs_server *server = NFS_SB(sb); |
1961 | 1968 | ||
1962 | sb->s_blocksize_bits = old_sb->s_blocksize_bits; | 1969 | sb->s_blocksize_bits = old_sb->s_blocksize_bits; |
1963 | sb->s_blocksize = old_sb->s_blocksize; | 1970 | sb->s_blocksize = old_sb->s_blocksize; |
1964 | sb->s_maxbytes = old_sb->s_maxbytes; | 1971 | sb->s_maxbytes = old_sb->s_maxbytes; |
1965 | 1972 | ||
1966 | if (server->nfs_client->rpc_ops->version == 3) { | 1973 | if (server->nfs_client->rpc_ops->version == 3) { |
1967 | /* The VFS shouldn't apply the umask to mode bits. We will do | 1974 | /* The VFS shouldn't apply the umask to mode bits. We will do |
1968 | * so ourselves when necessary. | 1975 | * so ourselves when necessary. |
1969 | */ | 1976 | */ |
1970 | sb->s_flags |= MS_POSIXACL; | 1977 | sb->s_flags |= MS_POSIXACL; |
1971 | sb->s_time_gran = 1; | 1978 | sb->s_time_gran = 1; |
1972 | } | 1979 | } |
1973 | 1980 | ||
1974 | sb->s_op = old_sb->s_op; | 1981 | sb->s_op = old_sb->s_op; |
1975 | nfs_initialise_sb(sb); | 1982 | nfs_initialise_sb(sb); |
1976 | } | 1983 | } |
1977 | 1984 | ||
1978 | static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags) | 1985 | static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags) |
1979 | { | 1986 | { |
1980 | const struct nfs_server *a = s->s_fs_info; | 1987 | const struct nfs_server *a = s->s_fs_info; |
1981 | const struct rpc_clnt *clnt_a = a->client; | 1988 | const struct rpc_clnt *clnt_a = a->client; |
1982 | const struct rpc_clnt *clnt_b = b->client; | 1989 | const struct rpc_clnt *clnt_b = b->client; |
1983 | 1990 | ||
1984 | if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK)) | 1991 | if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK)) |
1985 | goto Ebusy; | 1992 | goto Ebusy; |
1986 | if (a->nfs_client != b->nfs_client) | 1993 | if (a->nfs_client != b->nfs_client) |
1987 | goto Ebusy; | 1994 | goto Ebusy; |
1988 | if (a->flags != b->flags) | 1995 | if (a->flags != b->flags) |
1989 | goto Ebusy; | 1996 | goto Ebusy; |
1990 | if (a->wsize != b->wsize) | 1997 | if (a->wsize != b->wsize) |
1991 | goto Ebusy; | 1998 | goto Ebusy; |
1992 | if (a->rsize != b->rsize) | 1999 | if (a->rsize != b->rsize) |
1993 | goto Ebusy; | 2000 | goto Ebusy; |
1994 | if (a->acregmin != b->acregmin) | 2001 | if (a->acregmin != b->acregmin) |
1995 | goto Ebusy; | 2002 | goto Ebusy; |
1996 | if (a->acregmax != b->acregmax) | 2003 | if (a->acregmax != b->acregmax) |
1997 | goto Ebusy; | 2004 | goto Ebusy; |
1998 | if (a->acdirmin != b->acdirmin) | 2005 | if (a->acdirmin != b->acdirmin) |
1999 | goto Ebusy; | 2006 | goto Ebusy; |
2000 | if (a->acdirmax != b->acdirmax) | 2007 | if (a->acdirmax != b->acdirmax) |
2001 | goto Ebusy; | 2008 | goto Ebusy; |
2002 | if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) | 2009 | if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) |
2003 | goto Ebusy; | 2010 | goto Ebusy; |
2004 | return 1; | 2011 | return 1; |
2005 | Ebusy: | 2012 | Ebusy: |
2006 | return 0; | 2013 | return 0; |
2007 | } | 2014 | } |
2008 | 2015 | ||
2009 | struct nfs_sb_mountdata { | 2016 | struct nfs_sb_mountdata { |
2010 | struct nfs_server *server; | 2017 | struct nfs_server *server; |
2011 | int mntflags; | 2018 | int mntflags; |
2012 | }; | 2019 | }; |
2013 | 2020 | ||
2014 | static int nfs_set_super(struct super_block *s, void *data) | 2021 | static int nfs_set_super(struct super_block *s, void *data) |
2015 | { | 2022 | { |
2016 | struct nfs_sb_mountdata *sb_mntdata = data; | 2023 | struct nfs_sb_mountdata *sb_mntdata = data; |
2017 | struct nfs_server *server = sb_mntdata->server; | 2024 | struct nfs_server *server = sb_mntdata->server; |
2018 | int ret; | 2025 | int ret; |
2019 | 2026 | ||
2020 | s->s_flags = sb_mntdata->mntflags; | 2027 | s->s_flags = sb_mntdata->mntflags; |
2021 | s->s_fs_info = server; | 2028 | s->s_fs_info = server; |
2022 | ret = set_anon_super(s, server); | 2029 | ret = set_anon_super(s, server); |
2023 | if (ret == 0) | 2030 | if (ret == 0) |
2024 | server->s_dev = s->s_dev; | 2031 | server->s_dev = s->s_dev; |
2025 | return ret; | 2032 | return ret; |
2026 | } | 2033 | } |
2027 | 2034 | ||
2028 | static int nfs_compare_super_address(struct nfs_server *server1, | 2035 | static int nfs_compare_super_address(struct nfs_server *server1, |
2029 | struct nfs_server *server2) | 2036 | struct nfs_server *server2) |
2030 | { | 2037 | { |
2031 | struct sockaddr *sap1, *sap2; | 2038 | struct sockaddr *sap1, *sap2; |
2032 | 2039 | ||
2033 | sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr; | 2040 | sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr; |
2034 | sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr; | 2041 | sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr; |
2035 | 2042 | ||
2036 | if (sap1->sa_family != sap2->sa_family) | 2043 | if (sap1->sa_family != sap2->sa_family) |
2037 | return 0; | 2044 | return 0; |
2038 | 2045 | ||
2039 | switch (sap1->sa_family) { | 2046 | switch (sap1->sa_family) { |
2040 | case AF_INET: { | 2047 | case AF_INET: { |
2041 | struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1; | 2048 | struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1; |
2042 | struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2; | 2049 | struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2; |
2043 | if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) | 2050 | if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) |
2044 | return 0; | 2051 | return 0; |
2045 | if (sin1->sin_port != sin2->sin_port) | 2052 | if (sin1->sin_port != sin2->sin_port) |
2046 | return 0; | 2053 | return 0; |
2047 | break; | 2054 | break; |
2048 | } | 2055 | } |
2049 | case AF_INET6: { | 2056 | case AF_INET6: { |
2050 | struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1; | 2057 | struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1; |
2051 | struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2; | 2058 | struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2; |
2052 | if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr)) | 2059 | if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr)) |
2053 | return 0; | 2060 | return 0; |
2054 | if (sin1->sin6_port != sin2->sin6_port) | 2061 | if (sin1->sin6_port != sin2->sin6_port) |
2055 | return 0; | 2062 | return 0; |
2056 | break; | 2063 | break; |
2057 | } | 2064 | } |
2058 | default: | 2065 | default: |
2059 | return 0; | 2066 | return 0; |
2060 | } | 2067 | } |
2061 | 2068 | ||
2062 | return 1; | 2069 | return 1; |
2063 | } | 2070 | } |
2064 | 2071 | ||
2065 | static int nfs_compare_super(struct super_block *sb, void *data) | 2072 | static int nfs_compare_super(struct super_block *sb, void *data) |
2066 | { | 2073 | { |
2067 | struct nfs_sb_mountdata *sb_mntdata = data; | 2074 | struct nfs_sb_mountdata *sb_mntdata = data; |
2068 | struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb); | 2075 | struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb); |
2069 | int mntflags = sb_mntdata->mntflags; | 2076 | int mntflags = sb_mntdata->mntflags; |
2070 | 2077 | ||
2071 | if (!nfs_compare_super_address(old, server)) | 2078 | if (!nfs_compare_super_address(old, server)) |
2072 | return 0; | 2079 | return 0; |
2073 | /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */ | 2080 | /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */ |
2074 | if (old->flags & NFS_MOUNT_UNSHARED) | 2081 | if (old->flags & NFS_MOUNT_UNSHARED) |
2075 | return 0; | 2082 | return 0; |
2076 | if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0) | 2083 | if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0) |
2077 | return 0; | 2084 | return 0; |
2078 | return nfs_compare_mount_options(sb, server, mntflags); | 2085 | return nfs_compare_mount_options(sb, server, mntflags); |
2079 | } | 2086 | } |
2080 | 2087 | ||
2081 | static int nfs_bdi_register(struct nfs_server *server) | 2088 | static int nfs_bdi_register(struct nfs_server *server) |
2082 | { | 2089 | { |
2083 | return bdi_register_dev(&server->backing_dev_info, server->s_dev); | 2090 | return bdi_register_dev(&server->backing_dev_info, server->s_dev); |
2084 | } | 2091 | } |
2085 | 2092 | ||
2086 | static int nfs_get_sb(struct file_system_type *fs_type, | 2093 | static int nfs_get_sb(struct file_system_type *fs_type, |
2087 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | 2094 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) |
2088 | { | 2095 | { |
2089 | struct nfs_server *server = NULL; | 2096 | struct nfs_server *server = NULL; |
2090 | struct super_block *s; | 2097 | struct super_block *s; |
2091 | struct nfs_parsed_mount_data *data; | 2098 | struct nfs_parsed_mount_data *data; |
2092 | struct nfs_fh *mntfh; | 2099 | struct nfs_fh *mntfh; |
2093 | struct dentry *mntroot; | 2100 | struct dentry *mntroot; |
2094 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2101 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2095 | struct nfs_sb_mountdata sb_mntdata = { | 2102 | struct nfs_sb_mountdata sb_mntdata = { |
2096 | .mntflags = flags, | 2103 | .mntflags = flags, |
2097 | }; | 2104 | }; |
2098 | int error = -ENOMEM; | 2105 | int error = -ENOMEM; |
2099 | 2106 | ||
2100 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 2107 | data = nfs_alloc_parsed_mount_data(NFS_MOUNT_VER3 | NFS_MOUNT_TCP); |
2101 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); | 2108 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); |
2102 | if (data == NULL || mntfh == NULL) | 2109 | if (data == NULL || mntfh == NULL) |
2103 | goto out_free_fh; | 2110 | goto out_free_fh; |
2104 | 2111 | ||
2105 | security_init_mnt_opts(&data->lsm_opts); | 2112 | security_init_mnt_opts(&data->lsm_opts); |
2106 | 2113 | ||
2107 | /* Validate the mount data */ | 2114 | /* Validate the mount data */ |
2108 | error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name); | 2115 | error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name); |
2109 | if (error < 0) | 2116 | if (error < 0) |
2110 | goto out; | 2117 | goto out; |
2111 | 2118 | ||
2112 | #ifdef CONFIG_NFS_V4 | 2119 | #ifdef CONFIG_NFS_V4 |
2113 | if (data->version == 4) { | 2120 | if (data->version == 4) { |
2114 | error = nfs4_try_mount(flags, dev_name, data, mnt); | 2121 | error = nfs4_try_mount(flags, dev_name, data, mnt); |
2115 | kfree(data->client_address); | 2122 | kfree(data->client_address); |
2116 | goto out; | 2123 | goto out; |
2117 | } | 2124 | } |
2118 | #endif /* CONFIG_NFS_V4 */ | 2125 | #endif /* CONFIG_NFS_V4 */ |
2119 | 2126 | ||
2120 | /* Get a volume representation */ | 2127 | /* Get a volume representation */ |
2121 | server = nfs_create_server(data, mntfh); | 2128 | server = nfs_create_server(data, mntfh); |
2122 | if (IS_ERR(server)) { | 2129 | if (IS_ERR(server)) { |
2123 | error = PTR_ERR(server); | 2130 | error = PTR_ERR(server); |
2124 | goto out; | 2131 | goto out; |
2125 | } | 2132 | } |
2126 | sb_mntdata.server = server; | 2133 | sb_mntdata.server = server; |
2127 | 2134 | ||
2128 | if (server->flags & NFS_MOUNT_UNSHARED) | 2135 | if (server->flags & NFS_MOUNT_UNSHARED) |
2129 | compare_super = NULL; | 2136 | compare_super = NULL; |
2130 | 2137 | ||
2131 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2138 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2132 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2139 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2133 | if (IS_ERR(s)) { | 2140 | if (IS_ERR(s)) { |
2134 | error = PTR_ERR(s); | 2141 | error = PTR_ERR(s); |
2135 | goto out_err_nosb; | 2142 | goto out_err_nosb; |
2136 | } | 2143 | } |
2137 | 2144 | ||
2138 | if (s->s_fs_info != server) { | 2145 | if (s->s_fs_info != server) { |
2139 | nfs_free_server(server); | 2146 | nfs_free_server(server); |
2140 | server = NULL; | 2147 | server = NULL; |
2141 | } else { | 2148 | } else { |
2142 | error = nfs_bdi_register(server); | 2149 | error = nfs_bdi_register(server); |
2143 | if (error) | 2150 | if (error) |
2144 | goto error_splat_super; | 2151 | goto error_splat_super; |
2145 | } | 2152 | } |
2146 | 2153 | ||
2147 | if (!s->s_root) { | 2154 | if (!s->s_root) { |
2148 | /* initial superblock/root creation */ | 2155 | /* initial superblock/root creation */ |
2149 | nfs_fill_super(s, data); | 2156 | nfs_fill_super(s, data); |
2150 | nfs_fscache_get_super_cookie(s, data); | 2157 | nfs_fscache_get_super_cookie(s, data); |
2151 | } | 2158 | } |
2152 | 2159 | ||
2153 | mntroot = nfs_get_root(s, mntfh); | 2160 | mntroot = nfs_get_root(s, mntfh); |
2154 | if (IS_ERR(mntroot)) { | 2161 | if (IS_ERR(mntroot)) { |
2155 | error = PTR_ERR(mntroot); | 2162 | error = PTR_ERR(mntroot); |
2156 | goto error_splat_super; | 2163 | goto error_splat_super; |
2157 | } | 2164 | } |
2158 | 2165 | ||
2159 | error = security_sb_set_mnt_opts(s, &data->lsm_opts); | 2166 | error = security_sb_set_mnt_opts(s, &data->lsm_opts); |
2160 | if (error) | 2167 | if (error) |
2161 | goto error_splat_root; | 2168 | goto error_splat_root; |
2162 | 2169 | ||
2163 | s->s_flags |= MS_ACTIVE; | 2170 | s->s_flags |= MS_ACTIVE; |
2164 | mnt->mnt_sb = s; | 2171 | mnt->mnt_sb = s; |
2165 | mnt->mnt_root = mntroot; | 2172 | mnt->mnt_root = mntroot; |
2166 | error = 0; | 2173 | error = 0; |
2167 | 2174 | ||
2168 | out: | 2175 | out: |
2169 | kfree(data->nfs_server.hostname); | 2176 | kfree(data->nfs_server.hostname); |
2170 | kfree(data->mount_server.hostname); | 2177 | kfree(data->mount_server.hostname); |
2171 | kfree(data->fscache_uniq); | 2178 | kfree(data->fscache_uniq); |
2172 | security_free_mnt_opts(&data->lsm_opts); | 2179 | security_free_mnt_opts(&data->lsm_opts); |
2173 | out_free_fh: | 2180 | out_free_fh: |
2174 | kfree(mntfh); | 2181 | kfree(mntfh); |
2175 | kfree(data); | 2182 | kfree(data); |
2176 | return error; | 2183 | return error; |
2177 | 2184 | ||
2178 | out_err_nosb: | 2185 | out_err_nosb: |
2179 | nfs_free_server(server); | 2186 | nfs_free_server(server); |
2180 | goto out; | 2187 | goto out; |
2181 | 2188 | ||
2182 | error_splat_root: | 2189 | error_splat_root: |
2183 | dput(mntroot); | 2190 | dput(mntroot); |
2184 | error_splat_super: | 2191 | error_splat_super: |
2185 | deactivate_locked_super(s); | 2192 | deactivate_locked_super(s); |
2186 | goto out; | 2193 | goto out; |
2187 | } | 2194 | } |
2188 | 2195 | ||
2189 | /* | 2196 | /* |
2190 | * Destroy an NFS2/3 superblock | 2197 | * Destroy an NFS2/3 superblock |
2191 | */ | 2198 | */ |
2192 | static void nfs_kill_super(struct super_block *s) | 2199 | static void nfs_kill_super(struct super_block *s) |
2193 | { | 2200 | { |
2194 | struct nfs_server *server = NFS_SB(s); | 2201 | struct nfs_server *server = NFS_SB(s); |
2195 | 2202 | ||
2196 | kill_anon_super(s); | 2203 | kill_anon_super(s); |
2197 | bdi_unregister(&server->backing_dev_info); | 2204 | bdi_unregister(&server->backing_dev_info); |
2198 | nfs_fscache_release_super_cookie(s); | 2205 | nfs_fscache_release_super_cookie(s); |
2199 | nfs_free_server(server); | 2206 | nfs_free_server(server); |
2200 | } | 2207 | } |
2201 | 2208 | ||
2202 | /* | 2209 | /* |
2203 | * Clone an NFS2/3 server record on xdev traversal (FSID-change) | 2210 | * Clone an NFS2/3 server record on xdev traversal (FSID-change) |
2204 | */ | 2211 | */ |
2205 | static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, | 2212 | static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, |
2206 | const char *dev_name, void *raw_data, | 2213 | const char *dev_name, void *raw_data, |
2207 | struct vfsmount *mnt) | 2214 | struct vfsmount *mnt) |
2208 | { | 2215 | { |
2209 | struct nfs_clone_mount *data = raw_data; | 2216 | struct nfs_clone_mount *data = raw_data; |
2210 | struct super_block *s; | 2217 | struct super_block *s; |
2211 | struct nfs_server *server; | 2218 | struct nfs_server *server; |
2212 | struct dentry *mntroot; | 2219 | struct dentry *mntroot; |
2213 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2220 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2214 | struct nfs_sb_mountdata sb_mntdata = { | 2221 | struct nfs_sb_mountdata sb_mntdata = { |
2215 | .mntflags = flags, | 2222 | .mntflags = flags, |
2216 | }; | 2223 | }; |
2217 | int error; | 2224 | int error; |
2218 | 2225 | ||
2219 | dprintk("--> nfs_xdev_get_sb()\n"); | 2226 | dprintk("--> nfs_xdev_get_sb()\n"); |
2220 | 2227 | ||
2221 | /* create a new volume representation */ | 2228 | /* create a new volume representation */ |
2222 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr); | 2229 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr); |
2223 | if (IS_ERR(server)) { | 2230 | if (IS_ERR(server)) { |
2224 | error = PTR_ERR(server); | 2231 | error = PTR_ERR(server); |
2225 | goto out_err_noserver; | 2232 | goto out_err_noserver; |
2226 | } | 2233 | } |
2227 | sb_mntdata.server = server; | 2234 | sb_mntdata.server = server; |
2228 | 2235 | ||
2229 | if (server->flags & NFS_MOUNT_UNSHARED) | 2236 | if (server->flags & NFS_MOUNT_UNSHARED) |
2230 | compare_super = NULL; | 2237 | compare_super = NULL; |
2231 | 2238 | ||
2232 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2239 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2233 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2240 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2234 | if (IS_ERR(s)) { | 2241 | if (IS_ERR(s)) { |
2235 | error = PTR_ERR(s); | 2242 | error = PTR_ERR(s); |
2236 | goto out_err_nosb; | 2243 | goto out_err_nosb; |
2237 | } | 2244 | } |
2238 | 2245 | ||
2239 | if (s->s_fs_info != server) { | 2246 | if (s->s_fs_info != server) { |
2240 | nfs_free_server(server); | 2247 | nfs_free_server(server); |
2241 | server = NULL; | 2248 | server = NULL; |
2242 | } else { | 2249 | } else { |
2243 | error = nfs_bdi_register(server); | 2250 | error = nfs_bdi_register(server); |
2244 | if (error) | 2251 | if (error) |
2245 | goto error_splat_super; | 2252 | goto error_splat_super; |
2246 | } | 2253 | } |
2247 | 2254 | ||
2248 | if (!s->s_root) { | 2255 | if (!s->s_root) { |
2249 | /* initial superblock/root creation */ | 2256 | /* initial superblock/root creation */ |
2250 | nfs_clone_super(s, data->sb); | 2257 | nfs_clone_super(s, data->sb); |
2251 | } | 2258 | } |
2252 | 2259 | ||
2253 | mntroot = nfs_get_root(s, data->fh); | 2260 | mntroot = nfs_get_root(s, data->fh); |
2254 | if (IS_ERR(mntroot)) { | 2261 | if (IS_ERR(mntroot)) { |
2255 | error = PTR_ERR(mntroot); | 2262 | error = PTR_ERR(mntroot); |
2256 | goto error_splat_super; | 2263 | goto error_splat_super; |
2257 | } | 2264 | } |
2258 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { | 2265 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { |
2259 | dput(mntroot); | 2266 | dput(mntroot); |
2260 | error = -ESTALE; | 2267 | error = -ESTALE; |
2261 | goto error_splat_super; | 2268 | goto error_splat_super; |
2262 | } | 2269 | } |
2263 | 2270 | ||
2264 | s->s_flags |= MS_ACTIVE; | 2271 | s->s_flags |= MS_ACTIVE; |
2265 | mnt->mnt_sb = s; | 2272 | mnt->mnt_sb = s; |
2266 | mnt->mnt_root = mntroot; | 2273 | mnt->mnt_root = mntroot; |
2267 | 2274 | ||
2268 | /* clone any lsm security options from the parent to the new sb */ | 2275 | /* clone any lsm security options from the parent to the new sb */ |
2269 | security_sb_clone_mnt_opts(data->sb, s); | 2276 | security_sb_clone_mnt_opts(data->sb, s); |
2270 | 2277 | ||
2271 | dprintk("<-- nfs_xdev_get_sb() = 0\n"); | 2278 | dprintk("<-- nfs_xdev_get_sb() = 0\n"); |
2272 | return 0; | 2279 | return 0; |
2273 | 2280 | ||
2274 | out_err_nosb: | 2281 | out_err_nosb: |
2275 | nfs_free_server(server); | 2282 | nfs_free_server(server); |
2276 | out_err_noserver: | 2283 | out_err_noserver: |
2277 | dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error); | 2284 | dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error); |
2278 | return error; | 2285 | return error; |
2279 | 2286 | ||
2280 | error_splat_super: | 2287 | error_splat_super: |
2281 | deactivate_locked_super(s); | 2288 | deactivate_locked_super(s); |
2282 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); | 2289 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); |
2283 | return error; | 2290 | return error; |
2284 | } | 2291 | } |
2285 | 2292 | ||
2286 | #ifdef CONFIG_NFS_V4 | 2293 | #ifdef CONFIG_NFS_V4 |
2287 | 2294 | ||
2288 | /* | 2295 | /* |
2289 | * Finish setting up a cloned NFS4 superblock | 2296 | * Finish setting up a cloned NFS4 superblock |
2290 | */ | 2297 | */ |
2291 | static void nfs4_clone_super(struct super_block *sb, | 2298 | static void nfs4_clone_super(struct super_block *sb, |
2292 | const struct super_block *old_sb) | 2299 | const struct super_block *old_sb) |
2293 | { | 2300 | { |
2294 | sb->s_blocksize_bits = old_sb->s_blocksize_bits; | 2301 | sb->s_blocksize_bits = old_sb->s_blocksize_bits; |
2295 | sb->s_blocksize = old_sb->s_blocksize; | 2302 | sb->s_blocksize = old_sb->s_blocksize; |
2296 | sb->s_maxbytes = old_sb->s_maxbytes; | 2303 | sb->s_maxbytes = old_sb->s_maxbytes; |
2297 | sb->s_time_gran = 1; | 2304 | sb->s_time_gran = 1; |
2298 | sb->s_op = old_sb->s_op; | 2305 | sb->s_op = old_sb->s_op; |
2299 | nfs_initialise_sb(sb); | 2306 | nfs_initialise_sb(sb); |
2300 | } | 2307 | } |
2301 | 2308 | ||
2302 | /* | 2309 | /* |
2303 | * Set up an NFS4 superblock | 2310 | * Set up an NFS4 superblock |
2304 | */ | 2311 | */ |
2305 | static void nfs4_fill_super(struct super_block *sb) | 2312 | static void nfs4_fill_super(struct super_block *sb) |
2306 | { | 2313 | { |
2307 | sb->s_time_gran = 1; | 2314 | sb->s_time_gran = 1; |
2308 | sb->s_op = &nfs4_sops; | 2315 | sb->s_op = &nfs4_sops; |
2309 | nfs_initialise_sb(sb); | 2316 | nfs_initialise_sb(sb); |
2310 | } | 2317 | } |
2311 | 2318 | ||
2312 | static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args) | 2319 | static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args) |
2313 | { | 2320 | { |
2314 | args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3); | 2321 | args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3); |
2315 | } | 2322 | } |
2316 | 2323 | ||
2317 | static int nfs4_validate_text_mount_data(void *options, | 2324 | static int nfs4_validate_text_mount_data(void *options, |
2318 | struct nfs_parsed_mount_data *args, | 2325 | struct nfs_parsed_mount_data *args, |
2319 | const char *dev_name) | 2326 | const char *dev_name) |
2320 | { | 2327 | { |
2321 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; | 2328 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; |
2322 | 2329 | ||
2323 | nfs_set_default_port(sap, args->nfs_server.port, NFS_PORT); | 2330 | nfs_set_default_port(sap, args->nfs_server.port, NFS_PORT); |
2324 | 2331 | ||
2325 | nfs_validate_transport_protocol(args); | 2332 | nfs_validate_transport_protocol(args); |
2326 | 2333 | ||
2327 | nfs4_validate_mount_flags(args); | 2334 | nfs4_validate_mount_flags(args); |
2328 | 2335 | ||
2329 | if (args->version != 4) { | 2336 | if (args->version != 4) { |
2330 | dfprintk(MOUNT, | 2337 | dfprintk(MOUNT, |
2331 | "NFS4: Illegal mount version\n"); | 2338 | "NFS4: Illegal mount version\n"); |
2332 | return -EINVAL; | 2339 | return -EINVAL; |
2333 | } | 2340 | } |
2334 | 2341 | ||
2335 | if (args->auth_flavor_len > 1) { | 2342 | if (args->auth_flavor_len > 1) { |
2336 | dfprintk(MOUNT, | 2343 | dfprintk(MOUNT, |
2337 | "NFS4: Too many RPC auth flavours specified\n"); | 2344 | "NFS4: Too many RPC auth flavours specified\n"); |
2338 | return -EINVAL; | 2345 | return -EINVAL; |
2339 | } | 2346 | } |
2340 | 2347 | ||
2341 | if (args->client_address == NULL) { | 2348 | if (args->client_address == NULL) { |
2342 | dfprintk(MOUNT, | 2349 | dfprintk(MOUNT, |
2343 | "NFS4: mount program didn't pass callback address\n"); | 2350 | "NFS4: mount program didn't pass callback address\n"); |
2344 | return -EINVAL; | 2351 | return -EINVAL; |
2345 | } | 2352 | } |
2346 | 2353 | ||
2347 | return nfs_parse_devname(dev_name, | 2354 | return nfs_parse_devname(dev_name, |
2348 | &args->nfs_server.hostname, | 2355 | &args->nfs_server.hostname, |
2349 | NFS4_MAXNAMLEN, | 2356 | NFS4_MAXNAMLEN, |
2350 | &args->nfs_server.export_path, | 2357 | &args->nfs_server.export_path, |
2351 | NFS4_MAXPATHLEN); | 2358 | NFS4_MAXPATHLEN); |
2352 | } | 2359 | } |
2353 | 2360 | ||
2354 | /* | 2361 | /* |
2355 | * Validate NFSv4 mount options | 2362 | * Validate NFSv4 mount options |
2356 | */ | 2363 | */ |
2357 | static int nfs4_validate_mount_data(void *options, | 2364 | static int nfs4_validate_mount_data(void *options, |
2358 | struct nfs_parsed_mount_data *args, | 2365 | struct nfs_parsed_mount_data *args, |
2359 | const char *dev_name) | 2366 | const char *dev_name) |
2360 | { | 2367 | { |
2361 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; | 2368 | struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; |
2362 | struct nfs4_mount_data *data = (struct nfs4_mount_data *)options; | 2369 | struct nfs4_mount_data *data = (struct nfs4_mount_data *)options; |
2363 | char *c; | 2370 | char *c; |
2364 | 2371 | ||
2365 | if (data == NULL) | 2372 | if (data == NULL) |
2366 | goto out_no_data; | 2373 | goto out_no_data; |
2367 | 2374 | ||
2368 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
2369 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
2370 | args->acregmin = NFS_DEF_ACREGMIN; | ||
2371 | args->acregmax = NFS_DEF_ACREGMAX; | ||
2372 | args->acdirmin = NFS_DEF_ACDIRMIN; | ||
2373 | args->acdirmax = NFS_DEF_ACDIRMAX; | ||
2374 | args->nfs_server.port = NFS_UNSPEC_PORT; | ||
2375 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
2376 | args->auth_flavor_len = 1; | ||
2377 | args->version = 4; | 2375 | args->version = 4; |
2378 | args->minorversion = 0; | ||
2379 | |||
2380 | switch (data->version) { | 2376 | switch (data->version) { |
2381 | case 1: | 2377 | case 1: |
2382 | if (data->host_addrlen > sizeof(args->nfs_server.address)) | 2378 | if (data->host_addrlen > sizeof(args->nfs_server.address)) |
2383 | goto out_no_address; | 2379 | goto out_no_address; |
2384 | if (data->host_addrlen == 0) | 2380 | if (data->host_addrlen == 0) |
2385 | goto out_no_address; | 2381 | goto out_no_address; |
2386 | args->nfs_server.addrlen = data->host_addrlen; | 2382 | args->nfs_server.addrlen = data->host_addrlen; |
2387 | if (copy_from_user(sap, data->host_addr, data->host_addrlen)) | 2383 | if (copy_from_user(sap, data->host_addr, data->host_addrlen)) |
2388 | return -EFAULT; | 2384 | return -EFAULT; |
2389 | if (!nfs_verify_server_address(sap)) | 2385 | if (!nfs_verify_server_address(sap)) |
2390 | goto out_no_address; | 2386 | goto out_no_address; |
2391 | 2387 | ||
2392 | if (data->auth_flavourlen) { | 2388 | if (data->auth_flavourlen) { |
2393 | if (data->auth_flavourlen > 1) | 2389 | if (data->auth_flavourlen > 1) |
2394 | goto out_inval_auth; | 2390 | goto out_inval_auth; |
2395 | if (copy_from_user(&args->auth_flavors[0], | 2391 | if (copy_from_user(&args->auth_flavors[0], |
2396 | data->auth_flavours, | 2392 | data->auth_flavours, |
2397 | sizeof(args->auth_flavors[0]))) | 2393 | sizeof(args->auth_flavors[0]))) |
2398 | return -EFAULT; | 2394 | return -EFAULT; |
2399 | } | 2395 | } |
2400 | 2396 | ||
2401 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); | 2397 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); |
2402 | if (IS_ERR(c)) | 2398 | if (IS_ERR(c)) |
2403 | return PTR_ERR(c); | 2399 | return PTR_ERR(c); |
2404 | args->nfs_server.hostname = c; | 2400 | args->nfs_server.hostname = c; |
2405 | 2401 | ||
2406 | c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); | 2402 | c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); |
2407 | if (IS_ERR(c)) | 2403 | if (IS_ERR(c)) |
2408 | return PTR_ERR(c); | 2404 | return PTR_ERR(c); |
2409 | args->nfs_server.export_path = c; | 2405 | args->nfs_server.export_path = c; |
2410 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); | 2406 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); |
2411 | 2407 | ||
2412 | c = strndup_user(data->client_addr.data, 16); | 2408 | c = strndup_user(data->client_addr.data, 16); |
2413 | if (IS_ERR(c)) | 2409 | if (IS_ERR(c)) |
2414 | return PTR_ERR(c); | 2410 | return PTR_ERR(c); |
2415 | args->client_address = c; | 2411 | args->client_address = c; |
2416 | 2412 | ||
2417 | /* | 2413 | /* |
2418 | * Translate to nfs_parsed_mount_data, which nfs4_fill_super | 2414 | * Translate to nfs_parsed_mount_data, which nfs4_fill_super |
2419 | * can deal with. | 2415 | * can deal with. |
2420 | */ | 2416 | */ |
2421 | 2417 | ||
2422 | args->flags = data->flags & NFS4_MOUNT_FLAGMASK; | 2418 | args->flags = data->flags & NFS4_MOUNT_FLAGMASK; |
2423 | args->rsize = data->rsize; | 2419 | args->rsize = data->rsize; |
2424 | args->wsize = data->wsize; | 2420 | args->wsize = data->wsize; |
2425 | args->timeo = data->timeo; | 2421 | args->timeo = data->timeo; |
2426 | args->retrans = data->retrans; | 2422 | args->retrans = data->retrans; |
2427 | args->acregmin = data->acregmin; | 2423 | args->acregmin = data->acregmin; |
2428 | args->acregmax = data->acregmax; | 2424 | args->acregmax = data->acregmax; |
2429 | args->acdirmin = data->acdirmin; | 2425 | args->acdirmin = data->acdirmin; |
2430 | args->acdirmax = data->acdirmax; | 2426 | args->acdirmax = data->acdirmax; |
2431 | args->nfs_server.protocol = data->proto; | 2427 | args->nfs_server.protocol = data->proto; |
2432 | nfs_validate_transport_protocol(args); | 2428 | nfs_validate_transport_protocol(args); |
2433 | 2429 | ||
2434 | break; | 2430 | break; |
2435 | default: | 2431 | default: |
2436 | if (nfs_parse_mount_options((char *)options, args) == 0) | 2432 | if (nfs_parse_mount_options((char *)options, args) == 0) |
2437 | return -EINVAL; | 2433 | return -EINVAL; |
2438 | 2434 | ||
2439 | if (!nfs_verify_server_address(sap)) | 2435 | if (!nfs_verify_server_address(sap)) |
2440 | return -EINVAL; | 2436 | return -EINVAL; |
2441 | 2437 | ||
2442 | return nfs4_validate_text_mount_data(options, args, dev_name); | 2438 | return nfs4_validate_text_mount_data(options, args, dev_name); |
2443 | } | 2439 | } |
2444 | 2440 | ||
2445 | return 0; | 2441 | return 0; |
2446 | 2442 | ||
2447 | out_no_data: | 2443 | out_no_data: |
2448 | dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n"); | 2444 | dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n"); |
2449 | return -EINVAL; | 2445 | return -EINVAL; |
2450 | 2446 | ||
2451 | out_inval_auth: | 2447 | out_inval_auth: |
2452 | dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n", | 2448 | dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n", |
2453 | data->auth_flavourlen); | 2449 | data->auth_flavourlen); |
2454 | return -EINVAL; | 2450 | return -EINVAL; |
2455 | 2451 | ||
2456 | out_no_address: | 2452 | out_no_address: |
2457 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); | 2453 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); |
2458 | return -EINVAL; | 2454 | return -EINVAL; |
2459 | } | 2455 | } |
2460 | 2456 | ||
2461 | /* | 2457 | /* |
2462 | * Get the superblock for the NFS4 root partition | 2458 | * Get the superblock for the NFS4 root partition |
2463 | */ | 2459 | */ |
2464 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, | 2460 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, |
2465 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | 2461 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) |
2466 | { | 2462 | { |
2467 | struct nfs_parsed_mount_data *data = raw_data; | 2463 | struct nfs_parsed_mount_data *data = raw_data; |
2468 | struct super_block *s; | 2464 | struct super_block *s; |
2469 | struct nfs_server *server; | 2465 | struct nfs_server *server; |
2470 | struct nfs_fh *mntfh; | 2466 | struct nfs_fh *mntfh; |
2471 | struct dentry *mntroot; | 2467 | struct dentry *mntroot; |
2472 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2468 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2473 | struct nfs_sb_mountdata sb_mntdata = { | 2469 | struct nfs_sb_mountdata sb_mntdata = { |
2474 | .mntflags = flags, | 2470 | .mntflags = flags, |
2475 | }; | 2471 | }; |
2476 | int error = -ENOMEM; | 2472 | int error = -ENOMEM; |
2477 | 2473 | ||
2478 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); | 2474 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); |
2479 | if (data == NULL || mntfh == NULL) | 2475 | if (data == NULL || mntfh == NULL) |
2480 | goto out_free_fh; | 2476 | goto out_free_fh; |
2481 | 2477 | ||
2482 | security_init_mnt_opts(&data->lsm_opts); | 2478 | security_init_mnt_opts(&data->lsm_opts); |
2483 | 2479 | ||
2484 | /* Get a volume representation */ | 2480 | /* Get a volume representation */ |
2485 | server = nfs4_create_server(data, mntfh); | 2481 | server = nfs4_create_server(data, mntfh); |
2486 | if (IS_ERR(server)) { | 2482 | if (IS_ERR(server)) { |
2487 | error = PTR_ERR(server); | 2483 | error = PTR_ERR(server); |
2488 | goto out; | 2484 | goto out; |
2489 | } | 2485 | } |
2490 | sb_mntdata.server = server; | 2486 | sb_mntdata.server = server; |
2491 | 2487 | ||
2492 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2488 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2493 | compare_super = NULL; | 2489 | compare_super = NULL; |
2494 | 2490 | ||
2495 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2491 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2496 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2492 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2497 | if (IS_ERR(s)) { | 2493 | if (IS_ERR(s)) { |
2498 | error = PTR_ERR(s); | 2494 | error = PTR_ERR(s); |
2499 | goto out_free; | 2495 | goto out_free; |
2500 | } | 2496 | } |
2501 | 2497 | ||
2502 | if (s->s_fs_info != server) { | 2498 | if (s->s_fs_info != server) { |
2503 | nfs_free_server(server); | 2499 | nfs_free_server(server); |
2504 | server = NULL; | 2500 | server = NULL; |
2505 | } else { | 2501 | } else { |
2506 | error = nfs_bdi_register(server); | 2502 | error = nfs_bdi_register(server); |
2507 | if (error) | 2503 | if (error) |
2508 | goto error_splat_super; | 2504 | goto error_splat_super; |
2509 | } | 2505 | } |
2510 | 2506 | ||
2511 | if (!s->s_root) { | 2507 | if (!s->s_root) { |
2512 | /* initial superblock/root creation */ | 2508 | /* initial superblock/root creation */ |
2513 | nfs4_fill_super(s); | 2509 | nfs4_fill_super(s); |
2514 | nfs_fscache_get_super_cookie(s, data); | 2510 | nfs_fscache_get_super_cookie(s, data); |
2515 | } | 2511 | } |
2516 | 2512 | ||
2517 | mntroot = nfs4_get_root(s, mntfh); | 2513 | mntroot = nfs4_get_root(s, mntfh); |
2518 | if (IS_ERR(mntroot)) { | 2514 | if (IS_ERR(mntroot)) { |
2519 | error = PTR_ERR(mntroot); | 2515 | error = PTR_ERR(mntroot); |
2520 | goto error_splat_super; | 2516 | goto error_splat_super; |
2521 | } | 2517 | } |
2522 | 2518 | ||
2523 | error = security_sb_set_mnt_opts(s, &data->lsm_opts); | 2519 | error = security_sb_set_mnt_opts(s, &data->lsm_opts); |
2524 | if (error) | 2520 | if (error) |
2525 | goto error_splat_root; | 2521 | goto error_splat_root; |
2526 | 2522 | ||
2527 | s->s_flags |= MS_ACTIVE; | 2523 | s->s_flags |= MS_ACTIVE; |
2528 | mnt->mnt_sb = s; | 2524 | mnt->mnt_sb = s; |
2529 | mnt->mnt_root = mntroot; | 2525 | mnt->mnt_root = mntroot; |
2530 | error = 0; | 2526 | error = 0; |
2531 | 2527 | ||
2532 | out: | 2528 | out: |
2533 | security_free_mnt_opts(&data->lsm_opts); | 2529 | security_free_mnt_opts(&data->lsm_opts); |
2534 | out_free_fh: | 2530 | out_free_fh: |
2535 | kfree(mntfh); | 2531 | kfree(mntfh); |
2536 | return error; | 2532 | return error; |
2537 | 2533 | ||
2538 | out_free: | 2534 | out_free: |
2539 | nfs_free_server(server); | 2535 | nfs_free_server(server); |
2540 | goto out; | 2536 | goto out; |
2541 | 2537 | ||
2542 | error_splat_root: | 2538 | error_splat_root: |
2543 | dput(mntroot); | 2539 | dput(mntroot); |
2544 | error_splat_super: | 2540 | error_splat_super: |
2545 | deactivate_locked_super(s); | 2541 | deactivate_locked_super(s); |
2546 | goto out; | 2542 | goto out; |
2547 | } | 2543 | } |
2548 | 2544 | ||
2549 | static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type, | 2545 | static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type, |
2550 | int flags, void *data, const char *hostname) | 2546 | int flags, void *data, const char *hostname) |
2551 | { | 2547 | { |
2552 | struct vfsmount *root_mnt; | 2548 | struct vfsmount *root_mnt; |
2553 | char *root_devname; | 2549 | char *root_devname; |
2554 | size_t len; | 2550 | size_t len; |
2555 | 2551 | ||
2556 | len = strlen(hostname) + 3; | 2552 | len = strlen(hostname) + 3; |
2557 | root_devname = kmalloc(len, GFP_KERNEL); | 2553 | root_devname = kmalloc(len, GFP_KERNEL); |
2558 | if (root_devname == NULL) | 2554 | if (root_devname == NULL) |
2559 | return ERR_PTR(-ENOMEM); | 2555 | return ERR_PTR(-ENOMEM); |
2560 | snprintf(root_devname, len, "%s:/", hostname); | 2556 | snprintf(root_devname, len, "%s:/", hostname); |
2561 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); | 2557 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); |
2562 | kfree(root_devname); | 2558 | kfree(root_devname); |
2563 | return root_mnt; | 2559 | return root_mnt; |
2564 | } | 2560 | } |
2565 | 2561 | ||
2566 | static void nfs_fix_devname(const struct path *path, struct vfsmount *mnt) | 2562 | static void nfs_fix_devname(const struct path *path, struct vfsmount *mnt) |
2567 | { | 2563 | { |
2568 | char *page = (char *) __get_free_page(GFP_KERNEL); | 2564 | char *page = (char *) __get_free_page(GFP_KERNEL); |
2569 | char *devname, *tmp; | 2565 | char *devname, *tmp; |
2570 | 2566 | ||
2571 | if (page == NULL) | 2567 | if (page == NULL) |
2572 | return; | 2568 | return; |
2573 | devname = nfs_path(path->mnt->mnt_devname, | 2569 | devname = nfs_path(path->mnt->mnt_devname, |
2574 | path->mnt->mnt_root, path->dentry, | 2570 | path->mnt->mnt_root, path->dentry, |
2575 | page, PAGE_SIZE); | 2571 | page, PAGE_SIZE); |
2576 | if (devname == NULL) | 2572 | if (devname == NULL) |
2577 | goto out_freepage; | 2573 | goto out_freepage; |
2578 | tmp = kstrdup(devname, GFP_KERNEL); | 2574 | tmp = kstrdup(devname, GFP_KERNEL); |
2579 | if (tmp == NULL) | 2575 | if (tmp == NULL) |
2580 | goto out_freepage; | 2576 | goto out_freepage; |
2581 | kfree(mnt->mnt_devname); | 2577 | kfree(mnt->mnt_devname); |
2582 | mnt->mnt_devname = tmp; | 2578 | mnt->mnt_devname = tmp; |
2583 | out_freepage: | 2579 | out_freepage: |
2584 | free_page((unsigned long)page); | 2580 | free_page((unsigned long)page); |
2585 | } | 2581 | } |
2586 | 2582 | ||
2587 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, | 2583 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, |
2588 | const char *export_path, struct vfsmount *mnt_target) | 2584 | const char *export_path, struct vfsmount *mnt_target) |
2589 | { | 2585 | { |
2590 | struct mnt_namespace *ns_private; | 2586 | struct mnt_namespace *ns_private; |
2591 | struct nameidata nd; | 2587 | struct nameidata nd; |
2592 | struct super_block *s; | 2588 | struct super_block *s; |
2593 | int ret; | 2589 | int ret; |
2594 | 2590 | ||
2595 | ns_private = create_mnt_ns(root_mnt); | 2591 | ns_private = create_mnt_ns(root_mnt); |
2596 | ret = PTR_ERR(ns_private); | 2592 | ret = PTR_ERR(ns_private); |
2597 | if (IS_ERR(ns_private)) | 2593 | if (IS_ERR(ns_private)) |
2598 | goto out_mntput; | 2594 | goto out_mntput; |
2599 | 2595 | ||
2600 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, | 2596 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, |
2601 | export_path, LOOKUP_FOLLOW, &nd); | 2597 | export_path, LOOKUP_FOLLOW, &nd); |
2602 | 2598 | ||
2603 | put_mnt_ns(ns_private); | 2599 | put_mnt_ns(ns_private); |
2604 | 2600 | ||
2605 | if (ret != 0) | 2601 | if (ret != 0) |
2606 | goto out_err; | 2602 | goto out_err; |
2607 | 2603 | ||
2608 | s = nd.path.mnt->mnt_sb; | 2604 | s = nd.path.mnt->mnt_sb; |
2609 | atomic_inc(&s->s_active); | 2605 | atomic_inc(&s->s_active); |
2610 | mnt_target->mnt_sb = s; | 2606 | mnt_target->mnt_sb = s; |
2611 | mnt_target->mnt_root = dget(nd.path.dentry); | 2607 | mnt_target->mnt_root = dget(nd.path.dentry); |
2612 | 2608 | ||
2613 | /* Correct the device pathname */ | 2609 | /* Correct the device pathname */ |
2614 | nfs_fix_devname(&nd.path, mnt_target); | 2610 | nfs_fix_devname(&nd.path, mnt_target); |
2615 | 2611 | ||
2616 | path_put(&nd.path); | 2612 | path_put(&nd.path); |
2617 | down_write(&s->s_umount); | 2613 | down_write(&s->s_umount); |
2618 | return 0; | 2614 | return 0; |
2619 | out_mntput: | 2615 | out_mntput: |
2620 | mntput(root_mnt); | 2616 | mntput(root_mnt); |
2621 | out_err: | 2617 | out_err: |
2622 | return ret; | 2618 | return ret; |
2623 | } | 2619 | } |
2624 | 2620 | ||
2625 | static int nfs4_try_mount(int flags, const char *dev_name, | 2621 | static int nfs4_try_mount(int flags, const char *dev_name, |
2626 | struct nfs_parsed_mount_data *data, | 2622 | struct nfs_parsed_mount_data *data, |
2627 | struct vfsmount *mnt) | 2623 | struct vfsmount *mnt) |
2628 | { | 2624 | { |
2629 | char *export_path; | 2625 | char *export_path; |
2630 | struct vfsmount *root_mnt; | 2626 | struct vfsmount *root_mnt; |
2631 | int error; | 2627 | int error; |
2632 | 2628 | ||
2633 | dfprintk(MOUNT, "--> nfs4_try_mount()\n"); | 2629 | dfprintk(MOUNT, "--> nfs4_try_mount()\n"); |
2634 | 2630 | ||
2635 | export_path = data->nfs_server.export_path; | 2631 | export_path = data->nfs_server.export_path; |
2636 | data->nfs_server.export_path = "/"; | 2632 | data->nfs_server.export_path = "/"; |
2637 | root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, data, | 2633 | root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, data, |
2638 | data->nfs_server.hostname); | 2634 | data->nfs_server.hostname); |
2639 | data->nfs_server.export_path = export_path; | 2635 | data->nfs_server.export_path = export_path; |
2640 | 2636 | ||
2641 | error = PTR_ERR(root_mnt); | 2637 | error = PTR_ERR(root_mnt); |
2642 | if (IS_ERR(root_mnt)) | 2638 | if (IS_ERR(root_mnt)) |
2643 | goto out; | 2639 | goto out; |
2644 | 2640 | ||
2645 | error = nfs_follow_remote_path(root_mnt, export_path, mnt); | 2641 | error = nfs_follow_remote_path(root_mnt, export_path, mnt); |
2646 | 2642 | ||
2647 | out: | 2643 | out: |
2648 | dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n", error, | 2644 | dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n", error, |
2649 | error != 0 ? " [error]" : ""); | 2645 | error != 0 ? " [error]" : ""); |
2650 | return error; | 2646 | return error; |
2651 | } | 2647 | } |
2652 | 2648 | ||
2653 | /* | 2649 | /* |
2654 | * Get the superblock for an NFS4 mountpoint | 2650 | * Get the superblock for an NFS4 mountpoint |
2655 | */ | 2651 | */ |
2656 | static int nfs4_get_sb(struct file_system_type *fs_type, | 2652 | static int nfs4_get_sb(struct file_system_type *fs_type, |
2657 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | 2653 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) |
2658 | { | 2654 | { |
2659 | struct nfs_parsed_mount_data *data; | 2655 | struct nfs_parsed_mount_data *data; |
2660 | int error = -ENOMEM; | 2656 | int error = -ENOMEM; |
2661 | 2657 | ||
2662 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 2658 | data = nfs_alloc_parsed_mount_data(0); |
2663 | if (data == NULL) | 2659 | if (data == NULL) |
2664 | goto out_free_data; | 2660 | goto out_free_data; |
2665 | 2661 | ||
2666 | /* Validate the mount data */ | 2662 | /* Validate the mount data */ |
2667 | error = nfs4_validate_mount_data(raw_data, data, dev_name); | 2663 | error = nfs4_validate_mount_data(raw_data, data, dev_name); |
2668 | if (error < 0) | 2664 | if (error < 0) |
2669 | goto out; | 2665 | goto out; |
2670 | 2666 | ||
2671 | error = nfs4_try_mount(flags, dev_name, data, mnt); | 2667 | error = nfs4_try_mount(flags, dev_name, data, mnt); |
2672 | 2668 | ||
2673 | out: | 2669 | out: |
2674 | kfree(data->client_address); | 2670 | kfree(data->client_address); |
2675 | kfree(data->nfs_server.export_path); | 2671 | kfree(data->nfs_server.export_path); |
2676 | kfree(data->nfs_server.hostname); | 2672 | kfree(data->nfs_server.hostname); |
2677 | kfree(data->fscache_uniq); | 2673 | kfree(data->fscache_uniq); |
2678 | out_free_data: | 2674 | out_free_data: |
2679 | kfree(data); | 2675 | kfree(data); |
2680 | dprintk("<-- nfs4_get_sb() = %d%s\n", error, | 2676 | dprintk("<-- nfs4_get_sb() = %d%s\n", error, |
2681 | error != 0 ? " [error]" : ""); | 2677 | error != 0 ? " [error]" : ""); |
2682 | return error; | 2678 | return error; |
2683 | } | 2679 | } |
2684 | 2680 | ||
2685 | static void nfs4_kill_super(struct super_block *sb) | 2681 | static void nfs4_kill_super(struct super_block *sb) |
2686 | { | 2682 | { |
2687 | struct nfs_server *server = NFS_SB(sb); | 2683 | struct nfs_server *server = NFS_SB(sb); |
2688 | 2684 | ||
2689 | dprintk("--> %s\n", __func__); | 2685 | dprintk("--> %s\n", __func__); |
2690 | nfs_super_return_all_delegations(sb); | 2686 | nfs_super_return_all_delegations(sb); |
2691 | kill_anon_super(sb); | 2687 | kill_anon_super(sb); |
2692 | nfs4_renewd_prepare_shutdown(server); | 2688 | nfs4_renewd_prepare_shutdown(server); |
2693 | nfs_fscache_release_super_cookie(sb); | 2689 | nfs_fscache_release_super_cookie(sb); |
2694 | nfs_free_server(server); | 2690 | nfs_free_server(server); |
2695 | dprintk("<-- %s\n", __func__); | 2691 | dprintk("<-- %s\n", __func__); |
2696 | } | 2692 | } |
2697 | 2693 | ||
2698 | /* | 2694 | /* |
2699 | * Clone an NFS4 server record on xdev traversal (FSID-change) | 2695 | * Clone an NFS4 server record on xdev traversal (FSID-change) |
2700 | */ | 2696 | */ |
2701 | static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, | 2697 | static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, |
2702 | const char *dev_name, void *raw_data, | 2698 | const char *dev_name, void *raw_data, |
2703 | struct vfsmount *mnt) | 2699 | struct vfsmount *mnt) |
2704 | { | 2700 | { |
2705 | struct nfs_clone_mount *data = raw_data; | 2701 | struct nfs_clone_mount *data = raw_data; |
2706 | struct super_block *s; | 2702 | struct super_block *s; |
2707 | struct nfs_server *server; | 2703 | struct nfs_server *server; |
2708 | struct dentry *mntroot; | 2704 | struct dentry *mntroot; |
2709 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2705 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2710 | struct nfs_sb_mountdata sb_mntdata = { | 2706 | struct nfs_sb_mountdata sb_mntdata = { |
2711 | .mntflags = flags, | 2707 | .mntflags = flags, |
2712 | }; | 2708 | }; |
2713 | int error; | 2709 | int error; |
2714 | 2710 | ||
2715 | dprintk("--> nfs4_xdev_get_sb()\n"); | 2711 | dprintk("--> nfs4_xdev_get_sb()\n"); |
2716 | 2712 | ||
2717 | /* create a new volume representation */ | 2713 | /* create a new volume representation */ |
2718 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr); | 2714 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr); |
2719 | if (IS_ERR(server)) { | 2715 | if (IS_ERR(server)) { |
2720 | error = PTR_ERR(server); | 2716 | error = PTR_ERR(server); |
2721 | goto out_err_noserver; | 2717 | goto out_err_noserver; |
2722 | } | 2718 | } |
2723 | sb_mntdata.server = server; | 2719 | sb_mntdata.server = server; |
2724 | 2720 | ||
2725 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2721 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2726 | compare_super = NULL; | 2722 | compare_super = NULL; |
2727 | 2723 | ||
2728 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2724 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2729 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2725 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2730 | if (IS_ERR(s)) { | 2726 | if (IS_ERR(s)) { |
2731 | error = PTR_ERR(s); | 2727 | error = PTR_ERR(s); |
2732 | goto out_err_nosb; | 2728 | goto out_err_nosb; |
2733 | } | 2729 | } |
2734 | 2730 | ||
2735 | if (s->s_fs_info != server) { | 2731 | if (s->s_fs_info != server) { |
2736 | nfs_free_server(server); | 2732 | nfs_free_server(server); |
2737 | server = NULL; | 2733 | server = NULL; |
2738 | } else { | 2734 | } else { |
2739 | error = nfs_bdi_register(server); | 2735 | error = nfs_bdi_register(server); |
2740 | if (error) | 2736 | if (error) |
2741 | goto error_splat_super; | 2737 | goto error_splat_super; |
2742 | } | 2738 | } |
2743 | 2739 | ||
2744 | if (!s->s_root) { | 2740 | if (!s->s_root) { |
2745 | /* initial superblock/root creation */ | 2741 | /* initial superblock/root creation */ |
2746 | nfs4_clone_super(s, data->sb); | 2742 | nfs4_clone_super(s, data->sb); |
2747 | } | 2743 | } |
2748 | 2744 | ||
2749 | mntroot = nfs4_get_root(s, data->fh); | 2745 | mntroot = nfs4_get_root(s, data->fh); |
2750 | if (IS_ERR(mntroot)) { | 2746 | if (IS_ERR(mntroot)) { |
2751 | error = PTR_ERR(mntroot); | 2747 | error = PTR_ERR(mntroot); |
2752 | goto error_splat_super; | 2748 | goto error_splat_super; |
2753 | } | 2749 | } |
2754 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { | 2750 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { |
2755 | dput(mntroot); | 2751 | dput(mntroot); |
2756 | error = -ESTALE; | 2752 | error = -ESTALE; |
2757 | goto error_splat_super; | 2753 | goto error_splat_super; |
2758 | } | 2754 | } |
2759 | 2755 | ||
2760 | s->s_flags |= MS_ACTIVE; | 2756 | s->s_flags |= MS_ACTIVE; |
2761 | mnt->mnt_sb = s; | 2757 | mnt->mnt_sb = s; |
2762 | mnt->mnt_root = mntroot; | 2758 | mnt->mnt_root = mntroot; |
2763 | 2759 | ||
2764 | security_sb_clone_mnt_opts(data->sb, s); | 2760 | security_sb_clone_mnt_opts(data->sb, s); |
2765 | 2761 | ||
2766 | dprintk("<-- nfs4_xdev_get_sb() = 0\n"); | 2762 | dprintk("<-- nfs4_xdev_get_sb() = 0\n"); |
2767 | return 0; | 2763 | return 0; |
2768 | 2764 | ||
2769 | out_err_nosb: | 2765 | out_err_nosb: |
2770 | nfs_free_server(server); | 2766 | nfs_free_server(server); |
2771 | out_err_noserver: | 2767 | out_err_noserver: |
2772 | dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error); | 2768 | dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error); |
2773 | return error; | 2769 | return error; |
2774 | 2770 | ||
2775 | error_splat_super: | 2771 | error_splat_super: |
2776 | deactivate_locked_super(s); | 2772 | deactivate_locked_super(s); |
2777 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); | 2773 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); |
2778 | return error; | 2774 | return error; |
2779 | } | 2775 | } |
2780 | 2776 | ||
2781 | static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | 2777 | static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, |
2782 | int flags, const char *dev_name, void *raw_data, | 2778 | int flags, const char *dev_name, void *raw_data, |
2783 | struct vfsmount *mnt) | 2779 | struct vfsmount *mnt) |
2784 | { | 2780 | { |
2785 | struct nfs_clone_mount *data = raw_data; | 2781 | struct nfs_clone_mount *data = raw_data; |
2786 | struct super_block *s; | 2782 | struct super_block *s; |
2787 | struct nfs_server *server; | 2783 | struct nfs_server *server; |
2788 | struct dentry *mntroot; | 2784 | struct dentry *mntroot; |
2789 | struct nfs_fh mntfh; | 2785 | struct nfs_fh mntfh; |
2790 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 2786 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
2791 | struct nfs_sb_mountdata sb_mntdata = { | 2787 | struct nfs_sb_mountdata sb_mntdata = { |
2792 | .mntflags = flags, | 2788 | .mntflags = flags, |
2793 | }; | 2789 | }; |
2794 | int error; | 2790 | int error; |
2795 | 2791 | ||
2796 | dprintk("--> nfs4_referral_get_sb()\n"); | 2792 | dprintk("--> nfs4_referral_get_sb()\n"); |
2797 | 2793 | ||
2798 | /* create a new volume representation */ | 2794 | /* create a new volume representation */ |
2799 | server = nfs4_create_referral_server(data, &mntfh); | 2795 | server = nfs4_create_referral_server(data, &mntfh); |
2800 | if (IS_ERR(server)) { | 2796 | if (IS_ERR(server)) { |
2801 | error = PTR_ERR(server); | 2797 | error = PTR_ERR(server); |
2802 | goto out_err_noserver; | 2798 | goto out_err_noserver; |
2803 | } | 2799 | } |
2804 | sb_mntdata.server = server; | 2800 | sb_mntdata.server = server; |
2805 | 2801 | ||
2806 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2802 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2807 | compare_super = NULL; | 2803 | compare_super = NULL; |
2808 | 2804 | ||
2809 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2805 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2810 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2806 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2811 | if (IS_ERR(s)) { | 2807 | if (IS_ERR(s)) { |
2812 | error = PTR_ERR(s); | 2808 | error = PTR_ERR(s); |
2813 | goto out_err_nosb; | 2809 | goto out_err_nosb; |
2814 | } | 2810 | } |
2815 | 2811 | ||
2816 | if (s->s_fs_info != server) { | 2812 | if (s->s_fs_info != server) { |
2817 | nfs_free_server(server); | 2813 | nfs_free_server(server); |
2818 | server = NULL; | 2814 | server = NULL; |
2819 | } else { | 2815 | } else { |
2820 | error = nfs_bdi_register(server); | 2816 | error = nfs_bdi_register(server); |
2821 | if (error) | 2817 | if (error) |
2822 | goto error_splat_super; | 2818 | goto error_splat_super; |
2823 | } | 2819 | } |
2824 | 2820 | ||
2825 | if (!s->s_root) { | 2821 | if (!s->s_root) { |
2826 | /* initial superblock/root creation */ | 2822 | /* initial superblock/root creation */ |
2827 | nfs4_fill_super(s); | 2823 | nfs4_fill_super(s); |
2828 | } | 2824 | } |
2829 | 2825 | ||
2830 | mntroot = nfs4_get_root(s, &mntfh); | 2826 | mntroot = nfs4_get_root(s, &mntfh); |
2831 | if (IS_ERR(mntroot)) { | 2827 | if (IS_ERR(mntroot)) { |
2832 | error = PTR_ERR(mntroot); | 2828 | error = PTR_ERR(mntroot); |
2833 | goto error_splat_super; | 2829 | goto error_splat_super; |
2834 | } | 2830 | } |
2835 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { | 2831 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { |
2836 | dput(mntroot); | 2832 | dput(mntroot); |
2837 | error = -ESTALE; | 2833 | error = -ESTALE; |
2838 | goto error_splat_super; | 2834 | goto error_splat_super; |
2839 | } | 2835 | } |
2840 | 2836 | ||
2841 | s->s_flags |= MS_ACTIVE; | 2837 | s->s_flags |= MS_ACTIVE; |
2842 | mnt->mnt_sb = s; | 2838 | mnt->mnt_sb = s; |
2843 | mnt->mnt_root = mntroot; | 2839 | mnt->mnt_root = mntroot; |
2844 | 2840 | ||
2845 | security_sb_clone_mnt_opts(data->sb, s); | 2841 | security_sb_clone_mnt_opts(data->sb, s); |
2846 | 2842 | ||
2847 | dprintk("<-- nfs4_referral_get_sb() = 0\n"); | 2843 | dprintk("<-- nfs4_referral_get_sb() = 0\n"); |
2848 | return 0; | 2844 | return 0; |
2849 | 2845 | ||
2850 | out_err_nosb: | 2846 | out_err_nosb: |
2851 | nfs_free_server(server); | 2847 | nfs_free_server(server); |
2852 | out_err_noserver: | 2848 | out_err_noserver: |
2853 | dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error); | 2849 | dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error); |
2854 | return error; | 2850 | return error; |
2855 | 2851 | ||
2856 | error_splat_super: | 2852 | error_splat_super: |
2857 | deactivate_locked_super(s); | 2853 | deactivate_locked_super(s); |
2858 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); | 2854 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); |
2859 | return error; | 2855 | return error; |
2860 | } | 2856 | } |
2861 | 2857 | ||
2862 | /* | 2858 | /* |
2863 | * Create an NFS4 server record on referral traversal | 2859 | * Create an NFS4 server record on referral traversal |
2864 | */ | 2860 | */ |
2865 | static int nfs4_referral_get_sb(struct file_system_type *fs_type, | 2861 | static int nfs4_referral_get_sb(struct file_system_type *fs_type, |
2866 | int flags, const char *dev_name, void *raw_data, | 2862 | int flags, const char *dev_name, void *raw_data, |
2867 | struct vfsmount *mnt) | 2863 | struct vfsmount *mnt) |
2868 | { | 2864 | { |
2869 | struct nfs_clone_mount *data = raw_data; | 2865 | struct nfs_clone_mount *data = raw_data; |
2870 | char *export_path; | 2866 | char *export_path; |
2871 | struct vfsmount *root_mnt; | 2867 | struct vfsmount *root_mnt; |
2872 | int error; | 2868 | int error; |
2873 | 2869 | ||
2874 | dprintk("--> nfs4_referral_get_sb()\n"); | 2870 | dprintk("--> nfs4_referral_get_sb()\n"); |