Print this page
    
Fix NFS design problems re. multiple zone keys
Make NFS server zone-specific data all have the same lifetime
Fix rfs4_clean_state_exi
Fix exi_cache_reclaim
Fix mistakes in zone keys work
More fixes re. exi_zoneid and exi_tree
(danmcd -> Keep some ASSERT()s around for readability.)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/nfs/nfs4.h
          +++ new/usr/src/uts/common/nfs/nfs4.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  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   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   * Copyright 2018 Nexenta Systems, Inc.
  29   29   * Copyright 2019 Nexenta by DDN, Inc.
  30   30   */
  31   31  
  32   32  #ifndef _NFS4_H
  33   33  #define _NFS4_H
  34   34  
  35   35  #include <sys/types.h>
  36   36  #include <sys/vnode.h>
  37   37  #include <sys/fem.h>
  38   38  #include <rpc/rpc.h>
  39   39  #include <nfs/nfs.h>
  40   40  
  41   41  #ifdef _KERNEL
  42   42  #include <nfs/nfs4_kprot.h>
  43   43  #include <nfs/nfs4_drc.h>
  44   44  #include <sys/nvpair.h>
  45   45  #else
  46   46  #include <rpcsvc/nfs4_prot.h>
  47   47  #endif
  48   48  #include <nfs/nfs4_attr.h>
  49   49  #include <sys/acl.h>
  50   50  #include <sys/list.h>
  51   51  
  52   52  #ifdef  __cplusplus
  53   53  extern "C" {
  54   54  #endif
  55   55  
  56   56  #define NFS4_MAX_SECOID4        65536
  57   57  #define NFS4_MAX_UTF8STRING     65536
  58   58  #define NFS4_MAX_LINKTEXT4      65536
  59   59  #define NFS4_MAX_PATHNAME4      65536
  60   60  
  61   61  struct nfs_fsl_info {
  62   62          uint_t netbuf_len;
  63   63          uint_t netnm_len;
  64   64          uint_t knconf_len;
  65   65          char *netname;
  66   66          struct netbuf *addr;
  67   67          struct knetconfig *knconf;
  68   68  };
  69   69  
  70   70  #ifdef _KERNEL
  71   71  
  72   72  typedef struct nfs4_fhandle {
  73   73          int fh_len;
  74   74          char fh_buf[NFS4_FHSIZE];
  75   75  } nfs4_fhandle_t;
  76   76  
  77   77  #define NFS4_MINORVERSION 0
  78   78  #define CB4_MINORVERSION 0
  79   79  
  80   80  /*
  81   81   * Set the fattr4_change variable using a time struct. Note that change
  82   82   * is 64 bits, but timestruc_t is 128 bits in a 64-bit kernel.
  83   83   */
  84   84  #define NFS4_SET_FATTR4_CHANGE(change, ts)                      \
  85   85  {                                                       \
  86   86          change = (ts).tv_sec;                           \
  87   87          change <<= 32;                                  \
  88   88          change |= (uint32_t)((ts).tv_nsec);             \
  89   89  }
  90   90  
  91   91  /*
  92   92   * Server lease period.  Value is in seconds;  Also used for grace period
  93   93   */
  94   94  extern time_t rfs4_lease_time;
  95   95  
  96   96  /*
  97   97   * This set of typedefs and interfaces represent the core or base set
  98   98   * of functionality that backs the NFSv4 server's state related data
  99   99   * structures.  Since the NFSv4 server needs inter-RPC state to be
 100  100   * available that is unrelated to the filesystem (in other words,
 101  101   * soft-state), this functionality is needed to maintain that and is
 102  102   * written to be somewhat flexible to adapt to the various types of
 103  103   * data structures contained within the server.
 104  104   *
 105  105   * The basic structure at this level is that the server maintains a
 106  106   * global "database" which consists of a set of tables.  Each table
 107  107   * contains a set of like data structures.  Each table is indexed by
 108  108   * at least one hash function and in most cases two hashes.  Each
 109  109   * table's characteristics is set when it is created at run-time via
 110  110   * rfs4_table_create().  All table creation and related functions are
 111  111   * located in nfs4_state.c.  The generic database functionality is
 112  112   * located in nfs4_db.c.
 113  113   */
 114  114  
 115  115  typedef struct rfs4_dbe rfs4_dbe_t;             /* basic opaque db entry */
 116  116  typedef struct rfs4_table rfs4_table_t;         /* basic table type */
 117  117  typedef struct rfs4_index rfs4_index_t;         /* index */
 118  118  typedef struct rfs4_database rfs4_database_t;   /* and database */
 119  119  
 120  120  typedef struct {                /* opaque entry type for later use */
 121  121          rfs4_dbe_t *dbe;
 122  122  } *rfs4_entry_t;
 123  123  
 124  124  /*
 125  125   * NFSv4 server state databases
 126  126   *
 127  127   * Initilized when the module is loaded and used by NFSv4 state tables.
 128  128   * These kmem_cache free pools are used globally, the NFSv4 state tables
 129  129   * which make use of these kmem_cache free pools are per zone.
 130  130   */
 131  131  extern kmem_cache_t *rfs4_client_mem_cache;
 132  132  extern kmem_cache_t *rfs4_clntIP_mem_cache;
 133  133  extern kmem_cache_t *rfs4_openown_mem_cache;
 134  134  extern kmem_cache_t *rfs4_openstID_mem_cache;
 135  135  extern kmem_cache_t *rfs4_lockstID_mem_cache;
 136  136  extern kmem_cache_t *rfs4_lockown_mem_cache;
 137  137  extern kmem_cache_t *rfs4_file_mem_cache;
 138  138  extern kmem_cache_t *rfs4_delegstID_mem_cache;
 139  139  
 140  140  /* database, table, index creation entry points */
 141  141  extern rfs4_database_t *rfs4_database_create(uint32_t);
 142  142  extern void             rfs4_database_shutdown(rfs4_database_t *);
 143  143  extern void             rfs4_database_destroy(rfs4_database_t *);
 144  144  
 145  145  extern void             rfs4_database_destroy(rfs4_database_t *);
 146  146  
 147  147  extern kmem_cache_t     *nfs4_init_mem_cache(char *, uint32_t, uint32_t,
 148  148                                  uint32_t);
 149  149  extern rfs4_table_t     *rfs4_table_create(rfs4_database_t *, char *,
 150  150                                  time_t, uint32_t,
 151  151                                  bool_t (*create)(rfs4_entry_t, void *),
 152  152                                  void (*destroy)(rfs4_entry_t),
 153  153                                  bool_t (*expiry)(rfs4_entry_t),
 154  154                                  uint32_t, uint32_t, uint32_t, id_t);
 155  155  extern void             rfs4_table_destroy(rfs4_database_t *, rfs4_table_t *);
 156  156  extern rfs4_index_t     *rfs4_index_create(rfs4_table_t *, char *,
 157  157                                  uint32_t (*hash)(void *),
 158  158                                  bool_t (compare)(rfs4_entry_t, void *),
 159  159                                  void *(*mkkey)(rfs4_entry_t), bool_t);
 160  160  extern void             rfs4_index_destroy(rfs4_index_t *);
 161  161  
 162  162  /* Type used to direct rfs4_dbsearch() in what types of records to inspect */
 163  163  typedef enum {RFS4_DBS_VALID, RFS4_DBS_INVALID} rfs4_dbsearch_type_t;
 164  164  /* search and db entry manipulation entry points */
 165  165  extern rfs4_entry_t     rfs4_dbsearch(rfs4_index_t *, void *,
 166  166                                  bool_t *, void *, rfs4_dbsearch_type_t);
 167  167  extern void             rfs4_dbe_lock(rfs4_dbe_t *);
 168  168  extern void             rfs4_dbe_unlock(rfs4_dbe_t *);
 169  169  extern clock_t          rfs4_dbe_twait(rfs4_dbe_t *, clock_t);
 170  170  extern void             rfs4_dbe_cv_broadcast(rfs4_dbe_t *);
 171  171  extern void             rfs4_dbe_hold(rfs4_dbe_t *);
 172  172  extern void             rfs4_dbe_hold_nolock(rfs4_dbe_t *);
 173  173  extern void             rfs4_dbe_rele_nolock(rfs4_dbe_t *);
 174  174  extern void             rfs4_dbe_rele(rfs4_dbe_t *);
 175  175  extern uint32_t rfs4_dbe_refcnt(rfs4_dbe_t *);
 176  176  extern id_t             rfs4_dbe_getid(rfs4_dbe_t *);
 177  177  extern void             rfs4_dbe_invalidate(rfs4_dbe_t *);
 178  178  extern bool_t           rfs4_dbe_is_invalid(rfs4_dbe_t *);
 179  179  extern time_t           rfs4_dbe_get_timerele(rfs4_dbe_t *);
 180  180  extern void             rfs4_dbe_hide(rfs4_dbe_t *);
 181  181  extern void             rfs4_dbe_unhide(rfs4_dbe_t *);
 182  182  #ifdef DEBUG
 183  183  extern bool_t           rfs4_dbe_islocked(rfs4_dbe_t *);
 184  184  #endif
 185  185  extern void             rfs4_dbe_walk(rfs4_table_t *,
 186  186                          void (*callout)(rfs4_entry_t, void *), void *);
 187  187  
 188  188  /*
 189  189   * Minimal server stable storage.
 190  190   *
 191  191   * Currently the NFSv4 server will only save the client
 192  192   * ID (the long version) so that it will be able to
 193  193   * grant possible reclaim requests during the infamous
 194  194   * grace_period.
 195  195   */
 196  196  
 197  197  #define RFS4_SS_DIRSIZE 64 * 1024
 198  198  #define NFS4_SS_VERSION 1
 199  199  
 200  200  /* handy pathname structure */
 201  201  typedef struct ss_pn {
 202  202          char *leaf;
 203  203          char pn[MAXPATHLEN];
 204  204  } rfs4_ss_pn_t;
 205  205  
 206  206  /*
 207  207   * The server will build this link list on startup. It represents the
 208  208   * clients that have had valid state on the server in a prior instance.
 209  209   *
 210  210   */
 211  211  typedef struct rfs4_oldstate {
 212  212          struct rfs4_oldstate    *next;
 213  213          struct rfs4_oldstate    *prev;
 214  214          rfs4_ss_pn_t            *ss_pn;
 215  215          nfs_client_id4          cl_id4;
 216  216  } rfs4_oldstate_t;
 217  217  
 218  218  /*
 219  219   * This union is used to overlay the server's internal treatment of
 220  220   * the protocols stateid4 datatype.  Therefore, "bits" must not exceed
 221  221   * the size of stateid4 and more importantly should match the size of
 222  222   * stateid4.  The chgseq field must the first entry since it overlays
 223  223   * stateid4.seqid.
 224  224   */
 225  225  typedef union {
 226  226          stateid4 stateid;
 227  227          struct {
 228  228                  uint32_t chgseq;        /* State changes / protocol's seqid */
 229  229                  uint32_t boottime;      /* boot time  */
 230  230                  uint32_t type:2;        /* stateid_type_t as define below */
 231  231                  uint32_t clnodeid:8;    /* cluster server nodeid */
 232  232                  uint32_t ident:22;      /* 2^22-1 openowner x fhs */
 233  233                  pid_t    pid;           /* pid of corresponding lock owner */
 234  234          } bits;
 235  235  } stateid_t;
 236  236  /*
 237  237   * Note that the way the type field above is defined, this enum must
 238  238   * not have more than 4 members.
 239  239   */
 240  240  typedef enum {OPENID, LOCKID, DELEGID} stateid_type_t;
 241  241  
 242  242  
 243  243  /*
 244  244   * Set of RPC credentials used for a particular operation.
 245  245   * Used for operations like SETCLIENTID_CONFIRM where the
 246  246   * credentials needs to match those used at SETCLIENTID.
 247  247   */
 248  248  typedef void *cred_set_t;               /* For now XXX */
 249  249  
 250  250  /*
 251  251   * "wait" struct for use in the open open and lock owner state
 252  252   * structures to provide serialization between server threads that are
 253  253   * handling requests for the same open owner or lock stateid.  This
 254  254   * way only one thread will be updating things like sequence ids,
 255  255   * replay cache and stateid at a time.
 256  256   */
 257  257  typedef struct rfs4_state_wait {
 258  258          uint32_t                sw_active;
 259  259          uint32_t                sw_wait_count;
 260  260          kmutex_t                sw_cv_lock[1];
 261  261          kcondvar_t              sw_cv[1];
 262  262  } rfs4_state_wait_t;
 263  263  
 264  264  extern void     rfs4_sw_enter(rfs4_state_wait_t *);
 265  265  extern void     rfs4_sw_exit(rfs4_state_wait_t *);
 266  266  
 267  267  /*
 268  268   * This enum and the following rfs4_cbinfo_t struct are used to
 269  269   * maintain information about the callback path used from the server
 270  270   * to client for operations like CB_GETATTR and CB_RECALL.  The
 271  271   * rfs4_cbinfo_t struct is meant to be encompassed in the client
 272  272   * struct and managed within that structure's locking scheme.
 273  273   *
 274  274   * The various states of the callback path are used by the server to
 275  275   * determine if delegations should initially be provided to a client
 276  276   * and then later on if connectivity has been lost and delegations
 277  277   * should be revoked.
 278  278   */
 279  279  
 280  280  /*
 281  281   * CB_NOCHANGE - Special value used for interfaces within the delegation
 282  282   *              code to signify that "no change" has occurred to the
 283  283   *              callback path
 284  284   * CB_UNINIT    - No callback info provided by the client
 285  285   * CB_NONE      - Callback info provided but CB_NULL call
 286  286   *                has yet to be attempted
 287  287   * CB_OK        - Callback path tested with CB_NULL with success
 288  288   * CB_INPROG    - Callback path currently being tested with CB_NULL
 289  289   * CB_FAILED    - Callback path was == CB_OK but has failed
 290  290   *                with timeout/rpc error
 291  291   * CB_BAD       - Callback info provided but CB_NULL failed
 292  292   */
 293  293  typedef enum {
 294  294          CB_NOCHANGE = 0,
 295  295          CB_UNINIT = 1,
 296  296          CB_NONE = 2,
 297  297          CB_OK = 3,
 298  298          CB_INPROG = 4,
 299  299          CB_FAILED = 5,
 300  300          CB_BAD = 6
 301  301  } rfs4_cbstate_t;
 302  302  
 303  303  #define RFS4_CBCH_MAX   10      /* size callback client handle cache */
 304  304  /*
 305  305   * Callback info for a client.
 306  306   * Client only provides: cb_client4 and cb_ident
 307  307   * The rest of the information is used to track callback path status
 308  308   * and usage.
 309  309   *
 310  310   * cb_state - used as comments for the rfs4_cbstate_t enum indicate
 311  311   * cb_notified_of_cb_path_down - if the callback path was once CB_OK and
 312  312   *      has hence CB_FAILED, the client needs to be notified via RENEW.
 313  313   * cb_timefailed - current time when cb_state transitioned from
 314  314   *      CB_OK -> CB_FAILED.  Meant for observability.  When did that happen?
 315  315   * cb_chc_free/cb_chc - cache of client handles for the callback path
 316  316   * cb_ident - SETCLIENTID provided callback_ident value
 317  317   * callback - SETCLIENTID provided cb_client4 value
 318  318   * cb_refcnt - current number of users of this structure's content
 319  319   *      protected by cb_lock
 320  320   * cb_badbehavior - how many times did a client do something we didn't like?
 321  321   * cb_lock - lock for contents of cbinfo
 322  322   * cb_cv - used to allow threads to wait on CB_NULL completion
 323  323   * cb_nullcaller - is there a thread currently taking care of
 324  324   *      new callback information?
 325  325   * cb_cv_nullcaller - used by the thread doing CB_NULL to wait on
 326  326   *      threads that may be using client handles of the current
 327  327   *      client handle cache.
 328  328   * newer - new callback info provided by a client and awaiting
 329  329   *      CB_NULL testing and move to regular cbinfo.
 330  330   */
 331  331  typedef struct {
 332  332          rfs4_cbstate_t  cb_state;
 333  333          unsigned        cb_notified_of_cb_path_down:1;
 334  334          time_t          cb_timefailed;
 335  335          int             cb_chc_free;
 336  336          CLIENT          *cb_chc[RFS4_CBCH_MAX];
 337  337          uint32_t        cb_ident;
 338  338          cb_client4      cb_callback;
 339  339          uint32_t        cb_refcnt;
 340  340          uint32_t        cb_badbehavior;
 341  341          kmutex_t        cb_lock[1];
 342  342          kcondvar_t      cb_cv[1];
 343  343          bool_t          cb_nullcaller;
 344  344          kcondvar_t      cb_cv_nullcaller[1];
 345  345          struct {
 346  346                  bool_t          cb_new;
 347  347                  bool_t          cb_confirmed;
 348  348                  uint32_t        cb_ident;
 349  349                  cb_client4      cb_callback;
 350  350          } cb_newer;
 351  351  } rfs4_cbinfo_t;
 352  352  
 353  353  /*
 354  354   * A server instance. We can associate sets of clients - via a pointer in
 355  355   * rfs4_client_t - with a given server instance, allowing us to treat clients
 356  356   * in the set differently to clients in other sets.
 357  357   *
 358  358   * Currently used only for Sun Cluster HA-NFS support, to group clients
 359  359   * on NFS resource failover so each set of clients gets its own dedicated
 360  360   * grace period and distributed stable storage data.
 361  361   */
 362  362  typedef struct rfs4_servinst {
 363  363          int                     dss_npaths;
 364  364          krwlock_t               rwlock;
 365  365          krwlock_t               oldstate_lock;
 366  366          time_t                  start_time;
 367  367          time_t                  grace_period;
 368  368          rfs4_oldstate_t         *oldstate;
 369  369          struct rfs4_dss_path    **dss_paths;
 370  370          struct rfs4_servinst    *next;
 371  371          struct rfs4_servinst    *prev;
 372  372  } rfs4_servinst_t;
 373  373  
 374  374  /*
 375  375   * DSS: distributed stable storage
 376  376   */
 377  377  
 378  378  typedef struct rfs4_dss_path {
 379  379          struct rfs4_dss_path    *next; /* for insque/remque */
 380  380          struct rfs4_dss_path    *prev; /* for insque/remque */
 381  381          char                    *path;
 382  382          struct rfs4_servinst    *sip;
 383  383          unsigned                index; /* offset in servinst's array */
 384  384  } rfs4_dss_path_t;
 385  385  
 386  386  /* array of paths passed-in from nfsd command-line; stored in nvlist */
 387  387  char            **rfs4_dss_newpaths;
 388  388  uint_t          rfs4_dss_numnewpaths;
 389  389  
 390  390  /* nvlists of all DSS paths: current, and before last warmstart */
 391  391  nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths;
 392  392  
 393  393  /*
 394  394   * The server maintains a set of state on a per client basis that
 395  395   * matches that of the protocol requirements.  A client's state is
 396  396   * rooted with the rfs4_client_t struct of which there is one per
 397  397   * client and is created when SETCLIENTID/SETCLIENTID_CONFIRM are
 398  398   * received.  From there, the server then creates rfs4_openowner_t
 399  399   * structs for each new open owner from that client and are initiated
 400  400   * at OPEN/OPEN_CONFIRM (when the open owner is new to the server).
 401  401   * At OPEN, at least two other structures are created, and potentially a
 402  402   * third.  rfs4_state_t is created to track the association between an
 403  403   * open owner and a particular file. An rfs4_file_t struct may be
 404  404   * created (if the file is not already open) at OPEN as well.  The
 405  405   * rfs4_file_t struct is the only one that is per server and not per
 406  406   * client.  The rfs4_deleg_state_t struct is created in the
 407  407   * instance that the server is going to provide a delegation for the
 408  408   * file being OPENed.  Finally, the rfs4_lockowner_t is created at the
 409  409   * first use of a lock owner at the server and is a result of the LOCK
 410  410   * operation.  The rfs4_lo_state_t struct is then created to represent
 411  411   * the relation between the lock owner and the file.
 412  412   *
 413  413   */
 414  414  /*
 415  415   * The following ascii art represents each of these data structs and
 416  416   * their references to each other.  Note: "<-(x)->" represents the
 417  417   * doubly link lists (list_t).
 418  418   *
 419  419   *                          ____________________
 420  420   *                         |                    |
 421  421   *                         |    rfs4_client_t   |
 422  422   *                       ->|         (1)        |<-
 423  423   *                      /  |____________________|  \
 424  424   *                     /              ^             \
 425  425   *                    /               |              \
 426  426   *  ____________________    ____________________    ____________________
 427  427   * |                    |  |                    |  |                    |
 428  428   * |  rfs4_lockowner_t  |  |  rfs4_openowner_t  |  | rfs4_deleg_state_t |
 429  429   * |                    |  |     (3)    <-(1)-> |  |            <-(2)-> |
 430  430   * |____________________|  |____________________|  |____________________|
 431  431   *           ^                        ^                       |
 432  432   *           |                        |                       V
 433  433   *  ____________________    ____________________    ____________________
 434  434   * |                    |  |                    |  |                    |
 435  435   * |  rfs4_lo_state_t   |->|    rfs4_state_t    |->|     rfs4_file_t    |
 436  436   * |            <-(4)-> |  |     (4)    <-(3)-> |  |        (2)         |
 437  437   * |____________________|  |____________________|  |____________________|
 438  438   */
 439  439  /*
 440  440   * Each of these data types are kept in a separate rfs4_table_t and is
 441  441   * actually encapsulated within a rfs4_dbe_t struct.  The various
 442  442   * tables and their construction is done in nfs4_state.c but
 443  443   * documented here to completeness.
 444  444   *
 445  445   * Table                Data struct stored      Indexed by
 446  446   * -----                ------------------      ----------
 447  447   * rfs4_client_tab      rfs4_client_t           nfs_client_id4
 448  448   *                                              clientid4
 449  449   *
 450  450   * rfs4_openowner_tab   rfs4_openowner_t        open_owner4
 451  451   *
 452  452   * rfs4_state_tab       rfs4_state_t            open_owner4 | file
 453  453   *                                              stateid
 454  454   *
 455  455   * rfs4_lo_state_tab    rfs4_lo_state_t         lockowner | stateid
 456  456   *                                              lock_stateid
 457  457   *
 458  458   * rfs4_lockowner_tab   rfs4_lockowner_t        lockowner
 459  459   *                                              pid
 460  460   *
 461  461   * rfs4_file_tab        rfs4_file_t             filehandle
 462  462   *
 463  463   * rfs4_deleg_state_tab rfs4_deleg_state_t      clientid4 | file
 464  464   *                                              deleg_stateid
 465  465   */
 466  466  
 467  467  /*
 468  468   * The client struct, it is the root of all state for a particular
 469  469   * client.  The client is identified by the nfs_client_id4 via
 470  470   * SETCLIENTID and the server returns the clientid4 as short hand reference
 471  471   */
 472  472  /*
 473  473   * Client struct - as mentioned above it is the root of all state for
 474  474   * a single client as identified by the client supplied nfs_client_id4
 475  475   *
 476  476   * dbe - encapsulation struct
 477  477   * clientid - server assigned short hand reference to client
 478  478   * nfs_client - client supplied identifier for itself
 479  479   * confirm_verf - the value provided to the client for SETCLIENTID_CONFIRM
 480  480   * need_confirm - does this client need to be SETCLIENTID_CONFIRMed?
 481  481   *
 482  482   * unlksys_completed - has an F_UNLKSYS been done for this client which
 483  483   *              says that the use of cleanlocks() on individual files
 484  484   *              is not required?
 485  485   * can_reclaim - indicates if client is allowed to reclaim after server
 486  486   *              start-up (client had previous state at server)
 487  487   * ss_remove - indicates that the rfs4_client_destroy function should
 488  488   *              clean up stable storage file.
 489  489   * forced_expire - set if the sysadmin has used clear_locks for this client.
 490  490   * no_referrals - set if the client is Solaris and pre-dates referrals
 491  491   * deleg_revoked - how many delegations have been revoked for this client?
 492  492   *
 493  493   * cp_confirmed - this refers to a confirmed client struct that has
 494  494   * the same nfs_client_id4 as this client struct.  When/if this client
 495  495   * struct is confirmed via SETCLINETID_CONFIRM, the previously
 496  496   * confirmed client struct will be "closed" and hence this reference.
 497  497   *
 498  498   * last_access - used to determine if the client has let its lease expire
 499  499   * cbinfo - struct containing all callback related information
 500  500   * cr_set - credentials used for the SETCLIENTID/SETCLIENTID_CONFIRM pair
 501  501   * sysid - the lock manager sysid allocated for this client's file locks
 502  502   * openownerlist - root of openowners list associated with this client
 503  503   * ss_pn - Pathname to the stable storage file.
 504  504   * cl_addr - Clients network address.
 505  505   * server_instance - pointer to the currently associated server instance
 506  506   */
 507  507  typedef struct rfs4_client {
 508  508          rfs4_dbe_t              *rc_dbe;
 509  509          clientid4               rc_clientid;
 510  510          nfs_client_id4          rc_nfs_client;
 511  511          verifier4               rc_confirm_verf;
 512  512          unsigned                rc_need_confirm:1;
 513  513          unsigned                rc_unlksys_completed:1;
 514  514          unsigned                rc_can_reclaim:1;
 515  515          unsigned                rc_ss_remove:1;
 516  516          unsigned                rc_forced_expire:1;
 517  517          uint_t                  rc_deleg_revoked;
 518  518          struct rfs4_client      *rc_cp_confirmed;
 519  519          time_t                  rc_last_access;
 520  520          rfs4_cbinfo_t           rc_cbinfo;
 521  521          cred_set_t              rc_cr_set;
 522  522          sysid_t                 rc_sysidt;
 523  523          list_t                  rc_openownerlist;
 524  524          rfs4_ss_pn_t            *rc_ss_pn;
 525  525          struct sockaddr_storage rc_addr;
 526  526          rfs4_servinst_t         *rc_server_instance;
 527  527  } rfs4_client_t;
 528  528  
 529  529  /*
 530  530   * ClntIP struct - holds the diagnosis about whether the client
 531  531   * cannot support referrals.  Set to true for old Solaris clients.
 532  532   */
 533  533  
 534  534  typedef struct rfs4_clntip {
 535  535          rfs4_dbe_t              *ri_dbe;
 536  536          struct sockaddr_storage ri_addr;
 537  537          unsigned                ri_no_referrals:1;
 538  538  } rfs4_clntip_t;
 539  539  
 540  540  /*
 541  541   * The openowner contains the client supplied open_owner4 as well as
 542  542   * the matching sequence id and is used to track the client's usage of
 543  543   * the open_owner4.  Note that a reply is saved here as well for
 544  544   * processing of retransmissions.
 545  545   *
 546  546   * dbe - encapsulation struct
 547  547   * client - reference to rfs4_client_t for this openowner
 548  548   * owner - actual client supplied open_owner4
 549  549   * need_confirm - does this openowner need to be OPEN_CONFIRMed
 550  550   * postpone_confirm - set if error received on first use of open_owner
 551  551   * state2confirm - what stateid4 should be used on the OPEN_CONFIRM
 552  552   * open_seqid - what is the next open_seqid expected for this openowner
 553  553   * oo_sw - used to serialize access to the open seqid/reply handling
 554  554   * cr_set - credential used for the OPEN
 555  555   * statelist - root of state struct list associated with this openowner
 556  556   * node - node for client struct list of openowners
 557  557   * reply_fh - open replay processing needs the filehandle so that it is
 558  558   *      able to reset the current filehandle for appropriate compound
 559  559   *      processing and reply.
 560  560   * reply - last reply sent in relation to this openowner
 561  561   */
 562  562  typedef struct rfs4_openowner {
 563  563          rfs4_dbe_t              *ro_dbe;
 564  564          rfs4_client_t           *ro_client;
 565  565          open_owner4             ro_owner;
 566  566          unsigned                ro_need_confirm:1;
 567  567          unsigned                ro_postpone_confirm:1;
 568  568          seqid4                  ro_open_seqid;
 569  569          rfs4_state_wait_t       ro_sw;
 570  570          cred_set_t              ro_cr_set;
 571  571          list_t                  ro_statelist;
 572  572          list_node_t             ro_node;
 573  573          nfs_fh4                 ro_reply_fh;
 574  574          nfs_resop4              ro_reply;
 575  575  } rfs4_openowner_t;
 576  576  
 577  577  /*
 578  578   * This state struct represents the association between an openowner
 579  579   * and a file that has been OPENed by that openowner.
 580  580   *
 581  581   * dbe - encapsulation struct
 582  582   * stateid - server provided stateid
 583  583   * owner - reference back to the openowner for this state
 584  584   * finfo - reference to the open file for this state
 585  585   * open_access - how did the openowner OPEN the file (access)
 586  586   * open_deny - how did the openowner OPEN the file (deny)
 587  587   * share_access - what share reservation is on the file (access)
 588  588   * share_deny - what share reservation is on the file (deny)
 589  589   * closed - has this file been closed?
 590  590   * lostatelist - root of list of lo_state associated with this state/file
 591  591   * node - node for state struct list of states
 592  592   */
 593  593  typedef struct rfs4_state {
 594  594          rfs4_dbe_t              *rs_dbe;
 595  595          stateid_t               rs_stateid;
 596  596          rfs4_openowner_t        *rs_owner;
 597  597          struct rfs4_file        *rs_finfo;
 598  598          uint32_t                rs_open_access;
 599  599          uint32_t                rs_open_deny;
 600  600          uint32_t                rs_share_access;
 601  601          uint32_t                rs_share_deny;
 602  602          unsigned                rs_closed:1;
 603  603          list_t                  rs_lostatelist;
 604  604          list_node_t             rs_node;
 605  605  } rfs4_state_t;
 606  606  
 607  607  /*
 608  608   * Lockowner - track the lockowner and its related info
 609  609   *
 610  610   * dbe - encapsulation struct
 611  611   * client - reference to the client
 612  612   * owner - lockowner supplied by the client
 613  613   * pid - local identifier used for file locking
 614  614   */
 615  615  typedef struct rfs4_lockowner {
 616  616          rfs4_dbe_t              *rl_dbe;
 617  617          rfs4_client_t           *rl_client;
 618  618          lock_owner4             rl_owner;
 619  619          pid_t                   rl_pid;
 620  620  } rfs4_lockowner_t;
 621  621  
 622  622  /*
 623  623   * Lockowner_state associated with a state struct and lockowner
 624  624   *
 625  625   * dbe - encapsulation struct
 626  626   * state - reference back to state struct for open file
 627  627   * lockid - stateid for this lockowner/state
 628  628   * locker - reference to lockowner
 629  629   * seqid - sequence id for this lockowner/state
 630  630   * skip_seqid_check - used on initialization of struct
 631  631   * locks_cleaned - have all locks been released for this lockowner/file?
 632  632   * lock_completed - successful LOCK with lockowner/file?
 633  633   * ls_sw - used to serialize update seqid/reply/stateid handling
 634  634   * node - node for state struct list of lo_states
 635  635   * reply - last reply sent in relation to this lockowner/state
 636  636   */
 637  637  typedef struct rfs4_lo_state {
 638  638          rfs4_dbe_t              *rls_dbe;
 639  639          rfs4_state_t            *rls_state;
 640  640          stateid_t               rls_lockid;
 641  641          rfs4_lockowner_t        *rls_locker;
 642  642          seqid4                  rls_seqid;
 643  643          unsigned                rls_skip_seqid_check:1;
 644  644          unsigned                rls_locks_cleaned:1;
 645  645          unsigned                rls_lock_completed:1;
 646  646          rfs4_state_wait_t       rls_sw;
 647  647          list_node_t             rls_node;
 648  648          nfs_resop4              rls_reply;
 649  649  } rfs4_lo_state_t;
 650  650  
 651  651  /*
 652  652   * Delegation state - per client
 653  653   *
 654  654   * dbe - encapsulation struct
 655  655   * dtype - type of delegation (NONE, READ, WRITE)
 656  656   * delegid - stateid for this delegation
 657  657   * time_granted - time this delegation was assigned to client
 658  658   * time_recalled - time when the server started recall process
 659  659   * time_revoked - if revoked, time that the revoke occurred
 660  660   * finfo - reference to the file associated with this delegation
 661  661   * client - reference to client for which this delegation is associated
 662  662   * node - list of delegations for the file (WRITE == 1, READ == )
 663  663   */
 664  664  typedef struct rfs4_deleg_state {
 665  665          rfs4_dbe_t              *rds_dbe;
 666  666          open_delegation_type4   rds_dtype;
 667  667          stateid_t               rds_delegid;
 668  668          time_t                  rds_time_granted;
 669  669          time_t                  rds_time_recalled;
 670  670          time_t                  rds_time_revoked;
 671  671          struct rfs4_file        *rds_finfo;
 672  672          rfs4_client_t           *rds_client;
 673  673          list_node_t             rds_node;
 674  674  } rfs4_deleg_state_t;
 675  675  
 676  676  /*
 677  677   * Delegation info associated with the file
 678  678   *
 679  679   * dtype - type of delegation for file (NONE, READ, WRITE)
 680  680   * time_returned - time that last delegation was returned for file
 681  681   * time_recalled - time that recall sequence started
 682  682   * time_lastgrant - time that last delegation was provided to a client
 683  683   * time_lastwrite - time of last write to use the delegation stateid
 684  684   * time_rm_delayed - time of last remove/rename which was DELAYed
 685  685   * rdgrants - how many read delegations have been provided for this file
 686  686   * wrgrants - how many write delegations provided (can only be one)
 687  687   * recall_count - how many recall threads are outstanding
 688  688   * recall_lock - lock to protect contents of this struct
 689  689   * recall_cv - condition var for the "parent" thread to wait upon
 690  690   * deleg_change_grant - value for change attribute at time of write grant
 691  691   * deleg_change - most recent value of change obtained from client
 692  692   * deleg_change_ts - time of last deleg_change update
 693  693   * ever_recalled - has this particular delegation ever been recalled?
 694  694   * dont_grant - file deletion is impending, don't grant a delegation
 695  695   * conflicted_client - clientid of the client that caused a CB_RECALL
 696  696   *      to occur. This is used for delegation policy (should a delegation
 697  697   *      be granted shortly after it has been returned?)
 698  698   */
 699  699  typedef struct rfs4_dinfo {
 700  700          open_delegation_type4 rd_dtype;
 701  701          time_t          rd_time_returned;
 702  702          time_t          rd_time_recalled;
 703  703          time_t          rd_time_lastgrant;
 704  704          time_t          rd_time_lastwrite;
 705  705          time_t          rd_time_rm_delayed;
 706  706          uint32_t        rd_rdgrants;
 707  707          uint32_t        rd_wrgrants;
 708  708          int32_t         rd_recall_count;
 709  709          kmutex_t        rd_recall_lock[1];
 710  710          kcondvar_t      rd_recall_cv[1];
 711  711          bool_t          rd_ever_recalled;
 712  712          uint32_t        rd_hold_grant;
 713  713          clientid4       rd_conflicted_client;
 714  714  } rfs4_dinfo_t;
 715  715  
 716  716  /*
 717  717   * File
 718  718   *
 719  719   * dbe - encapsulation struct
 720  720   * vp - vnode for the file that is open or has a delegation
 721  721   * filehandle - the filehandle generated by the server for this file
 722  722   * delegstatelist - root of delegation list for this file
 723  723   * dinfo - see struct definition above
 724  724   * share_deny - union of all deny modes on file
 725  725   * share_access - union of all access modes on file
 726  726   * access_read - count of read access
 727  727   * access_write - count of write access
 728  728   * deny_read - count of deny reads
 729  729   * deny_write - count of deny writes
 730  730   * file_rwlock - lock for serializing the removal of a file while
 731  731   *      the state structures are active within the server
 732  732   *
 733  733   *      The only requirement for locking file_rwlock is that the
 734  734   *      caller have a reference to the containing rfs4_file.  The dbe
 735  735   *      lock may or may not be held for lock/unlock of file_rwlock.
 736  736   *      As mentioned above, the file_rwlock is used for serialization
 737  737   *      of file removal and more specifically reference to the held
 738  738   *      vnode (e.g. vp).
 739  739   */
 740  740  typedef struct rfs4_file {
 741  741          rfs4_dbe_t      *rf_dbe;
 742  742          vnode_t         *rf_vp;
 743  743          nfs_fh4         rf_filehandle;
 744  744          list_t          rf_delegstatelist;
 745  745          rfs4_dinfo_t    rf_dinfo;
 746  746          uint32_t        rf_share_deny;
 747  747          uint32_t        rf_share_access;
 748  748          uint32_t        rf_access_read;
 749  749          uint32_t        rf_access_write;
 750  750          uint32_t        rf_deny_read;
 751  751          uint32_t        rf_deny_write;
 752  752          krwlock_t       rf_file_rwlock;
 753  753  } rfs4_file_t;
 754  754  
 755  755  /*
 756  756   * nfs4_deleg_policy is used to signify the server's global delegation
 757  757   * policy.  The default is to NEVER delegate files and the
 758  758   * administrator must configure the server to enable delegations.
 759  759   *
 760  760   * The disable/enable delegation functions are used to eliminate a
 761  761   * race with exclusive creates.
 762  762   */
 763  763  typedef enum {
 764  764          SRV_NEVER_DELEGATE = 0,
 765  765          SRV_NORMAL_DELEGATE = 1
 766  766  } srv_deleg_policy_t;
 767  767  
 768  768  extern void rfs4_disable_delegation(void), rfs4_enable_delegation(void);
 769  769  
 770  770  /*
 771  771   * Request types for delegation. These correspond with
 772  772   * open_delegation_type4 with the addition of a new value, DELEG_ANY,
 773  773   * to reqequest any delegation.
 774  774   */
 775  775  typedef enum {
 776  776          DELEG_NONE = 0,         /* Corresponds to OPEN_DELEG_NONE */
 777  777          DELEG_READ = 1,         /* Corresponds to OPEN_DELEG_READ */
 778  778          DELEG_WRITE = 2,        /* Corresponds to OPEN_DELEG_WRITE */
 779  779          DELEG_ANY = -1          /* New value to request any delegation type */
 780  780  } delegreq_t;
 781  781  
 782  782  #define NFS4_DELEG4TYPE2REQTYPE(x) (delegreq_t)(x)
 783  783  
 784  784  /*
 785  785   * Zone global variables of NFSv4 server
 786  786   */
 787  787  typedef struct nfs4_srv {
 788  788          /* Unique write verifier */
 789  789          verifier4       write4verf;
 790  790          /* Delegation lock */
 791  791          kmutex_t        deleg_lock;
 792  792          /* Used to serialize create/destroy of nfs4_server_state database */
 793  793          kmutex_t        state_lock;
 794  794          rfs4_database_t *nfs4_server_state;
 795  795          /* Used to manage access to server instance linked list */
 796  796          kmutex_t        servinst_lock;
 797  797          rfs4_servinst_t *nfs4_cur_servinst;
 798  798          /* Used to manage access to nfs4_deleg_policy */
 799  799          krwlock_t       deleg_policy_lock;
 800  800          srv_deleg_policy_t nfs4_deleg_policy;
 801  801          /* Set first time we see one */
 802  802          int             seen_first_compound;
 803  803          /*
 804  804           * Circular double-linked list of paths for currently-served RGs.
 805  805           * No locking required -- only changed on server start.
 806  806           * Managed with insque/remque.
 807  807           */
 808  808          rfs4_dss_path_t *dss_pathlist;
 809  809          /* Duplicate request cache */
 810  810          rfs4_drc_t      *nfs4_drc;
 811  811          /* nfsv4 server start time */
 812  812          time_t rfs4_start_time;
 813  813          /* Used to serialize lookups of clientids */
 814  814          krwlock_t rfs4_findclient_lock;
 815  815  
 816  816          /* NFSv4 server state client tables */
 817  817          /* table expiry times */
 818  818          time_t rfs4_client_cache_time;
 819  819          time_t rfs4_openowner_cache_time;
 820  820          time_t rfs4_state_cache_time;
 821  821          time_t rfs4_lo_state_cache_time;
 822  822          time_t rfs4_lockowner_cache_time;
 823  823          time_t rfs4_file_cache_time;
 824  824          time_t rfs4_deleg_state_cache_time;
 825  825          time_t rfs4_clntip_cache_time;
 826  826          /* tables and indexes */
 827  827          /* client table */
 828  828          rfs4_table_t *rfs4_client_tab;
 829  829          rfs4_index_t *rfs4_clientid_idx;
 830  830          rfs4_index_t *rfs4_nfsclnt_idx;
 831  831          /* client IP table */
 832  832          rfs4_table_t *rfs4_clntip_tab;
 833  833          rfs4_index_t *rfs4_clntip_idx;
 834  834          /* Open Owner table */
 835  835          rfs4_table_t *rfs4_openowner_tab;
 836  836          rfs4_index_t *rfs4_openowner_idx;
 837  837          /* Open State ID table */
 838  838          rfs4_table_t *rfs4_state_tab;
 839  839          rfs4_index_t *rfs4_state_idx;
 840  840          rfs4_index_t *rfs4_state_owner_file_idx;
 841  841          rfs4_index_t *rfs4_state_file_idx;
 842  842          /* Lock State ID table */
 843  843          rfs4_table_t *rfs4_lo_state_tab;
 844  844          rfs4_index_t *rfs4_lo_state_idx;
 845  845          rfs4_index_t *rfs4_lo_state_owner_idx;
 846  846          /* Lock owner table */
 847  847          rfs4_table_t *rfs4_lockowner_tab;
 848  848          rfs4_index_t *rfs4_lockowner_idx;
 849  849          rfs4_index_t *rfs4_lockowner_pid_idx;
 850  850          /* File table */
 851  851          rfs4_table_t *rfs4_file_tab;
 852  852          rfs4_index_t *rfs4_file_idx;
 853  853          /* Deleg State table */
 854  854          rfs4_table_t *rfs4_deleg_state_tab;
 855  855          rfs4_index_t *rfs4_deleg_idx;
 856  856          rfs4_index_t *rfs4_deleg_state_idx;
 857  857  
 858  858          /* client stable storage */
 859  859          int rfs4_ss_enabled;
 860  860  } nfs4_srv_t;
 861  861  
 862  862  /*
 863  863   * max length of the NFSv4 server database name
 864  864   */
 865  865  #define RFS4_MAX_MEM_CACHE_NAME 48
 866  866  
 867  867  /*
 868  868   * global NFSv4 server kmem caches
 869  869   * r_db_name - The name of the state database and the table that will use it
 870  870   *             These tables are defined in nfs4_srv_t
 871  871   * r_db_mem_cache - The kmem cache associated with the state database name
 872  872   */
 873  873  typedef struct rfs4_db_mem_cache {
 874  874          char            r_db_name[RFS4_MAX_MEM_CACHE_NAME];
 875  875          kmem_cache_t    *r_db_mem_cache;
 876  876  } rfs4_db_mem_cache_t;
 877  877  
 878  878  #define RFS4_DB_MEM_CACHE_NUM 8
 879  879  
 880  880  rfs4_db_mem_cache_t rfs4_db_mem_cache_table[RFS4_DB_MEM_CACHE_NUM];
 881  881  
 882  882  
 883  883  extern srv_deleg_policy_t nfs4_get_deleg_policy();
 884  884  
 885  885  extern void             rfs4_servinst_create(nfs4_srv_t *, int, int, char **);
 886  886  extern void             rfs4_servinst_destroy_all(nfs4_srv_t *);
 887  887  extern void             rfs4_servinst_assign(nfs4_srv_t *, rfs4_client_t *,
 888  888                              rfs4_servinst_t *);
 889  889  extern rfs4_servinst_t  *rfs4_servinst(rfs4_client_t *);
 890  890  extern int              rfs4_clnt_in_grace(rfs4_client_t *);
 891  891  extern int              rfs4_servinst_in_grace(rfs4_servinst_t *);
 892  892  extern int              rfs4_servinst_grace_new(rfs4_servinst_t *);
  
    | 
      ↓ open down ↓ | 
    892 lines elided | 
    
      ↑ open up ↑ | 
  
 893  893  extern void             rfs4_grace_start(rfs4_servinst_t *);
 894  894  extern void             rfs4_grace_start_new(nfs4_srv_t *);
 895  895  extern void             rfs4_grace_reset_all(nfs4_srv_t *);
 896  896  extern void             rfs4_ss_oldstate(rfs4_oldstate_t *, char *, char *);
 897  897  extern void             rfs4_dss_readstate(nfs4_srv_t *, int, char **);
 898  898  
 899  899  /*
 900  900   * Various interfaces to manipulate the state structures introduced
 901  901   * above
 902  902   */
 903      -extern  void            rfs4_clean_state_exi(struct exportinfo *exi);
 904  903  extern  void            rfs4_free_reply(nfs_resop4 *);
 905  904  extern  void            rfs4_copy_reply(nfs_resop4 *, nfs_resop4 *);
 906  905  
 907  906  /* rfs4_client_t handling */
 908  907  extern  rfs4_client_t   *rfs4_findclient(nfs_client_id4 *,
 909  908                                          bool_t *, rfs4_client_t *);
 910  909  extern  rfs4_client_t   *rfs4_findclient_by_id(clientid4, bool_t);
 911  910  extern  rfs4_client_t   *rfs4_findclient_by_addr(struct sockaddr *);
 912  911  extern  void            rfs4_client_rele(rfs4_client_t *);
 913  912  extern  void            rfs4_client_close(rfs4_client_t *);
 914  913  extern  void            rfs4_client_state_remove(rfs4_client_t *);
 915  914  extern  void            rfs4_client_scv_next(rfs4_client_t *);
 916  915  extern  void            rfs4_update_lease(rfs4_client_t *);
 917  916  extern  bool_t          rfs4_lease_expired(rfs4_client_t *);
 918  917  extern  nfsstat4        rfs4_check_clientid(clientid4 *, int);
 919  918  
 920  919  /* rfs4_clntip_t handling */
 921  920  extern  rfs4_clntip_t   *rfs4_find_clntip(struct sockaddr *, bool_t *);
 922  921  extern  void            rfs4_invalidate_clntip(struct sockaddr *);
 923  922  
 924  923  /* rfs4_openowner_t handling */
 925  924  extern  rfs4_openowner_t *rfs4_findopenowner(open_owner4 *, bool_t *, seqid4);
 926  925  extern  void            rfs4_update_open_sequence(rfs4_openowner_t *);
 927  926  extern  void            rfs4_update_open_resp(rfs4_openowner_t *,
 928  927                                          nfs_resop4 *, nfs_fh4 *);
 929  928  extern  void            rfs4_openowner_rele(rfs4_openowner_t *);
 930  929  extern  void            rfs4_free_opens(rfs4_openowner_t *, bool_t, bool_t);
 931  930  
 932  931  /* rfs4_lockowner_t handling */
 933  932  extern  rfs4_lockowner_t *rfs4_findlockowner(lock_owner4 *, bool_t *);
 934  933  extern  rfs4_lockowner_t *rfs4_findlockowner_by_pid(pid_t);
 935  934  extern  void            rfs4_lockowner_rele(rfs4_lockowner_t *);
 936  935  
 937  936  /* rfs4_state_t handling */
 938  937  extern  rfs4_state_t    *rfs4_findstate_by_owner_file(rfs4_openowner_t *,
 939  938                                          rfs4_file_t *, bool_t *);
 940  939  extern  void            rfs4_state_rele(rfs4_state_t *);
 941  940  extern  void            rfs4_state_close(rfs4_state_t *, bool_t,
 942  941                                          bool_t, cred_t *);
 943  942  extern  void            rfs4_release_share_lock_state(rfs4_state_t *,
 944  943                                          cred_t *, bool_t);
 945  944  extern  void            rfs4_close_all_state(rfs4_file_t *);
 946  945  
 947  946  /* rfs4_lo_state_t handling */
 948  947  extern  rfs4_lo_state_t *rfs4_findlo_state_by_owner(rfs4_lockowner_t *,
 949  948                                                  rfs4_state_t *, bool_t *);
 950  949  extern  void            rfs4_lo_state_rele(rfs4_lo_state_t *, bool_t);
 951  950  extern  void            rfs4_update_lock_sequence(rfs4_lo_state_t *);
 952  951  extern  void            rfs4_update_lock_resp(rfs4_lo_state_t *,
 953  952                                          nfs_resop4 *);
 954  953  
 955  954  /* rfs4_file_t handling */
 956  955  extern  rfs4_file_t     *rfs4_findfile(vnode_t *, nfs_fh4 *, bool_t *);
 957  956  extern  rfs4_file_t     *rfs4_findfile_withlock(vnode_t *, nfs_fh4 *,
 958  957                                                  bool_t *);
 959  958  extern  void            rfs4_file_rele(rfs4_file_t *);
 960  959  
 961  960  /* General collection of "get state" functions */
 962  961  extern  nfsstat4        rfs4_get_state(stateid4 *, rfs4_state_t **,
 963  962                                          rfs4_dbsearch_type_t);
 964  963  extern  nfsstat4        rfs4_get_deleg_state(stateid4 *,
 965  964                                          rfs4_deleg_state_t **);
 966  965  extern  nfsstat4        rfs4_get_lo_state(stateid4 *, rfs4_lo_state_t **,
 967  966                                          bool_t);
 968  967  extern  nfsstat4        rfs4_check_stateid(int, vnode_t *, stateid4 *,
 969  968                                          bool_t, bool_t *, bool_t,
 970  969                                          caller_context_t *);
 971  970  extern  int             rfs4_check_stateid_seqid(rfs4_state_t *, stateid4 *);
 972  971  extern  int             rfs4_check_lo_stateid_seqid(rfs4_lo_state_t *,
 973  972                                          stateid4 *);
 974  973  
 975  974  /* return values for rfs4_check_stateid_seqid() */
 976  975  #define NFS4_CHECK_STATEID_OKAY 1
 977  976  #define NFS4_CHECK_STATEID_OLD  2
 978  977  #define NFS4_CHECK_STATEID_BAD  3
 979  978  #define NFS4_CHECK_STATEID_EXPIRED      4
 980  979  #define NFS4_CHECK_STATEID_REPLAY       5
 981  980  #define NFS4_CHECK_STATEID_CLOSED       6
 982  981  #define NFS4_CHECK_STATEID_UNCONFIRMED  7
 983  982  
 984  983  /* delay() time that server is willing to briefly wait for a delegreturn */
 985  984  #define NFS4_DELEGATION_CONFLICT_DELAY  (hz/10)
 986  985  
 987  986  /*
 988  987   * Interfaces for handling of callback's client handle cache and
 989  988   * callback interfaces themselves.
 990  989   */
 991  990  extern  void            rfs4_cbinfo_free(rfs4_cbinfo_t *);
 992  991  extern  void            rfs4_client_setcb(rfs4_client_t *, cb_client4 *,
 993  992                                          uint32_t);
 994  993  extern  void            rfs4_deleg_cb_check(rfs4_client_t *);
 995  994  extern  nfsstat4        rfs4_vop_getattr(vnode_t *, vattr_t *, int, cred_t *);
 996  995  
 997  996  /* rfs4_deleg_state_t handling and other delegation interfaces */
 998  997  extern  rfs4_deleg_state_t *rfs4_finddeleg(rfs4_state_t *, bool_t *);
 999  998  extern  rfs4_deleg_state_t *rfs4_finddelegstate(stateid_t *);
1000  999  extern  bool_t          rfs4_check_recall(rfs4_state_t *, uint32_t);
1001 1000  extern  void            rfs4_recall_deleg(rfs4_file_t *,
1002 1001                                  bool_t, rfs4_client_t *);
1003 1002  extern  int             rfs4_get_deleg(rfs4_state_t *,  open_delegation_type4,
1004 1003                          open_delegation_type4 (*policy)(rfs4_state_t *,
1005 1004                                  open_delegation_type4 dtype));
1006 1005  extern  rfs4_deleg_state_t *rfs4_grant_delegation(delegreq_t, rfs4_state_t *,
1007 1006                                  int *);
1008 1007  extern  void            rfs4_set_deleg_response(rfs4_deleg_state_t *,
1009 1008                                  open_delegation4 *, nfsace4 *, int);
1010 1009  extern  void            rfs4_return_deleg(rfs4_deleg_state_t *, bool_t);
1011 1010  extern  bool_t          rfs4_is_deleg(rfs4_state_t *);
1012 1011  extern  void            rfs4_deleg_state_rele(rfs4_deleg_state_t *);
1013 1012  extern  bool_t          rfs4_check_delegated_byfp(int, rfs4_file_t *,
1014 1013                                          bool_t, bool_t, bool_t, clientid4 *);
1015 1014  extern  void            rfs4_clear_dont_grant(rfs4_file_t *);
1016 1015  
1017 1016  /*
1018 1017   * nfs4 monitored operations.
1019 1018   */
1020 1019  extern int deleg_rd_open(femarg_t *, int, cred_t *, caller_context_t *);
1021 1020  extern int deleg_wr_open(femarg_t *, int, cred_t *, caller_context_t *);
1022 1021  extern int deleg_wr_read(femarg_t *, uio_t *, int, cred_t *,
1023 1022              caller_context_t *);
1024 1023  extern int deleg_rd_write(femarg_t *, uio_t *, int, cred_t *,
1025 1024              caller_context_t *);
1026 1025  extern int deleg_wr_write(femarg_t *, uio_t *, int, cred_t *,
1027 1026              caller_context_t *);
1028 1027  extern int deleg_rd_setattr(femarg_t *, vattr_t *, int, cred_t *,
1029 1028                  caller_context_t *);
1030 1029  extern int deleg_wr_setattr(femarg_t *, vattr_t *, int, cred_t *,
1031 1030                  caller_context_t *);
1032 1031  extern int deleg_rd_rwlock(femarg_t *, int, caller_context_t *);
1033 1032  extern int deleg_wr_rwlock(femarg_t *, int, caller_context_t *);
1034 1033  extern int deleg_rd_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *,
1035 1034                  caller_context_t *);
1036 1035  extern int deleg_wr_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *,
1037 1036                  caller_context_t *);
1038 1037  extern int deleg_rd_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
1039 1038                  caller_context_t *);
1040 1039  extern int deleg_wr_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
1041 1040                  caller_context_t *);
1042 1041  extern int deleg_rd_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
1043 1042                  caller_context_t *);
1044 1043  extern int deleg_wr_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
1045 1044                  caller_context_t *);
1046 1045  
1047 1046  extern void rfs4_mon_hold(void *);
1048 1047  extern void rfs4_mon_rele(void *);
1049 1048  
1050 1049  extern fem_t    *deleg_rdops;
1051 1050  extern fem_t    *deleg_wrops;
1052 1051  
1053 1052  extern int rfs4_share(rfs4_state_t *, uint32_t, uint32_t);
1054 1053  extern int rfs4_unshare(rfs4_state_t *);
1055 1054  extern void rfs4_set_deleg_policy(nfs4_srv_t *, srv_deleg_policy_t);
1056 1055  extern void rfs4_hold_deleg_policy(nfs4_srv_t *);
1057 1056  extern void rfs4_rele_deleg_policy(nfs4_srv_t *);
1058 1057  
1059 1058  #ifdef DEBUG
1060 1059  #define NFS4_DEBUG(var, args) if (var) cmn_err args
1061 1060  
1062 1061  extern int rfs4_debug;
1063 1062  extern int nfs4_client_attr_debug;
1064 1063  extern int nfs4_client_state_debug;
1065 1064  extern int nfs4_client_shadow_debug;
1066 1065  extern int nfs4_client_lock_debug;
1067 1066  extern int nfs4_client_lease_debug;
1068 1067  extern int nfs4_seqid_sync;
1069 1068  extern int nfs4_client_map_debug;
1070 1069  extern int nfs4_client_inactive_debug;
1071 1070  extern int nfs4_client_recov_debug;
1072 1071  extern int nfs4_client_failover_debug;
1073 1072  extern int nfs4_client_call_debug;
1074 1073  extern int nfs4_client_foo_debug;
1075 1074  extern int nfs4_client_zone_debug;
1076 1075  extern int nfs4_lost_rqst_debug;
1077 1076  extern int nfs4_open_stream_debug;
1078 1077  extern int nfs4_client_open_dg;
1079 1078  extern int nfs4_srvmnt_debug;
1080 1079  extern int nfs4_utf8_debug;
1081 1080  
1082 1081  void rfs4_dbe_debug(rfs4_dbe_t *e);
1083 1082  
1084 1083  #ifdef NFS4_DEBUG_MUTEX
1085 1084  void nfs4_debug_mutex_enter(kmutex_t *, char *, int);
1086 1085  void nfs4_debug_mutex_exit(kmutex_t *, char *, int);
1087 1086  
1088 1087  #define mutex_enter(m) nfs4_debug_mutex_enter((m), __FILE__, __LINE__)
1089 1088  #define mutex_exit(m) nfs4_debug_mutex_exit((m), __FILE__, __LINE__)
1090 1089  #endif /* NFS4_DEBUG_MUTEX */
1091 1090  
1092 1091  #else  /* ! DEBUG */
1093 1092  #define NFS4_DEBUG(var, args)
1094 1093  #endif /* DEBUG */
1095 1094  
1096 1095  /*
1097 1096   * XXX - temporary for testing of volatile fh
1098 1097   */
1099 1098  
1100 1099  #ifdef VOLATILE_FH_TEST
1101 1100  
1102 1101  struct nfs_fh4_fmt {
1103 1102          fhandle4_t      fh4_i;
1104 1103          uint32_t        fh4_flag;
1105 1104          uint32_t        fh4_volatile_id;
1106 1105  };
1107 1106  
1108 1107  #else /* VOLATILE_FH_TEST */
1109 1108  
1110 1109  struct nfs_fh4_fmt {
1111 1110          fhandle4_t      fh4_i;
1112 1111          uint32_t        fh4_flag;
1113 1112  };
1114 1113  
1115 1114  #endif /* VOLATILE_FH_TEST */
1116 1115  
1117 1116  #define FH4_NAMEDATTR   1
1118 1117  #define FH4_ATTRDIR     2
1119 1118  
1120 1119  #define fh4_fsid        fh4_i.fhx_fsid
1121 1120  #define fh4_len         fh4_i.fhx_len   /* fid length */
1122 1121  #define fh4_data        fh4_i.fhx_data  /* fid bytes */
1123 1122  #define fh4_xlen        fh4_i.fhx_xlen
1124 1123  #define fh4_xdata       fh4_i.fhx_xdata
1125 1124  typedef struct nfs_fh4_fmt nfs_fh4_fmt_t;
1126 1125  
1127 1126  #define fh4_to_fmt4(fh4p) ((nfs_fh4_fmt_t *)(fh4p)->nfs_fh4_val)
1128 1127  #define get_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) & (flag))
1129 1128  #define set_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) |= (flag))
1130 1129  #define clr_fh4_flag(fh4p, flag) ((fh4_to_fmt4(fh4p)->fh4_flag) &= ~(flag))
1131 1130  
1132 1131  #define NFS_FH4_LEN     sizeof (nfs_fh4_fmt_t)
1133 1132  
1134 1133  /*
1135 1134   * Copy fields from external (fhandle_t) to in-memory (nfs_fh4_fmt_t)
1136 1135   * format to support export info checking.  It does not copy over
1137 1136   * the complete filehandle, just the fsid, xlen and xdata.  It may
1138 1137   * need to be changed to be used in other places.
1139 1138   *
1140 1139   * NOTE: The macro expects the space to be  pre-allocated for
1141 1140   * the contents of nfs_fh4_fmt_t.
1142 1141   */
1143 1142  #define FH_TO_FMT4(exifh, nfs_fmt) {                            \
1144 1143          bzero((nfs_fmt), NFS_FH4_LEN);                          \
1145 1144          (nfs_fmt)->fh4_fsid = (exifh)->fh_fsid;                 \
1146 1145          (nfs_fmt)->fh4_xlen = (exifh)->fh_xlen;                 \
1147 1146          bcopy((exifh)->fh_xdata, (nfs_fmt)->fh4_xdata,          \
1148 1147              (exifh)->fh_xlen);                                  \
1149 1148  }
1150 1149  
1151 1150  /*
1152 1151   * A few definitions of repeatedly used constructs for nfsv4
1153 1152   */
1154 1153  #define UTF8STRING_FREE(str)    {                               \
1155 1154          kmem_free((str).utf8string_val, (str).utf8string_len);  \
1156 1155          (str).utf8string_val = NULL;                            \
1157 1156          (str).utf8string_len = 0;                               \
1158 1157  }
1159 1158  
1160 1159  /*
1161 1160   * NFS4_VOLATILE_FH yields non-zero if the filesystem uses non-persistent
1162 1161   * filehandles.
1163 1162   */
1164 1163  #define NFS4_VOLATILE_FH(mi)                                    \
1165 1164          ((mi)->mi_fh_expire_type &                              \
1166 1165          (FH4_VOLATILE_ANY | FH4_VOL_MIGRATION | FH4_VOL_RENAME))
1167 1166  
1168 1167  /*
1169 1168   * NFS_IS_DOTNAME checks if the name given represents a dot or dotdot entry
1170 1169   */
1171 1170  #define NFS_IS_DOTNAME(name)                                    \
1172 1171          (((name)[0] == '.') &&                                  \
1173 1172          (((name)[1] == '\0') || (((name)[1] == '.') && ((name)[2] == '\0'))))
1174 1173  
1175 1174  /*
1176 1175   * Define the number of bits in a bitmap word (uint32)
1177 1176   */
1178 1177  #define NFS4_BITMAP4_BITSPERWORD        (sizeof (uint32_t) * 8)
1179 1178  
1180 1179  /*
1181 1180   * Define the value for the access field of the compound_state structure
1182 1181   * based on the result of nfsauth access checking.
1183 1182   */
1184 1183  #define CS_ACCESS_OK            0x1
1185 1184  #define CS_ACCESS_DENIED        0x2
1186 1185  #define CS_ACCESS_LIMITED       0x4
1187 1186  
1188 1187  /*
1189 1188   * compound state in nfsv4 server
1190 1189   */
1191 1190  struct compound_state {
1192 1191          struct exportinfo *exi;
1193 1192          struct exportinfo *saved_exi;   /* export struct for saved_vp */
1194 1193          cred_t          *basecr;        /* UNIX cred:  only RPC request */
1195 1194          caddr_t         principal;
1196 1195          int             nfsflavor;
1197 1196          cred_t          *cr;            /* UNIX cred: RPC request and */
1198 1197                                          /* target export */
1199 1198          bool_t          cont;
1200 1199          uint_t          access;         /* access perm on vp per request */
1201 1200          bool_t          deleg;          /* TRUE if current fh has */
1202 1201                                          /* write delegated */
1203 1202          vnode_t         *vp;            /* modified by PUTFH, and by ops that */
1204 1203                                          /* input to GETFH */
1205 1204          bool_t          mandlock;       /* Is mandatory locking in effect */
1206 1205                                          /* for vp */
1207 1206          vnode_t         *saved_vp;      /* modified by SAVEFH, copied to */
1208 1207                                          /* vp by RESTOREFH */
1209 1208          nfsstat4        *statusp;
1210 1209          nfs_fh4         fh;             /* ditto. valid only if vp != NULL */
1211 1210          nfs_fh4         saved_fh;       /* ditto. valid only if */
1212 1211                                          /*      saved_vp != NULL */
1213 1212          struct svc_req  *req;
1214 1213          char            fhbuf[NFS4_FHSIZE];
1215 1214  };
1216 1215  
1217 1216  /*
1218 1217   * Conversion commands for nfsv4 server attr checking
1219 1218   */
1220 1219  enum nfs4_attr_cmd {
1221 1220          NFS4ATTR_SUPPORTED = 0,         /* check which attrs supported */
1222 1221          NFS4ATTR_GETIT = 1,             /* getattr - sys to fattr4 (r) */
1223 1222          NFS4ATTR_SETIT = 2,             /* setattr - fattr4 to sys (w) */
1224 1223          NFS4ATTR_VERIT = 3,             /* verify - fattr4 to sys (r) */
1225 1224          NFS4ATTR_FREEIT = 4             /* free any alloc'd space for attr */
1226 1225  };
1227 1226  
1228 1227  typedef enum nfs4_attr_cmd nfs4_attr_cmd_t;
1229 1228  
1230 1229  struct nfs4_svgetit_arg {
1231 1230          nfs4_attr_cmd_t op;             /* getit or setit */
1232 1231          struct compound_state *cs;
1233 1232          struct statvfs64 *sbp;
1234 1233          uint_t          flag;           /* VOP_GETATTR/VOP_SETATTR flag */
1235 1234          uint_t          xattr;          /* object is xattr */
1236 1235          bool_t          rdattr_error_req; /* if readdir & client wants */
1237 1236                                                  /* rdattr_error */
1238 1237          nfsstat4        rdattr_error;   /* used for per-entry status */
1239 1238                                          /* (if rdattr_err) */
1240 1239          bool_t          is_referral;    /* because sometimes we tell lies */
1241 1240          bool_t          mntdfid_set;
1242 1241          fattr4_mounted_on_fileid
1243 1242                          mounted_on_fileid;
1244 1243                                          /* readdir op can always return */
1245 1244                                          /* d_ino from server fs dirent  */
1246 1245                                          /* for mounted_on_fileid attr.  */
1247 1246                                          /* This field holds d_ino so    */
1248 1247                                          /* srv attr conv code can avoid */
1249 1248                                          /* doing an untraverse.         */
1250 1249          vattr_t         vap[1];
1251 1250  };
1252 1251  
1253 1252  struct nfs4_ntov_map {
1254 1253          bitmap4         fbit;           /* FATTR4_XXX_MASKY */
1255 1254          uint_t          vbit;           /* AT_XXX */
1256 1255          bool_t          vfsstat;
1257 1256          bool_t          mandatory;      /* attribute mandatory to implement? */
1258 1257          uint_t          nval;
1259 1258          int             xdr_size;       /* Size of XDR'd attr */
1260 1259          xdrproc_t       xfunc;
1261 1260          int (*sv_getit)(nfs4_attr_cmd_t, struct nfs4_svgetit_arg *,
1262 1261                  union nfs4_attr_u *);   /* subroutine for getting attr. */
1263 1262          char            *prtstr;        /* string attr for printing */
1264 1263  };
1265 1264  
1266 1265  struct nfs4attr_to_vattr {
1267 1266          vnode_t         *vp;
1268 1267          vattr_t         *vap;
1269 1268          nfs_fh4         *fhp;
1270 1269          nfsstat4        rdattr_error;
1271 1270          uint32_t        flag;
1272 1271          fattr4_change   change;
1273 1272          fattr4_fsid     srv_fsid;
1274 1273          fattr4_mounted_on_fileid        mntd_fid;
1275 1274  };
1276 1275  
1277 1276  typedef struct nfs4attr_to_vattr ntov4_t;
1278 1277  
1279 1278  /*
1280 1279   * nfs4attr_to_vattr flags
1281 1280   */
1282 1281  #define NTOV_FHP_VALID                  0x01
1283 1282  #define NTOV_RDATTR_ERROR_VALID         0x02
1284 1283  #define NTOV_CHANGE_VALID               0x04
1285 1284  #define NTOV_SUPP_VALID                 0x08
1286 1285  #define NTOV_SRV_FSID_VALID             0x10
1287 1286  #define NTOV_MOUNTED_ON_FILEID_VALID    0x20
1288 1287  
1289 1288  
1290 1289  #define FATTR4_MANDATTR_MASK (          \
1291 1290          FATTR4_SUPPORTED_ATTRS_MASK |   \
1292 1291          FATTR4_TYPE_MASK |              \
1293 1292          FATTR4_FH_EXPIRE_TYPE_MASK |    \
1294 1293          FATTR4_CHANGE_MASK |            \
1295 1294          FATTR4_SIZE_MASK |              \
1296 1295          FATTR4_LINK_SUPPORT_MASK |      \
1297 1296          FATTR4_SYMLINK_SUPPORT_MASK |   \
1298 1297          FATTR4_NAMED_ATTR_MASK |        \
1299 1298          FATTR4_FSID_MASK |              \
1300 1299          FATTR4_UNIQUE_HANDLES_MASK |    \
1301 1300          FATTR4_LEASE_TIME_MASK |        \
1302 1301          FATTR4_RDATTR_ERROR_MASK |      \
1303 1302          FATTR4_FILEHANDLE_MASK)
1304 1303  
1305 1304  
1306 1305  struct nfs4attr_to_osattr {
1307 1306          void *attrconv_arg;
1308 1307          uint_t mask;
1309 1308  };
1310 1309  
1311 1310  struct mntinfo4;
1312 1311  
1313 1312  /*
1314 1313   * lkp4_attr_setup lists the different options for attributes when calling
1315 1314   * nfs4lookup_setup - either no attributes (just lookups - e.g., secinfo),
1316 1315   * one component only (normal component lookup), get attributes for the
1317 1316   * last component (e.g., mount), attributes for each component (e.g.,
1318 1317   * failovers later), just the filehandle for the last component (e.g.,
1319 1318   * volatile filehandle recovery), or stuff that needs OPENATTR (e.g.
1320 1319   * looking up a named attribute or it's hidden directory).
1321 1320   */
1322 1321  enum lkp4_attr_setup {
1323 1322          LKP4_NO_ATTRIBUTES = 0,         /* no attrs or filehandles */
1324 1323          LKP4_ALL_ATTRIBUTES = 3,        /* multi-comp: attrs for all comps */
1325 1324          LKP4_LAST_NAMED_ATTR = 5,       /* multi-comp: named attr & attrdir */
1326 1325          LKP4_LAST_ATTRDIR = 6,          /* multi-comp: just attrdir */
1327 1326          LKP4_ALL_ATTR_SECINFO = 7       /* multi-comp: attrs for all comp and */
1328 1327                                          /*      secinfo for last comp */
1329 1328  };
1330 1329  
1331 1330  /*
1332 1331   * lookup4_param a set of parameters to nfs4lookup_setup -
1333 1332   * used to setup a path lookup compound request.
1334 1333   */
1335 1334  typedef struct lookup4_param {
1336 1335          enum lkp4_attr_setup l4_getattrs; /* (in) get attrs in the lookup? */
1337 1336          int             header_len;     /* (in) num ops before first lookup  */
1338 1337          int             trailer_len;    /* (in) num ops after last      */
1339 1338                                          /*      Lookup/Getattr          */
1340 1339          bitmap4         ga_bits;        /* (in) Which attributes for Getattr */
1341 1340          COMPOUND4args_clnt *argsp;      /* (in/out) args for compound struct */
1342 1341          COMPOUND4res_clnt  *resp;       /* (in/out) res for compound  struct */
1343 1342          int             arglen;         /* (out) argop buffer alloc'd length */
1344 1343          struct mntinfo4 *mi;
1345 1344  } lookup4_param_t;
1346 1345  
1347 1346  
1348 1347  #define NFS4_FATTR4_FINISH      -1      /* fattr4 index indicating finish */
1349 1348  
1350 1349  typedef int (*nfs4attr_to_os_t)(int, union nfs4_attr_u *,
1351 1350                  struct nfs4attr_to_osattr *);
1352 1351  
1353 1352  /*
1354 1353   * The nfs4_error_t is the basic structure to return error values
1355 1354   * from rfs4call.  It encapsulates the unix errno
1356 1355   * value, the nfsstat4 value and the rpc status value into a single
1357 1356   * structure.
1358 1357   *
1359 1358   * If error is set, then stat is ignored and rpc_status may be
1360 1359   * set if the error occurred as the result of a CLNT_CALL.  If
1361 1360   * stat is set, then rpc request succeeded, error and
1362 1361   * rpc_status are set to 0 and stat contains the result of
1363 1362   * operation, NFS4_OK or one of the NFS4ERR_* values.
1364 1363   *
1365 1364   * Functions which want to generate errors independently from
1366 1365   * rfs4call should set error to the desired errno value and
1367 1366   * set stat and rpc_status to 0.  nfs4_error_init() is a
1368 1367   * convenient function to do this.
1369 1368   */
1370 1369  typedef struct {
1371 1370          int             error;
1372 1371          nfsstat4        stat;
1373 1372          enum clnt_stat  rpc_status;
1374 1373  } nfs4_error_t;
1375 1374  
1376 1375  /*
1377 1376   * Shared functions
1378 1377   */
1379 1378  extern void     rfs4_op_readdir(nfs_argop4 *, nfs_resop4 *,
1380 1379                          struct svc_req *, struct compound_state *);
1381 1380  extern void     nfs_fh4_copy(nfs_fh4 *, nfs_fh4 *);
1382 1381  
1383 1382  extern void     nfs4_fattr4_free(fattr4 *);
1384 1383  
1385 1384  extern int      nfs4lookup_setup(char *, lookup4_param_t *, int);
1386 1385  extern void     nfs4_getattr_otw_norecovery(vnode_t *,
1387 1386                          nfs4_ga_res_t *, nfs4_error_t *, cred_t *, int);
1388 1387  extern int      nfs4_getattr_otw(vnode_t *, nfs4_ga_res_t *, cred_t *, int);
1389 1388  extern int      nfs4cmpfh(const nfs_fh4 *, const nfs_fh4 *);
1390 1389  extern int      nfs4cmpfhandle(nfs4_fhandle_t *, nfs4_fhandle_t *);
1391 1390  extern int      nfs4getattr(vnode_t *, struct vattr *, cred_t *);
1392 1391  extern int      nfs4_waitfor_purge_complete(vnode_t *);
1393 1392  extern int      nfs4_validate_caches(vnode_t *, cred_t *);
1394 1393  extern int      nfs4init(int, char *);
1395 1394  extern void     nfs4fini(void);
1396 1395  extern int      nfs4_vfsinit(void);
1397 1396  extern void     nfs4_vfsfini(void);
1398 1397  
1399 1398  extern void     nfs4_vnops_init(void);
1400 1399  extern void     nfs4_vnops_fini(void);
1401 1400  extern void     nfs_idmap_init(void);
1402 1401  extern void     nfs_idmap_flush(int);
1403 1402  extern void     nfs_idmap_fini(void);
1404 1403  extern int      nfs4_rnode_init(void);
1405 1404  extern int      nfs4_rnode_fini(void);
1406 1405  extern int      nfs4_shadow_init(void);
1407 1406  extern int      nfs4_shadow_fini(void);
1408 1407  extern int      nfs4_acache_init(void);
1409 1408  extern int      nfs4_acache_fini(void);
1410 1409  extern int      nfs4_subr_init(void);
1411 1410  extern int      nfs4_subr_fini(void);
1412 1411  extern void     nfs4_acl_init(void);
1413 1412  extern void     nfs4_acl_free_cache(vsecattr_t *);
1414 1413  
1415 1414  extern int      geterrno4(nfsstat4);
1416 1415  extern nfsstat4 puterrno4(int);
1417 1416  extern int      nfs4_need_to_bump_seqid(COMPOUND4res_clnt *);
1418 1417  extern int      nfs4tsize(void);
1419 1418  extern int      checkauth4(struct compound_state *, struct svc_req *);
1420 1419  extern nfsstat4 call_checkauth4(struct compound_state *, struct svc_req *);
1421 1420  extern int      is_exported_sec(int, struct exportinfo *);
1422 1421  extern void     nfs4_vmask_to_nmask(uint_t, bitmap4 *);
1423 1422  extern void     nfs4_vmask_to_nmask_set(uint_t, bitmap4 *);
1424 1423  extern int      nfs_idmap_str_uid(utf8string *u8s, uid_t *, bool_t);
1425 1424  extern int      nfs_idmap_str_gid(utf8string *u8s, gid_t *, bool_t);
1426 1425  extern int      nfs_idmap_uid_str(uid_t, utf8string *u8s, bool_t);
1427 1426  extern int      nfs_idmap_gid_str(gid_t gid, utf8string *u8s, bool_t);
1428 1427  extern int      nfs4_time_ntov(nfstime4 *, timestruc_t *);
1429 1428  extern int      nfs4_time_vton(timestruc_t *, nfstime4 *);
1430 1429  extern char     *utf8_to_str(utf8string *, uint_t *, char *);
1431 1430  extern char     *utf8_to_fn(utf8string *, uint_t *, char *);
1432 1431  extern utf8string *str_to_utf8(char *, utf8string *);
1433 1432  extern utf8string *utf8_copy(utf8string *, utf8string *);
1434 1433  extern int      utf8_compare(const utf8string *, const utf8string *);
1435 1434  extern nfsstat4 utf8_dir_verify(utf8string *);
1436 1435  extern char     *utf8_strchr(utf8string *, const char);
1437 1436  extern int      ln_ace4_cmp(nfsace4 *, nfsace4 *, int);
1438 1437  extern int      vs_aent_to_ace4(vsecattr_t *, vsecattr_t *, int, int);
1439 1438  extern int      vs_ace4_to_aent(vsecattr_t *, vsecattr_t *, uid_t, gid_t,
1440 1439      int, int);
1441 1440  extern int      vs_ace4_to_acet(vsecattr_t *, vsecattr_t *, uid_t, gid_t,
1442 1441      int);
1443 1442  extern int      vs_acet_to_ace4(vsecattr_t *, vsecattr_t *, int);
1444 1443  extern void     vs_acet_destroy(vsecattr_t *);
1445 1444  extern void     vs_ace4_destroy(vsecattr_t *);
1446 1445  extern void     vs_aent_destroy(vsecattr_t *);
1447 1446  
1448 1447  extern int      vn_find_nfs_record(vnode_t *, nvlist_t **, char **, char **);
1449 1448  extern int      vn_is_nfs_reparse(vnode_t *, cred_t *);
1450 1449  extern fs_locations4 *fetch_referral(vnode_t *, cred_t *);
1451 1450  extern char     *build_symlink(vnode_t *, cred_t *, size_t *);
1452 1451  
1453 1452  extern int      stateid4_cmp(stateid4 *, stateid4 *);
1454 1453  
1455 1454  extern vtype_t  nf4_to_vt[];
1456 1455  
1457 1456  extern struct nfs4_ntov_map nfs4_ntov_map[];
1458 1457  extern uint_t nfs4_ntov_map_size;
1459 1458  
1460 1459  extern kstat_named_t    *rfsproccnt_v4_ptr;
1461 1460  extern struct vfsops    *nfs4_vfsops;
1462 1461  extern struct vnodeops  *nfs4_vnodeops;
1463 1462  extern const struct     fs_operation_def nfs4_vnodeops_template[];
1464 1463  extern vnodeops_t       *nfs4_trigger_vnodeops;
1465 1464  extern const struct     fs_operation_def nfs4_trigger_vnodeops_template[];
1466 1465  
1467 1466  extern uint_t nfs4_tsize(struct knetconfig *);
1468 1467  extern uint_t rfs4_tsize(struct svc_req *);
1469 1468  
1470 1469  extern bool_t   xdr_inline_decode_nfs_fh4(uint32_t *, nfs_fh4_fmt_t *,
1471 1470                          uint32_t);
1472 1471  extern bool_t   xdr_inline_encode_nfs_fh4(uint32_t **, uint32_t *,
1473 1472                          nfs_fh4_fmt_t *);
1474 1473  
1475 1474  #ifdef DEBUG
1476 1475  extern int              rfs4_do_pre_op_attr;
1477 1476  extern int              rfs4_do_post_op_attr;
1478 1477  #endif
1479 1478  
1480 1479  extern stateid4 clnt_special0;
1481 1480  extern stateid4 clnt_special1;
1482 1481  #define CLNT_ISSPECIAL(id) (stateid4_cmp(id, &clnt_special0) || \
1483 1482                                  stateid4_cmp(id, &clnt_special1))
1484 1483  
1485 1484  /*
1486 1485   * The NFS Version 4 service procedures.
  
    | 
      ↓ open down ↓ | 
    573 lines elided | 
    
      ↑ open up ↑ | 
  
1487 1486   */
1488 1487  
1489 1488  extern void     rfs4_do_server_start(int, int, int);
1490 1489  extern void     rfs4_compound(COMPOUND4args *, COMPOUND4res *,
1491 1490                          struct exportinfo *, struct svc_req *, cred_t *, int *);
1492 1491  extern void     rfs4_compound_free(COMPOUND4res *);
1493 1492  extern void     rfs4_compound_flagproc(COMPOUND4args *, int *);
1494 1493  
1495 1494  extern void     rfs4_srvrinit(void);
1496 1495  extern void     rfs4_srvrfini(void);
     1496 +extern void     rfs4_srv_zone_init(nfs_globals_t *);
     1497 +extern void     rfs4_srv_zone_fini(nfs_globals_t *);
1497 1498  extern void     rfs4_state_g_init(void);
1498 1499  extern void     rfs4_state_zone_init(nfs4_srv_t *);
1499 1500  extern void     rfs4_state_g_fini(void);
1500 1501  extern void     rfs4_state_zone_fini(void);
     1502 +extern nfs4_srv_t *nfs4_get_srv(void);
1501 1503  
1502 1504  #endif
1503 1505  #ifdef  __cplusplus
1504 1506  }
1505 1507  #endif
1506 1508  
1507 1509  #endif /* _NFS4_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX