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 Side-by-side Diff
fs/nfs/super.c
... | ... | @@ -728,6 +728,27 @@ |
728 | 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 | 753 | * Sanity-check a server address provided by the mount command. |
733 | 754 | * |
... | ... | @@ -1637,20 +1658,6 @@ |
1637 | 1658 | if (data == NULL) |
1638 | 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 | 1661 | switch (data->version) { |
1655 | 1662 | case 1: |
1656 | 1663 | data->namlen = 0; |
... | ... | @@ -2097,7 +2104,7 @@ |
2097 | 2104 | }; |
2098 | 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 | 2108 | mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); |
2102 | 2109 | if (data == NULL || mntfh == NULL) |
2103 | 2110 | goto out_free_fh; |
2104 | 2111 | |
... | ... | @@ -2365,18 +2372,7 @@ |
2365 | 2372 | if (data == NULL) |
2366 | 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 | 2375 | args->version = 4; |
2378 | - args->minorversion = 0; | |
2379 | - | |
2380 | 2376 | switch (data->version) { |
2381 | 2377 | case 1: |
2382 | 2378 | if (data->host_addrlen > sizeof(args->nfs_server.address)) |
... | ... | @@ -2659,7 +2655,7 @@ |
2659 | 2655 | struct nfs_parsed_mount_data *data; |
2660 | 2656 | int error = -ENOMEM; |
2661 | 2657 | |
2662 | - data = kzalloc(sizeof(*data), GFP_KERNEL); | |
2658 | + data = nfs_alloc_parsed_mount_data(0); | |
2663 | 2659 | if (data == NULL) |
2664 | 2660 | goto out_free_data; |
2665 | 2661 |