Print this page
NEX-16452 NFS server in a zone state database needs to be per zone
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-6778 NFS kstats leak and cause system to hang
Revert "NEX-4261 Per-client NFS server IOPS, bandwidth, and latency kstats"
This reverts commit 586c3ab1927647487f01c337ddc011c642575a52.
Revert "NEX-5354 Aggregated IOPS, bandwidth, and latency kstats for NFS server"
This reverts commit c91d7614da8618ef48018102b077f60ecbbac8c2.
Revert "NEX-5667 nfssrv_stats_flags does not work for aggregated kstats"
This reverts commit 3dcf42618be7dd5f408c327f429c81e07ca08e74.
Revert "NEX-5750 Time values for aggregated NFS server kstats should be normalized"
This reverts commit 1f4d4f901153b0191027969fa4a8064f9d3b9ee1.
Revert "NEX-5942 Panic in rfs4_minorvers_mismatch() with NFSv4.1 client"
This reverts commit 40766417094a162f5e4cc8786c0fa0a7e5871cd9.
Revert "NEX-5752 NFS server: namespace collision in kstats"
This reverts commit ae81e668db86050da8e483264acb0cce0444a132.
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-4261 Per-client NFS server IOPS, bandwidth, and latency kstats
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-3097 IOPS, bandwidth, and latency kstats for NFS server
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/nfs/nfs4.h
          +++ new/usr/src/uts/common/nfs/nfs4.h
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
       24 + * Use is subject to license terms.
  24   25   */
  25   26  
  26   27  /*
  27      - * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  28      - * Use is subject to license terms.
       28 + * Copyright 2018 Nexenta Systems, Inc.
  29   29   */
  30   30  
  31   31  #ifndef _NFS4_H
  32   32  #define _NFS4_H
  33   33  
  34   34  #include <sys/types.h>
  35   35  #include <sys/vnode.h>
  36   36  #include <sys/fem.h>
  37   37  #include <rpc/rpc.h>
  38   38  #include <nfs/nfs.h>
  39   39  
  40   40  #ifdef _KERNEL
  41   41  #include <nfs/nfs4_kprot.h>
       42 +#include <nfs/nfs4_drc.h>
  42   43  #include <sys/nvpair.h>
  43   44  #else
  44   45  #include <rpcsvc/nfs4_prot.h>
  45   46  #endif
  46   47  #include <nfs/nfs4_attr.h>
  47   48  #include <sys/acl.h>
  48   49  #include <sys/list.h>
  49   50  
  50   51  #ifdef  __cplusplus
  51   52  extern "C" {
↓ open down ↓ 60 lines elided ↑ open up ↑
 112  113  
 113  114  typedef struct rfs4_dbe rfs4_dbe_t;             /* basic opaque db entry */
 114  115  typedef struct rfs4_table rfs4_table_t;         /* basic table type */
 115  116  typedef struct rfs4_index rfs4_index_t;         /* index */
 116  117  typedef struct rfs4_database rfs4_database_t;   /* and database */
 117  118  
 118  119  typedef struct {                /* opaque entry type for later use */
 119  120          rfs4_dbe_t *dbe;
 120  121  } *rfs4_entry_t;
 121  122  
 122      -extern rfs4_table_t *rfs4_client_tab;
      123 +/*
      124 + * NFSv4 server state databases
      125 + *
      126 + * Initilized when the module is loaded and used by NFSv4 state tables.
      127 + * These kmem_cache free pools are used globally, the NFSv4 state tables
      128 + * which make use of these kmem_cache free pools are per zone.
      129 + */
      130 +extern kmem_cache_t *rfs4_client_mem_cache;
      131 +extern kmem_cache_t *rfs4_clntIP_mem_cache;
      132 +extern kmem_cache_t *rfs4_openown_mem_cache;
      133 +extern kmem_cache_t *rfs4_openstID_mem_cache;
      134 +extern kmem_cache_t *rfs4_lockstID_mem_cache;
      135 +extern kmem_cache_t *rfs4_lockown_mem_cache;
      136 +extern kmem_cache_t *rfs4_file_mem_cache;
      137 +extern kmem_cache_t *rfs4_delegstID_mem_cache;
 123  138  
 124  139  /* database, table, index creation entry points */
 125  140  extern rfs4_database_t *rfs4_database_create(uint32_t);
 126  141  extern void             rfs4_database_shutdown(rfs4_database_t *);
 127  142  extern void             rfs4_database_destroy(rfs4_database_t *);
 128  143  
 129  144  extern void             rfs4_database_destroy(rfs4_database_t *);
 130  145  
      146 +extern kmem_cache_t     *nfs4_init_mem_cache(char *, uint32_t, uint32_t,
      147 +                                uint32_t);
 131  148  extern rfs4_table_t     *rfs4_table_create(rfs4_database_t *, char *,
 132  149                                  time_t, uint32_t,
 133  150                                  bool_t (*create)(rfs4_entry_t, void *),
 134  151                                  void (*destroy)(rfs4_entry_t),
 135  152                                  bool_t (*expiry)(rfs4_entry_t),
 136  153                                  uint32_t, uint32_t, uint32_t, id_t);
 137  154  extern void             rfs4_table_destroy(rfs4_database_t *, rfs4_table_t *);
 138  155  extern rfs4_index_t     *rfs4_index_create(rfs4_table_t *, char *,
 139  156                                  uint32_t (*hash)(void *),
 140  157                                  bool_t (compare)(rfs4_entry_t, void *),
↓ open down ↓ 221 lines elided ↑ open up ↑
 362  379          struct rfs4_dss_path    *prev; /* for insque/remque */
 363  380          char                    *path;
 364  381          struct rfs4_servinst    *sip;
 365  382          unsigned                index; /* offset in servinst's array */
 366  383  } rfs4_dss_path_t;
 367  384  
 368  385  /* array of paths passed-in from nfsd command-line; stored in nvlist */
 369  386  char            **rfs4_dss_newpaths;
 370  387  uint_t          rfs4_dss_numnewpaths;
 371  388  
 372      -/*
 373      - * Circular doubly-linked list of paths for currently-served RGs.
 374      - * No locking required: only changed on warmstart. Managed with insque/remque.
 375      - */
 376      -rfs4_dss_path_t *rfs4_dss_pathlist;
 377      -
 378  389  /* nvlists of all DSS paths: current, and before last warmstart */
 379  390  nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths;
 380  391  
 381  392  /*
 382  393   * The server maintains a set of state on a per client basis that
 383  394   * matches that of the protocol requirements.  A client's state is
 384  395   * rooted with the rfs4_client_t struct of which there is one per
 385  396   * client and is created when SETCLIENTID/SETCLIENTID_CONFIRM are
 386  397   * received.  From there, the server then creates rfs4_openowner_t
 387  398   * structs for each new open owner from that client and are initiated
↓ open down ↓ 345 lines elided ↑ open up ↑
 733  744          rfs4_dinfo_t    rf_dinfo;
 734  745          uint32_t        rf_share_deny;
 735  746          uint32_t        rf_share_access;
 736  747          uint32_t        rf_access_read;
 737  748          uint32_t        rf_access_write;
 738  749          uint32_t        rf_deny_read;
 739  750          uint32_t        rf_deny_write;
 740  751          krwlock_t       rf_file_rwlock;
 741  752  } rfs4_file_t;
 742  753  
 743      -extern int      rfs4_seen_first_compound;       /* set first time we see one */
 744      -
 745      -extern rfs4_servinst_t  *rfs4_cur_servinst;     /* current server instance */
 746      -extern kmutex_t         rfs4_servinst_lock;     /* protects linked list */
 747      -extern void             rfs4_servinst_create(int, int, char **);
 748      -extern void             rfs4_servinst_destroy_all(void);
 749      -extern void             rfs4_servinst_assign(rfs4_client_t *,
 750      -                            rfs4_servinst_t *);
 751      -extern rfs4_servinst_t  *rfs4_servinst(rfs4_client_t *);
 752      -extern int              rfs4_clnt_in_grace(rfs4_client_t *);
 753      -extern int              rfs4_servinst_in_grace(rfs4_servinst_t *);
 754      -extern int              rfs4_servinst_grace_new(rfs4_servinst_t *);
 755      -extern void             rfs4_grace_start(rfs4_servinst_t *);
 756      -extern void             rfs4_grace_start_new(void);
 757      -extern void             rfs4_grace_reset_all(void);
 758      -extern void             rfs4_ss_oldstate(rfs4_oldstate_t *, char *, char *);
 759      -extern void             rfs4_dss_readstate(int, char **);
 760      -
 761  754  /*
 762      - * rfs4_deleg_policy is used to signify the server's global delegation
      755 + * nfs4_deleg_policy is used to signify the server's global delegation
 763  756   * policy.  The default is to NEVER delegate files and the
 764  757   * administrator must configure the server to enable delegations.
 765  758   *
 766  759   * The disable/enable delegation functions are used to eliminate a
 767  760   * race with exclusive creates.
 768  761   */
 769  762  typedef enum {
 770  763          SRV_NEVER_DELEGATE = 0,
 771  764          SRV_NORMAL_DELEGATE = 1
 772  765  } srv_deleg_policy_t;
 773  766  
 774      -extern srv_deleg_policy_t rfs4_deleg_policy;
 775      -extern kmutex_t rfs4_deleg_lock;
 776  767  extern void rfs4_disable_delegation(void), rfs4_enable_delegation(void);
 777  768  
 778  769  /*
 779  770   * Request types for delegation. These correspond with
 780  771   * open_delegation_type4 with the addition of a new value, DELEG_ANY,
 781  772   * to reqequest any delegation.
 782  773   */
 783  774  typedef enum {
 784  775          DELEG_NONE = 0,         /* Corresponds to OPEN_DELEG_NONE */
 785  776          DELEG_READ = 1,         /* Corresponds to OPEN_DELEG_READ */
 786  777          DELEG_WRITE = 2,        /* Corresponds to OPEN_DELEG_WRITE */
 787  778          DELEG_ANY = -1          /* New value to request any delegation type */
 788  779  } delegreq_t;
 789  780  
 790  781  #define NFS4_DELEG4TYPE2REQTYPE(x) (delegreq_t)(x)
 791  782  
 792  783  /*
      784 + * Zone global variables of NFSv4 server
      785 + */
      786 +typedef struct nfs4_srv {
      787 +        /* Unique write verifier */
      788 +        verifier4       write4verf;
      789 +        /* Delegation lock */
      790 +        kmutex_t        deleg_lock;
      791 +        /* Used to serialize create/destroy of nfs4_server_state database */
      792 +        kmutex_t        state_lock;
      793 +        rfs4_database_t *nfs4_server_state;
      794 +        /* Used to manage access to server instance linked list */
      795 +        kmutex_t        servinst_lock;
      796 +        rfs4_servinst_t *nfs4_cur_servinst;
      797 +        /* Used to manage access to nfs4_deleg_policy */
      798 +        krwlock_t       deleg_policy_lock;
      799 +        srv_deleg_policy_t nfs4_deleg_policy;
      800 +        /* Set first time we see one */
      801 +        int             seen_first_compound;
      802 +        /*
      803 +         * Circular double-linked list of paths for currently-served RGs.
      804 +         * No locking required -- only changed on warmstart.
      805 +         * Managed with insque/remque.
      806 +         */
      807 +        rfs4_dss_path_t *dss_pathlist;
      808 +        /* Duplicate request cache */
      809 +        rfs4_drc_t      *nfs4_drc;
      810 +        /* nfsv4 server start time */
      811 +        time_t rfs4_start_time;
      812 +        /* Used to serialize lookups of clientids */
      813 +        krwlock_t rfs4_findclient_lock;
      814 +
      815 +        /* NFSv4 server state client tables */
      816 +        /* table expiry times */
      817 +        time_t rfs4_client_cache_time;
      818 +        time_t rfs4_openowner_cache_time;
      819 +        time_t rfs4_state_cache_time;
      820 +        time_t rfs4_lo_state_cache_time;
      821 +        time_t rfs4_lockowner_cache_time;
      822 +        time_t rfs4_file_cache_time;
      823 +        time_t rfs4_deleg_state_cache_time;
      824 +        time_t rfs4_clntip_cache_time;
      825 +        /* tables and indexes */
      826 +        /* client table */
      827 +        rfs4_table_t *rfs4_client_tab;
      828 +        rfs4_index_t *rfs4_clientid_idx;
      829 +        rfs4_index_t *rfs4_nfsclnt_idx;
      830 +        /* client IP table */
      831 +        rfs4_table_t *rfs4_clntip_tab;
      832 +        rfs4_index_t *rfs4_clntip_idx;
      833 +        /* Open Owner table */
      834 +        rfs4_table_t *rfs4_openowner_tab;
      835 +        rfs4_index_t *rfs4_openowner_idx;
      836 +        /* Open State ID table */
      837 +        rfs4_table_t *rfs4_state_tab;
      838 +        rfs4_index_t *rfs4_state_idx;
      839 +        rfs4_index_t *rfs4_state_owner_file_idx;
      840 +        rfs4_index_t *rfs4_state_file_idx;
      841 +        /* Lock State ID table */
      842 +        rfs4_table_t *rfs4_lo_state_tab;
      843 +        rfs4_index_t *rfs4_lo_state_idx;
      844 +        rfs4_index_t *rfs4_lo_state_owner_idx;
      845 +        /* Lock owner table */
      846 +        rfs4_table_t *rfs4_lockowner_tab;
      847 +        rfs4_index_t *rfs4_lockowner_idx;
      848 +        rfs4_index_t *rfs4_lockowner_pid_idx;
      849 +        /* File table */
      850 +        rfs4_table_t *rfs4_file_tab;
      851 +        rfs4_index_t *rfs4_file_idx;
      852 +        /* Deleg State table */
      853 +        rfs4_table_t *rfs4_deleg_state_tab;
      854 +        rfs4_index_t *rfs4_deleg_idx;
      855 +        rfs4_index_t *rfs4_deleg_state_idx;
      856 +
      857 +        /* client stable storage */
      858 +        int rfs4_ss_enabled;
      859 +} nfs4_srv_t;
      860 +
      861 +/*
      862 + * max length of the NFSv4 server database name
      863 + */
      864 +#define RFS4_MAX_MEM_CACHE_NAME 48
      865 +
      866 +/*
      867 + * global NFSv4 server kmem caches
      868 + * r_db_name - The name of the state database and the table that will use it
      869 + *             These tables are defined in nfs4_srv_t
      870 + * r_db_mem_cache - The kmem cache associated with the state database name
      871 + */
      872 +typedef struct rfs4_db_mem_cache {
      873 +        char            r_db_name[RFS4_MAX_MEM_CACHE_NAME];
      874 +        kmem_cache_t    *r_db_mem_cache;
      875 +} rfs4_db_mem_cache_t;
      876 +
      877 +#define RFS4_DB_MEM_CACHE_NUM 8
      878 +
      879 +rfs4_db_mem_cache_t rfs4_db_mem_cache_table[RFS4_DB_MEM_CACHE_NUM];
      880 +
      881 +
      882 +extern srv_deleg_policy_t nfs4_get_deleg_policy();
      883 +
      884 +extern void             rfs4_servinst_create(nfs4_srv_t *, int, int, char **);
      885 +extern void             rfs4_servinst_destroy_all(nfs4_srv_t *);
      886 +extern void             rfs4_servinst_assign(nfs4_srv_t *, rfs4_client_t *,
      887 +                            rfs4_servinst_t *);
      888 +extern rfs4_servinst_t  *rfs4_servinst(rfs4_client_t *);
      889 +extern int              rfs4_clnt_in_grace(rfs4_client_t *);
      890 +extern int              rfs4_servinst_in_grace(rfs4_servinst_t *);
      891 +extern int              rfs4_servinst_grace_new(rfs4_servinst_t *);
      892 +extern void             rfs4_grace_start(rfs4_servinst_t *);
      893 +extern void             rfs4_grace_start_new(nfs4_srv_t *);
      894 +extern void             rfs4_grace_reset_all(nfs4_srv_t *);
      895 +extern void             rfs4_ss_oldstate(rfs4_oldstate_t *, char *, char *);
      896 +extern void             rfs4_dss_readstate(nfs4_srv_t *, int, char **);
      897 +
      898 +/*
 793  899   * Various interfaces to manipulate the state structures introduced
 794  900   * above
 795  901   */
 796      -extern  kmutex_t        rfs4_state_lock;
 797  902  extern  void            rfs4_clean_state_exi(struct exportinfo *exi);
 798  903  extern  void            rfs4_free_reply(nfs_resop4 *);
 799  904  extern  void            rfs4_copy_reply(nfs_resop4 *, nfs_resop4 *);
 800  905  
 801  906  /* rfs4_client_t handling */
 802  907  extern  rfs4_client_t   *rfs4_findclient(nfs_client_id4 *,
 803  908                                          bool_t *, rfs4_client_t *);
 804  909  extern  rfs4_client_t   *rfs4_findclient_by_id(clientid4, bool_t);
 805  910  extern  rfs4_client_t   *rfs4_findclient_by_addr(struct sockaddr *);
 806  911  extern  void            rfs4_client_rele(rfs4_client_t *);
↓ open down ↓ 132 lines elided ↑ open up ↑
 939 1044                  caller_context_t *);
 940 1045  
 941 1046  extern void rfs4_mon_hold(void *);
 942 1047  extern void rfs4_mon_rele(void *);
 943 1048  
 944 1049  extern fem_t    *deleg_rdops;
 945 1050  extern fem_t    *deleg_wrops;
 946 1051  
 947 1052  extern int rfs4_share(rfs4_state_t *, uint32_t, uint32_t);
 948 1053  extern int rfs4_unshare(rfs4_state_t *);
 949      -extern  void            rfs4_set_deleg_policy(srv_deleg_policy_t);
     1054 +extern void rfs4_set_deleg_policy(nfs4_srv_t *, srv_deleg_policy_t);
     1055 +extern void rfs4_hold_deleg_policy(nfs4_srv_t *);
     1056 +extern void rfs4_rele_deleg_policy(nfs4_srv_t *);
     1057 +
 950 1058  #ifdef DEBUG
 951 1059  #define NFS4_DEBUG(var, args) if (var) cmn_err args
 952 1060  
 953 1061  extern int rfs4_debug;
 954 1062  extern int nfs4_client_attr_debug;
 955 1063  extern int nfs4_client_state_debug;
 956 1064  extern int nfs4_client_shadow_debug;
 957 1065  extern int nfs4_client_lock_debug;
 958 1066  extern int nfs4_client_lease_debug;
 959 1067  extern int nfs4_seqid_sync;
↓ open down ↓ 381 lines elided ↑ open up ↑
1341 1449  extern char     *build_symlink(vnode_t *, cred_t *, size_t *);
1342 1450  
1343 1451  extern int      stateid4_cmp(stateid4 *, stateid4 *);
1344 1452  
1345 1453  extern vtype_t  nf4_to_vt[];
1346 1454  
1347 1455  extern struct nfs4_ntov_map nfs4_ntov_map[];
1348 1456  extern uint_t nfs4_ntov_map_size;
1349 1457  
1350 1458  extern kstat_named_t    *rfsproccnt_v4_ptr;
     1459 +extern kstat_t          **rfsprocio_v4_ptr;
1351 1460  extern struct vfsops    *nfs4_vfsops;
1352 1461  extern struct vnodeops  *nfs4_vnodeops;
1353 1462  extern const struct     fs_operation_def nfs4_vnodeops_template[];
1354 1463  extern vnodeops_t       *nfs4_trigger_vnodeops;
1355 1464  extern const struct     fs_operation_def nfs4_trigger_vnodeops_template[];
1356 1465  
1357 1466  extern uint_t nfs4_tsize(struct knetconfig *);
1358 1467  extern uint_t rfs4_tsize(struct svc_req *);
1359 1468  
1360 1469  extern bool_t   xdr_inline_decode_nfs_fh4(uint32_t *, nfs_fh4_fmt_t *,
↓ open down ↓ 8 lines elided ↑ open up ↑
1369 1478  
1370 1479  extern stateid4 clnt_special0;
1371 1480  extern stateid4 clnt_special1;
1372 1481  #define CLNT_ISSPECIAL(id) (stateid4_cmp(id, &clnt_special0) || \
1373 1482                                  stateid4_cmp(id, &clnt_special1))
1374 1483  
1375 1484  /*
1376 1485   * The NFS Version 4 service procedures.
1377 1486   */
1378 1487  
     1488 +extern void     rfs4_do_server_start(int, int, int);
1379 1489  extern void     rfs4_compound(COMPOUND4args *, COMPOUND4res *,
1380 1490                          struct exportinfo *, struct svc_req *, cred_t *, int *);
1381 1491  extern void     rfs4_compound_free(COMPOUND4res *);
1382 1492  extern void     rfs4_compound_flagproc(COMPOUND4args *, int *);
     1493 +extern void     rfs4_compound_kstat_args(COMPOUND4args *);
     1494 +extern void     rfs4_compound_kstat_res(COMPOUND4res *);
1383 1495  
1384      -extern int      rfs4_srvrinit(void);
     1496 +extern void     rfs4_srvrinit(void);
1385 1497  extern void     rfs4_srvrfini(void);
1386      -extern void     rfs4_state_init(void);
1387      -extern void     rfs4_state_fini(void);
     1498 +extern void     rfs4_state_g_init(void);
     1499 +extern void     rfs4_state_zone_init(nfs4_srv_t *);
     1500 +extern void     rfs4_state_g_fini(void);
     1501 +extern void     rfs4_state_zone_fini(void);
1388 1502  
1389 1503  #endif
1390 1504  #ifdef  __cplusplus
1391 1505  }
1392 1506  #endif
1393 1507  
1394 1508  #endif /* _NFS4_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX