Bryan Schumaker | 428360d | 2012-07-16 16:39:17 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. |
| 3 | * Written by David Howells (dhowells@redhat.com) |
| 4 | */ |
Bryan Schumaker | fcf1039 | 2012-07-16 16:39:18 -0400 | [diff] [blame^] | 5 | #include <linux/module.h> |
Bryan Schumaker | 428360d | 2012-07-16 16:39:17 -0400 | [diff] [blame] | 6 | #include <linux/nfs_fs.h> |
| 7 | #include <linux/nfs_idmap.h> |
Bryan Schumaker | fcf1039 | 2012-07-16 16:39:18 -0400 | [diff] [blame^] | 8 | #include <linux/nfs_mount.h> |
Bryan Schumaker | 428360d | 2012-07-16 16:39:17 -0400 | [diff] [blame] | 9 | #include <linux/sunrpc/auth.h> |
| 10 | #include <linux/sunrpc/xprt.h> |
| 11 | #include <linux/sunrpc/bc_xprt.h> |
| 12 | #include "internal.h" |
| 13 | #include "callback.h" |
Bryan Schumaker | fcf1039 | 2012-07-16 16:39:18 -0400 | [diff] [blame^] | 14 | #include "delegation.h" |
| 15 | #include "pnfs.h" |
| 16 | #include "netns.h" |
Bryan Schumaker | 428360d | 2012-07-16 16:39:17 -0400 | [diff] [blame] | 17 | |
| 18 | #define NFSDBG_FACILITY NFSDBG_CLIENT |
| 19 | |
| 20 | /* |
Bryan Schumaker | fcf1039 | 2012-07-16 16:39:18 -0400 | [diff] [blame^] | 21 | * Turn off NFSv4 uid/gid mapping when using AUTH_SYS |
| 22 | */ |
| 23 | static bool nfs4_disable_idmapping = true; |
| 24 | |
| 25 | /* |
Bryan Schumaker | 428360d | 2012-07-16 16:39:17 -0400 | [diff] [blame] | 26 | * Initialize the NFS4 callback service |
| 27 | */ |
| 28 | static int nfs4_init_callback(struct nfs_client *clp) |
| 29 | { |
| 30 | int error; |
| 31 | |
| 32 | if (clp->rpc_ops->version == 4) { |
| 33 | struct rpc_xprt *xprt; |
| 34 | |
| 35 | xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt); |
| 36 | |
| 37 | if (nfs4_has_session(clp)) { |
| 38 | error = xprt_setup_backchannel(xprt, |
| 39 | NFS41_BC_MIN_CALLBACKS); |
| 40 | if (error < 0) |
| 41 | return error; |
| 42 | } |
| 43 | |
| 44 | error = nfs_callback_up(clp->cl_mvops->minor_version, xprt); |
| 45 | if (error < 0) { |
| 46 | dprintk("%s: failed to start callback. Error = %d\n", |
| 47 | __func__, error); |
| 48 | return error; |
| 49 | } |
| 50 | __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state); |
| 51 | } |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * Initialize the minor version specific parts of an NFS4 client record |
| 57 | */ |
| 58 | static int nfs4_init_client_minor_version(struct nfs_client *clp) |
| 59 | { |
| 60 | #if defined(CONFIG_NFS_V4_1) |
| 61 | if (clp->cl_mvops->minor_version) { |
| 62 | struct nfs4_session *session = NULL; |
| 63 | /* |
| 64 | * Create the session and mark it expired. |
| 65 | * When a SEQUENCE operation encounters the expired session |
| 66 | * it will do session recovery to initialize it. |
| 67 | */ |
| 68 | session = nfs4_alloc_session(clp); |
| 69 | if (!session) |
| 70 | return -ENOMEM; |
| 71 | |
| 72 | clp->cl_session = session; |
| 73 | /* |
| 74 | * The create session reply races with the server back |
| 75 | * channel probe. Mark the client NFS_CS_SESSION_INITING |
| 76 | * so that the client back channel can find the |
| 77 | * nfs_client struct |
| 78 | */ |
| 79 | nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING); |
| 80 | } |
| 81 | #endif /* CONFIG_NFS_V4_1 */ |
| 82 | |
| 83 | return nfs4_init_callback(clp); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * nfs4_init_client - Initialise an NFS4 client record |
| 88 | * |
| 89 | * @clp: nfs_client to initialise |
| 90 | * @timeparms: timeout parameters for underlying RPC transport |
| 91 | * @ip_addr: callback IP address in presentation format |
| 92 | * @authflavor: authentication flavor for underlying RPC transport |
| 93 | * |
| 94 | * Returns pointer to an NFS client, or an ERR_PTR value. |
| 95 | */ |
| 96 | struct nfs_client *nfs4_init_client(struct nfs_client *clp, |
| 97 | const struct rpc_timeout *timeparms, |
| 98 | const char *ip_addr, |
| 99 | rpc_authflavor_t authflavour) |
| 100 | { |
| 101 | char buf[INET6_ADDRSTRLEN + 1]; |
| 102 | int error; |
| 103 | |
| 104 | if (clp->cl_cons_state == NFS_CS_READY) { |
| 105 | /* the client is initialised already */ |
| 106 | dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp); |
| 107 | return clp; |
| 108 | } |
| 109 | |
| 110 | /* Check NFS protocol revision and initialize RPC op vector */ |
| 111 | clp->rpc_ops = &nfs_v4_clientops; |
| 112 | |
| 113 | __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags); |
| 114 | error = nfs_create_rpc_client(clp, timeparms, authflavour); |
| 115 | if (error < 0) |
| 116 | goto error; |
| 117 | |
| 118 | /* If no clientaddr= option was specified, find a usable cb address */ |
| 119 | if (ip_addr == NULL) { |
| 120 | struct sockaddr_storage cb_addr; |
| 121 | struct sockaddr *sap = (struct sockaddr *)&cb_addr; |
| 122 | |
| 123 | error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr)); |
| 124 | if (error < 0) |
| 125 | goto error; |
| 126 | error = rpc_ntop(sap, buf, sizeof(buf)); |
| 127 | if (error < 0) |
| 128 | goto error; |
| 129 | ip_addr = (const char *)buf; |
| 130 | } |
| 131 | strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); |
| 132 | |
| 133 | error = nfs_idmap_new(clp); |
| 134 | if (error < 0) { |
| 135 | dprintk("%s: failed to create idmapper. Error = %d\n", |
| 136 | __func__, error); |
| 137 | goto error; |
| 138 | } |
| 139 | __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); |
| 140 | |
| 141 | error = nfs4_init_client_minor_version(clp); |
| 142 | if (error < 0) |
| 143 | goto error; |
| 144 | |
| 145 | if (!nfs4_has_session(clp)) |
| 146 | nfs_mark_client_ready(clp, NFS_CS_READY); |
| 147 | return clp; |
| 148 | |
| 149 | error: |
| 150 | nfs_mark_client_ready(clp, error); |
| 151 | nfs_put_client(clp); |
| 152 | dprintk("<-- nfs4_init_client() = xerror %d\n", error); |
| 153 | return ERR_PTR(error); |
| 154 | } |
Bryan Schumaker | fcf1039 | 2012-07-16 16:39:18 -0400 | [diff] [blame^] | 155 | |
| 156 | static void nfs4_destroy_server(struct nfs_server *server) |
| 157 | { |
| 158 | nfs_server_return_all_delegations(server); |
| 159 | unset_pnfs_layoutdriver(server); |
| 160 | nfs4_purge_state_owners(server); |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | * NFSv4.0 callback thread helper |
| 165 | * |
| 166 | * Find a client by callback identifier |
| 167 | */ |
| 168 | struct nfs_client * |
| 169 | nfs4_find_client_ident(struct net *net, int cb_ident) |
| 170 | { |
| 171 | struct nfs_client *clp; |
| 172 | struct nfs_net *nn = net_generic(net, nfs_net_id); |
| 173 | |
| 174 | spin_lock(&nn->nfs_client_lock); |
| 175 | clp = idr_find(&nn->cb_ident_idr, cb_ident); |
| 176 | if (clp) |
| 177 | atomic_inc(&clp->cl_count); |
| 178 | spin_unlock(&nn->nfs_client_lock); |
| 179 | return clp; |
| 180 | } |
| 181 | |
| 182 | #if defined(CONFIG_NFS_V4_1) |
| 183 | /* Common match routine for v4.0 and v4.1 callback services */ |
| 184 | static bool nfs4_cb_match_client(const struct sockaddr *addr, |
| 185 | struct nfs_client *clp, u32 minorversion) |
| 186 | { |
| 187 | struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; |
| 188 | |
| 189 | /* Don't match clients that failed to initialise */ |
| 190 | if (!(clp->cl_cons_state == NFS_CS_READY || |
| 191 | clp->cl_cons_state == NFS_CS_SESSION_INITING)) |
| 192 | return false; |
| 193 | |
| 194 | smp_rmb(); |
| 195 | |
| 196 | /* Match the version and minorversion */ |
| 197 | if (clp->rpc_ops->version != 4 || |
| 198 | clp->cl_minorversion != minorversion) |
| 199 | return false; |
| 200 | |
| 201 | /* Match only the IP address, not the port number */ |
| 202 | if (!nfs_sockaddr_match_ipaddr(addr, clap)) |
| 203 | return false; |
| 204 | |
| 205 | return true; |
| 206 | } |
| 207 | |
| 208 | /* |
| 209 | * NFSv4.1 callback thread helper |
| 210 | * For CB_COMPOUND calls, find a client by IP address, protocol version, |
| 211 | * minorversion, and sessionID |
| 212 | * |
| 213 | * Returns NULL if no such client |
| 214 | */ |
| 215 | struct nfs_client * |
| 216 | nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr, |
| 217 | struct nfs4_sessionid *sid) |
| 218 | { |
| 219 | struct nfs_client *clp; |
| 220 | struct nfs_net *nn = net_generic(net, nfs_net_id); |
| 221 | |
| 222 | spin_lock(&nn->nfs_client_lock); |
| 223 | list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) { |
| 224 | if (nfs4_cb_match_client(addr, clp, 1) == false) |
| 225 | continue; |
| 226 | |
| 227 | if (!nfs4_has_session(clp)) |
| 228 | continue; |
| 229 | |
| 230 | /* Match sessionid*/ |
| 231 | if (memcmp(clp->cl_session->sess_id.data, |
| 232 | sid->data, NFS4_MAX_SESSIONID_LEN) != 0) |
| 233 | continue; |
| 234 | |
| 235 | atomic_inc(&clp->cl_count); |
| 236 | spin_unlock(&nn->nfs_client_lock); |
| 237 | return clp; |
| 238 | } |
| 239 | spin_unlock(&nn->nfs_client_lock); |
| 240 | return NULL; |
| 241 | } |
| 242 | |
| 243 | #else /* CONFIG_NFS_V4_1 */ |
| 244 | |
| 245 | struct nfs_client * |
| 246 | nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr, |
| 247 | struct nfs4_sessionid *sid) |
| 248 | { |
| 249 | return NULL; |
| 250 | } |
| 251 | #endif /* CONFIG_NFS_V4_1 */ |
| 252 | |
| 253 | /* |
| 254 | * Set up an NFS4 client |
| 255 | */ |
| 256 | static int nfs4_set_client(struct nfs_server *server, |
| 257 | const char *hostname, |
| 258 | const struct sockaddr *addr, |
| 259 | const size_t addrlen, |
| 260 | const char *ip_addr, |
| 261 | rpc_authflavor_t authflavour, |
| 262 | int proto, const struct rpc_timeout *timeparms, |
| 263 | u32 minorversion, struct net *net) |
| 264 | { |
| 265 | struct nfs_client_initdata cl_init = { |
| 266 | .hostname = hostname, |
| 267 | .addr = addr, |
| 268 | .addrlen = addrlen, |
| 269 | .rpc_ops = &nfs_v4_clientops, |
| 270 | .proto = proto, |
| 271 | .minorversion = minorversion, |
| 272 | .net = net, |
| 273 | }; |
| 274 | struct nfs_client *clp; |
| 275 | int error; |
| 276 | |
| 277 | dprintk("--> nfs4_set_client()\n"); |
| 278 | |
| 279 | if (server->flags & NFS_MOUNT_NORESVPORT) |
| 280 | set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags); |
| 281 | |
| 282 | /* Allocate or find a client reference we can use */ |
| 283 | clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour); |
| 284 | if (IS_ERR(clp)) { |
| 285 | error = PTR_ERR(clp); |
| 286 | goto error; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | * Query for the lease time on clientid setup or renewal |
| 291 | * |
| 292 | * Note that this will be set on nfs_clients that were created |
| 293 | * only for the DS role and did not set this bit, but now will |
| 294 | * serve a dual role. |
| 295 | */ |
| 296 | set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state); |
| 297 | |
| 298 | server->nfs_client = clp; |
| 299 | dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp); |
| 300 | return 0; |
| 301 | error: |
| 302 | dprintk("<-- nfs4_set_client() = xerror %d\n", error); |
| 303 | return error; |
| 304 | } |
| 305 | |
| 306 | /* |
| 307 | * Set up a pNFS Data Server client. |
| 308 | * |
| 309 | * Return any existing nfs_client that matches server address,port,version |
| 310 | * and minorversion. |
| 311 | * |
| 312 | * For a new nfs_client, use a soft mount (default), a low retrans and a |
| 313 | * low timeout interval so that if a connection is lost, we retry through |
| 314 | * the MDS. |
| 315 | */ |
| 316 | struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp, |
| 317 | const struct sockaddr *ds_addr, int ds_addrlen, |
| 318 | int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans) |
| 319 | { |
| 320 | struct nfs_client_initdata cl_init = { |
| 321 | .addr = ds_addr, |
| 322 | .addrlen = ds_addrlen, |
| 323 | .rpc_ops = &nfs_v4_clientops, |
| 324 | .proto = ds_proto, |
| 325 | .minorversion = mds_clp->cl_minorversion, |
| 326 | .net = mds_clp->cl_net, |
| 327 | }; |
| 328 | struct rpc_timeout ds_timeout; |
| 329 | struct nfs_client *clp; |
| 330 | |
| 331 | /* |
| 332 | * Set an authflavor equual to the MDS value. Use the MDS nfs_client |
| 333 | * cl_ipaddr so as to use the same EXCHANGE_ID co_ownerid as the MDS |
| 334 | * (section 13.1 RFC 5661). |
| 335 | */ |
| 336 | nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans); |
| 337 | clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr, |
| 338 | mds_clp->cl_rpcclient->cl_auth->au_flavor); |
| 339 | |
| 340 | dprintk("<-- %s %p\n", __func__, clp); |
| 341 | return clp; |
| 342 | } |
| 343 | EXPORT_SYMBOL_GPL(nfs4_set_ds_client); |
| 344 | |
| 345 | /* |
| 346 | * Session has been established, and the client marked ready. |
| 347 | * Set the mount rsize and wsize with negotiated fore channel |
| 348 | * attributes which will be bound checked in nfs_server_set_fsinfo. |
| 349 | */ |
| 350 | static void nfs4_session_set_rwsize(struct nfs_server *server) |
| 351 | { |
| 352 | #ifdef CONFIG_NFS_V4_1 |
| 353 | struct nfs4_session *sess; |
| 354 | u32 server_resp_sz; |
| 355 | u32 server_rqst_sz; |
| 356 | |
| 357 | if (!nfs4_has_session(server->nfs_client)) |
| 358 | return; |
| 359 | sess = server->nfs_client->cl_session; |
| 360 | server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; |
| 361 | server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; |
| 362 | |
| 363 | if (server->rsize > server_resp_sz) |
| 364 | server->rsize = server_resp_sz; |
| 365 | if (server->wsize > server_rqst_sz) |
| 366 | server->wsize = server_rqst_sz; |
| 367 | #endif /* CONFIG_NFS_V4_1 */ |
| 368 | } |
| 369 | |
| 370 | static int nfs4_server_common_setup(struct nfs_server *server, |
| 371 | struct nfs_fh *mntfh) |
| 372 | { |
| 373 | struct nfs_fattr *fattr; |
| 374 | int error; |
| 375 | |
| 376 | BUG_ON(!server->nfs_client); |
| 377 | BUG_ON(!server->nfs_client->rpc_ops); |
| 378 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 379 | |
| 380 | /* data servers support only a subset of NFSv4.1 */ |
| 381 | if (is_ds_only_client(server->nfs_client)) |
| 382 | return -EPROTONOSUPPORT; |
| 383 | |
| 384 | fattr = nfs_alloc_fattr(); |
| 385 | if (fattr == NULL) |
| 386 | return -ENOMEM; |
| 387 | |
| 388 | /* We must ensure the session is initialised first */ |
| 389 | error = nfs4_init_session(server); |
| 390 | if (error < 0) |
| 391 | goto out; |
| 392 | |
| 393 | /* Probe the root fh to retrieve its FSID and filehandle */ |
| 394 | error = nfs4_get_rootfh(server, mntfh); |
| 395 | if (error < 0) |
| 396 | goto out; |
| 397 | |
| 398 | dprintk("Server FSID: %llx:%llx\n", |
| 399 | (unsigned long long) server->fsid.major, |
| 400 | (unsigned long long) server->fsid.minor); |
| 401 | dprintk("Mount FH: %d\n", mntfh->size); |
| 402 | |
| 403 | nfs4_session_set_rwsize(server); |
| 404 | |
| 405 | error = nfs_probe_fsinfo(server, mntfh, fattr); |
| 406 | if (error < 0) |
| 407 | goto out; |
| 408 | |
| 409 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) |
| 410 | server->namelen = NFS4_MAXNAMLEN; |
| 411 | |
| 412 | nfs_server_insert_lists(server); |
| 413 | server->mount_time = jiffies; |
| 414 | server->destroy = nfs4_destroy_server; |
| 415 | out: |
| 416 | nfs_free_fattr(fattr); |
| 417 | return error; |
| 418 | } |
| 419 | |
| 420 | /* |
| 421 | * Create a version 4 volume record |
| 422 | */ |
| 423 | static int nfs4_init_server(struct nfs_server *server, |
| 424 | const struct nfs_parsed_mount_data *data) |
| 425 | { |
| 426 | struct rpc_timeout timeparms; |
| 427 | int error; |
| 428 | |
| 429 | dprintk("--> nfs4_init_server()\n"); |
| 430 | |
| 431 | nfs_init_timeout_values(&timeparms, data->nfs_server.protocol, |
| 432 | data->timeo, data->retrans); |
| 433 | |
| 434 | /* Initialise the client representation from the mount data */ |
| 435 | server->flags = data->flags; |
| 436 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR|NFS_CAP_POSIX_LOCK; |
| 437 | if (!(data->flags & NFS_MOUNT_NORDIRPLUS)) |
| 438 | server->caps |= NFS_CAP_READDIRPLUS; |
| 439 | server->options = data->options; |
| 440 | |
| 441 | /* Get a client record */ |
| 442 | error = nfs4_set_client(server, |
| 443 | data->nfs_server.hostname, |
| 444 | (const struct sockaddr *)&data->nfs_server.address, |
| 445 | data->nfs_server.addrlen, |
| 446 | data->client_address, |
| 447 | data->auth_flavors[0], |
| 448 | data->nfs_server.protocol, |
| 449 | &timeparms, |
| 450 | data->minorversion, |
| 451 | data->net); |
| 452 | if (error < 0) |
| 453 | goto error; |
| 454 | |
| 455 | /* |
| 456 | * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower |
| 457 | * authentication. |
| 458 | */ |
| 459 | if (nfs4_disable_idmapping && data->auth_flavors[0] == RPC_AUTH_UNIX) |
| 460 | server->caps |= NFS_CAP_UIDGID_NOMAP; |
| 461 | |
| 462 | if (data->rsize) |
| 463 | server->rsize = nfs_block_size(data->rsize, NULL); |
| 464 | if (data->wsize) |
| 465 | server->wsize = nfs_block_size(data->wsize, NULL); |
| 466 | |
| 467 | server->acregmin = data->acregmin * HZ; |
| 468 | server->acregmax = data->acregmax * HZ; |
| 469 | server->acdirmin = data->acdirmin * HZ; |
| 470 | server->acdirmax = data->acdirmax * HZ; |
| 471 | |
| 472 | server->port = data->nfs_server.port; |
| 473 | |
| 474 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); |
| 475 | |
| 476 | error: |
| 477 | /* Done */ |
| 478 | dprintk("<-- nfs4_init_server() = %d\n", error); |
| 479 | return error; |
| 480 | } |
| 481 | |
| 482 | /* |
| 483 | * Create a version 4 volume record |
| 484 | * - keyed on server and FSID |
| 485 | */ |
| 486 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, |
| 487 | struct nfs_fh *mntfh) |
| 488 | { |
| 489 | struct nfs_server *server; |
| 490 | int error; |
| 491 | |
| 492 | dprintk("--> nfs4_create_server()\n"); |
| 493 | |
| 494 | server = nfs_alloc_server(); |
| 495 | if (!server) |
| 496 | return ERR_PTR(-ENOMEM); |
| 497 | |
| 498 | /* set up the general RPC client */ |
| 499 | error = nfs4_init_server(server, data); |
| 500 | if (error < 0) |
| 501 | goto error; |
| 502 | |
| 503 | error = nfs4_server_common_setup(server, mntfh); |
| 504 | if (error < 0) |
| 505 | goto error; |
| 506 | |
| 507 | dprintk("<-- nfs4_create_server() = %p\n", server); |
| 508 | return server; |
| 509 | |
| 510 | error: |
| 511 | nfs_free_server(server); |
| 512 | dprintk("<-- nfs4_create_server() = error %d\n", error); |
| 513 | return ERR_PTR(error); |
| 514 | } |
| 515 | |
| 516 | /* |
| 517 | * Create an NFS4 referral server record |
| 518 | */ |
| 519 | struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, |
| 520 | struct nfs_fh *mntfh) |
| 521 | { |
| 522 | struct nfs_client *parent_client; |
| 523 | struct nfs_server *server, *parent_server; |
| 524 | int error; |
| 525 | |
| 526 | dprintk("--> nfs4_create_referral_server()\n"); |
| 527 | |
| 528 | server = nfs_alloc_server(); |
| 529 | if (!server) |
| 530 | return ERR_PTR(-ENOMEM); |
| 531 | |
| 532 | parent_server = NFS_SB(data->sb); |
| 533 | parent_client = parent_server->nfs_client; |
| 534 | |
| 535 | /* Initialise the client representation from the parent server */ |
| 536 | nfs_server_copy_userdata(server, parent_server); |
| 537 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR; |
| 538 | |
| 539 | /* Get a client representation. |
| 540 | * Note: NFSv4 always uses TCP, */ |
| 541 | error = nfs4_set_client(server, data->hostname, |
| 542 | data->addr, |
| 543 | data->addrlen, |
| 544 | parent_client->cl_ipaddr, |
| 545 | data->authflavor, |
| 546 | rpc_protocol(parent_server->client), |
| 547 | parent_server->client->cl_timeout, |
| 548 | parent_client->cl_mvops->minor_version, |
| 549 | parent_client->cl_net); |
| 550 | if (error < 0) |
| 551 | goto error; |
| 552 | |
| 553 | error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor); |
| 554 | if (error < 0) |
| 555 | goto error; |
| 556 | |
| 557 | error = nfs4_server_common_setup(server, mntfh); |
| 558 | if (error < 0) |
| 559 | goto error; |
| 560 | |
| 561 | dprintk("<-- nfs_create_referral_server() = %p\n", server); |
| 562 | return server; |
| 563 | |
| 564 | error: |
| 565 | nfs_free_server(server); |
| 566 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); |
| 567 | return ERR_PTR(error); |
| 568 | } |
| 569 | |
| 570 | module_param(nfs4_disable_idmapping, bool, 0644); |
| 571 | MODULE_PARM_DESC(nfs4_disable_idmapping, |
| 572 | "Turn off NFSv4 idmapping when using 'sec=sys'"); |