diff options
author | Andy Adamson <andros@netapp.com> | 2011-02-28 20:34:08 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-03-11 15:38:41 -0500 |
commit | 45a52a02072b2a7e265f024cfdb00127e08dd9f2 (patch) | |
tree | 33c98f48d5b652297f45406f47d9545cca37c7c5 /fs/nfs/client.c | |
parent | bf9c1387ca80deac792c9ecf1c64dfcc5d1cc768 (diff) |
NFS move nfs_client initialization into nfs_get_client
Now nfs_get_client returns an nfs_client ready to be used no matter if it was
found or created.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r-- | fs/nfs/client.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index bd3ca32879e7..b9ed2a8bc26a 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -481,7 +481,12 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat | |||
481 | * Look up a client by IP address and protocol version | 481 | * Look up a client by IP address and protocol version |
482 | * - creates a new record if one doesn't yet exist | 482 | * - creates a new record if one doesn't yet exist |
483 | */ | 483 | */ |
484 | static struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) | 484 | static struct nfs_client * |
485 | nfs_get_client(const struct nfs_client_initdata *cl_init, | ||
486 | const struct rpc_timeout *timeparms, | ||
487 | const char *ip_addr, | ||
488 | rpc_authflavor_t authflavour, | ||
489 | int noresvport) | ||
485 | { | 490 | { |
486 | struct nfs_client *clp, *new = NULL; | 491 | struct nfs_client *clp, *new = NULL; |
487 | int error; | 492 | int error; |
@@ -512,6 +517,13 @@ install_client: | |||
512 | clp = new; | 517 | clp = new; |
513 | list_add(&clp->cl_share_link, &nfs_client_list); | 518 | list_add(&clp->cl_share_link, &nfs_client_list); |
514 | spin_unlock(&nfs_client_lock); | 519 | spin_unlock(&nfs_client_lock); |
520 | |||
521 | error = cl_init->rpc_ops->init_client(clp, timeparms, ip_addr, | ||
522 | authflavour, noresvport); | ||
523 | if (error < 0) { | ||
524 | nfs_put_client(clp); | ||
525 | return ERR_PTR(error); | ||
526 | } | ||
515 | dprintk("--> nfs_get_client() = %p [new]\n", clp); | 527 | dprintk("--> nfs_get_client() = %p [new]\n", clp); |
516 | return clp; | 528 | return clp; |
517 | 529 | ||
@@ -767,9 +779,9 @@ static int nfs_init_server_rpcclient(struct nfs_server *server, | |||
767 | /* | 779 | /* |
768 | * Initialise an NFS2 or NFS3 client | 780 | * Initialise an NFS2 or NFS3 client |
769 | */ | 781 | */ |
770 | static int nfs_init_client(struct nfs_client *clp, | 782 | int nfs_init_client(struct nfs_client *clp, const struct rpc_timeout *timeparms, |
771 | const struct rpc_timeout *timeparms, | 783 | const char *ip_addr, rpc_authflavor_t authflavour, |
772 | const struct nfs_parsed_mount_data *data) | 784 | int noresvport) |
773 | { | 785 | { |
774 | int error; | 786 | int error; |
775 | 787 | ||
@@ -784,7 +796,7 @@ static int nfs_init_client(struct nfs_client *clp, | |||
784 | * - RFC 2623, sec 2.3.2 | 796 | * - RFC 2623, sec 2.3.2 |
785 | */ | 797 | */ |
786 | error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX, | 798 | error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX, |
787 | 0, data->flags & NFS_MOUNT_NORESVPORT); | 799 | 0, noresvport); |
788 | if (error < 0) | 800 | if (error < 0) |
789 | goto error; | 801 | goto error; |
790 | nfs_mark_client_ready(clp, NFS_CS_READY); | 802 | nfs_mark_client_ready(clp, NFS_CS_READY); |
@@ -820,19 +832,17 @@ static int nfs_init_server(struct nfs_server *server, | |||
820 | cl_init.rpc_ops = &nfs_v3_clientops; | 832 | cl_init.rpc_ops = &nfs_v3_clientops; |
821 | #endif | 833 | #endif |
822 | 834 | ||
835 | nfs_init_timeout_values(&timeparms, data->nfs_server.protocol, | ||
836 | data->timeo, data->retrans); | ||
837 | |||
823 | /* Allocate or find a client reference we can use */ | 838 | /* Allocate or find a client reference we can use */ |
824 | clp = nfs_get_client(&cl_init); | 839 | clp = nfs_get_client(&cl_init, &timeparms, NULL, RPC_AUTH_UNIX, |
840 | data->flags & NFS_MOUNT_NORESVPORT); | ||
825 | if (IS_ERR(clp)) { | 841 | if (IS_ERR(clp)) { |
826 | dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp)); | 842 | dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp)); |
827 | return PTR_ERR(clp); | 843 | return PTR_ERR(clp); |
828 | } | 844 | } |
829 | 845 | ||
830 | nfs_init_timeout_values(&timeparms, data->nfs_server.protocol, | ||
831 | data->timeo, data->retrans); | ||
832 | error = nfs_init_client(clp, &timeparms, data); | ||
833 | if (error < 0) | ||
834 | goto error; | ||
835 | |||
836 | server->nfs_client = clp; | 846 | server->nfs_client = clp; |
837 | 847 | ||
838 | /* Initialise the client representation from the mount data */ | 848 | /* Initialise the client representation from the mount data */ |
@@ -1307,11 +1317,11 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) | |||
1307 | /* | 1317 | /* |
1308 | * Initialise an NFS4 client record | 1318 | * Initialise an NFS4 client record |
1309 | */ | 1319 | */ |
1310 | static int nfs4_init_client(struct nfs_client *clp, | 1320 | int nfs4_init_client(struct nfs_client *clp, |
1311 | const struct rpc_timeout *timeparms, | 1321 | const struct rpc_timeout *timeparms, |
1312 | const char *ip_addr, | 1322 | const char *ip_addr, |
1313 | rpc_authflavor_t authflavour, | 1323 | rpc_authflavor_t authflavour, |
1314 | int flags) | 1324 | int noresvport) |
1315 | { | 1325 | { |
1316 | int error; | 1326 | int error; |
1317 | 1327 | ||
@@ -1325,7 +1335,7 @@ static int nfs4_init_client(struct nfs_client *clp, | |||
1325 | clp->rpc_ops = &nfs_v4_clientops; | 1335 | clp->rpc_ops = &nfs_v4_clientops; |
1326 | 1336 | ||
1327 | error = nfs_create_rpc_client(clp, timeparms, authflavour, | 1337 | error = nfs_create_rpc_client(clp, timeparms, authflavour, |
1328 | 1, flags & NFS_MOUNT_NORESVPORT); | 1338 | 1, noresvport); |
1329 | if (error < 0) | 1339 | if (error < 0) |
1330 | goto error; | 1340 | goto error; |
1331 | strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); | 1341 | strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); |
@@ -1378,22 +1388,16 @@ static int nfs4_set_client(struct nfs_server *server, | |||
1378 | dprintk("--> nfs4_set_client()\n"); | 1388 | dprintk("--> nfs4_set_client()\n"); |
1379 | 1389 | ||
1380 | /* Allocate or find a client reference we can use */ | 1390 | /* Allocate or find a client reference we can use */ |
1381 | clp = nfs_get_client(&cl_init); | 1391 | clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour, |
1392 | server->flags & NFS_MOUNT_NORESVPORT); | ||
1382 | if (IS_ERR(clp)) { | 1393 | if (IS_ERR(clp)) { |
1383 | error = PTR_ERR(clp); | 1394 | error = PTR_ERR(clp); |
1384 | goto error; | 1395 | goto error; |
1385 | } | 1396 | } |
1386 | error = nfs4_init_client(clp, timeparms, ip_addr, authflavour, | ||
1387 | server->flags); | ||
1388 | if (error < 0) | ||
1389 | goto error_put; | ||
1390 | 1397 | ||
1391 | server->nfs_client = clp; | 1398 | server->nfs_client = clp; |
1392 | dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp); | 1399 | dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp); |
1393 | return 0; | 1400 | return 0; |
1394 | |||
1395 | error_put: | ||
1396 | nfs_put_client(clp); | ||
1397 | error: | 1401 | error: |
1398 | dprintk("<-- nfs4_set_client() = xerror %d\n", error); | 1402 | dprintk("<-- nfs4_set_client() = xerror %d\n", error); |
1399 | return error; | 1403 | return error; |