diff options
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 867f70504531..810770f96816 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -728,6 +728,27 @@ static void nfs_umount_begin(struct super_block *sb) | |||
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 | * |
@@ -1430,10 +1451,13 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1430 | int status; | 1451 | int status; |
1431 | 1452 | ||
1432 | if (args->mount_server.version == 0) { | 1453 | if (args->mount_server.version == 0) { |
1433 | if (args->flags & NFS_MOUNT_VER3) | 1454 | switch (args->version) { |
1434 | args->mount_server.version = NFS_MNT3_VERSION; | 1455 | default: |
1435 | else | 1456 | args->mount_server.version = NFS_MNT3_VERSION; |
1436 | args->mount_server.version = NFS_MNT_VERSION; | 1457 | break; |
1458 | case 2: | ||
1459 | args->mount_server.version = NFS_MNT_VERSION; | ||
1460 | } | ||
1437 | } | 1461 | } |
1438 | request.version = args->mount_server.version; | 1462 | request.version = args->mount_server.version; |
1439 | 1463 | ||
@@ -1634,20 +1658,6 @@ static int nfs_validate_mount_data(void *options, | |||
1634 | if (data == NULL) | 1658 | if (data == NULL) |
1635 | goto out_no_data; | 1659 | goto out_no_data; |
1636 | 1660 | ||
1637 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); | ||
1638 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
1639 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
1640 | args->acregmin = NFS_DEF_ACREGMIN; | ||
1641 | args->acregmax = NFS_DEF_ACREGMAX; | ||
1642 | args->acdirmin = NFS_DEF_ACDIRMIN; | ||
1643 | args->acdirmax = NFS_DEF_ACDIRMAX; | ||
1644 | args->mount_server.port = NFS_UNSPEC_PORT; | ||
1645 | args->nfs_server.port = NFS_UNSPEC_PORT; | ||
1646 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
1647 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1648 | args->auth_flavor_len = 1; | ||
1649 | args->minorversion = 0; | ||
1650 | |||
1651 | switch (data->version) { | 1661 | switch (data->version) { |
1652 | case 1: | 1662 | case 1: |
1653 | data->namlen = 0; | 1663 | data->namlen = 0; |
@@ -1778,7 +1788,7 @@ static int nfs_validate_mount_data(void *options, | |||
1778 | } | 1788 | } |
1779 | 1789 | ||
1780 | #ifndef CONFIG_NFS_V3 | 1790 | #ifndef CONFIG_NFS_V3 |
1781 | if (args->flags & NFS_MOUNT_VER3) | 1791 | if (args->version == 3) |
1782 | goto out_v3_not_compiled; | 1792 | goto out_v3_not_compiled; |
1783 | #endif /* !CONFIG_NFS_V3 */ | 1793 | #endif /* !CONFIG_NFS_V3 */ |
1784 | 1794 | ||
@@ -1918,6 +1928,8 @@ static inline void nfs_initialise_sb(struct super_block *sb) | |||
1918 | if (server->flags & NFS_MOUNT_NOAC) | 1928 | if (server->flags & NFS_MOUNT_NOAC) |
1919 | sb->s_flags |= MS_SYNCHRONOUS; | 1929 | sb->s_flags |= MS_SYNCHRONOUS; |
1920 | 1930 | ||
1931 | sb->s_bdi = &server->backing_dev_info; | ||
1932 | |||
1921 | nfs_super_set_maxbytes(sb, server->maxfilesize); | 1933 | nfs_super_set_maxbytes(sb, server->maxfilesize); |
1922 | } | 1934 | } |
1923 | 1935 | ||
@@ -1934,7 +1946,7 @@ static void nfs_fill_super(struct super_block *sb, | |||
1934 | if (data->bsize) | 1946 | if (data->bsize) |
1935 | 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); |
1936 | 1948 | ||
1937 | if (server->flags & NFS_MOUNT_VER3) { | 1949 | if (server->nfs_client->rpc_ops->version == 3) { |
1938 | /* 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 |
1939 | * so ourselves when necessary. | 1951 | * so ourselves when necessary. |
1940 | */ | 1952 | */ |
@@ -1958,7 +1970,7 @@ static void nfs_clone_super(struct super_block *sb, | |||
1958 | sb->s_blocksize = old_sb->s_blocksize; | 1970 | sb->s_blocksize = old_sb->s_blocksize; |
1959 | sb->s_maxbytes = old_sb->s_maxbytes; | 1971 | sb->s_maxbytes = old_sb->s_maxbytes; |
1960 | 1972 | ||
1961 | if (server->flags & NFS_MOUNT_VER3) { | 1973 | if (server->nfs_client->rpc_ops->version == 3) { |
1962 | /* 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 |
1963 | * so ourselves when necessary. | 1975 | * so ourselves when necessary. |
1964 | */ | 1976 | */ |
@@ -2092,7 +2104,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
2092 | }; | 2104 | }; |
2093 | int error = -ENOMEM; | 2105 | int error = -ENOMEM; |
2094 | 2106 | ||
2095 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 2107 | data = nfs_alloc_parsed_mount_data(NFS_MOUNT_VER3 | NFS_MOUNT_TCP); |
2096 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); | 2108 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); |
2097 | if (data == NULL || mntfh == NULL) | 2109 | if (data == NULL || mntfh == NULL) |
2098 | goto out_free_fh; | 2110 | goto out_free_fh; |
@@ -2142,7 +2154,8 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
2142 | if (!s->s_root) { | 2154 | if (!s->s_root) { |
2143 | /* initial superblock/root creation */ | 2155 | /* initial superblock/root creation */ |
2144 | nfs_fill_super(s, data); | 2156 | nfs_fill_super(s, data); |
2145 | nfs_fscache_get_super_cookie(s, data); | 2157 | nfs_fscache_get_super_cookie( |
2158 | s, data ? data->fscache_uniq : NULL, NULL); | ||
2146 | } | 2159 | } |
2147 | 2160 | ||
2148 | mntroot = nfs_get_root(s, mntfh); | 2161 | mntroot = nfs_get_root(s, mntfh); |
@@ -2188,8 +2201,8 @@ static void nfs_kill_super(struct super_block *s) | |||
2188 | { | 2201 | { |
2189 | struct nfs_server *server = NFS_SB(s); | 2202 | struct nfs_server *server = NFS_SB(s); |
2190 | 2203 | ||
2191 | bdi_unregister(&server->backing_dev_info); | ||
2192 | kill_anon_super(s); | 2204 | kill_anon_super(s); |
2205 | bdi_unregister(&server->backing_dev_info); | ||
2193 | nfs_fscache_release_super_cookie(s); | 2206 | nfs_fscache_release_super_cookie(s); |
2194 | nfs_free_server(server); | 2207 | nfs_free_server(server); |
2195 | } | 2208 | } |
@@ -2243,6 +2256,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, | |||
2243 | if (!s->s_root) { | 2256 | if (!s->s_root) { |
2244 | /* initial superblock/root creation */ | 2257 | /* initial superblock/root creation */ |
2245 | nfs_clone_super(s, data->sb); | 2258 | nfs_clone_super(s, data->sb); |
2259 | nfs_fscache_get_super_cookie(s, NULL, data); | ||
2246 | } | 2260 | } |
2247 | 2261 | ||
2248 | mntroot = nfs_get_root(s, data->fh); | 2262 | mntroot = nfs_get_root(s, data->fh); |
@@ -2360,18 +2374,7 @@ static int nfs4_validate_mount_data(void *options, | |||
2360 | if (data == NULL) | 2374 | if (data == NULL) |
2361 | goto out_no_data; | 2375 | goto out_no_data; |
2362 | 2376 | ||
2363 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
2364 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
2365 | args->acregmin = NFS_DEF_ACREGMIN; | ||
2366 | args->acregmax = NFS_DEF_ACREGMAX; | ||
2367 | args->acdirmin = NFS_DEF_ACDIRMIN; | ||
2368 | args->acdirmax = NFS_DEF_ACDIRMAX; | ||
2369 | args->nfs_server.port = NFS_UNSPEC_PORT; | ||
2370 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
2371 | args->auth_flavor_len = 1; | ||
2372 | args->version = 4; | 2377 | args->version = 4; |
2373 | args->minorversion = 0; | ||
2374 | |||
2375 | switch (data->version) { | 2378 | switch (data->version) { |
2376 | case 1: | 2379 | case 1: |
2377 | if (data->host_addrlen > sizeof(args->nfs_server.address)) | 2380 | if (data->host_addrlen > sizeof(args->nfs_server.address)) |
@@ -2506,7 +2509,8 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, | |||
2506 | if (!s->s_root) { | 2509 | if (!s->s_root) { |
2507 | /* initial superblock/root creation */ | 2510 | /* initial superblock/root creation */ |
2508 | nfs4_fill_super(s); | 2511 | nfs4_fill_super(s); |
2509 | nfs_fscache_get_super_cookie(s, data); | 2512 | nfs_fscache_get_super_cookie( |
2513 | s, data ? data->fscache_uniq : NULL, NULL); | ||
2510 | } | 2514 | } |
2511 | 2515 | ||
2512 | mntroot = nfs4_get_root(s, mntfh); | 2516 | mntroot = nfs4_get_root(s, mntfh); |
@@ -2654,7 +2658,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type, | |||
2654 | struct nfs_parsed_mount_data *data; | 2658 | struct nfs_parsed_mount_data *data; |
2655 | int error = -ENOMEM; | 2659 | int error = -ENOMEM; |
2656 | 2660 | ||
2657 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 2661 | data = nfs_alloc_parsed_mount_data(0); |
2658 | if (data == NULL) | 2662 | if (data == NULL) |
2659 | goto out_free_data; | 2663 | goto out_free_data; |
2660 | 2664 | ||
@@ -2739,6 +2743,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, | |||
2739 | if (!s->s_root) { | 2743 | if (!s->s_root) { |
2740 | /* initial superblock/root creation */ | 2744 | /* initial superblock/root creation */ |
2741 | nfs4_clone_super(s, data->sb); | 2745 | nfs4_clone_super(s, data->sb); |
2746 | nfs_fscache_get_super_cookie(s, NULL, data); | ||
2742 | } | 2747 | } |
2743 | 2748 | ||
2744 | mntroot = nfs4_get_root(s, data->fh); | 2749 | mntroot = nfs4_get_root(s, data->fh); |
@@ -2820,6 +2825,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, | |||
2820 | if (!s->s_root) { | 2825 | if (!s->s_root) { |
2821 | /* initial superblock/root creation */ | 2826 | /* initial superblock/root creation */ |
2822 | nfs4_fill_super(s); | 2827 | nfs4_fill_super(s); |
2828 | nfs_fscache_get_super_cookie(s, NULL, data); | ||
2823 | } | 2829 | } |
2824 | 2830 | ||
2825 | mntroot = nfs4_get_root(s, &mntfh); | 2831 | mntroot = nfs4_get_root(s, &mntfh); |