linux/fs/nfs/client.c
<<
>>
Prefs
   1/* client.c: NFS client sharing and management code
   2 *
   3 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
   4 * Written by David Howells (dhowells@redhat.com)
   5 *
   6 * This program is free software; you can redistribute it and/or
   7 * modify it under the terms of the GNU General Public License
   8 * as published by the Free Software Foundation; either version
   9 * 2 of the License, or (at your option) any later version.
  10 */
  11
  12
  13#include <linux/module.h>
  14#include <linux/init.h>
  15#include <linux/sched.h>
  16#include <linux/time.h>
  17#include <linux/kernel.h>
  18#include <linux/mm.h>
  19#include <linux/string.h>
  20#include <linux/stat.h>
  21#include <linux/errno.h>
  22#include <linux/unistd.h>
  23#include <linux/sunrpc/clnt.h>
  24#include <linux/sunrpc/stats.h>
  25#include <linux/sunrpc/metrics.h>
  26#include <linux/sunrpc/xprtsock.h>
  27#include <linux/sunrpc/xprtrdma.h>
  28#include <linux/nfs_fs.h>
  29#include <linux/nfs_mount.h>
  30#include <linux/nfs4_mount.h>
  31#include <linux/lockd/bind.h>
  32#include <linux/seq_file.h>
  33#include <linux/mount.h>
  34#include <linux/nfs_idmap.h>
  35#include <linux/vfs.h>
  36#include <linux/inet.h>
  37#include <linux/in6.h>
  38#include <linux/slab.h>
  39#include <net/ipv6.h>
  40#include <linux/nfs_xdr.h>
  41#include <linux/sunrpc/bc_xprt.h>
  42
  43#include <asm/system.h>
  44
  45#include "nfs4_fs.h"
  46#include "callback.h"
  47#include "delegation.h"
  48#include "iostat.h"
  49#include "internal.h"
  50#include "fscache.h"
  51#include "pnfs.h"
  52
  53#define NFSDBG_FACILITY         NFSDBG_CLIENT
  54
  55static DEFINE_SPINLOCK(nfs_client_lock);
  56static LIST_HEAD(nfs_client_list);
  57static LIST_HEAD(nfs_volume_list);
  58static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq);
  59#ifdef CONFIG_NFS_V4
  60static DEFINE_IDR(cb_ident_idr); /* Protected by nfs_client_lock */
  61
  62/*
  63 * Get a unique NFSv4.0 callback identifier which will be used
  64 * by the V4.0 callback service to lookup the nfs_client struct
  65 */
  66static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
  67{
  68        int ret = 0;
  69
  70        if (clp->rpc_ops->version != 4 || minorversion != 0)
  71                return ret;
  72retry:
  73        if (!idr_pre_get(&cb_ident_idr, GFP_KERNEL))
  74                return -ENOMEM;
  75        spin_lock(&nfs_client_lock);
  76        ret = idr_get_new(&cb_ident_idr, clp, &clp->cl_cb_ident);
  77        spin_unlock(&nfs_client_lock);
  78        if (ret == -EAGAIN)
  79                goto retry;
  80        return ret;
  81}
  82#endif /* CONFIG_NFS_V4 */
  83
  84/*
  85 * Turn off NFSv4 uid/gid mapping when using AUTH_SYS
  86 */
  87static bool nfs4_disable_idmapping = true;
  88
  89/*
  90 * RPC cruft for NFS
  91 */
  92static struct rpc_version *nfs_version[5] = {
  93        [2]                     = &nfs_version2,
  94#ifdef CONFIG_NFS_V3
  95        [3]                     = &nfs_version3,
  96#endif
  97#ifdef CONFIG_NFS_V4
  98        [4]                     = &nfs_version4,
  99#endif
 100};
 101
 102struct rpc_program nfs_program = {
 103        .name                   = "nfs",
 104        .number                 = NFS_PROGRAM,
 105        .nrvers                 = ARRAY_SIZE(nfs_version),
 106        .version                = nfs_version,
 107        .stats                  = &nfs_rpcstat,
 108        .pipe_dir_name          = NFS_PIPE_DIRNAME,
 109};
 110
 111struct rpc_stat nfs_rpcstat = {
 112        .program                = &nfs_program
 113};
 114
 115
 116#ifdef CONFIG_NFS_V3_ACL
 117static struct rpc_stat          nfsacl_rpcstat = { &nfsacl_program };
 118static struct rpc_version *     nfsacl_version[] = {
 119        [3]                     = &nfsacl_version3,
 120};
 121
 122struct rpc_program              nfsacl_program = {
 123        .name                   = "nfsacl",
 124        .number                 = NFS_ACL_PROGRAM,
 125        .nrvers                 = ARRAY_SIZE(nfsacl_version),
 126        .version                = nfsacl_version,
 127        .stats                  = &nfsacl_rpcstat,
 128};
 129#endif  /* CONFIG_NFS_V3_ACL */
 130
 131struct nfs_client_initdata {
 132        const char *hostname;
 133        const struct sockaddr *addr;
 134        size_t addrlen;
 135        const struct nfs_rpc_ops *rpc_ops;
 136        int proto;
 137        u32 minorversion;
 138};
 139
 140/*
 141 * Allocate a shared client record
 142 *
 143 * Since these are allocated/deallocated very rarely, we don't
 144 * bother putting them in a slab cache...
 145 */
 146static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
 147{
 148        struct nfs_client *clp;
 149        struct rpc_cred *cred;
 150        int err = -ENOMEM;
 151
 152        if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
 153                goto error_0;
 154
 155        clp->rpc_ops = cl_init->rpc_ops;
 156
 157        atomic_set(&clp->cl_count, 1);
 158        clp->cl_cons_state = NFS_CS_INITING;
 159
 160        memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen);
 161        clp->cl_addrlen = cl_init->addrlen;
 162
 163        if (cl_init->hostname) {
 164                err = -ENOMEM;
 165                clp->cl_hostname = kstrdup(cl_init->hostname, GFP_KERNEL);
 166                if (!clp->cl_hostname)
 167                        goto error_cleanup;
 168        }
 169
 170        INIT_LIST_HEAD(&clp->cl_superblocks);
 171        clp->cl_rpcclient = ERR_PTR(-EINVAL);
 172
 173        clp->cl_proto = cl_init->proto;
 174
 175#ifdef CONFIG_NFS_V4
 176        err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
 177        if (err)
 178                goto error_cleanup;
 179
 180        spin_lock_init(&clp->cl_lock);
 181        INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
 182        rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
 183        clp->cl_boot_time = CURRENT_TIME;
 184        clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
 185        clp->cl_minorversion = cl_init->minorversion;
 186        clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
 187#endif
 188        cred = rpc_lookup_machine_cred("*");
 189        if (!IS_ERR(cred))
 190                clp->cl_machine_cred = cred;
 191        nfs_fscache_get_client_cookie(clp);
 192
 193        return clp;
 194
 195error_cleanup:
 196        kfree(clp);
 197error_0:
 198        return ERR_PTR(err);
 199}
 200
 201#ifdef CONFIG_NFS_V4
 202#ifdef CONFIG_NFS_V4_1
 203static void nfs4_shutdown_session(struct nfs_client *clp)
 204{
 205        if (nfs4_has_session(clp))
 206                nfs4_destroy_session(clp->cl_session);
 207}
 208#else /* CONFIG_NFS_V4_1 */
 209static void nfs4_shutdown_session(struct nfs_client *clp)
 210{
 211}
 212#endif /* CONFIG_NFS_V4_1 */
 213
 214/*
 215 * Destroy the NFS4 callback service
 216 */
 217static void nfs4_destroy_callback(struct nfs_client *clp)
 218{
 219        if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
 220                nfs_callback_down(clp->cl_mvops->minor_version);
 221}
 222
 223static void nfs4_shutdown_client(struct nfs_client *clp)
 224{
 225        if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
 226                nfs4_kill_renewd(clp);
 227        nfs4_shutdown_session(clp);
 228        nfs4_destroy_callback(clp);
 229        if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
 230                nfs_idmap_delete(clp);
 231
 232        rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
 233}
 234
 235/* idr_remove_all is not needed as all id's are removed by nfs_put_client */
 236void nfs_cleanup_cb_ident_idr(void)
 237{
 238        idr_destroy(&cb_ident_idr);
 239}
 240
 241/* nfs_client_lock held */
 242static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
 243{
 244        if (clp->cl_cb_ident)
 245                idr_remove(&cb_ident_idr, clp->cl_cb_ident);
 246}
 247
 248static void pnfs_init_server(struct nfs_server *server)
 249{
 250        rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC");
 251}
 252
 253static void nfs4_destroy_server(struct nfs_server *server)
 254{
 255        nfs4_purge_state_owners(server);
 256}
 257
 258#else
 259static void nfs4_shutdown_client(struct nfs_client *clp)
 260{
 261}
 262
 263void nfs_cleanup_cb_ident_idr(void)
 264{
 265}
 266
 267static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
 268{
 269}
 270
 271static void pnfs_init_server(struct nfs_server *server)
 272{
 273}
 274
 275#endif /* CONFIG_NFS_V4 */
 276
 277/*
 278 * Destroy a shared client record
 279 */
 280static void nfs_free_client(struct nfs_client *clp)
 281{
 282        dprintk("--> nfs_free_client(%u)\n", clp->rpc_ops->version);
 283
 284        nfs4_shutdown_client(clp);
 285
 286        nfs_fscache_release_client_cookie(clp);
 287
 288        /* -EIO all pending I/O */
 289        if (!IS_ERR(clp->cl_rpcclient))
 290                rpc_shutdown_client(clp->cl_rpcclient);
 291
 292        if (clp->cl_machine_cred != NULL)
 293                put_rpccred(clp->cl_machine_cred);
 294
 295        nfs4_deviceid_purge_client(clp);
 296
 297        kfree(clp->cl_hostname);
 298        kfree(clp->server_scope);
 299        kfree(clp);
 300
 301        dprintk("<-- nfs_free_client()\n");
 302}
 303
 304/*
 305 * Release a reference to a shared client record
 306 */
 307void nfs_put_client(struct nfs_client *clp)
 308{
 309        if (!clp)
 310                return;
 311
 312        dprintk("--> nfs_put_client({%d})\n", atomic_read(&clp->cl_count));
 313
 314        if (atomic_dec_and_lock(&clp->cl_count, &nfs_client_lock)) {
 315                list_del(&clp->cl_share_link);
 316                nfs_cb_idr_remove_locked(clp);
 317                spin_unlock(&nfs_client_lock);
 318
 319                BUG_ON(!list_empty(&clp->cl_superblocks));
 320
 321                nfs_free_client(clp);
 322        }
 323}
 324EXPORT_SYMBOL_GPL(nfs_put_client);
 325
 326#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 327/*
 328 * Test if two ip6 socket addresses refer to the same socket by
 329 * comparing relevant fields. The padding bytes specifically, are not
 330 * compared. sin6_flowinfo is not compared because it only affects QoS
 331 * and sin6_scope_id is only compared if the address is "link local"
 332 * because "link local" addresses need only be unique to a specific
 333 * link. Conversely, ordinary unicast addresses might have different
 334 * sin6_scope_id.
 335 *
 336 * The caller should ensure both socket addresses are AF_INET6.
 337 */
 338static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
 339                                      const struct sockaddr *sa2)
 340{
 341        const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
 342        const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
 343
 344        if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
 345                return 0;
 346        else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
 347                return sin1->sin6_scope_id == sin2->sin6_scope_id;
 348
 349        return 1;
 350}
 351#else   /* !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) */
 352static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
 353                                      const struct sockaddr *sa2)
 354{
 355        return 0;
 356}
 357#endif
 358
 359/*
 360 * Test if two ip4 socket addresses refer to the same socket, by
 361 * comparing relevant fields. The padding bytes specifically, are
 362 * not compared.
 363 *
 364 * The caller should ensure both socket addresses are AF_INET.
 365 */
 366static int nfs_sockaddr_match_ipaddr4(const struct sockaddr *sa1,
 367                                      const struct sockaddr *sa2)
 368{
 369        const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
 370        const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
 371
 372        return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
 373}
 374
 375static int nfs_sockaddr_cmp_ip6(const struct sockaddr *sa1,
 376                                const struct sockaddr *sa2)
 377{
 378        const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
 379        const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
 380
 381        return nfs_sockaddr_match_ipaddr6(sa1, sa2) &&
 382                (sin1->sin6_port == sin2->sin6_port);
 383}
 384
 385static int nfs_sockaddr_cmp_ip4(const struct sockaddr *sa1,
 386                                const struct sockaddr *sa2)
 387{
 388        const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
 389        const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
 390
 391        return nfs_sockaddr_match_ipaddr4(sa1, sa2) &&
 392                (sin1->sin_port == sin2->sin_port);
 393}
 394
 395/*
 396 * Test if two socket addresses represent the same actual socket,
 397 * by comparing (only) relevant fields, excluding the port number.
 398 */
 399static int nfs_sockaddr_match_ipaddr(const struct sockaddr *sa1,
 400                                     const struct sockaddr *sa2)
 401{
 402        if (sa1->sa_family != sa2->sa_family)
 403                return 0;
 404
 405        switch (sa1->sa_family) {
 406        case AF_INET:
 407                return nfs_sockaddr_match_ipaddr4(sa1, sa2);
 408        case AF_INET6:
 409                return nfs_sockaddr_match_ipaddr6(sa1, sa2);
 410        }
 411        return 0;
 412}
 413
 414/*
 415 * Test if two socket addresses represent the same actual socket,
 416 * by comparing (only) relevant fields, including the port number.
 417 */
 418static int nfs_sockaddr_cmp(const struct sockaddr *sa1,
 419                            const struct sockaddr *sa2)
 420{
 421        if (sa1->sa_family != sa2->sa_family)
 422                return 0;
 423
 424        switch (sa1->sa_family) {
 425        case AF_INET:
 426                return nfs_sockaddr_cmp_ip4(sa1, sa2);
 427        case AF_INET6:
 428                return nfs_sockaddr_cmp_ip6(sa1, sa2);
 429        }
 430        return 0;
 431}
 432
 433/* Common match routine for v4.0 and v4.1 callback services */
 434bool
 435nfs4_cb_match_client(const struct sockaddr *addr, struct nfs_client *clp,
 436                     u32 minorversion)
 437{
 438        struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
 439
 440        /* Don't match clients that failed to initialise */
 441        if (!(clp->cl_cons_state == NFS_CS_READY ||
 442            clp->cl_cons_state == NFS_CS_SESSION_INITING))
 443                return false;
 444
 445        /* Match the version and minorversion */
 446        if (clp->rpc_ops->version != 4 ||
 447            clp->cl_minorversion != minorversion)
 448                return false;
 449
 450        /* Match only the IP address, not the port number */
 451        if (!nfs_sockaddr_match_ipaddr(addr, clap))
 452                return false;
 453
 454        return true;
 455}
 456
 457/*
 458 * Find an nfs_client on the list that matches the initialisation data
 459 * that is supplied.
 460 */
 461static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *data)
 462{
 463        struct nfs_client *clp;
 464        const struct sockaddr *sap = data->addr;
 465
 466        list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
 467                const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
 468                /* Don't match clients that failed to initialise properly */
 469                if (clp->cl_cons_state < 0)
 470                        continue;
 471
 472                /* Different NFS versions cannot share the same nfs_client */
 473                if (clp->rpc_ops != data->rpc_ops)
 474                        continue;
 475
 476                if (clp->cl_proto != data->proto)
 477                        continue;
 478                /* Match nfsv4 minorversion */
 479                if (clp->cl_minorversion != data->minorversion)
 480                        continue;
 481                /* Match the full socket address */
 482                if (!nfs_sockaddr_cmp(sap, clap))
 483                        continue;
 484
 485                atomic_inc(&clp->cl_count);
 486                return clp;
 487        }
 488        return NULL;
 489}
 490
 491/*
 492 * Look up a client by IP address and protocol version
 493 * - creates a new record if one doesn't yet exist
 494 */
 495static struct nfs_client *
 496nfs_get_client(const struct nfs_client_initdata *cl_init,
 497               const struct rpc_timeout *timeparms,
 498               const char *ip_addr,
 499               rpc_authflavor_t authflavour,
 500               int noresvport)
 501{
 502        struct nfs_client *clp, *new = NULL;
 503        int error;
 504
 505        dprintk("--> nfs_get_client(%s,v%u)\n",
 506                cl_init->hostname ?: "", cl_init->rpc_ops->version);
 507
 508        /* see if the client already exists */
 509        do {
 510                spin_lock(&nfs_client_lock);
 511
 512                clp = nfs_match_client(cl_init);
 513                if (clp)
 514                        goto found_client;
 515                if (new)
 516                        goto install_client;
 517
 518                spin_unlock(&nfs_client_lock);
 519
 520                new = nfs_alloc_client(cl_init);
 521        } while (!IS_ERR(new));
 522
 523        dprintk("--> nfs_get_client() = %ld [failed]\n", PTR_ERR(new));
 524        return new;
 525
 526        /* install a new client and return with it unready */
 527install_client:
 528        clp = new;
 529        list_add(&clp->cl_share_link, &nfs_client_list);
 530        spin_unlock(&nfs_client_lock);
 531
 532        error = cl_init->rpc_ops->init_client(clp, timeparms, ip_addr,
 533                                              authflavour, noresvport);
 534        if (error < 0) {
 535                nfs_put_client(clp);
 536                return ERR_PTR(error);
 537        }
 538        dprintk("--> nfs_get_client() = %p [new]\n", clp);
 539        return clp;
 540
 541        /* found an existing client
 542         * - make sure it's ready before returning
 543         */
 544found_client:
 545        spin_unlock(&nfs_client_lock);
 546
 547        if (new)
 548                nfs_free_client(new);
 549
 550        error = wait_event_killable(nfs_client_active_wq,
 551                                clp->cl_cons_state < NFS_CS_INITING);
 552        if (error < 0) {
 553                nfs_put_client(clp);
 554                return ERR_PTR(-ERESTARTSYS);
 555        }
 556
 557        if (clp->cl_cons_state < NFS_CS_READY) {
 558                error = clp->cl_cons_state;
 559                nfs_put_client(clp);
 560                return ERR_PTR(error);
 561        }
 562
 563        BUG_ON(clp->cl_cons_state != NFS_CS_READY);
 564
 565        dprintk("--> nfs_get_client() = %p [share]\n", clp);
 566        return clp;
 567}
 568
 569/*
 570 * Mark a server as ready or failed
 571 */
 572void nfs_mark_client_ready(struct nfs_client *clp, int state)
 573{
 574        clp->cl_cons_state = state;
 575        wake_up_all(&nfs_client_active_wq);
 576}
 577
 578/*
 579 * With sessions, the client is not marked ready until after a
 580 * successful EXCHANGE_ID and CREATE_SESSION.
 581 *
 582 * Map errors cl_cons_state errors to EPROTONOSUPPORT to indicate
 583 * other versions of NFS can be tried.
 584 */
 585int nfs4_check_client_ready(struct nfs_client *clp)
 586{
 587        if (!nfs4_has_session(clp))
 588                return 0;
 589        if (clp->cl_cons_state < NFS_CS_READY)
 590                return -EPROTONOSUPPORT;
 591        return 0;
 592}
 593
 594/*
 595 * Initialise the timeout values for a connection
 596 */
 597static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
 598                                    unsigned int timeo, unsigned int retrans)
 599{
 600        to->to_initval = timeo * HZ / 10;
 601        to->to_retries = retrans;
 602
 603        switch (proto) {
 604        case XPRT_TRANSPORT_TCP:
 605        case XPRT_TRANSPORT_RDMA:
 606                if (to->to_retries == 0)
 607                        to->to_retries = NFS_DEF_TCP_RETRANS;
 608                if (to->to_initval == 0)
 609                        to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10;
 610                if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
 611                        to->to_initval = NFS_MAX_TCP_TIMEOUT;
 612                to->to_increment = to->to_initval;
 613                to->to_maxval = to->to_initval + (to->to_increment * to->to_retries);
 614                if (to->to_maxval > NFS_MAX_TCP_TIMEOUT)
 615                        to->to_maxval = NFS_MAX_TCP_TIMEOUT;
 616                if (to->to_maxval < to->to_initval)
 617                        to->to_maxval = to->to_initval;
 618                to->to_exponential = 0;
 619                break;
 620        case XPRT_TRANSPORT_UDP:
 621                if (to->to_retries == 0)
 622                        to->to_retries = NFS_DEF_UDP_RETRANS;
 623                if (!to->to_initval)
 624                        to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10;
 625                if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
 626                        to->to_initval = NFS_MAX_UDP_TIMEOUT;
 627                to->to_maxval = NFS_MAX_UDP_TIMEOUT;
 628                to->to_exponential = 1;
 629                break;
 630        default:
 631                BUG();
 632        }
 633}
 634
 635/*
 636 * Create an RPC client handle
 637 */
 638static int nfs_create_rpc_client(struct nfs_client *clp,
 639                                 const struct rpc_timeout *timeparms,
 640                                 rpc_authflavor_t flavor,
 641                                 int discrtry, int noresvport)
 642{
 643        struct rpc_clnt         *clnt = NULL;
 644        struct rpc_create_args args = {
 645                .net            = &init_net,
 646                .protocol       = clp->cl_proto,
 647                .address        = (struct sockaddr *)&clp->cl_addr,
 648                .addrsize       = clp->cl_addrlen,
 649                .timeout        = timeparms,
 650                .servername     = clp->cl_hostname,
 651                .program        = &nfs_program,
 652                .version        = clp->rpc_ops->version,
 653                .authflavor     = flavor,
 654        };
 655
 656        if (discrtry)
 657                args.flags |= RPC_CLNT_CREATE_DISCRTRY;
 658        if (noresvport)
 659                args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
 660
 661        if (!IS_ERR(clp->cl_rpcclient))
 662                return 0;
 663
 664        clnt = rpc_create(&args);
 665        if (IS_ERR(clnt)) {
 666                dprintk("%s: cannot create RPC client. Error = %ld\n",
 667                                __func__, PTR_ERR(clnt));
 668                return PTR_ERR(clnt);
 669        }
 670
 671        clp->cl_rpcclient = clnt;
 672        return 0;
 673}
 674
 675/*
 676 * Version 2 or 3 client destruction
 677 */
 678static void nfs_destroy_server(struct nfs_server *server)
 679{
 680        if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
 681                        !(server->flags & NFS_MOUNT_LOCAL_FCNTL))
 682                nlmclnt_done(server->nlm_host);
 683}
 684
 685/*
 686 * Version 2 or 3 lockd setup
 687 */
 688static int nfs_start_lockd(struct nfs_server *server)
 689{
 690        struct nlm_host *host;
 691        struct nfs_client *clp = server->nfs_client;
 692        struct nlmclnt_initdata nlm_init = {
 693                .hostname       = clp->cl_hostname,
 694                .address        = (struct sockaddr *)&clp->cl_addr,
 695                .addrlen        = clp->cl_addrlen,
 696                .nfs_version    = clp->rpc_ops->version,
 697                .noresvport     = server->flags & NFS_MOUNT_NORESVPORT ?
 698                                        1 : 0,
 699        };
 700
 701        if (nlm_init.nfs_version > 3)
 702                return 0;
 703        if ((server->flags & NFS_MOUNT_LOCAL_FLOCK) &&
 704                        (server->flags & NFS_MOUNT_LOCAL_FCNTL))
 705                return 0;
 706
 707        switch (clp->cl_proto) {
 708                default:
 709                        nlm_init.protocol = IPPROTO_TCP;
 710                        break;
 711                case XPRT_TRANSPORT_UDP:
 712                        nlm_init.protocol = IPPROTO_UDP;
 713        }
 714
 715        host = nlmclnt_init(&nlm_init);
 716        if (IS_ERR(host))
 717                return PTR_ERR(host);
 718
 719        server->nlm_host = host;
 720        server->destroy = nfs_destroy_server;
 721        return 0;
 722}
 723
 724/*
 725 * Initialise an NFSv3 ACL client connection
 726 */
 727#ifdef CONFIG_NFS_V3_ACL
 728static void nfs_init_server_aclclient(struct nfs_server *server)
 729{
 730        if (server->nfs_client->rpc_ops->version != 3)
 731                goto out_noacl;
 732        if (server->flags & NFS_MOUNT_NOACL)
 733                goto out_noacl;
 734
 735        server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
 736        if (IS_ERR(server->client_acl))
 737                goto out_noacl;
 738
 739        /* No errors! Assume that Sun nfsacls are supported */
 740        server->caps |= NFS_CAP_ACLS;
 741        return;
 742
 743out_noacl:
 744        server->caps &= ~NFS_CAP_ACLS;
 745}
 746#else
 747static inline void nfs_init_server_aclclient(struct nfs_server *server)
 748{
 749        server->flags &= ~NFS_MOUNT_NOACL;
 750        server->caps &= ~NFS_CAP_ACLS;
 751}
 752#endif
 753
 754/*
 755 * Create a general RPC client
 756 */
 757static int nfs_init_server_rpcclient(struct nfs_server *server,
 758                const struct rpc_timeout *timeo,
 759                rpc_authflavor_t pseudoflavour)
 760{
 761        struct nfs_client *clp = server->nfs_client;
 762
 763        server->client = rpc_clone_client(clp->cl_rpcclient);
 764        if (IS_ERR(server->client)) {
 765                dprintk("%s: couldn't create rpc_client!\n", __func__);
 766                return PTR_ERR(server->client);
 767        }
 768
 769        memcpy(&server->client->cl_timeout_default,
 770                        timeo,
 771                        sizeof(server->client->cl_timeout_default));
 772        server->client->cl_timeout = &server->client->cl_timeout_default;
 773
 774        if (pseudoflavour != clp->cl_rpcclient->cl_auth->au_flavor) {
 775                struct rpc_auth *auth;
 776
 777                auth = rpcauth_create(pseudoflavour, server->client);
 778                if (IS_ERR(auth)) {
 779                        dprintk("%s: couldn't create credcache!\n", __func__);
 780                        return PTR_ERR(auth);
 781                }
 782        }
 783        server->client->cl_softrtry = 0;
 784        if (server->flags & NFS_MOUNT_SOFT)
 785                server->client->cl_softrtry = 1;
 786
 787        return 0;
 788}
 789
 790/*
 791 * Initialise an NFS2 or NFS3 client
 792 */
 793int nfs_init_client(struct nfs_client *clp, const struct rpc_timeout *timeparms,
 794                    const char *ip_addr, rpc_authflavor_t authflavour,
 795                    int noresvport)
 796{
 797        int error;
 798
 799        if (clp->cl_cons_state == NFS_CS_READY) {
 800                /* the client is already initialised */
 801                dprintk("<-- nfs_init_client() = 0 [already %p]\n", clp);
 802                return 0;
 803        }
 804
 805        /*
 806         * Create a client RPC handle for doing FSSTAT with UNIX auth only
 807         * - RFC 2623, sec 2.3.2
 808         */
 809        error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX,
 810                                      0, noresvport);
 811        if (error < 0)
 812                goto error;
 813        nfs_mark_client_ready(clp, NFS_CS_READY);
 814        return 0;
 815
 816error:
 817        nfs_mark_client_ready(clp, error);
 818        dprintk("<-- nfs_init_client() = xerror %d\n", error);
 819        return error;
 820}
 821
 822/*
 823 * Create a version 2 or 3 client
 824 */
 825static int nfs_init_server(struct nfs_server *server,
 826                           const struct nfs_parsed_mount_data *data)
 827{
 828        struct nfs_client_initdata cl_init = {
 829                .hostname = data->nfs_server.hostname,
 830                .addr = (const struct sockaddr *)&data->nfs_server.address,
 831                .addrlen = data->nfs_server.addrlen,
 832                .rpc_ops = &nfs_v2_clientops,
 833                .proto = data->nfs_server.protocol,
 834        };
 835        struct rpc_timeout timeparms;
 836        struct nfs_client *clp;
 837        int error;
 838
 839        dprintk("--> nfs_init_server()\n");
 840
 841#ifdef CONFIG_NFS_V3
 842        if (data->version == 3)
 843                cl_init.rpc_ops = &nfs_v3_clientops;
 844#endif
 845
 846        nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
 847                        data->timeo, data->retrans);
 848
 849        /* Allocate or find a client reference we can use */
 850        clp = nfs_get_client(&cl_init, &timeparms, NULL, RPC_AUTH_UNIX,
 851                             data->flags & NFS_MOUNT_NORESVPORT);
 852        if (IS_ERR(clp)) {
 853                dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp));
 854                return PTR_ERR(clp);
 855        }
 856
 857        server->nfs_client = clp;
 858
 859        /* Initialise the client representation from the mount data */
 860        server->flags = data->flags;
 861        server->options = data->options;
 862        server->caps |= NFS_CAP_HARDLINKS|NFS_CAP_SYMLINKS|NFS_CAP_FILEID|
 863                NFS_CAP_MODE|NFS_CAP_NLINK|NFS_CAP_OWNER|NFS_CAP_OWNER_GROUP|
 864                NFS_CAP_ATIME|NFS_CAP_CTIME|NFS_CAP_MTIME;
 865
 866        if (data->rsize)
 867                server->rsize = nfs_block_size(data->rsize, NULL);
 868        if (data->wsize)
 869                server->wsize = nfs_block_size(data->wsize, NULL);
 870
 871        server->acregmin = data->acregmin * HZ;
 872        server->acregmax = data->acregmax * HZ;
 873        server->acdirmin = data->acdirmin * HZ;
 874        server->acdirmax = data->acdirmax * HZ;
 875
 876        /* Start lockd here, before we might error out */
 877        error = nfs_start_lockd(server);
 878        if (error < 0)
 879                goto error;
 880
 881        server->port = data->nfs_server.port;
 882
 883        error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
 884        if (error < 0)
 885                goto error;
 886
 887        /* Preserve the values of mount_server-related mount options */
 888        if (data->mount_server.addrlen) {
 889                memcpy(&server->mountd_address, &data->mount_server.address,
 890                        data->mount_server.addrlen);
 891                server->mountd_addrlen = data->mount_server.addrlen;
 892        }
 893        server->mountd_version = data->mount_server.version;
 894        server->mountd_port = data->mount_server.port;
 895        server->mountd_protocol = data->mount_server.protocol;
 896
 897        server->namelen  = data->namlen;
 898        /* Create a client RPC handle for the NFSv3 ACL management interface */
 899        nfs_init_server_aclclient(server);
 900        dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp);
 901        return 0;
 902
 903error:
 904        server->nfs_client = NULL;
 905        nfs_put_client(clp);
 906        dprintk("<-- nfs_init_server() = xerror %d\n", error);
 907        return error;
 908}
 909
 910/*
 911 * Load up the server record from information gained in an fsinfo record
 912 */
 913static void nfs_server_set_fsinfo(struct nfs_server *server,
 914                                  struct nfs_fh *mntfh,
 915                                  struct nfs_fsinfo *fsinfo)
 916{
 917        unsigned long max_rpc_payload;
 918
 919        /* Work out a lot of parameters */
 920        if (server->rsize == 0)
 921                server->rsize = nfs_block_size(fsinfo->rtpref, NULL);
 922        if (server->wsize == 0)
 923                server->wsize = nfs_block_size(fsinfo->wtpref, NULL);
 924
 925        if (fsinfo->rtmax >= 512 && server->rsize > fsinfo->rtmax)
 926                server->rsize = nfs_block_size(fsinfo->rtmax, NULL);
 927        if (fsinfo->wtmax >= 512 && server->wsize > fsinfo->wtmax)
 928                server->wsize = nfs_block_size(fsinfo->wtmax, NULL);
 929
 930        max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL);
 931        if (server->rsize > max_rpc_payload)
 932                server->rsize = max_rpc_payload;
 933        if (server->rsize > NFS_MAX_FILE_IO_SIZE)
 934                server->rsize = NFS_MAX_FILE_IO_SIZE;
 935        server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 936
 937        server->backing_dev_info.name = "nfs";
 938        server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD;
 939
 940        if (server->wsize > max_rpc_payload)
 941                server->wsize = max_rpc_payload;
 942        if (server->wsize > NFS_MAX_FILE_IO_SIZE)
 943                server->wsize = NFS_MAX_FILE_IO_SIZE;
 944        server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 945        server->pnfs_blksize = fsinfo->blksize;
 946        set_pnfs_layoutdriver(server, mntfh, fsinfo->layouttype);
 947
 948        server->wtmult = nfs_block_bits(fsinfo->wtmult, NULL);
 949
 950        server->dtsize = nfs_block_size(fsinfo->dtpref, NULL);
 951        if (server->dtsize > PAGE_CACHE_SIZE * NFS_MAX_READDIR_PAGES)
 952                server->dtsize = PAGE_CACHE_SIZE * NFS_MAX_READDIR_PAGES;
 953        if (server->dtsize > server->rsize)
 954                server->dtsize = server->rsize;
 955
 956        if (server->flags & NFS_MOUNT_NOAC) {
 957                server->acregmin = server->acregmax = 0;
 958                server->acdirmin = server->acdirmax = 0;
 959        }
 960
 961        server->maxfilesize = fsinfo->maxfilesize;
 962
 963        server->time_delta = fsinfo->time_delta;
 964
 965        /* We're airborne Set socket buffersize */
 966        rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100);
 967}
 968
 969/*
 970 * Probe filesystem information, including the FSID on v2/v3
 971 */
 972static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr)
 973{
 974        struct nfs_fsinfo fsinfo;
 975        struct nfs_client *clp = server->nfs_client;
 976        int error;
 977
 978        dprintk("--> nfs_probe_fsinfo()\n");
 979
 980        if (clp->rpc_ops->set_capabilities != NULL) {
 981                error = clp->rpc_ops->set_capabilities(server, mntfh);
 982                if (error < 0)
 983                        goto out_error;
 984        }
 985
 986        fsinfo.fattr = fattr;
 987        fsinfo.layouttype = 0;
 988        error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo);
 989        if (error < 0)
 990                goto out_error;
 991
 992        nfs_server_set_fsinfo(server, mntfh, &fsinfo);
 993
 994        /* Get some general file system info */
 995        if (server->namelen == 0) {
 996                struct nfs_pathconf pathinfo;
 997
 998                pathinfo.fattr = fattr;
 999                nfs_fattr_init(fattr);
1000
1001                if (clp->rpc_ops->pathconf(server, mntfh, &pathinfo) >= 0)
1002                        server->namelen = pathinfo.max_namelen;
1003        }
1004
1005        dprintk("<-- nfs_probe_fsinfo() = 0\n");
1006        return 0;
1007
1008out_error:
1009        dprintk("nfs_probe_fsinfo: error = %d\n", -error);
1010        return error;
1011}
1012
1013/*
1014 * Copy useful information when duplicating a server record
1015 */
1016static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source)
1017{
1018        target->flags = source->flags;
1019        target->rsize = source->rsize;
1020        target->wsize = source->wsize;
1021        target->acregmin = source->acregmin;
1022        target->acregmax = source->acregmax;
1023        target->acdirmin = source->acdirmin;
1024        target->acdirmax = source->acdirmax;
1025        target->caps = source->caps;
1026        target->options = source->options;
1027}
1028
1029static void nfs_server_insert_lists(struct nfs_server *server)
1030{
1031        struct nfs_client *clp = server->nfs_client;
1032
1033        spin_lock(&nfs_client_lock);
1034        list_add_tail_rcu(&server->client_link, &clp->cl_superblocks);
1035        list_add_tail(&server->master_link, &nfs_volume_list);
1036        clear_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
1037        spin_unlock(&nfs_client_lock);
1038
1039}
1040
1041static void nfs_server_remove_lists(struct nfs_server *server)
1042{
1043        struct nfs_client *clp = server->nfs_client;
1044
1045        spin_lock(&nfs_client_lock);
1046        list_del_rcu(&server->client_link);
1047        if (clp && list_empty(&clp->cl_superblocks))
1048                set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
1049        list_del(&server->master_link);
1050        spin_unlock(&nfs_client_lock);
1051
1052        synchronize_rcu();
1053}
1054
1055/*
1056 * Allocate and initialise a server record
1057 */
1058static struct nfs_server *nfs_alloc_server(void)
1059{
1060        struct nfs_server *server;
1061
1062        server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL);
1063        if (!server)
1064                return NULL;
1065
1066        server->client = server->client_acl = ERR_PTR(-EINVAL);
1067
1068        /* Zero out the NFS state stuff */
1069        INIT_LIST_HEAD(&server->client_link);
1070        INIT_LIST_HEAD(&server->master_link);
1071        INIT_LIST_HEAD(&server->delegations);
1072        INIT_LIST_HEAD(&server->layouts);
1073        INIT_LIST_HEAD(&server->state_owners_lru);
1074
1075        atomic_set(&server->active, 0);
1076
1077        server->io_stats = nfs_alloc_iostats();
1078        if (!server->io_stats) {
1079                kfree(server);
1080                return NULL;
1081        }
1082
1083        if (bdi_init(&server->backing_dev_info)) {
1084                nfs_free_iostats(server->io_stats);
1085                kfree(server);
1086                return NULL;
1087        }
1088
1089        pnfs_init_server(server);
1090
1091        return server;
1092}
1093
1094/*
1095 * Free up a server record
1096 */
1097void nfs_free_server(struct nfs_server *server)
1098{
1099        dprintk("--> nfs_free_server()\n");
1100
1101        nfs_server_remove_lists(server);
1102        unset_pnfs_layoutdriver(server);
1103
1104        if (server->destroy != NULL)
1105                server->destroy(server);
1106
1107        if (!IS_ERR(server->client_acl))
1108                rpc_shutdown_client(server->client_acl);
1109        if (!IS_ERR(server->client))
1110                rpc_shutdown_client(server->client);
1111
1112        nfs_put_client(server->nfs_client);
1113
1114        nfs_free_iostats(server->io_stats);
1115        bdi_destroy(&server->backing_dev_info);
1116        kfree(server);
1117        nfs_release_automount_timer();
1118        dprintk("<-- nfs_free_server()\n");
1119}
1120
1121/*
1122 * Create a version 2 or 3 volume record
1123 * - keyed on server and FSID
1124 */
1125struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
1126                                     struct nfs_fh *mntfh)
1127{
1128        struct nfs_server *server;
1129        struct nfs_fattr *fattr;
1130        int error;
1131
1132        server = nfs_alloc_server();
1133        if (!server)
1134                return ERR_PTR(-ENOMEM);
1135
1136        error = -ENOMEM;
1137        fattr = nfs_alloc_fattr();
1138        if (fattr == NULL)
1139                goto error;
1140
1141        /* Get a client representation */
1142        error = nfs_init_server(server, data);
1143        if (error < 0)
1144                goto error;
1145
1146        BUG_ON(!server->nfs_client);
1147        BUG_ON(!server->nfs_client->rpc_ops);
1148        BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
1149
1150        /* Probe the root fh to retrieve its FSID */
1151        error = nfs_probe_fsinfo(server, mntfh, fattr);
1152        if (error < 0)
1153                goto error;
1154        if (server->nfs_client->rpc_ops->version == 3) {
1155                if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
1156                        server->namelen = NFS3_MAXNAMLEN;
1157                if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
1158                        server->caps |= NFS_CAP_READDIRPLUS;
1159        } else {
1160                if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
1161                        server->namelen = NFS2_MAXNAMLEN;
1162        }
1163
1164        if (!(fattr->valid & NFS_ATTR_FATTR)) {
1165                error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr);
1166                if (error < 0) {
1167                        dprintk("nfs_create_server: getattr error = %d\n", -error);
1168                        goto error;
1169                }
1170        }
1171        memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid));
1172
1173        dprintk("Server FSID: %llx:%llx\n",
1174                (unsigned long long) server->fsid.major,
1175                (unsigned long long) server->fsid.minor);
1176
1177        nfs_server_insert_lists(server);
1178        server->mount_time = jiffies;
1179        nfs_free_fattr(fattr);
1180        return server;
1181
1182error:
1183        nfs_free_fattr(fattr);
1184        nfs_free_server(server);
1185        return ERR_PTR(error);
1186}
1187
1188#ifdef CONFIG_NFS_V4
1189/*
1190 * NFSv4.0 callback thread helper
1191 *
1192 * Find a client by IP address, protocol version, and minorversion
1193 *
1194 * Called from the pg_authenticate method. The callback identifier
1195 * is not used as it has not been decoded.
1196 *
1197 * Returns NULL if no such client
1198 */
1199struct nfs_client *
1200nfs4_find_client_no_ident(const struct sockaddr *addr)
1201{
1202        struct nfs_client *clp;
1203
1204        spin_lock(&nfs_client_lock);
1205        list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
1206                if (nfs4_cb_match_client(addr, clp, 0) == false)
1207                        continue;
1208                atomic_inc(&clp->cl_count);
1209                spin_unlock(&nfs_client_lock);
1210                return clp;
1211        }
1212        spin_unlock(&nfs_client_lock);
1213        return NULL;
1214}
1215
1216/*
1217 * NFSv4.0 callback thread helper
1218 *
1219 * Find a client by callback identifier
1220 */
1221struct nfs_client *
1222nfs4_find_client_ident(int cb_ident)
1223{
1224        struct nfs_client *clp;
1225
1226        spin_lock(&nfs_client_lock);
1227        clp = idr_find(&cb_ident_idr, cb_ident);
1228        if (clp)
1229                atomic_inc(&clp->cl_count);
1230        spin_unlock(&nfs_client_lock);
1231        return clp;
1232}
1233
1234#if defined(CONFIG_NFS_V4_1)
1235/*
1236 * NFSv4.1 callback thread helper
1237 * For CB_COMPOUND calls, find a client by IP address, protocol version,
1238 * minorversion, and sessionID
1239 *
1240 * Returns NULL if no such client
1241 */
1242struct nfs_client *
1243nfs4_find_client_sessionid(const struct sockaddr *addr,
1244                           struct nfs4_sessionid *sid)
1245{
1246        struct nfs_client *clp;
1247
1248        spin_lock(&nfs_client_lock);
1249        list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
1250                if (nfs4_cb_match_client(addr, clp, 1) == false)
1251                        continue;
1252
1253                if (!nfs4_has_session(clp))
1254                        continue;
1255
1256                /* Match sessionid*/
1257                if (memcmp(clp->cl_session->sess_id.data,
1258                    sid->data, NFS4_MAX_SESSIONID_LEN) != 0)
1259                        continue;
1260
1261                atomic_inc(&clp->cl_count);
1262                spin_unlock(&nfs_client_lock);
1263                return clp;
1264        }
1265        spin_unlock(&nfs_client_lock);
1266        return NULL;
1267}
1268
1269#else /* CONFIG_NFS_V4_1 */
1270
1271struct nfs_client *
1272nfs4_find_client_sessionid(const struct sockaddr *addr,
1273                           struct nfs4_sessionid *sid)
1274{
1275        return NULL;
1276}
1277#endif /* CONFIG_NFS_V4_1 */
1278
1279/*
1280 * Initialize the NFS4 callback service
1281 */
1282static int nfs4_init_callback(struct nfs_client *clp)
1283{
1284        int error;
1285
1286        if (clp->rpc_ops->version == 4) {
1287                if (nfs4_has_session(clp)) {
1288                        error = xprt_setup_backchannel(
1289                                                clp->cl_rpcclient->cl_xprt,
1290                                                NFS41_BC_MIN_CALLBACKS);
1291                        if (error < 0)
1292                                return error;
1293                }
1294
1295                error = nfs_callback_up(clp->cl_mvops->minor_version,
1296                                        clp->cl_rpcclient->cl_xprt);
1297                if (error < 0) {
1298                        dprintk("%s: failed to start callback. Error = %d\n",
1299                                __func__, error);
1300                        return error;
1301                }
1302                __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
1303        }
1304        return 0;
1305}
1306
1307/*
1308 * Initialize the minor version specific parts of an NFS4 client record
1309 */
1310static int nfs4_init_client_minor_version(struct nfs_client *clp)
1311{
1312#if defined(CONFIG_NFS_V4_1)
1313        if (clp->cl_mvops->minor_version) {
1314                struct nfs4_session *session = NULL;
1315                /*
1316                 * Create the session and mark it expired.
1317                 * When a SEQUENCE operation encounters the expired session
1318                 * it will do session recovery to initialize it.
1319                 */
1320                session = nfs4_alloc_session(clp);
1321                if (!session)
1322                        return -ENOMEM;
1323
1324                clp->cl_session = session;
1325                /*
1326                 * The create session reply races with the server back
1327                 * channel probe. Mark the client NFS_CS_SESSION_INITING
1328                 * so that the client back channel can find the
1329                 * nfs_client struct
1330                 */
1331                clp->cl_cons_state = NFS_CS_SESSION_INITING;
1332        }
1333#endif /* CONFIG_NFS_V4_1 */
1334
1335        return nfs4_init_callback(clp);
1336}
1337
1338/*
1339 * Initialise an NFS4 client record
1340 */
1341int nfs4_init_client(struct nfs_client *clp,
1342                     const struct rpc_timeout *timeparms,
1343                     const char *ip_addr,
1344                     rpc_authflavor_t authflavour,
1345                     int noresvport)
1346{
1347        int error;
1348
1349        if (clp->cl_cons_state == NFS_CS_READY) {
1350                /* the client is initialised already */
1351                dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp);
1352                return 0;
1353        }
1354
1355        /* Check NFS protocol revision and initialize RPC op vector */
1356        clp->rpc_ops = &nfs_v4_clientops;
1357
1358        error = nfs_create_rpc_client(clp, timeparms, authflavour,
1359                                      1, noresvport);
1360        if (error < 0)
1361                goto error;
1362        strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
1363
1364        error = nfs_idmap_new(clp);
1365        if (error < 0) {
1366                dprintk("%s: failed to create idmapper. Error = %d\n",
1367                        __func__, error);
1368                goto error;
1369        }
1370        __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
1371
1372        error = nfs4_init_client_minor_version(clp);
1373        if (error < 0)
1374                goto error;
1375
1376        if (!nfs4_has_session(clp))
1377                nfs_mark_client_ready(clp, NFS_CS_READY);
1378        return 0;
1379
1380error:
1381        nfs_mark_client_ready(clp, error);
1382        dprintk("<-- nfs4_init_client() = xerror %d\n", error);
1383        return error;
1384}
1385
1386/*
1387 * Set up an NFS4 client
1388 */
1389static int nfs4_set_client(struct nfs_server *server,
1390                const char *hostname,
1391                const struct sockaddr *addr,
1392                const size_t addrlen,
1393                const char *ip_addr,
1394                rpc_authflavor_t authflavour,
1395                int proto, const struct rpc_timeout *timeparms,
1396                u32 minorversion)
1397{
1398        struct nfs_client_initdata cl_init = {
1399                .hostname = hostname,
1400                .addr = addr,
1401                .addrlen = addrlen,
1402                .rpc_ops = &nfs_v4_clientops,
1403                .proto = proto,
1404                .minorversion = minorversion,
1405        };
1406        struct nfs_client *clp;
1407        int error;
1408
1409        dprintk("--> nfs4_set_client()\n");
1410
1411        /* Allocate or find a client reference we can use */
1412        clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour,
1413                             server->flags & NFS_MOUNT_NORESVPORT);
1414        if (IS_ERR(clp)) {
1415                error = PTR_ERR(clp);
1416                goto error;
1417        }
1418
1419        /*
1420         * Query for the lease time on clientid setup or renewal
1421         *
1422         * Note that this will be set on nfs_clients that were created
1423         * only for the DS role and did not set this bit, but now will
1424         * serve a dual role.
1425         */
1426        set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
1427
1428        server->nfs_client = clp;
1429        dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp);
1430        return 0;
1431error:
1432        dprintk("<-- nfs4_set_client() = xerror %d\n", error);
1433        return error;
1434}
1435
1436/*
1437 * Set up a pNFS Data Server client.
1438 *
1439 * Return any existing nfs_client that matches server address,port,version
1440 * and minorversion.
1441 *
1442 * For a new nfs_client, use a soft mount (default), a low retrans and a
1443 * low timeout interval so that if a connection is lost, we retry through
1444 * the MDS.
1445 */
1446struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
1447                const struct sockaddr *ds_addr,
1448                int ds_addrlen, int ds_proto)
1449{
1450        struct nfs_client_initdata cl_init = {
1451                .addr = ds_addr,
1452                .addrlen = ds_addrlen,
1453                .rpc_ops = &nfs_v4_clientops,
1454                .proto = ds_proto,
1455                .minorversion = mds_clp->cl_minorversion,
1456        };
1457        struct rpc_timeout ds_timeout = {
1458                .to_initval = 15 * HZ,
1459                .to_maxval = 15 * HZ,
1460                .to_retries = 1,
1461                .to_exponential = 1,
1462        };
1463        struct nfs_client *clp;
1464
1465        /*
1466         * Set an authflavor equual to the MDS value. Use the MDS nfs_client
1467         * cl_ipaddr so as to use the same EXCHANGE_ID co_ownerid as the MDS
1468         * (section 13.1 RFC 5661).
1469         */
1470        clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr,
1471                             mds_clp->cl_rpcclient->cl_auth->au_flavor, 0);
1472
1473        dprintk("<-- %s %p\n", __func__, clp);
1474        return clp;
1475}
1476EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
1477
1478/*
1479 * Session has been established, and the client marked ready.
1480 * Set the mount rsize and wsize with negotiated fore channel
1481 * attributes which will be bound checked in nfs_server_set_fsinfo.
1482 */
1483static void nfs4_session_set_rwsize(struct nfs_server *server)
1484{
1485#ifdef CONFIG_NFS_V4_1
1486        struct nfs4_session *sess;
1487        u32 server_resp_sz;
1488        u32 server_rqst_sz;
1489
1490        if (!nfs4_has_session(server->nfs_client))
1491                return;
1492        sess = server->nfs_client->cl_session;
1493        server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
1494        server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
1495
1496        if (server->rsize > server_resp_sz)
1497                server->rsize = server_resp_sz;
1498        if (server->wsize > server_rqst_sz)
1499                server->wsize = server_rqst_sz;
1500#endif /* CONFIG_NFS_V4_1 */
1501}
1502
1503static int nfs4_server_common_setup(struct nfs_server *server,
1504                struct nfs_fh *mntfh)
1505{
1506        struct nfs_fattr *fattr;
1507        int error;
1508
1509        BUG_ON(!server->nfs_client);
1510        BUG_ON(!server->nfs_client->rpc_ops);
1511        BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
1512
1513        /* data servers support only a subset of NFSv4.1 */
1514        if (is_ds_only_client(server->nfs_client))
1515                return -EPROTONOSUPPORT;
1516
1517        fattr = nfs_alloc_fattr();
1518        if (fattr == NULL)
1519                return -ENOMEM;
1520
1521        /* We must ensure the session is initialised first */
1522        error = nfs4_init_session(server);
1523        if (error < 0)
1524                goto out;
1525
1526        /* Probe the root fh to retrieve its FSID and filehandle */
1527        error = nfs4_get_rootfh(server, mntfh);
1528        if (error < 0)
1529                goto out;
1530
1531        dprintk("Server FSID: %llx:%llx\n",
1532                        (unsigned long long) server->fsid.major,
1533                        (unsigned long long) server->fsid.minor);
1534        dprintk("Mount FH: %d\n", mntfh->size);
1535
1536        nfs4_session_set_rwsize(server);
1537
1538        error = nfs_probe_fsinfo(server, mntfh, fattr);
1539        if (error < 0)
1540                goto out;
1541
1542        if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
1543                server->namelen = NFS4_MAXNAMLEN;
1544
1545        nfs_server_insert_lists(server);
1546        server->mount_time = jiffies;
1547        server->destroy = nfs4_destroy_server;
1548out:
1549        nfs_free_fattr(fattr);
1550        return error;
1551}
1552
1553/*
1554 * Create a version 4 volume record
1555 */
1556static int nfs4_init_server(struct nfs_server *server,
1557                const struct nfs_parsed_mount_data *data)
1558{
1559        struct rpc_timeout timeparms;
1560        int error;
1561
1562        dprintk("--> nfs4_init_server()\n");
1563
1564        nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
1565                        data->timeo, data->retrans);
1566
1567        /* Initialise the client representation from the mount data */
1568        server->flags = data->flags;
1569        server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR|NFS_CAP_POSIX_LOCK;
1570        if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
1571                        server->caps |= NFS_CAP_READDIRPLUS;
1572        server->options = data->options;
1573
1574        /* Get a client record */
1575        error = nfs4_set_client(server,
1576                        data->nfs_server.hostname,
1577                        (const struct sockaddr *)&data->nfs_server.address,
1578                        data->nfs_server.addrlen,
1579                        data->client_address,
1580                        data->auth_flavors[0],
1581                        data->nfs_server.protocol,
1582                        &timeparms,
1583                        data->minorversion);
1584        if (error < 0)
1585                goto error;
1586
1587        /*
1588         * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
1589         * authentication.
1590         */
1591        if (nfs4_disable_idmapping && data->auth_flavors[0] == RPC_AUTH_UNIX)
1592                server->caps |= NFS_CAP_UIDGID_NOMAP;
1593
1594        if (data->rsize)
1595                server->rsize = nfs_block_size(data->rsize, NULL);
1596        if (data->wsize)
1597                server->wsize = nfs_block_size(data->wsize, NULL);
1598
1599        server->acregmin = data->acregmin * HZ;
1600        server->acregmax = data->acregmax * HZ;
1601        server->acdirmin = data->acdirmin * HZ;
1602        server->acdirmax = data->acdirmax * HZ;
1603
1604        server->port = data->nfs_server.port;
1605
1606        error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
1607
1608error:
1609        /* Done */
1610        dprintk("<-- nfs4_init_server() = %d\n", error);
1611        return error;
1612}
1613
1614/*
1615 * Create a version 4 volume record
1616 * - keyed on server and FSID
1617 */
1618struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
1619                                      struct nfs_fh *mntfh)
1620{
1621        struct nfs_server *server;
1622        int error;
1623
1624        dprintk("--> nfs4_create_server()\n");
1625
1626        server = nfs_alloc_server();
1627        if (!server)
1628                return ERR_PTR(-ENOMEM);
1629
1630        /* set up the general RPC client */
1631        error = nfs4_init_server(server, data);
1632        if (error < 0)
1633                goto error;
1634
1635        error = nfs4_server_common_setup(server, mntfh);
1636        if (error < 0)
1637                goto error;
1638
1639        dprintk("<-- nfs4_create_server() = %p\n", server);
1640        return server;
1641
1642error:
1643        nfs_free_server(server);
1644        dprintk("<-- nfs4_create_server() = error %d\n", error);
1645        return ERR_PTR(error);
1646}
1647
1648/*
1649 * Create an NFS4 referral server record
1650 */
1651struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
1652                                               struct nfs_fh *mntfh)
1653{
1654        struct nfs_client *parent_client;
1655        struct nfs_server *server, *parent_server;
1656        int error;
1657
1658        dprintk("--> nfs4_create_referral_server()\n");
1659
1660        server = nfs_alloc_server();
1661        if (!server)
1662                return ERR_PTR(-ENOMEM);
1663
1664        parent_server = NFS_SB(data->sb);
1665        parent_client = parent_server->nfs_client;
1666
1667        /* Initialise the client representation from the parent server */
1668        nfs_server_copy_userdata(server, parent_server);
1669        server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR;
1670
1671        /* Get a client representation.
1672         * Note: NFSv4 always uses TCP, */
1673        error = nfs4_set_client(server, data->hostname,
1674                                data->addr,
1675                                data->addrlen,
1676                                parent_client->cl_ipaddr,
1677                                data->authflavor,
1678                                parent_server->client->cl_xprt->prot,
1679                                parent_server->client->cl_timeout,
1680                                parent_client->cl_mvops->minor_version);
1681        if (error < 0)
1682                goto error;
1683
1684        error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor);
1685        if (error < 0)
1686                goto error;
1687
1688        error = nfs4_server_common_setup(server, mntfh);
1689        if (error < 0)
1690                goto error;
1691
1692        dprintk("<-- nfs_create_referral_server() = %p\n", server);
1693        return server;
1694
1695error:
1696        nfs_free_server(server);
1697        dprintk("<-- nfs4_create_referral_server() = error %d\n", error);
1698        return ERR_PTR(error);
1699}
1700
1701#endif /* CONFIG_NFS_V4 */
1702
1703/*
1704 * Clone an NFS2, NFS3 or NFS4 server record
1705 */
1706struct nfs_server *nfs_clone_server(struct nfs_server *source,
1707                                    struct nfs_fh *fh,
1708                                    struct nfs_fattr *fattr)
1709{
1710        struct nfs_server *server;
1711        struct nfs_fattr *fattr_fsinfo;
1712        int error;
1713
1714        dprintk("--> nfs_clone_server(,%llx:%llx,)\n",
1715                (unsigned long long) fattr->fsid.major,
1716                (unsigned long long) fattr->fsid.minor);
1717
1718        server = nfs_alloc_server();
1719        if (!server)
1720                return ERR_PTR(-ENOMEM);
1721
1722        error = -ENOMEM;
1723        fattr_fsinfo = nfs_alloc_fattr();
1724        if (fattr_fsinfo == NULL)
1725                goto out_free_server;
1726
1727        /* Copy data from the source */
1728        server->nfs_client = source->nfs_client;
1729        server->destroy = source->destroy;
1730        atomic_inc(&server->nfs_client->cl_count);
1731        nfs_server_copy_userdata(server, source);
1732
1733        server->fsid = fattr->fsid;
1734
1735        error = nfs_init_server_rpcclient(server,
1736                        source->client->cl_timeout,
1737                        source->client->cl_auth->au_flavor);
1738        if (error < 0)
1739                goto out_free_server;
1740        if (!IS_ERR(source->client_acl))
1741                nfs_init_server_aclclient(server);
1742
1743        /* probe the filesystem info for this server filesystem */
1744        error = nfs_probe_fsinfo(server, fh, fattr_fsinfo);
1745        if (error < 0)
1746                goto out_free_server;
1747
1748        if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
1749                server->namelen = NFS4_MAXNAMLEN;
1750
1751        dprintk("Cloned FSID: %llx:%llx\n",
1752                (unsigned long long) server->fsid.major,
1753                (unsigned long long) server->fsid.minor);
1754
1755        error = nfs_start_lockd(server);
1756        if (error < 0)
1757                goto out_free_server;
1758
1759        nfs_server_insert_lists(server);
1760        server->mount_time = jiffies;
1761
1762        nfs_free_fattr(fattr_fsinfo);
1763        dprintk("<-- nfs_clone_server() = %p\n", server);
1764        return server;
1765
1766out_free_server:
1767        nfs_free_fattr(fattr_fsinfo);
1768        nfs_free_server(server);
1769        dprintk("<-- nfs_clone_server() = error %d\n", error);
1770        return ERR_PTR(error);
1771}
1772
1773#ifdef CONFIG_PROC_FS
1774static struct proc_dir_entry *proc_fs_nfs;
1775
1776static int nfs_server_list_open(struct inode *inode, struct file *file);
1777static void *nfs_server_list_start(struct seq_file *p, loff_t *pos);
1778static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos);
1779static void nfs_server_list_stop(struct seq_file *p, void *v);
1780static int nfs_server_list_show(struct seq_file *m, void *v);
1781
1782static const struct seq_operations nfs_server_list_ops = {
1783        .start  = nfs_server_list_start,
1784        .next   = nfs_server_list_next,
1785        .stop   = nfs_server_list_stop,
1786        .show   = nfs_server_list_show,
1787};
1788
1789static const struct file_operations nfs_server_list_fops = {
1790        .open           = nfs_server_list_open,
1791        .read           = seq_read,
1792        .llseek         = seq_lseek,
1793        .release        = seq_release,
1794        .owner          = THIS_MODULE,
1795};
1796
1797static int nfs_volume_list_open(struct inode *inode, struct file *file);
1798static void *nfs_volume_list_start(struct seq_file *p, loff_t *pos);
1799static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos);
1800static void nfs_volume_list_stop(struct seq_file *p, void *v);
1801static int nfs_volume_list_show(struct seq_file *m, void *v);
1802
1803static const struct seq_operations nfs_volume_list_ops = {
1804        .start  = nfs_volume_list_start,
1805        .next   = nfs_volume_list_next,
1806        .stop   = nfs_volume_list_stop,
1807        .show   = nfs_volume_list_show,
1808};
1809
1810static const struct file_operations nfs_volume_list_fops = {
1811        .open           = nfs_volume_list_open,
1812        .read           = seq_read,
1813        .llseek         = seq_lseek,
1814        .release        = seq_release,
1815        .owner          = THIS_MODULE,
1816};
1817
1818/*
1819 * open "/proc/fs/nfsfs/servers" which provides a summary of servers with which
1820 * we're dealing
1821 */
1822static int nfs_server_list_open(struct inode *inode, struct file *file)
1823{
1824        struct seq_file *m;
1825        int ret;
1826
1827        ret = seq_open(file, &nfs_server_list_ops);
1828        if (ret < 0)
1829                return ret;
1830
1831        m = file->private_data;
1832        m->private = PDE(inode)->data;
1833
1834        return 0;
1835}
1836
1837/*
1838 * set up the iterator to start reading from the server list and return the first item
1839 */
1840static void *nfs_server_list_start(struct seq_file *m, loff_t *_pos)
1841{
1842        /* lock the list against modification */
1843        spin_lock(&nfs_client_lock);
1844        return seq_list_start_head(&nfs_client_list, *_pos);
1845}
1846
1847/*
1848 * move to next server
1849 */
1850static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos)
1851{
1852        return seq_list_next(v, &nfs_client_list, pos);
1853}
1854
1855/*
1856 * clean up after reading from the transports list
1857 */
1858static void nfs_server_list_stop(struct seq_file *p, void *v)
1859{
1860        spin_unlock(&nfs_client_lock);
1861}
1862
1863/*
1864 * display a header line followed by a load of call lines
1865 */
1866static int nfs_server_list_show(struct seq_file *m, void *v)
1867{
1868        struct nfs_client *clp;
1869
1870        /* display header on line 1 */
1871        if (v == &nfs_client_list) {
1872                seq_puts(m, "NV SERVER   PORT USE HOSTNAME\n");
1873                return 0;
1874        }
1875
1876        /* display one transport per line on subsequent lines */
1877        clp = list_entry(v, struct nfs_client, cl_share_link);
1878
1879        /* Check if the client is initialized */
1880        if (clp->cl_cons_state != NFS_CS_READY)
1881                return 0;
1882
1883        seq_printf(m, "v%u %s %s %3d %s\n",
1884                   clp->rpc_ops->version,
1885                   rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1886                   rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1887                   atomic_read(&clp->cl_count),
1888                   clp->cl_hostname);
1889
1890        return 0;
1891}
1892
1893/*
1894 * open "/proc/fs/nfsfs/volumes" which provides a summary of extant volumes
1895 */
1896static int nfs_volume_list_open(struct inode *inode, struct file *file)
1897{
1898        struct seq_file *m;
1899        int ret;
1900
1901        ret = seq_open(file, &nfs_volume_list_ops);
1902        if (ret < 0)
1903                return ret;
1904
1905        m = file->private_data;
1906        m->private = PDE(inode)->data;
1907
1908        return 0;
1909}
1910
1911/*
1912 * set up the iterator to start reading from the volume list and return the first item
1913 */
1914static void *nfs_volume_list_start(struct seq_file *m, loff_t *_pos)
1915{
1916        /* lock the list against modification */
1917        spin_lock(&nfs_client_lock);
1918        return seq_list_start_head(&nfs_volume_list, *_pos);
1919}
1920
1921/*
1922 * move to next volume
1923 */
1924static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos)
1925{
1926        return seq_list_next(v, &nfs_volume_list, pos);
1927}
1928
1929/*
1930 * clean up after reading from the transports list
1931 */
1932static void nfs_volume_list_stop(struct seq_file *p, void *v)
1933{
1934        spin_unlock(&nfs_client_lock);
1935}
1936
1937/*
1938 * display a header line followed by a load of call lines
1939 */
1940static int nfs_volume_list_show(struct seq_file *m, void *v)
1941{
1942        struct nfs_server *server;
1943        struct nfs_client *clp;
1944        char dev[8], fsid[17];
1945
1946        /* display header on line 1 */
1947        if (v == &nfs_volume_list) {
1948                seq_puts(m, "NV SERVER   PORT DEV     FSID              FSC\n");
1949                return 0;
1950        }
1951        /* display one transport per line on subsequent lines */
1952        server = list_entry(v, struct nfs_server, master_link);
1953        clp = server->nfs_client;
1954
1955        snprintf(dev, 8, "%u:%u",
1956                 MAJOR(server->s_dev), MINOR(server->s_dev));
1957
1958        snprintf(fsid, 17, "%llx:%llx",
1959                 (unsigned long long) server->fsid.major,
1960                 (unsigned long long) server->fsid.minor);
1961
1962        seq_printf(m, "v%u %s %s %-7s %-17s %s\n",
1963                   clp->rpc_ops->version,
1964                   rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1965                   rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1966                   dev,
1967                   fsid,
1968                   nfs_server_fscache_state(server));
1969
1970        return 0;
1971}
1972
1973/*
1974 * initialise the /proc/fs/nfsfs/ directory
1975 */
1976int __init nfs_fs_proc_init(void)
1977{
1978        struct proc_dir_entry *p;
1979
1980        proc_fs_nfs = proc_mkdir("fs/nfsfs", NULL);
1981        if (!proc_fs_nfs)
1982                goto error_0;
1983
1984        /* a file of servers with which we're dealing */
1985        p = proc_create("servers", S_IFREG|S_IRUGO,
1986                        proc_fs_nfs, &nfs_server_list_fops);
1987        if (!p)
1988                goto error_1;
1989
1990        /* a file of volumes that we have mounted */
1991        p = proc_create("volumes", S_IFREG|S_IRUGO,
1992                        proc_fs_nfs, &nfs_volume_list_fops);
1993        if (!p)
1994                goto error_2;
1995        return 0;
1996
1997error_2:
1998        remove_proc_entry("servers", proc_fs_nfs);
1999error_1:
2000        remove_proc_entry("fs/nfsfs", NULL);
2001error_0:
2002        return -ENOMEM;
2003}
2004
2005/*
2006 * clean up the /proc/fs/nfsfs/ directory
2007 */
2008void nfs_fs_proc_exit(void)
2009{
2010        remove_proc_entry("volumes", proc_fs_nfs);
2011        remove_proc_entry("servers", proc_fs_nfs);
2012        remove_proc_entry("fs/nfsfs", NULL);
2013}
2014
2015#endif /* CONFIG_PROC_FS */
2016
2017module_param(nfs4_disable_idmapping, bool, 0644);
2018MODULE_PARM_DESC(nfs4_disable_idmapping,
2019                "Turn off NFSv4 idmapping when using 'sec=sys'");
2020