diff options
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 1537 |
1 files changed, 1537 insertions, 0 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c new file mode 100644 index 000000000000..e8a9bee74d9d --- /dev/null +++ b/fs/nfs/super.c | |||
@@ -0,0 +1,1537 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/super.c | ||
3 | * | ||
4 | * Copyright (C) 1992 Rick Sladkey | ||
5 | * | ||
6 | * nfs superblock handling functions | ||
7 | * | ||
8 | * Modularised by Alan Cox <Alan.Cox@linux.org>, while hacking some | ||
9 | * experimental NFS changes. Modularisation taken straight from SYS5 fs. | ||
10 | * | ||
11 | * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts. | ||
12 | * J.S.Peatfield@damtp.cam.ac.uk | ||
13 | * | ||
14 | * Split from inode.c by David Howells <dhowells@redhat.com> | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | |||
22 | #include <linux/time.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/mm.h> | ||
25 | #include <linux/string.h> | ||
26 | #include <linux/stat.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/unistd.h> | ||
29 | #include <linux/sunrpc/clnt.h> | ||
30 | #include <linux/sunrpc/stats.h> | ||
31 | #include <linux/sunrpc/metrics.h> | ||
32 | #include <linux/nfs_fs.h> | ||
33 | #include <linux/nfs_mount.h> | ||
34 | #include <linux/nfs4_mount.h> | ||
35 | #include <linux/lockd/bind.h> | ||
36 | #include <linux/smp_lock.h> | ||
37 | #include <linux/seq_file.h> | ||
38 | #include <linux/mount.h> | ||
39 | #include <linux/nfs_idmap.h> | ||
40 | #include <linux/vfs.h> | ||
41 | #include <linux/inet.h> | ||
42 | #include <linux/nfs_xdr.h> | ||
43 | |||
44 | #include <asm/system.h> | ||
45 | #include <asm/uaccess.h> | ||
46 | |||
47 | #include "nfs4_fs.h" | ||
48 | #include "callback.h" | ||
49 | #include "delegation.h" | ||
50 | #include "iostat.h" | ||
51 | #include "internal.h" | ||
52 | |||
53 | #define NFSDBG_FACILITY NFSDBG_VFS | ||
54 | |||
55 | /* Maximum number of readahead requests | ||
56 | * FIXME: this should really be a sysctl so that users may tune it to suit | ||
57 | * their needs. People that do NFS over a slow network, might for | ||
58 | * instance want to reduce it to something closer to 1 for improved | ||
59 | * interactive response. | ||
60 | */ | ||
61 | #define NFS_MAX_READAHEAD (RPC_DEF_SLOT_TABLE - 1) | ||
62 | |||
63 | /* | ||
64 | * RPC cruft for NFS | ||
65 | */ | ||
66 | static struct rpc_version * nfs_version[] = { | ||
67 | NULL, | ||
68 | NULL, | ||
69 | &nfs_version2, | ||
70 | #if defined(CONFIG_NFS_V3) | ||
71 | &nfs_version3, | ||
72 | #elif defined(CONFIG_NFS_V4) | ||
73 | NULL, | ||
74 | #endif | ||
75 | #if defined(CONFIG_NFS_V4) | ||
76 | &nfs_version4, | ||
77 | #endif | ||
78 | }; | ||
79 | |||
80 | static struct rpc_program nfs_program = { | ||
81 | .name = "nfs", | ||
82 | .number = NFS_PROGRAM, | ||
83 | .nrvers = ARRAY_SIZE(nfs_version), | ||
84 | .version = nfs_version, | ||
85 | .stats = &nfs_rpcstat, | ||
86 | .pipe_dir_name = "/nfs", | ||
87 | }; | ||
88 | |||
89 | struct rpc_stat nfs_rpcstat = { | ||
90 | .program = &nfs_program | ||
91 | }; | ||
92 | |||
93 | |||
94 | #ifdef CONFIG_NFS_V3_ACL | ||
95 | static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program }; | ||
96 | static struct rpc_version * nfsacl_version[] = { | ||
97 | [3] = &nfsacl_version3, | ||
98 | }; | ||
99 | |||
100 | struct rpc_program nfsacl_program = { | ||
101 | .name = "nfsacl", | ||
102 | .number = NFS_ACL_PROGRAM, | ||
103 | .nrvers = ARRAY_SIZE(nfsacl_version), | ||
104 | .version = nfsacl_version, | ||
105 | .stats = &nfsacl_rpcstat, | ||
106 | }; | ||
107 | #endif /* CONFIG_NFS_V3_ACL */ | ||
108 | |||
109 | static void nfs_umount_begin(struct vfsmount *, int); | ||
110 | static int nfs_statfs(struct dentry *, struct kstatfs *); | ||
111 | static int nfs_show_options(struct seq_file *, struct vfsmount *); | ||
112 | static int nfs_show_stats(struct seq_file *, struct vfsmount *); | ||
113 | static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); | ||
114 | static int nfs_clone_nfs_sb(struct file_system_type *fs_type, | ||
115 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
116 | static void nfs_kill_super(struct super_block *); | ||
117 | |||
118 | static struct file_system_type nfs_fs_type = { | ||
119 | .owner = THIS_MODULE, | ||
120 | .name = "nfs", | ||
121 | .get_sb = nfs_get_sb, | ||
122 | .kill_sb = nfs_kill_super, | ||
123 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
124 | }; | ||
125 | |||
126 | struct file_system_type clone_nfs_fs_type = { | ||
127 | .owner = THIS_MODULE, | ||
128 | .name = "nfs", | ||
129 | .get_sb = nfs_clone_nfs_sb, | ||
130 | .kill_sb = nfs_kill_super, | ||
131 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
132 | }; | ||
133 | |||
134 | static struct super_operations nfs_sops = { | ||
135 | .alloc_inode = nfs_alloc_inode, | ||
136 | .destroy_inode = nfs_destroy_inode, | ||
137 | .write_inode = nfs_write_inode, | ||
138 | .statfs = nfs_statfs, | ||
139 | .clear_inode = nfs_clear_inode, | ||
140 | .umount_begin = nfs_umount_begin, | ||
141 | .show_options = nfs_show_options, | ||
142 | .show_stats = nfs_show_stats, | ||
143 | }; | ||
144 | |||
145 | #ifdef CONFIG_NFS_V4 | ||
146 | static int nfs4_get_sb(struct file_system_type *fs_type, | ||
147 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
148 | static int nfs_clone_nfs4_sb(struct file_system_type *fs_type, | ||
149 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
150 | static int nfs_referral_nfs4_sb(struct file_system_type *fs_type, | ||
151 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | ||
152 | static void nfs4_kill_super(struct super_block *sb); | ||
153 | |||
154 | static struct file_system_type nfs4_fs_type = { | ||
155 | .owner = THIS_MODULE, | ||
156 | .name = "nfs4", | ||
157 | .get_sb = nfs4_get_sb, | ||
158 | .kill_sb = nfs4_kill_super, | ||
159 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
160 | }; | ||
161 | |||
162 | struct file_system_type clone_nfs4_fs_type = { | ||
163 | .owner = THIS_MODULE, | ||
164 | .name = "nfs4", | ||
165 | .get_sb = nfs_clone_nfs4_sb, | ||
166 | .kill_sb = nfs4_kill_super, | ||
167 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
168 | }; | ||
169 | |||
170 | struct file_system_type nfs_referral_nfs4_fs_type = { | ||
171 | .owner = THIS_MODULE, | ||
172 | .name = "nfs4", | ||
173 | .get_sb = nfs_referral_nfs4_sb, | ||
174 | .kill_sb = nfs4_kill_super, | ||
175 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
176 | }; | ||
177 | |||
178 | static struct super_operations nfs4_sops = { | ||
179 | .alloc_inode = nfs_alloc_inode, | ||
180 | .destroy_inode = nfs_destroy_inode, | ||
181 | .write_inode = nfs_write_inode, | ||
182 | .statfs = nfs_statfs, | ||
183 | .clear_inode = nfs4_clear_inode, | ||
184 | .umount_begin = nfs_umount_begin, | ||
185 | .show_options = nfs_show_options, | ||
186 | .show_stats = nfs_show_stats, | ||
187 | }; | ||
188 | #endif | ||
189 | |||
190 | #ifdef CONFIG_NFS_V4 | ||
191 | static const int nfs_set_port_min = 0; | ||
192 | static const int nfs_set_port_max = 65535; | ||
193 | |||
194 | static int param_set_port(const char *val, struct kernel_param *kp) | ||
195 | { | ||
196 | char *endp; | ||
197 | int num = simple_strtol(val, &endp, 0); | ||
198 | if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max) | ||
199 | return -EINVAL; | ||
200 | *((int *)kp->arg) = num; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | module_param_call(callback_tcpport, param_set_port, param_get_int, | ||
205 | &nfs_callback_set_tcpport, 0644); | ||
206 | #endif | ||
207 | |||
208 | #ifdef CONFIG_NFS_V4 | ||
209 | static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) | ||
210 | { | ||
211 | char *endp; | ||
212 | int num = simple_strtol(val, &endp, 0); | ||
213 | int jif = num * HZ; | ||
214 | if (endp == val || *endp || num < 0 || jif < num) | ||
215 | return -EINVAL; | ||
216 | *((int *)kp->arg) = jif; | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, | ||
221 | &nfs_idmap_cache_timeout, 0644); | ||
222 | #endif | ||
223 | |||
224 | /* | ||
225 | * Register the NFS filesystems | ||
226 | */ | ||
227 | int __init register_nfs_fs(void) | ||
228 | { | ||
229 | int ret; | ||
230 | |||
231 | ret = register_filesystem(&nfs_fs_type); | ||
232 | if (ret < 0) | ||
233 | goto error_0; | ||
234 | |||
235 | #ifdef CONFIG_NFS_V4 | ||
236 | ret = nfs_register_sysctl(); | ||
237 | if (ret < 0) | ||
238 | goto error_1; | ||
239 | ret = register_filesystem(&nfs4_fs_type); | ||
240 | if (ret < 0) | ||
241 | goto error_2; | ||
242 | #endif | ||
243 | return 0; | ||
244 | |||
245 | #ifdef CONFIG_NFS_V4 | ||
246 | error_2: | ||
247 | nfs_unregister_sysctl(); | ||
248 | error_1: | ||
249 | unregister_filesystem(&nfs_fs_type); | ||
250 | #endif | ||
251 | error_0: | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | /* | ||
256 | * Unregister the NFS filesystems | ||
257 | */ | ||
258 | void __exit unregister_nfs_fs(void) | ||
259 | { | ||
260 | #ifdef CONFIG_NFS_V4 | ||
261 | unregister_filesystem(&nfs4_fs_type); | ||
262 | nfs_unregister_sysctl(); | ||
263 | #endif | ||
264 | unregister_filesystem(&nfs_fs_type); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Deliver file system statistics to userspace | ||
269 | */ | ||
270 | static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
271 | { | ||
272 | struct super_block *sb = dentry->d_sb; | ||
273 | struct nfs_server *server = NFS_SB(sb); | ||
274 | unsigned char blockbits; | ||
275 | unsigned long blockres; | ||
276 | struct nfs_fh *rootfh = NFS_FH(sb->s_root->d_inode); | ||
277 | struct nfs_fattr fattr; | ||
278 | struct nfs_fsstat res = { | ||
279 | .fattr = &fattr, | ||
280 | }; | ||
281 | int error; | ||
282 | |||
283 | lock_kernel(); | ||
284 | |||
285 | error = server->rpc_ops->statfs(server, rootfh, &res); | ||
286 | buf->f_type = NFS_SUPER_MAGIC; | ||
287 | if (error < 0) | ||
288 | goto out_err; | ||
289 | |||
290 | /* | ||
291 | * Current versions of glibc do not correctly handle the | ||
292 | * case where f_frsize != f_bsize. Eventually we want to | ||
293 | * report the value of wtmult in this field. | ||
294 | */ | ||
295 | buf->f_frsize = sb->s_blocksize; | ||
296 | |||
297 | /* | ||
298 | * On most *nix systems, f_blocks, f_bfree, and f_bavail | ||
299 | * are reported in units of f_frsize. Linux hasn't had | ||
300 | * an f_frsize field in its statfs struct until recently, | ||
301 | * thus historically Linux's sys_statfs reports these | ||
302 | * fields in units of f_bsize. | ||
303 | */ | ||
304 | buf->f_bsize = sb->s_blocksize; | ||
305 | blockbits = sb->s_blocksize_bits; | ||
306 | blockres = (1 << blockbits) - 1; | ||
307 | buf->f_blocks = (res.tbytes + blockres) >> blockbits; | ||
308 | buf->f_bfree = (res.fbytes + blockres) >> blockbits; | ||
309 | buf->f_bavail = (res.abytes + blockres) >> blockbits; | ||
310 | |||
311 | buf->f_files = res.tfiles; | ||
312 | buf->f_ffree = res.afiles; | ||
313 | |||
314 | buf->f_namelen = server->namelen; | ||
315 | out: | ||
316 | unlock_kernel(); | ||
317 | return 0; | ||
318 | |||
319 | out_err: | ||
320 | dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); | ||
321 | buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1; | ||
322 | goto out; | ||
323 | |||
324 | } | ||
325 | |||
326 | static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) | ||
327 | { | ||
328 | static struct { | ||
329 | rpc_authflavor_t flavour; | ||
330 | const char *str; | ||
331 | } sec_flavours[] = { | ||
332 | { RPC_AUTH_NULL, "null" }, | ||
333 | { RPC_AUTH_UNIX, "sys" }, | ||
334 | { RPC_AUTH_GSS_KRB5, "krb5" }, | ||
335 | { RPC_AUTH_GSS_KRB5I, "krb5i" }, | ||
336 | { RPC_AUTH_GSS_KRB5P, "krb5p" }, | ||
337 | { RPC_AUTH_GSS_LKEY, "lkey" }, | ||
338 | { RPC_AUTH_GSS_LKEYI, "lkeyi" }, | ||
339 | { RPC_AUTH_GSS_LKEYP, "lkeyp" }, | ||
340 | { RPC_AUTH_GSS_SPKM, "spkm" }, | ||
341 | { RPC_AUTH_GSS_SPKMI, "spkmi" }, | ||
342 | { RPC_AUTH_GSS_SPKMP, "spkmp" }, | ||
343 | { -1, "unknown" } | ||
344 | }; | ||
345 | int i; | ||
346 | |||
347 | for (i=0; sec_flavours[i].flavour != -1; i++) { | ||
348 | if (sec_flavours[i].flavour == flavour) | ||
349 | break; | ||
350 | } | ||
351 | return sec_flavours[i].str; | ||
352 | } | ||
353 | |||
354 | /* | ||
355 | * Describe the mount options in force on this server representation | ||
356 | */ | ||
357 | static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, int showdefaults) | ||
358 | { | ||
359 | static struct proc_nfs_info { | ||
360 | int flag; | ||
361 | char *str; | ||
362 | char *nostr; | ||
363 | } nfs_info[] = { | ||
364 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, | ||
365 | { NFS_MOUNT_INTR, ",intr", "" }, | ||
366 | { NFS_MOUNT_NOCTO, ",nocto", "" }, | ||
367 | { NFS_MOUNT_NOAC, ",noac", "" }, | ||
368 | { NFS_MOUNT_NONLM, ",nolock", "" }, | ||
369 | { NFS_MOUNT_NOACL, ",noacl", "" }, | ||
370 | { 0, NULL, NULL } | ||
371 | }; | ||
372 | struct proc_nfs_info *nfs_infop; | ||
373 | char buf[12]; | ||
374 | char *proto; | ||
375 | |||
376 | seq_printf(m, ",vers=%d", nfss->rpc_ops->version); | ||
377 | seq_printf(m, ",rsize=%d", nfss->rsize); | ||
378 | seq_printf(m, ",wsize=%d", nfss->wsize); | ||
379 | if (nfss->acregmin != 3*HZ || showdefaults) | ||
380 | seq_printf(m, ",acregmin=%d", nfss->acregmin/HZ); | ||
381 | if (nfss->acregmax != 60*HZ || showdefaults) | ||
382 | seq_printf(m, ",acregmax=%d", nfss->acregmax/HZ); | ||
383 | if (nfss->acdirmin != 30*HZ || showdefaults) | ||
384 | seq_printf(m, ",acdirmin=%d", nfss->acdirmin/HZ); | ||
385 | if (nfss->acdirmax != 60*HZ || showdefaults) | ||
386 | seq_printf(m, ",acdirmax=%d", nfss->acdirmax/HZ); | ||
387 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | ||
388 | if (nfss->flags & nfs_infop->flag) | ||
389 | seq_puts(m, nfs_infop->str); | ||
390 | else | ||
391 | seq_puts(m, nfs_infop->nostr); | ||
392 | } | ||
393 | switch (nfss->client->cl_xprt->prot) { | ||
394 | case IPPROTO_TCP: | ||
395 | proto = "tcp"; | ||
396 | break; | ||
397 | case IPPROTO_UDP: | ||
398 | proto = "udp"; | ||
399 | break; | ||
400 | default: | ||
401 | snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot); | ||
402 | proto = buf; | ||
403 | } | ||
404 | seq_printf(m, ",proto=%s", proto); | ||
405 | seq_printf(m, ",timeo=%lu", 10U * nfss->retrans_timeo / HZ); | ||
406 | seq_printf(m, ",retrans=%u", nfss->retrans_count); | ||
407 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | * Describe the mount options on this VFS mountpoint | ||
412 | */ | ||
413 | static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) | ||
414 | { | ||
415 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
416 | |||
417 | nfs_show_mount_options(m, nfss, 0); | ||
418 | |||
419 | seq_puts(m, ",addr="); | ||
420 | seq_escape(m, nfss->hostname, " \t\n\\"); | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | /* | ||
426 | * Present statistical information for this VFS mountpoint | ||
427 | */ | ||
428 | static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) | ||
429 | { | ||
430 | int i, cpu; | ||
431 | struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); | ||
432 | struct rpc_auth *auth = nfss->client->cl_auth; | ||
433 | struct nfs_iostats totals = { }; | ||
434 | |||
435 | seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS); | ||
436 | |||
437 | /* | ||
438 | * Display all mount option settings | ||
439 | */ | ||
440 | seq_printf(m, "\n\topts:\t"); | ||
441 | seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); | ||
442 | seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); | ||
443 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); | ||
444 | seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); | ||
445 | nfs_show_mount_options(m, nfss, 1); | ||
446 | |||
447 | seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); | ||
448 | |||
449 | seq_printf(m, "\n\tcaps:\t"); | ||
450 | seq_printf(m, "caps=0x%x", nfss->caps); | ||
451 | seq_printf(m, ",wtmult=%d", nfss->wtmult); | ||
452 | seq_printf(m, ",dtsize=%d", nfss->dtsize); | ||
453 | seq_printf(m, ",bsize=%d", nfss->bsize); | ||
454 | seq_printf(m, ",namelen=%d", nfss->namelen); | ||
455 | |||
456 | #ifdef CONFIG_NFS_V4 | ||
457 | if (nfss->rpc_ops->version == 4) { | ||
458 | seq_printf(m, "\n\tnfsv4:\t"); | ||
459 | seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); | ||
460 | seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); | ||
461 | seq_printf(m, ",acl=0x%x", nfss->acl_bitmask); | ||
462 | } | ||
463 | #endif | ||
464 | |||
465 | /* | ||
466 | * Display security flavor in effect for this mount | ||
467 | */ | ||
468 | seq_printf(m, "\n\tsec:\tflavor=%d", auth->au_ops->au_flavor); | ||
469 | if (auth->au_flavor) | ||
470 | seq_printf(m, ",pseudoflavor=%d", auth->au_flavor); | ||
471 | |||
472 | /* | ||
473 | * Display superblock I/O counters | ||
474 | */ | ||
475 | for_each_possible_cpu(cpu) { | ||
476 | struct nfs_iostats *stats; | ||
477 | |||
478 | preempt_disable(); | ||
479 | stats = per_cpu_ptr(nfss->io_stats, cpu); | ||
480 | |||
481 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
482 | totals.events[i] += stats->events[i]; | ||
483 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
484 | totals.bytes[i] += stats->bytes[i]; | ||
485 | |||
486 | preempt_enable(); | ||
487 | } | ||
488 | |||
489 | seq_printf(m, "\n\tevents:\t"); | ||
490 | for (i = 0; i < __NFSIOS_COUNTSMAX; i++) | ||
491 | seq_printf(m, "%lu ", totals.events[i]); | ||
492 | seq_printf(m, "\n\tbytes:\t"); | ||
493 | for (i = 0; i < __NFSIOS_BYTESMAX; i++) | ||
494 | seq_printf(m, "%Lu ", totals.bytes[i]); | ||
495 | seq_printf(m, "\n"); | ||
496 | |||
497 | rpc_print_iostats(m, nfss->client); | ||
498 | |||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | /* | ||
503 | * Begin unmount by attempting to remove all automounted mountpoints we added | ||
504 | * in response to traversals | ||
505 | */ | ||
506 | static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags) | ||
507 | { | ||
508 | struct nfs_server *server; | ||
509 | struct rpc_clnt *rpc; | ||
510 | |||
511 | shrink_submounts(vfsmnt, &nfs_automount_list); | ||
512 | if (!(flags & MNT_FORCE)) | ||
513 | return; | ||
514 | /* -EIO all pending I/O */ | ||
515 | server = NFS_SB(vfsmnt->mnt_sb); | ||
516 | rpc = server->client; | ||
517 | if (!IS_ERR(rpc)) | ||
518 | rpc_killall_tasks(rpc); | ||
519 | rpc = server->client_acl; | ||
520 | if (!IS_ERR(rpc)) | ||
521 | rpc_killall_tasks(rpc); | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * Obtain the root inode of the file system. | ||
526 | */ | ||
527 | static struct inode * | ||
528 | nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *fsinfo) | ||
529 | { | ||
530 | struct nfs_server *server = NFS_SB(sb); | ||
531 | int error; | ||
532 | |||
533 | error = server->rpc_ops->getroot(server, rootfh, fsinfo); | ||
534 | if (error < 0) { | ||
535 | dprintk("nfs_get_root: getattr error = %d\n", -error); | ||
536 | return ERR_PTR(error); | ||
537 | } | ||
538 | |||
539 | server->fsid = fsinfo->fattr->fsid; | ||
540 | return nfs_fhget(sb, rootfh, fsinfo->fattr); | ||
541 | } | ||
542 | |||
543 | /* | ||
544 | * Do NFS version-independent mount processing, and sanity checking | ||
545 | */ | ||
546 | static int | ||
547 | nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) | ||
548 | { | ||
549 | struct nfs_server *server; | ||
550 | struct inode *root_inode; | ||
551 | struct nfs_fattr fattr; | ||
552 | struct nfs_fsinfo fsinfo = { | ||
553 | .fattr = &fattr, | ||
554 | }; | ||
555 | struct nfs_pathconf pathinfo = { | ||
556 | .fattr = &fattr, | ||
557 | }; | ||
558 | int no_root_error = 0; | ||
559 | unsigned long max_rpc_payload; | ||
560 | |||
561 | /* We probably want something more informative here */ | ||
562 | snprintf(sb->s_id, sizeof(sb->s_id), "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev)); | ||
563 | |||
564 | server = NFS_SB(sb); | ||
565 | |||
566 | sb->s_magic = NFS_SUPER_MAGIC; | ||
567 | |||
568 | server->io_stats = nfs_alloc_iostats(); | ||
569 | if (server->io_stats == NULL) | ||
570 | return -ENOMEM; | ||
571 | |||
572 | root_inode = nfs_get_root(sb, &server->fh, &fsinfo); | ||
573 | /* Did getting the root inode fail? */ | ||
574 | if (IS_ERR(root_inode)) { | ||
575 | no_root_error = PTR_ERR(root_inode); | ||
576 | goto out_no_root; | ||
577 | } | ||
578 | sb->s_root = d_alloc_root(root_inode); | ||
579 | if (!sb->s_root) { | ||
580 | no_root_error = -ENOMEM; | ||
581 | goto out_no_root; | ||
582 | } | ||
583 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
584 | |||
585 | /* mount time stamp, in seconds */ | ||
586 | server->mount_time = jiffies; | ||
587 | |||
588 | /* Get some general file system info */ | ||
589 | if (server->namelen == 0 && | ||
590 | server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0) | ||
591 | server->namelen = pathinfo.max_namelen; | ||
592 | /* Work out a lot of parameters */ | ||
593 | if (server->rsize == 0) | ||
594 | server->rsize = nfs_block_size(fsinfo.rtpref, NULL); | ||
595 | if (server->wsize == 0) | ||
596 | server->wsize = nfs_block_size(fsinfo.wtpref, NULL); | ||
597 | |||
598 | if (fsinfo.rtmax >= 512 && server->rsize > fsinfo.rtmax) | ||
599 | server->rsize = nfs_block_size(fsinfo.rtmax, NULL); | ||
600 | if (fsinfo.wtmax >= 512 && server->wsize > fsinfo.wtmax) | ||
601 | server->wsize = nfs_block_size(fsinfo.wtmax, NULL); | ||
602 | |||
603 | max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL); | ||
604 | if (server->rsize > max_rpc_payload) | ||
605 | server->rsize = max_rpc_payload; | ||
606 | if (server->rsize > NFS_MAX_FILE_IO_SIZE) | ||
607 | server->rsize = NFS_MAX_FILE_IO_SIZE; | ||
608 | server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
609 | |||
610 | if (server->wsize > max_rpc_payload) | ||
611 | server->wsize = max_rpc_payload; | ||
612 | if (server->wsize > NFS_MAX_FILE_IO_SIZE) | ||
613 | server->wsize = NFS_MAX_FILE_IO_SIZE; | ||
614 | server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
615 | |||
616 | if (sb->s_blocksize == 0) | ||
617 | sb->s_blocksize = nfs_block_bits(server->wsize, | ||
618 | &sb->s_blocksize_bits); | ||
619 | server->wtmult = nfs_block_bits(fsinfo.wtmult, NULL); | ||
620 | |||
621 | server->dtsize = nfs_block_size(fsinfo.dtpref, NULL); | ||
622 | if (server->dtsize > PAGE_CACHE_SIZE) | ||
623 | server->dtsize = PAGE_CACHE_SIZE; | ||
624 | if (server->dtsize > server->rsize) | ||
625 | server->dtsize = server->rsize; | ||
626 | |||
627 | if (server->flags & NFS_MOUNT_NOAC) { | ||
628 | server->acregmin = server->acregmax = 0; | ||
629 | server->acdirmin = server->acdirmax = 0; | ||
630 | sb->s_flags |= MS_SYNCHRONOUS; | ||
631 | } | ||
632 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; | ||
633 | |||
634 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); | ||
635 | |||
636 | server->client->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0; | ||
637 | server->client->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0; | ||
638 | |||
639 | /* We're airborne Set socket buffersize */ | ||
640 | rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100); | ||
641 | return 0; | ||
642 | /* Yargs. It didn't work out. */ | ||
643 | out_no_root: | ||
644 | dprintk("nfs_sb_init: get root inode failed: errno %d\n", -no_root_error); | ||
645 | if (!IS_ERR(root_inode)) | ||
646 | iput(root_inode); | ||
647 | return no_root_error; | ||
648 | } | ||
649 | |||
650 | /* | ||
651 | * Initialise the timeout values for a connection | ||
652 | */ | ||
653 | static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, unsigned int timeo, unsigned int retrans) | ||
654 | { | ||
655 | to->to_initval = timeo * HZ / 10; | ||
656 | to->to_retries = retrans; | ||
657 | if (!to->to_retries) | ||
658 | to->to_retries = 2; | ||
659 | |||
660 | switch (proto) { | ||
661 | case IPPROTO_TCP: | ||
662 | if (!to->to_initval) | ||
663 | to->to_initval = 60 * HZ; | ||
664 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | ||
665 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | ||
666 | to->to_increment = to->to_initval; | ||
667 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); | ||
668 | to->to_exponential = 0; | ||
669 | break; | ||
670 | case IPPROTO_UDP: | ||
671 | default: | ||
672 | if (!to->to_initval) | ||
673 | to->to_initval = 11 * HZ / 10; | ||
674 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | ||
675 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | ||
676 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; | ||
677 | to->to_exponential = 1; | ||
678 | break; | ||
679 | } | ||
680 | } | ||
681 | |||
682 | /* | ||
683 | * Create an RPC client handle. | ||
684 | */ | ||
685 | static struct rpc_clnt * | ||
686 | nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) | ||
687 | { | ||
688 | struct rpc_timeout timeparms; | ||
689 | struct rpc_xprt *xprt = NULL; | ||
690 | struct rpc_clnt *clnt = NULL; | ||
691 | int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; | ||
692 | |||
693 | nfs_init_timeout_values(&timeparms, proto, data->timeo, data->retrans); | ||
694 | |||
695 | server->retrans_timeo = timeparms.to_initval; | ||
696 | server->retrans_count = timeparms.to_retries; | ||
697 | |||
698 | /* create transport and client */ | ||
699 | xprt = xprt_create_proto(proto, &server->addr, &timeparms); | ||
700 | if (IS_ERR(xprt)) { | ||
701 | dprintk("%s: cannot create RPC transport. Error = %ld\n", | ||
702 | __FUNCTION__, PTR_ERR(xprt)); | ||
703 | return (struct rpc_clnt *)xprt; | ||
704 | } | ||
705 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
706 | server->rpc_ops->version, data->pseudoflavor); | ||
707 | if (IS_ERR(clnt)) { | ||
708 | dprintk("%s: cannot create RPC client. Error = %ld\n", | ||
709 | __FUNCTION__, PTR_ERR(xprt)); | ||
710 | goto out_fail; | ||
711 | } | ||
712 | |||
713 | clnt->cl_intr = 1; | ||
714 | clnt->cl_softrtry = 1; | ||
715 | |||
716 | return clnt; | ||
717 | |||
718 | out_fail: | ||
719 | return clnt; | ||
720 | } | ||
721 | |||
722 | /* | ||
723 | * Clone a server record | ||
724 | */ | ||
725 | static struct nfs_server *nfs_clone_server(struct super_block *sb, struct nfs_clone_mount *data) | ||
726 | { | ||
727 | struct nfs_server *server = NFS_SB(sb); | ||
728 | struct nfs_server *parent = NFS_SB(data->sb); | ||
729 | struct inode *root_inode; | ||
730 | struct nfs_fsinfo fsinfo; | ||
731 | void *err = ERR_PTR(-ENOMEM); | ||
732 | |||
733 | sb->s_op = data->sb->s_op; | ||
734 | sb->s_blocksize = data->sb->s_blocksize; | ||
735 | sb->s_blocksize_bits = data->sb->s_blocksize_bits; | ||
736 | sb->s_maxbytes = data->sb->s_maxbytes; | ||
737 | |||
738 | server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
739 | server->io_stats = nfs_alloc_iostats(); | ||
740 | if (server->io_stats == NULL) | ||
741 | goto out; | ||
742 | |||
743 | server->client = rpc_clone_client(parent->client); | ||
744 | if (IS_ERR((err = server->client))) | ||
745 | goto out; | ||
746 | |||
747 | if (!IS_ERR(parent->client_sys)) { | ||
748 | server->client_sys = rpc_clone_client(parent->client_sys); | ||
749 | if (IS_ERR((err = server->client_sys))) | ||
750 | goto out; | ||
751 | } | ||
752 | if (!IS_ERR(parent->client_acl)) { | ||
753 | server->client_acl = rpc_clone_client(parent->client_acl); | ||
754 | if (IS_ERR((err = server->client_acl))) | ||
755 | goto out; | ||
756 | } | ||
757 | root_inode = nfs_fhget(sb, data->fh, data->fattr); | ||
758 | if (!root_inode) | ||
759 | goto out; | ||
760 | sb->s_root = d_alloc_root(root_inode); | ||
761 | if (!sb->s_root) | ||
762 | goto out_put_root; | ||
763 | fsinfo.fattr = data->fattr; | ||
764 | if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0) | ||
765 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); | ||
766 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
767 | sb->s_flags |= MS_ACTIVE; | ||
768 | return server; | ||
769 | out_put_root: | ||
770 | iput(root_inode); | ||
771 | out: | ||
772 | return err; | ||
773 | } | ||
774 | |||
775 | /* | ||
776 | * Copy an existing superblock and attach revised data | ||
777 | */ | ||
778 | static int nfs_clone_generic_sb(struct nfs_clone_mount *data, | ||
779 | struct super_block *(*fill_sb)(struct nfs_server *, struct nfs_clone_mount *), | ||
780 | struct nfs_server *(*fill_server)(struct super_block *, struct nfs_clone_mount *), | ||
781 | struct vfsmount *mnt) | ||
782 | { | ||
783 | struct nfs_server *server; | ||
784 | struct nfs_server *parent = NFS_SB(data->sb); | ||
785 | struct super_block *sb = ERR_PTR(-EINVAL); | ||
786 | char *hostname; | ||
787 | int error = -ENOMEM; | ||
788 | int len; | ||
789 | |||
790 | server = kmalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
791 | if (server == NULL) | ||
792 | goto out_err; | ||
793 | memcpy(server, parent, sizeof(*server)); | ||
794 | hostname = (data->hostname != NULL) ? data->hostname : parent->hostname; | ||
795 | len = strlen(hostname) + 1; | ||
796 | server->hostname = kmalloc(len, GFP_KERNEL); | ||
797 | if (server->hostname == NULL) | ||
798 | goto free_server; | ||
799 | memcpy(server->hostname, hostname, len); | ||
800 | error = rpciod_up(); | ||
801 | if (error != 0) | ||
802 | goto free_hostname; | ||
803 | |||
804 | sb = fill_sb(server, data); | ||
805 | if (IS_ERR(sb)) { | ||
806 | error = PTR_ERR(sb); | ||
807 | goto kill_rpciod; | ||
808 | } | ||
809 | |||
810 | if (sb->s_root) | ||
811 | goto out_rpciod_down; | ||
812 | |||
813 | server = fill_server(sb, data); | ||
814 | if (IS_ERR(server)) { | ||
815 | error = PTR_ERR(server); | ||
816 | goto out_deactivate; | ||
817 | } | ||
818 | return simple_set_mnt(mnt, sb); | ||
819 | out_deactivate: | ||
820 | up_write(&sb->s_umount); | ||
821 | deactivate_super(sb); | ||
822 | return error; | ||
823 | out_rpciod_down: | ||
824 | rpciod_down(); | ||
825 | kfree(server->hostname); | ||
826 | kfree(server); | ||
827 | return simple_set_mnt(mnt, sb); | ||
828 | kill_rpciod: | ||
829 | rpciod_down(); | ||
830 | free_hostname: | ||
831 | kfree(server->hostname); | ||
832 | free_server: | ||
833 | kfree(server); | ||
834 | out_err: | ||
835 | return error; | ||
836 | } | ||
837 | |||
838 | /* | ||
839 | * Set up an NFS2/3 superblock | ||
840 | * | ||
841 | * The way this works is that the mount process passes a structure | ||
842 | * in the data argument which contains the server's IP address | ||
843 | * and the root file handle obtained from the server's mount | ||
844 | * daemon. We stash these away in the private superblock fields. | ||
845 | */ | ||
846 | static int | ||
847 | nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent) | ||
848 | { | ||
849 | struct nfs_server *server; | ||
850 | rpc_authflavor_t authflavor; | ||
851 | |||
852 | server = NFS_SB(sb); | ||
853 | sb->s_blocksize_bits = 0; | ||
854 | sb->s_blocksize = 0; | ||
855 | if (data->bsize) | ||
856 | sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); | ||
857 | if (data->rsize) | ||
858 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
859 | if (data->wsize) | ||
860 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
861 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
862 | |||
863 | server->acregmin = data->acregmin*HZ; | ||
864 | server->acregmax = data->acregmax*HZ; | ||
865 | server->acdirmin = data->acdirmin*HZ; | ||
866 | server->acdirmax = data->acdirmax*HZ; | ||
867 | |||
868 | /* Start lockd here, before we might error out */ | ||
869 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
870 | lockd_up(); | ||
871 | |||
872 | server->namelen = data->namlen; | ||
873 | server->hostname = kmalloc(strlen(data->hostname) + 1, GFP_KERNEL); | ||
874 | if (!server->hostname) | ||
875 | return -ENOMEM; | ||
876 | strcpy(server->hostname, data->hostname); | ||
877 | |||
878 | /* Check NFS protocol revision and initialize RPC op vector | ||
879 | * and file handle pool. */ | ||
880 | #ifdef CONFIG_NFS_V3 | ||
881 | if (server->flags & NFS_MOUNT_VER3) { | ||
882 | server->rpc_ops = &nfs_v3_clientops; | ||
883 | server->caps |= NFS_CAP_READDIRPLUS; | ||
884 | } else { | ||
885 | server->rpc_ops = &nfs_v2_clientops; | ||
886 | } | ||
887 | #else | ||
888 | server->rpc_ops = &nfs_v2_clientops; | ||
889 | #endif | ||
890 | |||
891 | /* Fill in pseudoflavor for mount version < 5 */ | ||
892 | if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) | ||
893 | data->pseudoflavor = RPC_AUTH_UNIX; | ||
894 | authflavor = data->pseudoflavor; /* save for sb_init() */ | ||
895 | /* XXX maybe we want to add a server->pseudoflavor field */ | ||
896 | |||
897 | /* Create RPC client handles */ | ||
898 | server->client = nfs_create_client(server, data); | ||
899 | if (IS_ERR(server->client)) | ||
900 | return PTR_ERR(server->client); | ||
901 | /* RFC 2623, sec 2.3.2 */ | ||
902 | if (authflavor != RPC_AUTH_UNIX) { | ||
903 | struct rpc_auth *auth; | ||
904 | |||
905 | server->client_sys = rpc_clone_client(server->client); | ||
906 | if (IS_ERR(server->client_sys)) | ||
907 | return PTR_ERR(server->client_sys); | ||
908 | auth = rpcauth_create(RPC_AUTH_UNIX, server->client_sys); | ||
909 | if (IS_ERR(auth)) | ||
910 | return PTR_ERR(auth); | ||
911 | } else { | ||
912 | atomic_inc(&server->client->cl_count); | ||
913 | server->client_sys = server->client; | ||
914 | } | ||
915 | if (server->flags & NFS_MOUNT_VER3) { | ||
916 | #ifdef CONFIG_NFS_V3_ACL | ||
917 | if (!(server->flags & NFS_MOUNT_NOACL)) { | ||
918 | server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3); | ||
919 | /* No errors! Assume that Sun nfsacls are supported */ | ||
920 | if (!IS_ERR(server->client_acl)) | ||
921 | server->caps |= NFS_CAP_ACLS; | ||
922 | } | ||
923 | #else | ||
924 | server->flags &= ~NFS_MOUNT_NOACL; | ||
925 | #endif /* CONFIG_NFS_V3_ACL */ | ||
926 | /* | ||
927 | * The VFS shouldn't apply the umask to mode bits. We will | ||
928 | * do so ourselves when necessary. | ||
929 | */ | ||
930 | sb->s_flags |= MS_POSIXACL; | ||
931 | if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) | ||
932 | server->namelen = NFS3_MAXNAMLEN; | ||
933 | sb->s_time_gran = 1; | ||
934 | } else { | ||
935 | if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) | ||
936 | server->namelen = NFS2_MAXNAMLEN; | ||
937 | } | ||
938 | |||
939 | sb->s_op = &nfs_sops; | ||
940 | return nfs_sb_init(sb, authflavor); | ||
941 | } | ||
942 | |||
943 | static int nfs_set_super(struct super_block *s, void *data) | ||
944 | { | ||
945 | s->s_fs_info = data; | ||
946 | return set_anon_super(s, data); | ||
947 | } | ||
948 | |||
949 | static int nfs_compare_super(struct super_block *sb, void *data) | ||
950 | { | ||
951 | struct nfs_server *server = data; | ||
952 | struct nfs_server *old = NFS_SB(sb); | ||
953 | |||
954 | if (old->addr.sin_addr.s_addr != server->addr.sin_addr.s_addr) | ||
955 | return 0; | ||
956 | if (old->addr.sin_port != server->addr.sin_port) | ||
957 | return 0; | ||
958 | return !nfs_compare_fh(&old->fh, &server->fh); | ||
959 | } | ||
960 | |||
961 | static int nfs_get_sb(struct file_system_type *fs_type, | ||
962 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
963 | { | ||
964 | int error; | ||
965 | struct nfs_server *server = NULL; | ||
966 | struct super_block *s; | ||
967 | struct nfs_fh *root; | ||
968 | struct nfs_mount_data *data = raw_data; | ||
969 | |||
970 | error = -EINVAL; | ||
971 | if (data == NULL) { | ||
972 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
973 | goto out_err_noserver; | ||
974 | } | ||
975 | if (data->version <= 0 || data->version > NFS_MOUNT_VERSION) { | ||
976 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
977 | goto out_err_noserver; | ||
978 | } | ||
979 | switch (data->version) { | ||
980 | case 1: | ||
981 | data->namlen = 0; | ||
982 | case 2: | ||
983 | data->bsize = 0; | ||
984 | case 3: | ||
985 | if (data->flags & NFS_MOUNT_VER3) { | ||
986 | dprintk("%s: mount structure version %d does not support NFSv3\n", | ||
987 | __FUNCTION__, | ||
988 | data->version); | ||
989 | goto out_err_noserver; | ||
990 | } | ||
991 | data->root.size = NFS2_FHSIZE; | ||
992 | memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); | ||
993 | case 4: | ||
994 | if (data->flags & NFS_MOUNT_SECFLAVOUR) { | ||
995 | dprintk("%s: mount structure version %d does not support strong security\n", | ||
996 | __FUNCTION__, | ||
997 | data->version); | ||
998 | goto out_err_noserver; | ||
999 | } | ||
1000 | case 5: | ||
1001 | memset(data->context, 0, sizeof(data->context)); | ||
1002 | } | ||
1003 | #ifndef CONFIG_NFS_V3 | ||
1004 | /* If NFSv3 is not compiled in, return -EPROTONOSUPPORT */ | ||
1005 | error = -EPROTONOSUPPORT; | ||
1006 | if (data->flags & NFS_MOUNT_VER3) { | ||
1007 | dprintk("%s: NFSv3 not compiled into kernel\n", __FUNCTION__); | ||
1008 | goto out_err_noserver; | ||
1009 | } | ||
1010 | #endif /* CONFIG_NFS_V3 */ | ||
1011 | |||
1012 | error = -ENOMEM; | ||
1013 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1014 | if (!server) | ||
1015 | goto out_err_noserver; | ||
1016 | /* Zero out the NFS state stuff */ | ||
1017 | init_nfsv4_state(server); | ||
1018 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1019 | |||
1020 | root = &server->fh; | ||
1021 | if (data->flags & NFS_MOUNT_VER3) | ||
1022 | root->size = data->root.size; | ||
1023 | else | ||
1024 | root->size = NFS2_FHSIZE; | ||
1025 | error = -EINVAL; | ||
1026 | if (root->size > sizeof(root->data)) { | ||
1027 | dprintk("%s: invalid root filehandle\n", __FUNCTION__); | ||
1028 | goto out_err; | ||
1029 | } | ||
1030 | memcpy(root->data, data->root.data, root->size); | ||
1031 | |||
1032 | /* We now require that the mount process passes the remote address */ | ||
1033 | memcpy(&server->addr, &data->addr, sizeof(server->addr)); | ||
1034 | if (server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
1035 | dprintk("%s: mount program didn't pass remote address!\n", | ||
1036 | __FUNCTION__); | ||
1037 | goto out_err; | ||
1038 | } | ||
1039 | |||
1040 | /* Fire up rpciod if not yet running */ | ||
1041 | error = rpciod_up(); | ||
1042 | if (error < 0) { | ||
1043 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
1044 | __FUNCTION__, error); | ||
1045 | goto out_err; | ||
1046 | } | ||
1047 | |||
1048 | s = sget(fs_type, nfs_compare_super, nfs_set_super, server); | ||
1049 | if (IS_ERR(s)) { | ||
1050 | error = PTR_ERR(s); | ||
1051 | goto out_err_rpciod; | ||
1052 | } | ||
1053 | |||
1054 | if (s->s_root) | ||
1055 | goto out_rpciod_down; | ||
1056 | |||
1057 | s->s_flags = flags; | ||
1058 | |||
1059 | error = nfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
1060 | if (error) { | ||
1061 | up_write(&s->s_umount); | ||
1062 | deactivate_super(s); | ||
1063 | return error; | ||
1064 | } | ||
1065 | s->s_flags |= MS_ACTIVE; | ||
1066 | return simple_set_mnt(mnt, s); | ||
1067 | |||
1068 | out_rpciod_down: | ||
1069 | rpciod_down(); | ||
1070 | kfree(server); | ||
1071 | return simple_set_mnt(mnt, s); | ||
1072 | |||
1073 | out_err_rpciod: | ||
1074 | rpciod_down(); | ||
1075 | out_err: | ||
1076 | kfree(server); | ||
1077 | out_err_noserver: | ||
1078 | return error; | ||
1079 | } | ||
1080 | |||
1081 | static void nfs_kill_super(struct super_block *s) | ||
1082 | { | ||
1083 | struct nfs_server *server = NFS_SB(s); | ||
1084 | |||
1085 | kill_anon_super(s); | ||
1086 | |||
1087 | if (!IS_ERR(server->client)) | ||
1088 | rpc_shutdown_client(server->client); | ||
1089 | if (!IS_ERR(server->client_sys)) | ||
1090 | rpc_shutdown_client(server->client_sys); | ||
1091 | if (!IS_ERR(server->client_acl)) | ||
1092 | rpc_shutdown_client(server->client_acl); | ||
1093 | |||
1094 | if (!(server->flags & NFS_MOUNT_NONLM)) | ||
1095 | lockd_down(); /* release rpc.lockd */ | ||
1096 | |||
1097 | rpciod_down(); /* release rpciod */ | ||
1098 | |||
1099 | nfs_free_iostats(server->io_stats); | ||
1100 | kfree(server->hostname); | ||
1101 | kfree(server); | ||
1102 | nfs_release_automount_timer(); | ||
1103 | } | ||
1104 | |||
1105 | static struct super_block *nfs_clone_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1106 | { | ||
1107 | struct super_block *sb; | ||
1108 | |||
1109 | server->fsid = data->fattr->fsid; | ||
1110 | nfs_copy_fh(&server->fh, data->fh); | ||
1111 | sb = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server); | ||
1112 | if (!IS_ERR(sb) && sb->s_root == NULL && !(server->flags & NFS_MOUNT_NONLM)) | ||
1113 | lockd_up(); | ||
1114 | return sb; | ||
1115 | } | ||
1116 | |||
1117 | static int nfs_clone_nfs_sb(struct file_system_type *fs_type, | ||
1118 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1119 | { | ||
1120 | struct nfs_clone_mount *data = raw_data; | ||
1121 | return nfs_clone_generic_sb(data, nfs_clone_sb, nfs_clone_server, mnt); | ||
1122 | } | ||
1123 | |||
1124 | #ifdef CONFIG_NFS_V4 | ||
1125 | static struct rpc_clnt *nfs4_create_client(struct nfs_server *server, | ||
1126 | struct rpc_timeout *timeparms, int proto, rpc_authflavor_t flavor) | ||
1127 | { | ||
1128 | struct nfs4_client *clp; | ||
1129 | struct rpc_xprt *xprt = NULL; | ||
1130 | struct rpc_clnt *clnt = NULL; | ||
1131 | int err = -EIO; | ||
1132 | |||
1133 | clp = nfs4_get_client(&server->addr.sin_addr); | ||
1134 | if (!clp) { | ||
1135 | dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); | ||
1136 | return ERR_PTR(err); | ||
1137 | } | ||
1138 | |||
1139 | /* Now create transport and client */ | ||
1140 | down_write(&clp->cl_sem); | ||
1141 | if (IS_ERR(clp->cl_rpcclient)) { | ||
1142 | xprt = xprt_create_proto(proto, &server->addr, timeparms); | ||
1143 | if (IS_ERR(xprt)) { | ||
1144 | up_write(&clp->cl_sem); | ||
1145 | err = PTR_ERR(xprt); | ||
1146 | dprintk("%s: cannot create RPC transport. Error = %d\n", | ||
1147 | __FUNCTION__, err); | ||
1148 | goto out_fail; | ||
1149 | } | ||
1150 | /* Bind to a reserved port! */ | ||
1151 | xprt->resvport = 1; | ||
1152 | clnt = rpc_create_client(xprt, server->hostname, &nfs_program, | ||
1153 | server->rpc_ops->version, flavor); | ||
1154 | if (IS_ERR(clnt)) { | ||
1155 | up_write(&clp->cl_sem); | ||
1156 | err = PTR_ERR(clnt); | ||
1157 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1158 | __FUNCTION__, err); | ||
1159 | goto out_fail; | ||
1160 | } | ||
1161 | clnt->cl_intr = 1; | ||
1162 | clnt->cl_softrtry = 1; | ||
1163 | clp->cl_rpcclient = clnt; | ||
1164 | memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); | ||
1165 | nfs_idmap_new(clp); | ||
1166 | } | ||
1167 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
1168 | clnt = rpc_clone_client(clp->cl_rpcclient); | ||
1169 | if (!IS_ERR(clnt)) | ||
1170 | server->nfs4_state = clp; | ||
1171 | up_write(&clp->cl_sem); | ||
1172 | clp = NULL; | ||
1173 | |||
1174 | if (IS_ERR(clnt)) { | ||
1175 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1176 | __FUNCTION__, err); | ||
1177 | return clnt; | ||
1178 | } | ||
1179 | |||
1180 | if (server->nfs4_state->cl_idmap == NULL) { | ||
1181 | dprintk("%s: failed to create idmapper.\n", __FUNCTION__); | ||
1182 | return ERR_PTR(-ENOMEM); | ||
1183 | } | ||
1184 | |||
1185 | if (clnt->cl_auth->au_flavor != flavor) { | ||
1186 | struct rpc_auth *auth; | ||
1187 | |||
1188 | auth = rpcauth_create(flavor, clnt); | ||
1189 | if (IS_ERR(auth)) { | ||
1190 | dprintk("%s: couldn't create credcache!\n", __FUNCTION__); | ||
1191 | return (struct rpc_clnt *)auth; | ||
1192 | } | ||
1193 | } | ||
1194 | return clnt; | ||
1195 | |||
1196 | out_fail: | ||
1197 | if (clp) | ||
1198 | nfs4_put_client(clp); | ||
1199 | return ERR_PTR(err); | ||
1200 | } | ||
1201 | |||
1202 | /* | ||
1203 | * Set up an NFS4 superblock | ||
1204 | */ | ||
1205 | static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, int silent) | ||
1206 | { | ||
1207 | struct nfs_server *server; | ||
1208 | struct rpc_timeout timeparms; | ||
1209 | rpc_authflavor_t authflavour; | ||
1210 | int err = -EIO; | ||
1211 | |||
1212 | sb->s_blocksize_bits = 0; | ||
1213 | sb->s_blocksize = 0; | ||
1214 | server = NFS_SB(sb); | ||
1215 | if (data->rsize != 0) | ||
1216 | server->rsize = nfs_block_size(data->rsize, NULL); | ||
1217 | if (data->wsize != 0) | ||
1218 | server->wsize = nfs_block_size(data->wsize, NULL); | ||
1219 | server->flags = data->flags & NFS_MOUNT_FLAGMASK; | ||
1220 | server->caps = NFS_CAP_ATOMIC_OPEN; | ||
1221 | |||
1222 | server->acregmin = data->acregmin*HZ; | ||
1223 | server->acregmax = data->acregmax*HZ; | ||
1224 | server->acdirmin = data->acdirmin*HZ; | ||
1225 | server->acdirmax = data->acdirmax*HZ; | ||
1226 | |||
1227 | server->rpc_ops = &nfs_v4_clientops; | ||
1228 | |||
1229 | nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans); | ||
1230 | |||
1231 | server->retrans_timeo = timeparms.to_initval; | ||
1232 | server->retrans_count = timeparms.to_retries; | ||
1233 | |||
1234 | /* Now create transport and client */ | ||
1235 | authflavour = RPC_AUTH_UNIX; | ||
1236 | if (data->auth_flavourlen != 0) { | ||
1237 | if (data->auth_flavourlen != 1) { | ||
1238 | dprintk("%s: Invalid number of RPC auth flavours %d.\n", | ||
1239 | __FUNCTION__, data->auth_flavourlen); | ||
1240 | err = -EINVAL; | ||
1241 | goto out_fail; | ||
1242 | } | ||
1243 | if (copy_from_user(&authflavour, data->auth_flavours, sizeof(authflavour))) { | ||
1244 | err = -EFAULT; | ||
1245 | goto out_fail; | ||
1246 | } | ||
1247 | } | ||
1248 | |||
1249 | server->client = nfs4_create_client(server, &timeparms, data->proto, authflavour); | ||
1250 | if (IS_ERR(server->client)) { | ||
1251 | err = PTR_ERR(server->client); | ||
1252 | dprintk("%s: cannot create RPC client. Error = %d\n", | ||
1253 | __FUNCTION__, err); | ||
1254 | goto out_fail; | ||
1255 | } | ||
1256 | |||
1257 | sb->s_time_gran = 1; | ||
1258 | |||
1259 | sb->s_op = &nfs4_sops; | ||
1260 | err = nfs_sb_init(sb, authflavour); | ||
1261 | |||
1262 | out_fail: | ||
1263 | return err; | ||
1264 | } | ||
1265 | |||
1266 | static int nfs4_compare_super(struct super_block *sb, void *data) | ||
1267 | { | ||
1268 | struct nfs_server *server = data; | ||
1269 | struct nfs_server *old = NFS_SB(sb); | ||
1270 | |||
1271 | if (strcmp(server->hostname, old->hostname) != 0) | ||
1272 | return 0; | ||
1273 | if (strcmp(server->mnt_path, old->mnt_path) != 0) | ||
1274 | return 0; | ||
1275 | return 1; | ||
1276 | } | ||
1277 | |||
1278 | static void * | ||
1279 | nfs_copy_user_string(char *dst, struct nfs_string *src, int maxlen) | ||
1280 | { | ||
1281 | void *p = NULL; | ||
1282 | |||
1283 | if (!src->len) | ||
1284 | return ERR_PTR(-EINVAL); | ||
1285 | if (src->len < maxlen) | ||
1286 | maxlen = src->len; | ||
1287 | if (dst == NULL) { | ||
1288 | p = dst = kmalloc(maxlen + 1, GFP_KERNEL); | ||
1289 | if (p == NULL) | ||
1290 | return ERR_PTR(-ENOMEM); | ||
1291 | } | ||
1292 | if (copy_from_user(dst, src->data, maxlen)) { | ||
1293 | kfree(p); | ||
1294 | return ERR_PTR(-EFAULT); | ||
1295 | } | ||
1296 | dst[maxlen] = '\0'; | ||
1297 | return dst; | ||
1298 | } | ||
1299 | |||
1300 | static int nfs4_get_sb(struct file_system_type *fs_type, | ||
1301 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1302 | { | ||
1303 | int error; | ||
1304 | struct nfs_server *server; | ||
1305 | struct super_block *s; | ||
1306 | struct nfs4_mount_data *data = raw_data; | ||
1307 | void *p; | ||
1308 | |||
1309 | if (data == NULL) { | ||
1310 | dprintk("%s: missing data argument\n", __FUNCTION__); | ||
1311 | return -EINVAL; | ||
1312 | } | ||
1313 | if (data->version <= 0 || data->version > NFS4_MOUNT_VERSION) { | ||
1314 | dprintk("%s: bad mount version\n", __FUNCTION__); | ||
1315 | return -EINVAL; | ||
1316 | } | ||
1317 | |||
1318 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1319 | if (!server) | ||
1320 | return -ENOMEM; | ||
1321 | /* Zero out the NFS state stuff */ | ||
1322 | init_nfsv4_state(server); | ||
1323 | server->client = server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1324 | |||
1325 | p = nfs_copy_user_string(NULL, &data->hostname, 256); | ||
1326 | if (IS_ERR(p)) | ||
1327 | goto out_err; | ||
1328 | server->hostname = p; | ||
1329 | |||
1330 | p = nfs_copy_user_string(NULL, &data->mnt_path, 1024); | ||
1331 | if (IS_ERR(p)) | ||
1332 | goto out_err; | ||
1333 | server->mnt_path = p; | ||
1334 | |||
1335 | p = nfs_copy_user_string(server->ip_addr, &data->client_addr, | ||
1336 | sizeof(server->ip_addr) - 1); | ||
1337 | if (IS_ERR(p)) | ||
1338 | goto out_err; | ||
1339 | |||
1340 | /* We now require that the mount process passes the remote address */ | ||
1341 | if (data->host_addrlen != sizeof(server->addr)) { | ||
1342 | error = -EINVAL; | ||
1343 | goto out_free; | ||
1344 | } | ||
1345 | if (copy_from_user(&server->addr, data->host_addr, sizeof(server->addr))) { | ||
1346 | error = -EFAULT; | ||
1347 | goto out_free; | ||
1348 | } | ||
1349 | if (server->addr.sin_family != AF_INET || | ||
1350 | server->addr.sin_addr.s_addr == INADDR_ANY) { | ||
1351 | dprintk("%s: mount program didn't pass remote IP address!\n", | ||
1352 | __FUNCTION__); | ||
1353 | error = -EINVAL; | ||
1354 | goto out_free; | ||
1355 | } | ||
1356 | |||
1357 | /* Fire up rpciod if not yet running */ | ||
1358 | error = rpciod_up(); | ||
1359 | if (error < 0) { | ||
1360 | dprintk("%s: couldn't start rpciod! Error = %d\n", | ||
1361 | __FUNCTION__, error); | ||
1362 | goto out_free; | ||
1363 | } | ||
1364 | |||
1365 | s = sget(fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1366 | |||
1367 | if (IS_ERR(s)) { | ||
1368 | error = PTR_ERR(s); | ||
1369 | goto out_free; | ||
1370 | } | ||
1371 | |||
1372 | if (s->s_root) { | ||
1373 | kfree(server->mnt_path); | ||
1374 | kfree(server->hostname); | ||
1375 | kfree(server); | ||
1376 | return simple_set_mnt(mnt, s); | ||
1377 | } | ||
1378 | |||
1379 | s->s_flags = flags; | ||
1380 | |||
1381 | error = nfs4_fill_super(s, data, flags & MS_SILENT ? 1 : 0); | ||
1382 | if (error) { | ||
1383 | up_write(&s->s_umount); | ||
1384 | deactivate_super(s); | ||
1385 | return error; | ||
1386 | } | ||
1387 | s->s_flags |= MS_ACTIVE; | ||
1388 | return simple_set_mnt(mnt, s); | ||
1389 | out_err: | ||
1390 | error = PTR_ERR(p); | ||
1391 | out_free: | ||
1392 | kfree(server->mnt_path); | ||
1393 | kfree(server->hostname); | ||
1394 | kfree(server); | ||
1395 | return error; | ||
1396 | } | ||
1397 | |||
1398 | static void nfs4_kill_super(struct super_block *sb) | ||
1399 | { | ||
1400 | struct nfs_server *server = NFS_SB(sb); | ||
1401 | |||
1402 | nfs_return_all_delegations(sb); | ||
1403 | kill_anon_super(sb); | ||
1404 | |||
1405 | nfs4_renewd_prepare_shutdown(server); | ||
1406 | |||
1407 | if (server->client != NULL && !IS_ERR(server->client)) | ||
1408 | rpc_shutdown_client(server->client); | ||
1409 | |||
1410 | destroy_nfsv4_state(server); | ||
1411 | |||
1412 | rpciod_down(); | ||
1413 | |||
1414 | nfs_free_iostats(server->io_stats); | ||
1415 | kfree(server->hostname); | ||
1416 | kfree(server); | ||
1417 | nfs_release_automount_timer(); | ||
1418 | } | ||
1419 | |||
1420 | /* | ||
1421 | * Constructs the SERVER-side path | ||
1422 | */ | ||
1423 | static inline char *nfs4_dup_path(const struct dentry *dentry) | ||
1424 | { | ||
1425 | char *page = (char *) __get_free_page(GFP_USER); | ||
1426 | char *path; | ||
1427 | |||
1428 | path = nfs4_path(dentry, page, PAGE_SIZE); | ||
1429 | if (!IS_ERR(path)) { | ||
1430 | int len = PAGE_SIZE + page - path; | ||
1431 | char *tmp = path; | ||
1432 | |||
1433 | path = kmalloc(len, GFP_KERNEL); | ||
1434 | if (path) | ||
1435 | memcpy(path, tmp, len); | ||
1436 | else | ||
1437 | path = ERR_PTR(-ENOMEM); | ||
1438 | } | ||
1439 | free_page((unsigned long)page); | ||
1440 | return path; | ||
1441 | } | ||
1442 | |||
1443 | static struct super_block *nfs4_clone_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1444 | { | ||
1445 | const struct dentry *dentry = data->dentry; | ||
1446 | struct nfs4_client *clp = server->nfs4_state; | ||
1447 | struct super_block *sb; | ||
1448 | |||
1449 | server->fsid = data->fattr->fsid; | ||
1450 | nfs_copy_fh(&server->fh, data->fh); | ||
1451 | server->mnt_path = nfs4_dup_path(dentry); | ||
1452 | if (IS_ERR(server->mnt_path)) { | ||
1453 | sb = (struct super_block *)server->mnt_path; | ||
1454 | goto err; | ||
1455 | } | ||
1456 | sb = sget(&nfs4_fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1457 | if (IS_ERR(sb) || sb->s_root) | ||
1458 | goto free_path; | ||
1459 | nfs4_server_capabilities(server, &server->fh); | ||
1460 | |||
1461 | down_write(&clp->cl_sem); | ||
1462 | atomic_inc(&clp->cl_count); | ||
1463 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
1464 | up_write(&clp->cl_sem); | ||
1465 | return sb; | ||
1466 | free_path: | ||
1467 | kfree(server->mnt_path); | ||
1468 | err: | ||
1469 | server->mnt_path = NULL; | ||
1470 | return sb; | ||
1471 | } | ||
1472 | |||
1473 | static int nfs_clone_nfs4_sb(struct file_system_type *fs_type, | ||
1474 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1475 | { | ||
1476 | struct nfs_clone_mount *data = raw_data; | ||
1477 | return nfs_clone_generic_sb(data, nfs4_clone_sb, nfs_clone_server, mnt); | ||
1478 | } | ||
1479 | |||
1480 | static struct super_block *nfs4_referral_sb(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1481 | { | ||
1482 | struct super_block *sb = ERR_PTR(-ENOMEM); | ||
1483 | int len; | ||
1484 | |||
1485 | len = strlen(data->mnt_path) + 1; | ||
1486 | server->mnt_path = kmalloc(len, GFP_KERNEL); | ||
1487 | if (server->mnt_path == NULL) | ||
1488 | goto err; | ||
1489 | memcpy(server->mnt_path, data->mnt_path, len); | ||
1490 | memcpy(&server->addr, data->addr, sizeof(struct sockaddr_in)); | ||
1491 | |||
1492 | sb = sget(&nfs4_fs_type, nfs4_compare_super, nfs_set_super, server); | ||
1493 | if (IS_ERR(sb) || sb->s_root) | ||
1494 | goto free_path; | ||
1495 | return sb; | ||
1496 | free_path: | ||
1497 | kfree(server->mnt_path); | ||
1498 | err: | ||
1499 | server->mnt_path = NULL; | ||
1500 | return sb; | ||
1501 | } | ||
1502 | |||
1503 | static struct nfs_server *nfs4_referral_server(struct super_block *sb, struct nfs_clone_mount *data) | ||
1504 | { | ||
1505 | struct nfs_server *server = NFS_SB(sb); | ||
1506 | struct rpc_timeout timeparms; | ||
1507 | int proto, timeo, retrans; | ||
1508 | void *err; | ||
1509 | |||
1510 | proto = IPPROTO_TCP; | ||
1511 | /* Since we are following a referral and there may be alternatives, | ||
1512 | set the timeouts and retries to low values */ | ||
1513 | timeo = 2; | ||
1514 | retrans = 1; | ||
1515 | nfs_init_timeout_values(&timeparms, proto, timeo, retrans); | ||
1516 | |||
1517 | server->client = nfs4_create_client(server, &timeparms, proto, data->authflavor); | ||
1518 | if (IS_ERR((err = server->client))) | ||
1519 | goto out_err; | ||
1520 | |||
1521 | sb->s_time_gran = 1; | ||
1522 | sb->s_op = &nfs4_sops; | ||
1523 | err = ERR_PTR(nfs_sb_init(sb, data->authflavor)); | ||
1524 | if (!IS_ERR(err)) | ||
1525 | return server; | ||
1526 | out_err: | ||
1527 | return (struct nfs_server *)err; | ||
1528 | } | ||
1529 | |||
1530 | static int nfs_referral_nfs4_sb(struct file_system_type *fs_type, | ||
1531 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | ||
1532 | { | ||
1533 | struct nfs_clone_mount *data = raw_data; | ||
1534 | return nfs_clone_generic_sb(data, nfs4_referral_sb, nfs4_referral_server, mnt); | ||
1535 | } | ||
1536 | |||
1537 | #endif | ||