Print this page
195 Need replacement for nfs/lockd+klm

Split Close
Expand all
Collapse all
          --- old/usr/src/head/rpcsvc/nlm_prot.x
          +++ new/usr/src/uts/common/rpcsvc/nlm_prot.x
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   *
  14   14   * When distributing Covered Code, include this CDDL HEADER in each
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23      - * Network lock manager protocol definition
  24   23   * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc.
  25   24   * All rights reserved.
  26   25   *
       26 + * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       27 + *
  27   28   * Protocol used between local lock manager and remote lock manager.
  28   29   *
  29   30   * There are currently 3 versions of the protocol in use.  Versions 1
  30   31   * and 3 are used with NFS version 2.  Version 4 is used with NFS
  31   32   * version 3.
  32   33   *
  33   34   * (Note: there is also a version 2, but it defines an orthogonal set of
  34   35   * procedures that the status monitor uses to notify the lock manager of
  35   36   * changes in monitored systems.)
  36   37   */
  37   38  
  38      -%#pragma ident  "%Z%%M% %I%     %E% SMI"
  39      -
  40   39  #if RPC_HDR
  41   40  %
  42   41  %#include <rpc/rpc_sztypes.h>
  43   42  %
  44   43  #endif
  45   44  
  46   45  #ifdef RPC_HDR
  47   46  %#define LM_MAXSTRLEN   1024
  48   47  %#define LM_MAXNAMELEN  (LM_MAXSTRLEN + 1)
  49   48  #endif
↓ open down ↓ 144 lines elided ↑ open up ↑
 194  193   * bytes.  For NLM 4, the file handle is already a count followed by
 195  194   * data bytes, so the handle is copied directly into the netobj, rather
 196  195   * than being encoded with an additional byte count.
 197  196   */
 198  197  
 199  198  /*
 200  199   * Status of a call to the lock manager.
 201  200   */
 202  201  
 203  202  enum nlm4_stats {
 204      -        NLM4_GRANTED = 0,               /* lock was granted */
 205      -        NLM4_DENIED = 1,                /* lock was not granted, usually */
      203 +        nlm4_granted = 0,               /* lock was granted */
      204 +        nlm4_denied = 1,                /* lock was not granted, usually */
 206  205                                          /* due to conflicting lock */
 207      -        NLM4_DENIED_NOLOCKS = 2,        /* not granted: out of resources */
 208      -        NLM4_BLOCKED = 3,               /* not granted: expect callback */
      206 +        nlm4_denied_nolocks = 2,        /* not granted: out of resources */
      207 +        nlm4_blocked = 3,               /* not granted: expect callback */
 209  208                                          /* when granted */
 210      -        NLM4_DENIED_GRACE_PERIOD = 4,   /* not granted: server is */
      209 +        nlm4_denied_grace_period = 4,   /* not granted: server is */
 211  210                                          /* reestablishing old locks */
 212      -        NLM4_DEADLCK = 5,               /* not granted: deadlock detected */
 213      -        NLM4_ROFS = 6,                  /* not granted: read-only filesystem */
 214      -        NLM4_STALE_FH = 7,              /* not granted: stale file handle */
 215      -        NLM4_FBIG = 8,                  /* not granted: offset or length */
      211 +        nlm4_deadlck = 5,               /* not granted: deadlock detected */
      212 +        nlm4_rofs = 6,                  /* not granted: read-only filesystem */
      213 +        nlm4_stale_fh = 7,              /* not granted: stale file handle */
      214 +        nlm4_fbig = 8,                  /* not granted: offset or length */
 216  215                                          /* too big */
 217      -        NLM4_FAILED = 9                 /* not granted: some other error */
      216 +        nlm4_failed = 9                 /* not granted: some other error */
 218  217  };
 219  218  
 220  219  /*
 221  220   * The holder of a conflicting lock.
 222  221   */
 223  222  
 224  223  struct nlm4_holder {
 225  224          bool exclusive;
 226  225          int32 svid;
 227  226          netobj oh;
 228  227          uint64 l_offset;
 229  228          uint64 l_len;
 230  229  };
 231  230  
 232  231  union nlm4_testrply switch (nlm4_stats stat) {
 233      -        case NLM4_DENIED:
      232 +        case nlm4_denied:
 234  233                  struct nlm4_holder holder;
 235  234          default:
 236  235                  void;
 237  236  };
 238  237  
 239  238  struct nlm4_stat {
 240  239          nlm4_stats stat;
 241  240  };
 242  241  
 243  242  struct nlm4_res {
↓ open down ↓ 35 lines elided ↑ open up ↑
 279  278          netobj cookie;
 280  279          bool exclusive;
 281  280          struct nlm4_lock alock;
 282  281  };
 283  282  
 284  283  struct nlm4_unlockargs {
 285  284          netobj cookie;
 286  285          struct nlm4_lock alock;
 287  286  };
 288  287  
 289      -#ifdef RPC_HDR
 290      -%/*
 291      -% * The following enums are actually bit encoded for efficient
 292      -% * boolean algebra.... DON'T change them.....
 293      -% */
 294      -#endif
 295      -
 296      -enum    fsh4_mode {
 297      -        FSM_DN  = 0,    /* deny none */
 298      -        FSM_DR  = 1,    /* deny read */
 299      -        FSM_DW  = 2,    /* deny write */
 300      -        FSM_DRW = 3     /* deny read/write */
 301      -};
 302      -
 303      -enum    fsh4_access {
 304      -        FSA_NONE = 0,   /* for completeness */
 305      -        FSA_R    = 1,   /* read only */
 306      -        FSA_W    = 2,   /* write only */
 307      -        FSA_RW   = 3    /* read/write */
 308      -};
 309      -
 310  288  struct  nlm4_share {
 311  289          string caller_name<LM_MAXSTRLEN>;
 312  290          netobj  fh;
 313  291          netobj  oh;
 314      -        fsh4_mode       mode;
 315      -        fsh4_access     access;
      292 +        fsh_mode        mode;
      293 +        fsh_access      access;
 316  294  };
 317  295  
 318  296  struct  nlm4_shareargs {
 319  297          netobj  cookie;
 320  298          nlm4_share      share;
 321  299          bool    reclaim;
 322  300  };
 323  301  
 324  302  struct  nlm4_shareres {
 325  303          netobj  cookie;
 326  304          nlm4_stats      stat;
 327  305          int32   sequence;
 328  306  };
 329  307  
 330  308  struct  nlm4_notify {
 331  309          string name<LM_MAXNAMELEN>;
 332  310          int32 state;
 333  311  };
 334  312  
 335  313  /*
      314 + * Argument for the NLM call-back procedure called by rpc.statd
      315 + * when a monitored host status changes.  The statd calls the
      316 + * NLM prog,vers,proc specified in the SM_MON call.
      317 + * NB: This struct must exactly match sm_inter.x:sm_status
      318 + * and requires LM_MAXSTRLEN == SM_MAXSTRLEN
      319 + */
      320 +struct nlm_sm_status {
      321 +        string mon_name<LM_MAXSTRLEN>; /* name of host */
      322 +        int32 state;                    /* new state */
      323 +        opaque priv[16];                /* private data */
      324 +};
      325 +
      326 +/*
 336  327   * Over-the-wire protocol used between the network lock managers
 337  328   */
 338  329  
 339  330  program NLM_PROG {
      331 +
 340  332          version NLM_VERS {
 341  333  
      334 +                void
      335 +                        NLM_NULL(void) =                        0;
      336 +
 342  337                  nlm_testres
 343  338                          NLM_TEST(nlm_testargs) =                1;
 344  339  
 345  340                  nlm_res
 346  341                          NLM_LOCK(nlm_lockargs) =                2;
 347  342  
 348  343                  nlm_res
 349  344                          NLM_CANCEL(nlm_cancargs) =              3;
 350  345  
 351  346                  nlm_res
↓ open down ↓ 23 lines elided ↑ open up ↑
 375  370                  void
 376  371                          NLM_LOCK_RES(nlm_res) =                 12;
 377  372                  void
 378  373                          NLM_CANCEL_RES(nlm_res) =               13;
 379  374                  void
 380  375                          NLM_UNLOCK_RES(nlm_res) =               14;
 381  376                  void
 382  377                          NLM_GRANTED_RES(nlm_res) =              15;
 383  378          } = 1;
 384  379  
      380 +        /*
      381 +         * Private (loopback-only) call-backs from statd,
      382 +         * used to notify that some machine has restarted.
      383 +         * The meaning of these is up to the lock manager
      384 +         * implemenation.  (See the SM_MON calls.)
      385 +         */
      386 +        version NLM_SM {
      387 +                void NLM_SM_NOTIFY1(struct nlm_sm_status) =     17;
      388 +                void NLM_SM_NOTIFY2(struct nlm_sm_status) =     18;
      389 +        } = 2;
      390 +
 385  391          version NLM_VERSX {
 386  392                  nlm_shareres
 387  393                          NLM_SHARE(nlm_shareargs) =              20;
 388  394                  nlm_shareres
 389  395                          NLM_UNSHARE(nlm_shareargs) =            21;
 390  396                  nlm_res
 391  397                          NLM_NM_LOCK(nlm_lockargs) =             22;
 392  398                  void
 393  399                          NLM_FREE_ALL(nlm_notify) =              23;
 394  400          } = 3;
 395  401  
 396  402          version NLM4_VERS {
 397  403                  void
 398      -                        NLMPROC4_NULL(void) =                   0;
      404 +                        NLM4_NULL(void) =                       0;
 399  405                  nlm4_testres
 400      -                        NLMPROC4_TEST(nlm4_testargs) =          1;
      406 +                        NLM4_TEST(nlm4_testargs) =              1;
 401  407                  nlm4_res
 402      -                        NLMPROC4_LOCK(nlm4_lockargs) =          2;
      408 +                        NLM4_LOCK(nlm4_lockargs) =              2;
 403  409                  nlm4_res
 404      -                        NLMPROC4_CANCEL(nlm4_cancargs) =        3;
      410 +                        NLM4_CANCEL(nlm4_cancargs) =    3;
 405  411                  nlm4_res
 406      -                        NLMPROC4_UNLOCK(nlm4_unlockargs) =      4;
      412 +                        NLM4_UNLOCK(nlm4_unlockargs) =  4;
 407  413                  /*
 408  414                   * remote lock manager call-back to grant lock
 409  415                   */
 410  416                  nlm4_res
 411      -                        NLMPROC4_GRANTED(nlm4_testargs) =       5;
      417 +                        NLM4_GRANTED(nlm4_testargs) =   5;
 412  418  
 413  419                  /*
 414  420                   * message passing style of requesting lock
 415  421                   */
 416  422  
 417  423                  void
 418      -                        NLMPROC4_TEST_MSG(nlm4_testargs) =      6;
      424 +                        NLM4_TEST_MSG(nlm4_testargs) =  6;
 419  425                  void
 420      -                        NLMPROC4_LOCK_MSG(nlm4_lockargs) =      7;
      426 +                        NLM4_LOCK_MSG(nlm4_lockargs) =  7;
 421  427                  void
 422      -                        NLMPROC4_CANCEL_MSG(nlm4_cancargs) =    8;
      428 +                        NLM4_CANCEL_MSG(nlm4_cancargs) =        8;
 423  429                  void
 424      -                        NLMPROC4_UNLOCK_MSG(nlm4_unlockargs) =  9;
      430 +                        NLM4_UNLOCK_MSG(nlm4_unlockargs) =      9;
 425  431                  void
 426      -                        NLMPROC4_GRANTED_MSG(nlm4_testargs) =   10;
      432 +                        NLM4_GRANTED_MSG(nlm4_testargs) =       10;
 427  433                  void
 428      -                        NLMPROC4_TEST_RES(nlm4_testres) =       11;
      434 +                        NLM4_TEST_RES(nlm4_testres) =   11;
 429  435                  void
 430      -                        NLMPROC4_LOCK_RES(nlm4_res) =           12;
      436 +                        NLM4_LOCK_RES(nlm4_res) =               12;
 431  437                  void
 432      -                        NLMPROC4_CANCEL_RES(nlm4_res) =         13;
      438 +                        NLM4_CANCEL_RES(nlm4_res) =             13;
 433  439                  void
 434      -                        NLMPROC4_UNLOCK_RES(nlm4_res) =         14;
      440 +                        NLM4_UNLOCK_RES(nlm4_res) =             14;
 435  441                  void
 436      -                        NLMPROC4_GRANTED_RES(nlm4_res) =        15;
      442 +                        NLM4_GRANTED_RES(nlm4_res) =    15;
 437  443  
 438  444                  /*
 439  445                   * DOS-style file sharing
 440  446                   */
 441  447  
 442  448                  nlm4_shareres
 443      -                        NLMPROC4_SHARE(nlm4_shareargs) =        20;
      449 +                        NLM4_SHARE(nlm4_shareargs) =    20;
 444  450                  nlm4_shareres
 445      -                        NLMPROC4_UNSHARE(nlm4_shareargs) =      21;
      451 +                        NLM4_UNSHARE(nlm4_shareargs) =  21;
 446  452                  nlm4_res
 447      -                        NLMPROC4_NM_LOCK(nlm4_lockargs) =       22;
      453 +                        NLM4_NM_LOCK(nlm4_lockargs) =   22;
 448  454                  void
 449      -                        NLMPROC4_FREE_ALL(nlm4_notify) =        23;
      455 +                        NLM4_FREE_ALL(nlm4_notify) =    23;
 450  456          } = 4;
 451  457  
 452  458  } = 100021;
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX