diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/Makefile | 3 | ||||
-rw-r--r-- | fs/nfs/dir.c | 16 | ||||
-rw-r--r-- | fs/nfs/inode.c | 303 | ||||
-rw-r--r-- | fs/nfs/namespace.c | 89 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 |
6 files changed, 409 insertions, 5 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index ec61fd56a1a9..d9d494cee388 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile | |||
@@ -5,7 +5,8 @@ | |||
5 | obj-$(CONFIG_NFS_FS) += nfs.o | 5 | obj-$(CONFIG_NFS_FS) += nfs.o |
6 | 6 | ||
7 | nfs-y := dir.o file.o inode.o nfs2xdr.o pagelist.o \ | 7 | nfs-y := dir.o file.o inode.o nfs2xdr.o pagelist.o \ |
8 | proc.o read.o symlink.o unlink.o write.o | 8 | proc.o read.o symlink.o unlink.o write.o \ |
9 | namespace.o | ||
9 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o | 10 | nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o |
10 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o | 11 | nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o |
11 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o | 12 | nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1d3d8922a663..3ddda6f7ecc2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -868,6 +868,17 @@ int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) | |||
868 | return (nd->intent.open.flags & O_EXCL) != 0; | 868 | return (nd->intent.open.flags & O_EXCL) != 0; |
869 | } | 869 | } |
870 | 870 | ||
871 | static inline int nfs_reval_fsid(struct inode *dir, | ||
872 | struct nfs_fh *fh, struct nfs_fattr *fattr) | ||
873 | { | ||
874 | struct nfs_server *server = NFS_SERVER(dir); | ||
875 | |||
876 | if (!nfs_fsid_equal(&server->fsid, &fattr->fsid)) | ||
877 | /* Revalidate fsid on root dir */ | ||
878 | return __nfs_revalidate_inode(server, dir->i_sb->s_root->d_inode); | ||
879 | return 0; | ||
880 | } | ||
881 | |||
871 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) | 882 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) |
872 | { | 883 | { |
873 | struct dentry *res; | 884 | struct dentry *res; |
@@ -900,6 +911,11 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
900 | res = ERR_PTR(error); | 911 | res = ERR_PTR(error); |
901 | goto out_unlock; | 912 | goto out_unlock; |
902 | } | 913 | } |
914 | error = nfs_reval_fsid(dir, &fhandle, &fattr); | ||
915 | if (error < 0) { | ||
916 | res = ERR_PTR(error); | ||
917 | goto out_unlock; | ||
918 | } | ||
903 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); | 919 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); |
904 | res = (struct dentry *)inode; | 920 | res = (struct dentry *)inode; |
905 | if (IS_ERR(res)) | 921 | if (IS_ERR(res)) |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 1a809f6f8989..47167ab64f5b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -221,6 +221,14 @@ nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) | |||
221 | return nfs_block_bits(bsize, nrbitsp); | 221 | return nfs_block_bits(bsize, nrbitsp); |
222 | } | 222 | } |
223 | 223 | ||
224 | static inline void | ||
225 | nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize) | ||
226 | { | ||
227 | sb->s_maxbytes = (loff_t)maxfilesize; | ||
228 | if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) | ||
229 | sb->s_maxbytes = MAX_LFS_FILESIZE; | ||
230 | } | ||
231 | |||
224 | /* | 232 | /* |
225 | * Obtain the root inode of the file system. | 233 | * Obtain the root inode of the file system. |
226 | */ | 234 | */ |
@@ -331,9 +339,7 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) | |||
331 | } | 339 | } |
332 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; | 340 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; |
333 | 341 | ||
334 | sb->s_maxbytes = fsinfo.maxfilesize; | 342 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); |
335 | if (sb->s_maxbytes > MAX_LFS_FILESIZE) | ||
336 | sb->s_maxbytes = MAX_LFS_FILESIZE; | ||
337 | 343 | ||
338 | server->client->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0; | 344 | server->client->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0; |
339 | server->client->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0; | 345 | server->client->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0; |
@@ -877,6 +883,11 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
877 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) | 883 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) |
878 | && fattr->size <= NFS_LIMIT_READDIRPLUS) | 884 | && fattr->size <= NFS_LIMIT_READDIRPLUS) |
879 | set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); | 885 | set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); |
886 | /* Deal with crossing mountpoints */ | ||
887 | if (!nfs_fsid_equal(&NFS_SB(sb)->fsid, &fattr->fsid)) { | ||
888 | inode->i_op = &nfs_mountpoint_inode_operations; | ||
889 | inode->i_fop = NULL; | ||
890 | } | ||
880 | } else if (S_ISLNK(inode->i_mode)) | 891 | } else if (S_ISLNK(inode->i_mode)) |
881 | inode->i_op = &nfs_symlink_inode_operations; | 892 | inode->i_op = &nfs_symlink_inode_operations; |
882 | else | 893 | else |
@@ -1650,6 +1661,141 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1650 | * File system information | 1661 | * File system information |
1651 | */ | 1662 | */ |
1652 | 1663 | ||
1664 | /* | ||
1665 | * nfs_path - reconstruct the path given an arbitrary dentry | ||
1666 | * @base - arbitrary string to prepend to the path | ||
1667 | * @dentry - pointer to dentry | ||
1668 | * @buffer - result buffer | ||
1669 | * @buflen - length of buffer | ||
1670 | * | ||
1671 | * Helper function for constructing the path from the | ||
1672 | * root dentry to an arbitrary hashed dentry. | ||
1673 | * | ||
1674 | * This is mainly for use in figuring out the path on the | ||
1675 | * server side when automounting on top of an existing partition. | ||
1676 | */ | ||
1677 | static char *nfs_path(const char *base, const struct dentry *dentry, | ||
1678 | char *buffer, ssize_t buflen) | ||
1679 | { | ||
1680 | char *end = buffer+buflen; | ||
1681 | int namelen; | ||
1682 | |||
1683 | *--end = '\0'; | ||
1684 | buflen--; | ||
1685 | spin_lock(&dcache_lock); | ||
1686 | while (!IS_ROOT(dentry)) { | ||
1687 | namelen = dentry->d_name.len; | ||
1688 | buflen -= namelen + 1; | ||
1689 | if (buflen < 0) | ||
1690 | goto Elong; | ||
1691 | end -= namelen; | ||
1692 | memcpy(end, dentry->d_name.name, namelen); | ||
1693 | *--end = '/'; | ||
1694 | dentry = dentry->d_parent; | ||
1695 | } | ||
1696 | spin_unlock(&dcache_lock); | ||
1697 | namelen = strlen(base); | ||
1698 | /* Strip off excess slashes in base string */ | ||
1699 | while (namelen > 0 && base[namelen - 1] == '/') | ||
1700 | namelen--; | ||
1701 | buflen -= namelen; | ||
1702 | if (buflen < 0) | ||
1703 | goto Elong; | ||
1704 | end -= namelen; | ||
1705 | memcpy(end, base, namelen); | ||
1706 | return end; | ||
1707 | Elong: | ||
1708 | return ERR_PTR(-ENAMETOOLONG); | ||
1709 | } | ||
1710 | |||
1711 | struct nfs_clone_mount { | ||
1712 | const struct super_block *sb; | ||
1713 | const struct dentry *dentry; | ||
1714 | struct nfs_fh *fh; | ||
1715 | struct nfs_fattr *fattr; | ||
1716 | }; | ||
1717 | |||
1718 | static struct super_block *nfs_clone_generic_sb(struct nfs_clone_mount *data, | ||
1719 | struct super_block *(*clone_client)(struct nfs_server *, struct nfs_clone_mount *)) | ||
1720 | { | ||
1721 | struct nfs_server *server; | ||
1722 | struct nfs_server *parent = NFS_SB(data->sb); | ||
1723 | struct super_block *sb = ERR_PTR(-EINVAL); | ||
1724 | void *err = ERR_PTR(-ENOMEM); | ||
1725 | struct inode *root_inode; | ||
1726 | struct nfs_fsinfo fsinfo; | ||
1727 | int len; | ||
1728 | |||
1729 | server = kmalloc(sizeof(struct nfs_server), GFP_KERNEL); | ||
1730 | if (server == NULL) | ||
1731 | goto out_err; | ||
1732 | memcpy(server, parent, sizeof(*server)); | ||
1733 | len = strlen(parent->hostname) + 1; | ||
1734 | server->hostname = kmalloc(len, GFP_KERNEL); | ||
1735 | if (server->hostname == NULL) | ||
1736 | goto free_server; | ||
1737 | memcpy(server->hostname, parent->hostname, len); | ||
1738 | server->fsid = data->fattr->fsid; | ||
1739 | nfs_copy_fh(&server->fh, data->fh); | ||
1740 | if (rpciod_up() != 0) | ||
1741 | goto free_hostname; | ||
1742 | |||
1743 | sb = clone_client(server, data); | ||
1744 | if (IS_ERR((err = sb)) || sb->s_root) | ||
1745 | goto kill_rpciod; | ||
1746 | |||
1747 | sb->s_op = data->sb->s_op; | ||
1748 | sb->s_blocksize = data->sb->s_blocksize; | ||
1749 | sb->s_blocksize_bits = data->sb->s_blocksize_bits; | ||
1750 | sb->s_maxbytes = data->sb->s_maxbytes; | ||
1751 | |||
1752 | server->client_sys = server->client_acl = ERR_PTR(-EINVAL); | ||
1753 | err = ERR_PTR(-ENOMEM); | ||
1754 | server->io_stats = nfs_alloc_iostats(); | ||
1755 | if (server->io_stats == NULL) | ||
1756 | goto out_deactivate; | ||
1757 | |||
1758 | server->client = rpc_clone_client(parent->client); | ||
1759 | if (IS_ERR((err = server->client))) | ||
1760 | goto out_deactivate; | ||
1761 | if (!IS_ERR(parent->client_sys)) { | ||
1762 | server->client_sys = rpc_clone_client(parent->client_sys); | ||
1763 | if (IS_ERR((err = server->client_sys))) | ||
1764 | goto out_deactivate; | ||
1765 | } | ||
1766 | if (!IS_ERR(parent->client_acl)) { | ||
1767 | server->client_acl = rpc_clone_client(parent->client_acl); | ||
1768 | if (IS_ERR((err = server->client_acl))) | ||
1769 | goto out_deactivate; | ||
1770 | } | ||
1771 | root_inode = nfs_fhget(sb, data->fh, data->fattr); | ||
1772 | if (!root_inode) | ||
1773 | goto out_deactivate; | ||
1774 | sb->s_root = d_alloc_root(root_inode); | ||
1775 | if (!sb->s_root) | ||
1776 | goto out_put_root; | ||
1777 | fsinfo.fattr = data->fattr; | ||
1778 | if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0) | ||
1779 | nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); | ||
1780 | sb->s_root->d_op = server->rpc_ops->dentry_ops; | ||
1781 | sb->s_flags |= MS_ACTIVE; | ||
1782 | return sb; | ||
1783 | out_put_root: | ||
1784 | iput(root_inode); | ||
1785 | out_deactivate: | ||
1786 | up_write(&sb->s_umount); | ||
1787 | deactivate_super(sb); | ||
1788 | return (struct super_block *)err; | ||
1789 | kill_rpciod: | ||
1790 | rpciod_down(); | ||
1791 | free_hostname: | ||
1792 | kfree(server->hostname); | ||
1793 | free_server: | ||
1794 | kfree(server); | ||
1795 | out_err: | ||
1796 | return (struct super_block *)err; | ||
1797 | } | ||
1798 | |||
1653 | static int nfs_set_super(struct super_block *s, void *data) | 1799 | static int nfs_set_super(struct super_block *s, void *data) |
1654 | { | 1800 | { |
1655 | s->s_fs_info = data; | 1801 | s->s_fs_info = data; |
@@ -1807,6 +1953,31 @@ static struct file_system_type nfs_fs_type = { | |||
1807 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | 1953 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, |
1808 | }; | 1954 | }; |
1809 | 1955 | ||
1956 | static struct super_block *nfs_clone_client(struct nfs_server *server, struct nfs_clone_mount *data) | ||
1957 | { | ||
1958 | struct super_block *sb; | ||
1959 | |||
1960 | sb = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server); | ||
1961 | if (!IS_ERR(sb) && sb->s_root == NULL && !(server->flags & NFS_MOUNT_NONLM)) | ||
1962 | lockd_up(); | ||
1963 | return sb; | ||
1964 | } | ||
1965 | |||
1966 | static struct super_block *nfs_clone_nfs_sb(struct file_system_type *fs_type, | ||
1967 | int flags, const char *dev_name, void *raw_data) | ||
1968 | { | ||
1969 | struct nfs_clone_mount *data = raw_data; | ||
1970 | return nfs_clone_generic_sb(data, nfs_clone_client); | ||
1971 | } | ||
1972 | |||
1973 | static struct file_system_type clone_nfs_fs_type = { | ||
1974 | .owner = THIS_MODULE, | ||
1975 | .name = "nfs", | ||
1976 | .get_sb = nfs_clone_nfs_sb, | ||
1977 | .kill_sb = nfs_kill_super, | ||
1978 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
1979 | }; | ||
1980 | |||
1810 | #ifdef CONFIG_NFS_V4 | 1981 | #ifdef CONFIG_NFS_V4 |
1811 | 1982 | ||
1812 | static void nfs4_clear_inode(struct inode *); | 1983 | static void nfs4_clear_inode(struct inode *); |
@@ -2156,6 +2327,75 @@ static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) | |||
2156 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, | 2327 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, |
2157 | &nfs_idmap_cache_timeout, 0644); | 2328 | &nfs_idmap_cache_timeout, 0644); |
2158 | 2329 | ||
2330 | /* Constructs the SERVER-side path */ | ||
2331 | static inline char *nfs4_path(const struct dentry *dentry, char *buffer, ssize_t buflen) | ||
2332 | { | ||
2333 | return nfs_path(NFS_SB(dentry->d_sb)->mnt_path, dentry, buffer, buflen); | ||
2334 | } | ||
2335 | |||
2336 | static inline char *nfs4_dup_path(const struct dentry *dentry) | ||
2337 | { | ||
2338 | char *page = (char *) __get_free_page(GFP_USER); | ||
2339 | char *path; | ||
2340 | |||
2341 | path = nfs4_path(dentry, page, PAGE_SIZE); | ||
2342 | if (!IS_ERR(path)) { | ||
2343 | int len = PAGE_SIZE + page - path; | ||
2344 | char *tmp = path; | ||
2345 | |||
2346 | path = kmalloc(len, GFP_KERNEL); | ||
2347 | if (path) | ||
2348 | memcpy(path, tmp, len); | ||
2349 | else | ||
2350 | path = ERR_PTR(-ENOMEM); | ||
2351 | } | ||
2352 | free_page((unsigned long)page); | ||
2353 | return path; | ||
2354 | } | ||
2355 | |||
2356 | static struct super_block *nfs4_clone_client(struct nfs_server *server, struct nfs_clone_mount *data) | ||
2357 | { | ||
2358 | const struct dentry *dentry = data->dentry; | ||
2359 | struct nfs4_client *clp = server->nfs4_state; | ||
2360 | struct super_block *sb; | ||
2361 | |||
2362 | server->mnt_path = nfs4_dup_path(dentry); | ||
2363 | if (IS_ERR(server->mnt_path)) { | ||
2364 | sb = (struct super_block *)server->mnt_path; | ||
2365 | goto err; | ||
2366 | } | ||
2367 | sb = sget(&nfs4_fs_type, nfs4_compare_super, nfs_set_super, server); | ||
2368 | if (IS_ERR(sb) || sb->s_root) | ||
2369 | goto free_path; | ||
2370 | nfs4_server_capabilities(server, &server->fh); | ||
2371 | |||
2372 | down_write(&clp->cl_sem); | ||
2373 | atomic_inc(&clp->cl_count); | ||
2374 | list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); | ||
2375 | up_write(&clp->cl_sem); | ||
2376 | return sb; | ||
2377 | free_path: | ||
2378 | kfree(server->mnt_path); | ||
2379 | err: | ||
2380 | server->mnt_path = NULL; | ||
2381 | return sb; | ||
2382 | } | ||
2383 | |||
2384 | static struct super_block *nfs_clone_nfs4_sb(struct file_system_type *fs_type, | ||
2385 | int flags, const char *dev_name, void *raw_data) | ||
2386 | { | ||
2387 | struct nfs_clone_mount *data = raw_data; | ||
2388 | return nfs_clone_generic_sb(data, nfs4_clone_client); | ||
2389 | } | ||
2390 | |||
2391 | static struct file_system_type clone_nfs4_fs_type = { | ||
2392 | .owner = THIS_MODULE, | ||
2393 | .name = "nfs", | ||
2394 | .get_sb = nfs_clone_nfs4_sb, | ||
2395 | .kill_sb = nfs4_kill_super, | ||
2396 | .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, | ||
2397 | }; | ||
2398 | |||
2159 | #define nfs4_init_once(nfsi) \ | 2399 | #define nfs4_init_once(nfsi) \ |
2160 | do { \ | 2400 | do { \ |
2161 | INIT_LIST_HEAD(&(nfsi)->open_states); \ | 2401 | INIT_LIST_HEAD(&(nfsi)->open_states); \ |
@@ -2183,12 +2423,69 @@ static inline void unregister_nfs4fs(void) | |||
2183 | nfs_unregister_sysctl(); | 2423 | nfs_unregister_sysctl(); |
2184 | } | 2424 | } |
2185 | #else | 2425 | #else |
2426 | #define nfs4_clone_client(a,b) ERR_PTR(-EINVAL) | ||
2186 | #define nfs4_init_once(nfsi) \ | 2427 | #define nfs4_init_once(nfsi) \ |
2187 | do { } while (0) | 2428 | do { } while (0) |
2188 | #define register_nfs4fs() (0) | 2429 | #define register_nfs4fs() (0) |
2189 | #define unregister_nfs4fs() | 2430 | #define unregister_nfs4fs() |
2190 | #endif | 2431 | #endif |
2191 | 2432 | ||
2433 | static inline char *nfs_devname(const struct vfsmount *mnt_parent, | ||
2434 | const struct dentry *dentry, | ||
2435 | char *buffer, ssize_t buflen) | ||
2436 | { | ||
2437 | return nfs_path(mnt_parent->mnt_devname, dentry, buffer, buflen); | ||
2438 | } | ||
2439 | |||
2440 | /** | ||
2441 | * nfs_do_submount - set up mountpoint when crossing a filesystem boundary | ||
2442 | * @mnt_parent - mountpoint of parent directory | ||
2443 | * @dentry - parent directory | ||
2444 | * @fh - filehandle for new root dentry | ||
2445 | * @fattr - attributes for new root inode | ||
2446 | * | ||
2447 | */ | ||
2448 | struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, | ||
2449 | const struct dentry *dentry, struct nfs_fh *fh, | ||
2450 | struct nfs_fattr *fattr) | ||
2451 | { | ||
2452 | struct nfs_clone_mount mountdata = { | ||
2453 | .sb = mnt_parent->mnt_sb, | ||
2454 | .dentry = dentry, | ||
2455 | .fh = fh, | ||
2456 | .fattr = fattr, | ||
2457 | }; | ||
2458 | struct vfsmount *mnt = ERR_PTR(-ENOMEM); | ||
2459 | char *page = (char *) __get_free_page(GFP_USER); | ||
2460 | char *devname; | ||
2461 | |||
2462 | dprintk("%s: submounting on %s/%s\n", __FUNCTION__, | ||
2463 | dentry->d_parent->d_name.name, | ||
2464 | dentry->d_name.name); | ||
2465 | if (page == NULL) | ||
2466 | goto out; | ||
2467 | devname = nfs_devname(mnt_parent, dentry, page, PAGE_SIZE); | ||
2468 | mnt = (struct vfsmount *)devname; | ||
2469 | if (IS_ERR(devname)) | ||
2470 | goto free_page; | ||
2471 | switch (NFS_SB(mnt_parent->mnt_sb)->rpc_ops->version) { | ||
2472 | case 2: | ||
2473 | case 3: | ||
2474 | mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, &mountdata); | ||
2475 | break; | ||
2476 | case 4: | ||
2477 | mnt = vfs_kern_mount(&clone_nfs4_fs_type, 0, devname, &mountdata); | ||
2478 | break; | ||
2479 | default: | ||
2480 | BUG(); | ||
2481 | } | ||
2482 | free_page: | ||
2483 | free_page((unsigned long)page); | ||
2484 | out: | ||
2485 | dprintk("%s: done\n", __FUNCTION__); | ||
2486 | return mnt; | ||
2487 | } | ||
2488 | |||
2192 | extern int nfs_init_nfspagecache(void); | 2489 | extern int nfs_init_nfspagecache(void); |
2193 | extern void nfs_destroy_nfspagecache(void); | 2490 | extern void nfs_destroy_nfspagecache(void); |
2194 | extern int nfs_init_readpagecache(void); | 2491 | extern int nfs_init_readpagecache(void); |
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c new file mode 100644 index 000000000000..a155505c36f1 --- /dev/null +++ b/fs/nfs/namespace.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | * linux/fs/nfs/namespace.c | ||
3 | * | ||
4 | * Copyright (C) 2005 Trond Myklebust <Trond.Myklebust@netapp.com> | ||
5 | * | ||
6 | * NFS namespace | ||
7 | */ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | |||
11 | #include <linux/dcache.h> | ||
12 | #include <linux/mount.h> | ||
13 | #include <linux/namei.h> | ||
14 | #include <linux/nfs_fs.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/sunrpc/clnt.h> | ||
17 | #include <linux/vfs.h> | ||
18 | |||
19 | #define NFSDBG_FACILITY NFSDBG_VFS | ||
20 | |||
21 | /* | ||
22 | * nfs_follow_mountpoint - handle crossing a mountpoint on the server | ||
23 | * @dentry - dentry of mountpoint | ||
24 | * @nd - nameidata info | ||
25 | * | ||
26 | * When we encounter a mountpoint on the server, we want to set up | ||
27 | * a mountpoint on the client too, to prevent inode numbers from | ||
28 | * colliding, and to allow "df" to work properly. | ||
29 | * On NFSv4, we also want to allow for the fact that different | ||
30 | * filesystems may be migrated to different servers in a failover | ||
31 | * situation, and that different filesystems may want to use | ||
32 | * different security flavours. | ||
33 | */ | ||
34 | static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | ||
35 | { | ||
36 | struct vfsmount *mnt; | ||
37 | struct nfs_server *server = NFS_SERVER(dentry->d_inode); | ||
38 | struct dentry *parent; | ||
39 | struct nfs_fh fh; | ||
40 | struct nfs_fattr fattr; | ||
41 | int err; | ||
42 | |||
43 | BUG_ON(IS_ROOT(dentry)); | ||
44 | dprintk("%s: enter\n", __FUNCTION__); | ||
45 | dput(nd->dentry); | ||
46 | nd->dentry = dget(dentry); | ||
47 | if (d_mountpoint(nd->dentry)) | ||
48 | goto out_follow; | ||
49 | /* Look it up again */ | ||
50 | parent = dget_parent(nd->dentry); | ||
51 | err = server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &fh, &fattr); | ||
52 | dput(parent); | ||
53 | if (err != 0) | ||
54 | goto out_err; | ||
55 | |||
56 | mnt = nfs_do_submount(nd->mnt, nd->dentry, &fh, &fattr); | ||
57 | err = PTR_ERR(mnt); | ||
58 | if (IS_ERR(mnt)) | ||
59 | goto out_err; | ||
60 | |||
61 | mntget(mnt); | ||
62 | err = do_add_mount(mnt, nd, nd->mnt->mnt_flags, NULL); | ||
63 | if (err < 0) { | ||
64 | mntput(mnt); | ||
65 | if (err == -EBUSY) | ||
66 | goto out_follow; | ||
67 | goto out_err; | ||
68 | } | ||
69 | mntput(nd->mnt); | ||
70 | dput(nd->dentry); | ||
71 | nd->mnt = mnt; | ||
72 | nd->dentry = dget(mnt->mnt_root); | ||
73 | out: | ||
74 | dprintk("%s: done, returned %d\n", __FUNCTION__, err); | ||
75 | return ERR_PTR(err); | ||
76 | out_err: | ||
77 | path_release(nd); | ||
78 | goto out; | ||
79 | out_follow: | ||
80 | while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) | ||
81 | ; | ||
82 | err = 0; | ||
83 | goto out; | ||
84 | } | ||
85 | |||
86 | struct inode_operations nfs_mountpoint_inode_operations = { | ||
87 | .follow_link = nfs_follow_mountpoint, | ||
88 | .getattr = nfs_getattr, | ||
89 | }; | ||
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 0f5e4e7cddec..307832fd1a49 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -217,6 +217,7 @@ extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); | |||
217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); | 217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); |
218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
220 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); | ||
220 | 221 | ||
221 | extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; | 222 | extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; |
222 | extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; | 223 | extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ef4c6cccf958..308407205e6c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -1331,7 +1331,7 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f | |||
1331 | return status; | 1331 | return status; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | static int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) | 1334 | int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) |
1335 | { | 1335 | { |
1336 | struct nfs4_exception exception = { }; | 1336 | struct nfs4_exception exception = { }; |
1337 | int err; | 1337 | int err; |