aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/client.c56
-rw-r--r--fs/nfs/internal.h9
-rw-r--r--fs/nfs/nfs3proc.c1
-rw-r--r--fs/nfs/nfs4proc.c1
-rw-r--r--fs/nfs/proc.c1
-rw-r--r--include/linux/nfs_xdr.h3
6 files changed, 45 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 */
484static struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) 484static struct nfs_client *
485nfs_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 */
770static int nfs_init_client(struct nfs_client *clp, 782int 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 */
1310static int nfs4_init_client(struct nfs_client *clp, 1320int 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
1395error_put:
1396 nfs_put_client(clp);
1397error: 1401error:
1398 dprintk("<-- nfs4_set_client() = xerror %d\n", error); 1402 dprintk("<-- nfs4_set_client() = xerror %d\n", error);
1399 return error; 1403 return error;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index cf9fdbdabc67..4d7b3a97e522 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -215,6 +215,10 @@ extern struct rpc_procinfo nfs4_procedures[];
215 215
216/* proc.c */ 216/* proc.c */
217void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 217void nfs_close_context(struct nfs_open_context *ctx, int is_sync);
218extern int nfs_init_client(struct nfs_client *clp,
219 const struct rpc_timeout *timeparms,
220 const char *ip_addr, rpc_authflavor_t authflavour,
221 int noresvport);
218 222
219/* dir.c */ 223/* dir.c */
220extern int nfs_access_cache_shrinker(struct shrinker *shrink, 224extern int nfs_access_cache_shrinker(struct shrinker *shrink,
@@ -274,6 +278,11 @@ extern int nfs_migrate_page(struct address_space *,
274#endif 278#endif
275 279
276/* nfs4proc.c */ 280/* nfs4proc.c */
281extern int nfs4_init_client(struct nfs_client *clp,
282 const struct rpc_timeout *timeparms,
283 const char *ip_addr,
284 rpc_authflavor_t authflavour,
285 int noresvport);
277extern int _nfs4_call_sync(struct nfs_server *server, 286extern int _nfs4_call_sync(struct nfs_server *server,
278 struct rpc_message *msg, 287 struct rpc_message *msg,
279 struct nfs4_sequence_args *args, 288 struct nfs4_sequence_args *args,
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index ce939c062a52..d0c80d8b3f96 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -885,4 +885,5 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
885 .lock = nfs3_proc_lock, 885 .lock = nfs3_proc_lock,
886 .clear_acl_cache = nfs3_forget_cached_acls, 886 .clear_acl_cache = nfs3_forget_cached_acls,
887 .close_context = nfs_close_context, 887 .close_context = nfs_close_context,
888 .init_client = nfs_init_client,
888}; 889};
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0a07e353a961..55a8fc2f3df4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5648,6 +5648,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
5648 .clear_acl_cache = nfs4_zap_acl_attr, 5648 .clear_acl_cache = nfs4_zap_acl_attr,
5649 .close_context = nfs4_close_context, 5649 .close_context = nfs4_close_context,
5650 .open_context = nfs4_atomic_open, 5650 .open_context = nfs4_atomic_open,
5651 .init_client = nfs4_init_client,
5651}; 5652};
5652 5653
5653static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = { 5654static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 77d5e21c4ad6..b8ec170f2a0f 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -741,4 +741,5 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
741 .lock = nfs_proc_lock, 741 .lock = nfs_proc_lock,
742 .lock_check_bounds = nfs_lock_check_bounds, 742 .lock_check_bounds = nfs_lock_check_bounds,
743 .close_context = nfs_close_context, 743 .close_context = nfs_close_context,
744 .init_client = nfs_init_client,
744}; 745};
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 51bfadbe24e2..d159fe733381 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1040,6 +1040,7 @@ struct nfs_write_data {
1040}; 1040};
1041 1041
1042struct nfs_access_entry; 1042struct nfs_access_entry;
1043struct nfs_client;
1043 1044
1044/* 1045/*
1045 * RPC procedure vector for NFSv2/NFSv3 demuxing 1046 * RPC procedure vector for NFSv2/NFSv3 demuxing
@@ -1104,6 +1105,8 @@ struct nfs_rpc_ops {
1104 struct nfs_open_context *ctx, 1105 struct nfs_open_context *ctx,
1105 int open_flags, 1106 int open_flags,
1106 struct iattr *iattr); 1107 struct iattr *iattr);
1108 int (*init_client) (struct nfs_client *, const struct rpc_timeout *,
1109 const char *, rpc_authflavor_t, int);
1107}; 1110};
1108 1111
1109/* 1112/*