2 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
3 * Written by David Howells (dhowells@redhat.com)
5 #include <linux/module.h>
6 #include <linux/nfs_fs.h>
7 #include <linux/nfs_idmap.h>
8 #include <linux/nfs_mount.h>
9 #include <linux/sunrpc/auth.h>
10 #include <linux/sunrpc/xprt.h>
11 #include <linux/sunrpc/bc_xprt.h>
14 #include "delegation.h"
15 #include "nfs4session.h"
19 #define NFSDBG_FACILITY NFSDBG_CLIENT
22 * Get a unique NFSv4.0 callback identifier which will be used
23 * by the V4.0 callback service to lookup the nfs_client struct
25 static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
28 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
30 if (clp->rpc_ops->version != 4 || minorversion != 0)
33 if (!idr_pre_get(&nn->cb_ident_idr, GFP_KERNEL))
35 spin_lock(&nn->nfs_client_lock);
36 ret = idr_get_new(&nn->cb_ident_idr, clp, &clp->cl_cb_ident);
37 spin_unlock(&nn->nfs_client_lock);
43 #ifdef CONFIG_NFS_V4_1
44 static void nfs4_shutdown_session(struct nfs_client *clp)
46 if (nfs4_has_session(clp)) {
47 nfs4_destroy_session(clp->cl_session);
48 nfs4_destroy_clientid(clp);
52 #else /* CONFIG_NFS_V4_1 */
53 static void nfs4_shutdown_session(struct nfs_client *clp)
56 #endif /* CONFIG_NFS_V4_1 */
58 struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
61 struct nfs_client *clp = nfs_alloc_client(cl_init);
65 err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
69 spin_lock_init(&clp->cl_lock);
70 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
71 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
72 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
73 clp->cl_minorversion = cl_init->minorversion;
74 clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
83 * Destroy the NFS4 callback service
85 static void nfs4_destroy_callback(struct nfs_client *clp)
87 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
88 nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
91 static void nfs4_shutdown_client(struct nfs_client *clp)
93 if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
94 nfs4_kill_renewd(clp);
95 nfs4_shutdown_session(clp);
96 nfs4_destroy_callback(clp);
97 if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
98 nfs_idmap_delete(clp);
100 rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
101 kfree(clp->cl_serverowner);
102 kfree(clp->cl_serverscope);
103 kfree(clp->cl_implid);
106 void nfs4_free_client(struct nfs_client *clp)
108 nfs4_shutdown_client(clp);
109 nfs_free_client(clp);
113 * Initialize the NFS4 callback service
115 static int nfs4_init_callback(struct nfs_client *clp)
119 if (clp->rpc_ops->version == 4) {
120 struct rpc_xprt *xprt;
122 xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt);
124 if (nfs4_has_session(clp)) {
125 error = xprt_setup_backchannel(xprt,
126 NFS41_BC_MIN_CALLBACKS);
131 error = nfs_callback_up(clp->cl_mvops->minor_version, xprt);
133 dprintk("%s: failed to start callback. Error = %d\n",
137 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
143 * Initialize the minor version specific parts of an NFS4 client record
145 static int nfs4_init_client_minor_version(struct nfs_client *clp)
147 #if defined(CONFIG_NFS_V4_1)
148 if (clp->cl_mvops->minor_version) {
149 struct nfs4_session *session = NULL;
151 * Create the session and mark it expired.
152 * When a SEQUENCE operation encounters the expired session
153 * it will do session recovery to initialize it.
155 session = nfs4_alloc_session(clp);
159 clp->cl_session = session;
161 * The create session reply races with the server back
162 * channel probe. Mark the client NFS_CS_SESSION_INITING
163 * so that the client back channel can find the
166 nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
168 #endif /* CONFIG_NFS_V4_1 */
170 return nfs4_init_callback(clp);
174 * nfs4_init_client - Initialise an NFS4 client record
176 * @clp: nfs_client to initialise
177 * @timeparms: timeout parameters for underlying RPC transport
178 * @ip_addr: callback IP address in presentation format
179 * @authflavor: authentication flavor for underlying RPC transport
181 * Returns pointer to an NFS client, or an ERR_PTR value.
183 struct nfs_client *nfs4_init_client(struct nfs_client *clp,
184 const struct rpc_timeout *timeparms,
186 rpc_authflavor_t authflavour)
188 char buf[INET6_ADDRSTRLEN + 1];
189 struct nfs_client *old;
192 if (clp->cl_cons_state == NFS_CS_READY) {
193 /* the client is initialised already */
194 dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp);
198 /* Check NFS protocol revision and initialize RPC op vector */
199 clp->rpc_ops = &nfs_v4_clientops;
201 __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
202 error = nfs_create_rpc_client(clp, timeparms, authflavour);
206 /* If no clientaddr= option was specified, find a usable cb address */
207 if (ip_addr == NULL) {
208 struct sockaddr_storage cb_addr;
209 struct sockaddr *sap = (struct sockaddr *)&cb_addr;
211 error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
214 error = rpc_ntop(sap, buf, sizeof(buf));
217 ip_addr = (const char *)buf;
219 strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
221 error = nfs_idmap_new(clp);
223 dprintk("%s: failed to create idmapper. Error = %d\n",
227 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
229 error = nfs4_init_client_minor_version(clp);
233 if (!nfs4_has_session(clp))
234 nfs_mark_client_ready(clp, NFS_CS_READY);
236 error = nfs4_discover_server_trunking(clp, &old);
241 clp->cl_preserve_clid = true;
248 nfs_mark_client_ready(clp, error);
250 dprintk("<-- nfs4_init_client() = xerror %d\n", error);
251 return ERR_PTR(error);
255 * SETCLIENTID just did a callback update with the callback ident in
256 * "drop," but server trunking discovery claims "drop" and "keep" are
257 * actually the same server. Swap the callback IDs so that "keep"
258 * will continue to use the callback ident the server now knows about,
259 * and so that "keep"'s original callback ident is destroyed when
262 static void nfs4_swap_callback_idents(struct nfs_client *keep,
263 struct nfs_client *drop)
265 struct nfs_net *nn = net_generic(keep->cl_net, nfs_net_id);
266 unsigned int save = keep->cl_cb_ident;
268 if (keep->cl_cb_ident == drop->cl_cb_ident)
271 dprintk("%s: keeping callback ident %u and dropping ident %u\n",
272 __func__, keep->cl_cb_ident, drop->cl_cb_ident);
274 spin_lock(&nn->nfs_client_lock);
276 idr_replace(&nn->cb_ident_idr, keep, drop->cl_cb_ident);
277 keep->cl_cb_ident = drop->cl_cb_ident;
279 idr_replace(&nn->cb_ident_idr, drop, save);
280 drop->cl_cb_ident = save;
282 spin_unlock(&nn->nfs_client_lock);
286 * nfs40_walk_client_list - Find server that recognizes a client ID
288 * @new: nfs_client with client ID to test
289 * @result: OUT: found nfs_client, or new
290 * @cred: credential to use for trunking test
292 * Returns zero, a negative errno, or a negative NFS4ERR status.
293 * If zero is returned, an nfs_client pointer is planted in "result."
295 * NB: nfs40_walk_client_list() relies on the new nfs_client being
296 * the last nfs_client on the list.
298 int nfs40_walk_client_list(struct nfs_client *new,
299 struct nfs_client **result,
300 struct rpc_cred *cred)
302 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
303 struct nfs_client *pos, *n, *prev = NULL;
304 struct nfs4_setclientid_res clid = {
305 .clientid = new->cl_clientid,
306 .confirm = new->cl_confirm,
308 int status = -NFS4ERR_STALE_CLIENTID;
310 spin_lock(&nn->nfs_client_lock);
311 list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
312 /* If "pos" isn't marked ready, we can't trust the
313 * remaining fields in "pos" */
314 if (pos->cl_cons_state < NFS_CS_READY)
317 if (pos->rpc_ops != new->rpc_ops)
320 if (pos->cl_proto != new->cl_proto)
323 if (pos->cl_minorversion != new->cl_minorversion)
326 if (pos->cl_clientid != new->cl_clientid)
329 atomic_inc(&pos->cl_count);
330 spin_unlock(&nn->nfs_client_lock);
333 nfs_put_client(prev);
336 status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
338 case -NFS4ERR_STALE_CLIENTID:
341 nfs4_swap_callback_idents(pos, new);
345 dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n",
346 __func__, pos, atomic_read(&pos->cl_count));
351 spin_lock(&nn->nfs_client_lock);
353 spin_unlock(&nn->nfs_client_lock);
357 * No matching nfs_client found. This should be impossible,
358 * because the new nfs_client has already been added to
359 * nfs_client_list by nfs_get_client().
361 * Don't BUG(), since the caller is holding a mutex.
364 nfs_put_client(prev);
365 dprintk("NFS: <-- %s status = %d\n", __func__, status);
369 #ifdef CONFIG_NFS_V4_1
371 * Returns true if the client IDs match
373 static bool nfs4_match_clientids(struct nfs_client *a, struct nfs_client *b)
375 if (a->cl_clientid != b->cl_clientid) {
376 dprintk("NFS: --> %s client ID %llx does not match %llx\n",
377 __func__, a->cl_clientid, b->cl_clientid);
380 dprintk("NFS: --> %s client ID %llx matches %llx\n",
381 __func__, a->cl_clientid, b->cl_clientid);
386 * Returns true if the server owners match
389 nfs4_match_serverowners(struct nfs_client *a, struct nfs_client *b)
391 struct nfs41_server_owner *o1 = a->cl_serverowner;
392 struct nfs41_server_owner *o2 = b->cl_serverowner;
394 if (o1->minor_id != o2->minor_id) {
395 dprintk("NFS: --> %s server owner minor IDs do not match\n",
400 if (o1->major_id_sz != o2->major_id_sz)
401 goto out_major_mismatch;
402 if (memcmp(o1->major_id, o2->major_id, o1->major_id_sz) != 0)
403 goto out_major_mismatch;
405 dprintk("NFS: --> %s server owners match\n", __func__);
409 dprintk("NFS: --> %s server owner major IDs do not match\n",
415 * nfs41_walk_client_list - Find nfs_client that matches a client/server owner
417 * @new: nfs_client with client ID to test
418 * @result: OUT: found nfs_client, or new
419 * @cred: credential to use for trunking test
421 * Returns zero, a negative errno, or a negative NFS4ERR status.
422 * If zero is returned, an nfs_client pointer is planted in "result."
424 * NB: nfs41_walk_client_list() relies on the new nfs_client being
425 * the last nfs_client on the list.
427 int nfs41_walk_client_list(struct nfs_client *new,
428 struct nfs_client **result,
429 struct rpc_cred *cred)
431 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
432 struct nfs_client *pos, *n, *prev = NULL;
435 spin_lock(&nn->nfs_client_lock);
436 list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
437 /* If "pos" isn't marked ready, we can't trust the
438 * remaining fields in "pos", especially the client
439 * ID and serverowner fields. Wait for CREATE_SESSION
441 if (pos->cl_cons_state < NFS_CS_READY) {
442 atomic_inc(&pos->cl_count);
443 spin_unlock(&nn->nfs_client_lock);
446 nfs_put_client(prev);
449 error = nfs_wait_client_init_complete(pos);
452 spin_lock(&nn->nfs_client_lock);
456 spin_lock(&nn->nfs_client_lock);
459 if (pos->rpc_ops != new->rpc_ops)
462 if (pos->cl_proto != new->cl_proto)
465 if (pos->cl_minorversion != new->cl_minorversion)
468 if (!nfs4_match_clientids(pos, new))
471 if (!nfs4_match_serverowners(pos, new))
474 atomic_inc(&pos->cl_count);
475 spin_unlock(&nn->nfs_client_lock);
476 dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n",
477 __func__, pos, atomic_read(&pos->cl_count));
484 * No matching nfs_client found. This should be impossible,
485 * because the new nfs_client has already been added to
486 * nfs_client_list by nfs_get_client().
488 * Don't BUG(), since the caller is holding a mutex.
490 spin_unlock(&nn->nfs_client_lock);
491 pr_err("NFS: %s Error: no matching nfs_client found\n", __func__);
492 return -NFS4ERR_STALE_CLIENTID;
494 #endif /* CONFIG_NFS_V4_1 */
496 static void nfs4_destroy_server(struct nfs_server *server)
498 nfs_server_return_all_delegations(server);
499 unset_pnfs_layoutdriver(server);
500 nfs4_purge_state_owners(server);
504 * NFSv4.0 callback thread helper
506 * Find a client by callback identifier
509 nfs4_find_client_ident(struct net *net, int cb_ident)
511 struct nfs_client *clp;
512 struct nfs_net *nn = net_generic(net, nfs_net_id);
514 spin_lock(&nn->nfs_client_lock);
515 clp = idr_find(&nn->cb_ident_idr, cb_ident);
517 atomic_inc(&clp->cl_count);
518 spin_unlock(&nn->nfs_client_lock);
522 #if defined(CONFIG_NFS_V4_1)
523 /* Common match routine for v4.0 and v4.1 callback services */
524 static bool nfs4_cb_match_client(const struct sockaddr *addr,
525 struct nfs_client *clp, u32 minorversion)
527 struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
529 /* Don't match clients that failed to initialise */
530 if (!(clp->cl_cons_state == NFS_CS_READY ||
531 clp->cl_cons_state == NFS_CS_SESSION_INITING))
536 /* Match the version and minorversion */
537 if (clp->rpc_ops->version != 4 ||
538 clp->cl_minorversion != minorversion)
541 /* Match only the IP address, not the port number */
542 if (!nfs_sockaddr_match_ipaddr(addr, clap))
549 * NFSv4.1 callback thread helper
550 * For CB_COMPOUND calls, find a client by IP address, protocol version,
551 * minorversion, and sessionID
553 * Returns NULL if no such client
556 nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr,
557 struct nfs4_sessionid *sid)
559 struct nfs_client *clp;
560 struct nfs_net *nn = net_generic(net, nfs_net_id);
562 spin_lock(&nn->nfs_client_lock);
563 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
564 if (nfs4_cb_match_client(addr, clp, 1) == false)
567 if (!nfs4_has_session(clp))
571 if (memcmp(clp->cl_session->sess_id.data,
572 sid->data, NFS4_MAX_SESSIONID_LEN) != 0)
575 atomic_inc(&clp->cl_count);
576 spin_unlock(&nn->nfs_client_lock);
579 spin_unlock(&nn->nfs_client_lock);
583 #else /* CONFIG_NFS_V4_1 */
586 nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr,
587 struct nfs4_sessionid *sid)
591 #endif /* CONFIG_NFS_V4_1 */
594 * Set up an NFS4 client
596 static int nfs4_set_client(struct nfs_server *server,
597 const char *hostname,
598 const struct sockaddr *addr,
599 const size_t addrlen,
601 rpc_authflavor_t authflavour,
602 int proto, const struct rpc_timeout *timeparms,
603 u32 minorversion, struct net *net)
605 struct nfs_client_initdata cl_init = {
606 .hostname = hostname,
611 .minorversion = minorversion,
614 struct nfs_client *clp;
617 dprintk("--> nfs4_set_client()\n");
619 if (server->flags & NFS_MOUNT_NORESVPORT)
620 set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
622 /* Allocate or find a client reference we can use */
623 clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour);
625 error = PTR_ERR(clp);
630 * Query for the lease time on clientid setup or renewal
632 * Note that this will be set on nfs_clients that were created
633 * only for the DS role and did not set this bit, but now will
636 set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
638 server->nfs_client = clp;
639 dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp);
642 dprintk("<-- nfs4_set_client() = xerror %d\n", error);
647 * Set up a pNFS Data Server client.
649 * Return any existing nfs_client that matches server address,port,version
652 * For a new nfs_client, use a soft mount (default), a low retrans and a
653 * low timeout interval so that if a connection is lost, we retry through
656 struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
657 const struct sockaddr *ds_addr, int ds_addrlen,
658 int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans)
660 struct nfs_client_initdata cl_init = {
662 .addrlen = ds_addrlen,
665 .minorversion = mds_clp->cl_minorversion,
666 .net = mds_clp->cl_net,
668 struct rpc_timeout ds_timeout;
669 struct nfs_client *clp;
672 * Set an authflavor equual to the MDS value. Use the MDS nfs_client
673 * cl_ipaddr so as to use the same EXCHANGE_ID co_ownerid as the MDS
674 * (section 13.1 RFC 5661).
676 nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);
677 clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr,
678 mds_clp->cl_rpcclient->cl_auth->au_flavor);
680 dprintk("<-- %s %p\n", __func__, clp);
683 EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
686 * Session has been established, and the client marked ready.
687 * Set the mount rsize and wsize with negotiated fore channel
688 * attributes which will be bound checked in nfs_server_set_fsinfo.
690 static void nfs4_session_set_rwsize(struct nfs_server *server)
692 #ifdef CONFIG_NFS_V4_1
693 struct nfs4_session *sess;
697 if (!nfs4_has_session(server->nfs_client))
699 sess = server->nfs_client->cl_session;
700 server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
701 server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
703 if (server->rsize > server_resp_sz)
704 server->rsize = server_resp_sz;
705 if (server->wsize > server_rqst_sz)
706 server->wsize = server_rqst_sz;
707 #endif /* CONFIG_NFS_V4_1 */
710 static int nfs4_server_common_setup(struct nfs_server *server,
711 struct nfs_fh *mntfh)
713 struct nfs_fattr *fattr;
716 /* data servers support only a subset of NFSv4.1 */
717 if (is_ds_only_client(server->nfs_client))
718 return -EPROTONOSUPPORT;
720 fattr = nfs_alloc_fattr();
724 /* We must ensure the session is initialised first */
725 error = nfs4_init_session(server);
729 /* Probe the root fh to retrieve its FSID and filehandle */
730 error = nfs4_get_rootfh(server, mntfh);
734 dprintk("Server FSID: %llx:%llx\n",
735 (unsigned long long) server->fsid.major,
736 (unsigned long long) server->fsid.minor);
737 dprintk("Mount FH: %d\n", mntfh->size);
739 nfs4_session_set_rwsize(server);
741 error = nfs_probe_fsinfo(server, mntfh, fattr);
745 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
746 server->namelen = NFS4_MAXNAMLEN;
748 nfs_server_insert_lists(server);
749 server->mount_time = jiffies;
750 server->destroy = nfs4_destroy_server;
752 nfs_free_fattr(fattr);
757 * Create a version 4 volume record
759 static int nfs4_init_server(struct nfs_server *server,
760 const struct nfs_parsed_mount_data *data)
762 struct rpc_timeout timeparms;
765 dprintk("--> nfs4_init_server()\n");
767 nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
768 data->timeo, data->retrans);
770 /* Initialise the client representation from the mount data */
771 server->flags = data->flags;
772 server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR|NFS_CAP_POSIX_LOCK;
773 if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
774 server->caps |= NFS_CAP_READDIRPLUS;
775 server->options = data->options;
777 /* Get a client record */
778 error = nfs4_set_client(server,
779 data->nfs_server.hostname,
780 (const struct sockaddr *)&data->nfs_server.address,
781 data->nfs_server.addrlen,
782 data->client_address,
783 data->auth_flavors[0],
784 data->nfs_server.protocol,
792 * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
795 if (nfs4_disable_idmapping && data->auth_flavors[0] == RPC_AUTH_UNIX)
796 server->caps |= NFS_CAP_UIDGID_NOMAP;
799 server->rsize = nfs_block_size(data->rsize, NULL);
801 server->wsize = nfs_block_size(data->wsize, NULL);
803 server->acregmin = data->acregmin * HZ;
804 server->acregmax = data->acregmax * HZ;
805 server->acdirmin = data->acdirmin * HZ;
806 server->acdirmax = data->acdirmax * HZ;
808 server->port = data->nfs_server.port;
810 error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
814 dprintk("<-- nfs4_init_server() = %d\n", error);
819 * Create a version 4 volume record
820 * - keyed on server and FSID
822 /*struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
823 struct nfs_fh *mntfh)*/
824 struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
825 struct nfs_subversion *nfs_mod)
827 struct nfs_server *server;
830 dprintk("--> nfs4_create_server()\n");
832 server = nfs_alloc_server();
834 return ERR_PTR(-ENOMEM);
836 /* set up the general RPC client */
837 error = nfs4_init_server(server, mount_info->parsed);
841 error = nfs4_server_common_setup(server, mount_info->mntfh);
845 dprintk("<-- nfs4_create_server() = %p\n", server);
849 nfs_free_server(server);
850 dprintk("<-- nfs4_create_server() = error %d\n", error);
851 return ERR_PTR(error);
855 * Create an NFS4 referral server record
857 struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
858 struct nfs_fh *mntfh)
860 struct nfs_client *parent_client;
861 struct nfs_server *server, *parent_server;
864 dprintk("--> nfs4_create_referral_server()\n");
866 server = nfs_alloc_server();
868 return ERR_PTR(-ENOMEM);
870 parent_server = NFS_SB(data->sb);
871 parent_client = parent_server->nfs_client;
873 /* Initialise the client representation from the parent server */
874 nfs_server_copy_userdata(server, parent_server);
875 server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR;
877 /* Get a client representation.
878 * Note: NFSv4 always uses TCP, */
879 error = nfs4_set_client(server, data->hostname,
882 parent_client->cl_ipaddr,
884 rpc_protocol(parent_server->client),
885 parent_server->client->cl_timeout,
886 parent_client->cl_mvops->minor_version,
887 parent_client->cl_net);
891 error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor);
895 error = nfs4_server_common_setup(server, mntfh);
899 dprintk("<-- nfs_create_referral_server() = %p\n", server);
903 nfs_free_server(server);
904 dprintk("<-- nfs4_create_referral_server() = error %d\n", error);
905 return ERR_PTR(error);