Print this page
195 Need replacement for nfs/lockd+klm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Jeremy Jones <jeremy@delphix.com>
Reviewed by: Jeff Biseda <jbiseda@delphix.com>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Network lock manager protocol definition
  24  * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc.
  25  * All rights reserved.
  26  *


  27  * Protocol used between local lock manager and remote lock manager.
  28  *
  29  * There are currently 3 versions of the protocol in use.  Versions 1
  30  * and 3 are used with NFS version 2.  Version 4 is used with NFS
  31  * version 3.
  32  *
  33  * (Note: there is also a version 2, but it defines an orthogonal set of
  34  * procedures that the status monitor uses to notify the lock manager of
  35  * changes in monitored systems.)
  36  */
  37 
  38 %#pragma ident  "%Z%%M% %I%     %E% SMI"
  39 
  40 #if RPC_HDR
  41 %
  42 %#include <rpc/rpc_sztypes.h>
  43 %
  44 #endif
  45 
  46 #ifdef RPC_HDR
  47 %#define LM_MAXSTRLEN   1024
  48 %#define LM_MAXNAMELEN  (LM_MAXSTRLEN + 1)
  49 #endif
  50 
  51 /*
  52  * Types for versions 1 and 3.
  53  */
  54 
  55 /*
  56  * Status of a call to the lock manager.  The lower case enums violate the
  57  * current style guide, but we're stuck with 'em.
  58  */
  59 


 184 };
 185 
 186 /*
 187  * Types for version 4.
 188  *
 189  * This revision is designed to work with NFS V3.  The main changes from
 190  * NFS V2 to V3 that affect the NLM protocol are that all file offsets
 191  * and sizes are now unsigned 64-bit ints, and file handles are now
 192  * variable length.  In NLM V1 and V3, the fixed-length V2 file handle
 193  * was encoded as a 'netobj', which is a count followed by the data
 194  * bytes.  For NLM 4, the file handle is already a count followed by
 195  * data bytes, so the handle is copied directly into the netobj, rather
 196  * than being encoded with an additional byte count.
 197  */
 198 
 199 /*
 200  * Status of a call to the lock manager.
 201  */
 202 
 203 enum nlm4_stats {
 204         NLM4_GRANTED = 0,               /* lock was granted */
 205         NLM4_DENIED = 1,                /* lock was not granted, usually */
 206                                         /* due to conflicting lock */
 207         NLM4_DENIED_NOLOCKS = 2,        /* not granted: out of resources */
 208         NLM4_BLOCKED = 3,               /* not granted: expect callback */
 209                                         /* when granted */
 210         NLM4_DENIED_GRACE_PERIOD = 4,   /* not granted: server is */
 211                                         /* 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 */
 216                                         /* too big */
 217         NLM4_FAILED = 9                 /* not granted: some other error */
 218 };
 219 
 220 /*
 221  * The holder of a conflicting lock.
 222  */
 223 
 224 struct nlm4_holder {
 225         bool exclusive;
 226         int32 svid;
 227         netobj oh;
 228         uint64 l_offset;
 229         uint64 l_len;
 230 };
 231 
 232 union nlm4_testrply switch (nlm4_stats stat) {
 233         case NLM4_DENIED:
 234                 struct nlm4_holder holder;
 235         default:
 236                 void;
 237 };
 238 
 239 struct nlm4_stat {
 240         nlm4_stats stat;
 241 };
 242 
 243 struct nlm4_res {
 244         netobj cookie;
 245         nlm4_stat stat;
 246 };
 247 
 248 struct nlm4_testres {
 249         netobj cookie;
 250         nlm4_testrply stat;
 251 };
 252 
 253 struct nlm4_lock {


 269 };
 270 
 271 struct nlm4_cancargs {
 272         netobj cookie;
 273         bool block;
 274         bool exclusive;
 275         struct nlm4_lock alock;
 276 };
 277 
 278 struct nlm4_testargs {
 279         netobj cookie;
 280         bool exclusive;
 281         struct nlm4_lock alock;
 282 };
 283 
 284 struct nlm4_unlockargs {
 285         netobj cookie;
 286         struct nlm4_lock alock;
 287 };
 288 
 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 struct  nlm4_share {
 311         string caller_name<LM_MAXSTRLEN>;
 312         netobj  fh;
 313         netobj  oh;
 314         fsh4_mode       mode;
 315         fsh4_access     access;
 316 };
 317 
 318 struct  nlm4_shareargs {
 319         netobj  cookie;
 320         nlm4_share      share;
 321         bool    reclaim;
 322 };
 323 
 324 struct  nlm4_shareres {
 325         netobj  cookie;
 326         nlm4_stats      stat;
 327         int32   sequence;
 328 };
 329 
 330 struct  nlm4_notify {
 331         string name<LM_MAXNAMELEN>;
 332         int32 state;
 333 };
 334 
 335 /*













 336  * Over-the-wire protocol used between the network lock managers
 337  */
 338 
 339 program NLM_PROG {

 340         version NLM_VERS {
 341 



 342                 nlm_testres
 343                         NLM_TEST(nlm_testargs) =                1;
 344 
 345                 nlm_res
 346                         NLM_LOCK(nlm_lockargs) =                2;
 347 
 348                 nlm_res
 349                         NLM_CANCEL(nlm_cancargs) =              3;
 350 
 351                 nlm_res
 352                         NLM_UNLOCK(nlm_unlockargs) =            4;
 353                 /*
 354                  * remote lock manager call-back to grant lock
 355                  */
 356                 nlm_res
 357                         NLM_GRANTED(nlm_testargs) =             5;
 358 
 359                 /*
 360                  * message passing style of requesting lock
 361                  */


 365                 void
 366                         NLM_LOCK_MSG(nlm_lockargs) =            7;
 367                 void
 368                         NLM_CANCEL_MSG(nlm_cancargs) =          8;
 369                 void
 370                         NLM_UNLOCK_MSG(nlm_unlockargs) =        9;
 371                 void
 372                         NLM_GRANTED_MSG(nlm_testargs) =         10;
 373                 void
 374                         NLM_TEST_RES(nlm_testres) =             11;
 375                 void
 376                         NLM_LOCK_RES(nlm_res) =                 12;
 377                 void
 378                         NLM_CANCEL_RES(nlm_res) =               13;
 379                 void
 380                         NLM_UNLOCK_RES(nlm_res) =               14;
 381                 void
 382                         NLM_GRANTED_RES(nlm_res) =              15;
 383         } = 1;
 384 











 385         version NLM_VERSX {
 386                 nlm_shareres
 387                         NLM_SHARE(nlm_shareargs) =              20;
 388                 nlm_shareres
 389                         NLM_UNSHARE(nlm_shareargs) =            21;
 390                 nlm_res
 391                         NLM_NM_LOCK(nlm_lockargs) =             22;
 392                 void
 393                         NLM_FREE_ALL(nlm_notify) =              23;
 394         } = 3;
 395 
 396         version NLM4_VERS {
 397                 void
 398                         NLMPROC4_NULL(void) =                   0;
 399                 nlm4_testres
 400                         NLMPROC4_TEST(nlm4_testargs) =          1;
 401                 nlm4_res
 402                         NLMPROC4_LOCK(nlm4_lockargs) =          2;
 403                 nlm4_res
 404                         NLMPROC4_CANCEL(nlm4_cancargs) =        3;
 405                 nlm4_res
 406                         NLMPROC4_UNLOCK(nlm4_unlockargs) =      4;
 407                 /*
 408                  * remote lock manager call-back to grant lock
 409                  */
 410                 nlm4_res
 411                         NLMPROC4_GRANTED(nlm4_testargs) =       5;
 412 
 413                 /*
 414                  * message passing style of requesting lock
 415                  */
 416 
 417                 void
 418                         NLMPROC4_TEST_MSG(nlm4_testargs) =      6;
 419                 void
 420                         NLMPROC4_LOCK_MSG(nlm4_lockargs) =      7;
 421                 void
 422                         NLMPROC4_CANCEL_MSG(nlm4_cancargs) =    8;
 423                 void
 424                         NLMPROC4_UNLOCK_MSG(nlm4_unlockargs) =  9;
 425                 void
 426                         NLMPROC4_GRANTED_MSG(nlm4_testargs) =   10;
 427                 void
 428                         NLMPROC4_TEST_RES(nlm4_testres) =       11;
 429                 void
 430                         NLMPROC4_LOCK_RES(nlm4_res) =           12;
 431                 void
 432                         NLMPROC4_CANCEL_RES(nlm4_res) =         13;
 433                 void
 434                         NLMPROC4_UNLOCK_RES(nlm4_res) =         14;
 435                 void
 436                         NLMPROC4_GRANTED_RES(nlm4_res) =        15;
 437 
 438                 /*
 439                  * DOS-style file sharing
 440                  */
 441 
 442                 nlm4_shareres
 443                         NLMPROC4_SHARE(nlm4_shareargs) =        20;
 444                 nlm4_shareres
 445                         NLMPROC4_UNSHARE(nlm4_shareargs) =      21;
 446                 nlm4_res
 447                         NLMPROC4_NM_LOCK(nlm4_lockargs) =       22;
 448                 void
 449                         NLMPROC4_FREE_ALL(nlm4_notify) =        23;
 450         } = 4;
 451 
 452 } = 100021;


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*

  23  * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc.
  24  * All rights reserved.
  25  *
  26  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  27  *
  28  * Protocol used between local lock manager and remote lock manager.
  29  *
  30  * There are currently 3 versions of the protocol in use.  Versions 1
  31  * and 3 are used with NFS version 2.  Version 4 is used with NFS
  32  * version 3.
  33  *
  34  * (Note: there is also a version 2, but it defines an orthogonal set of
  35  * procedures that the status monitor uses to notify the lock manager of
  36  * changes in monitored systems.)
  37  */
  38 


  39 #if RPC_HDR
  40 %
  41 %#include <rpc/rpc_sztypes.h>
  42 %
  43 #endif
  44 
  45 #ifdef RPC_HDR
  46 %#define LM_MAXSTRLEN   1024
  47 %#define LM_MAXNAMELEN  (LM_MAXSTRLEN + 1)
  48 #endif
  49 
  50 /*
  51  * Types for versions 1 and 3.
  52  */
  53 
  54 /*
  55  * Status of a call to the lock manager.  The lower case enums violate the
  56  * current style guide, but we're stuck with 'em.
  57  */
  58 


 183 };
 184 
 185 /*
 186  * Types for version 4.
 187  *
 188  * This revision is designed to work with NFS V3.  The main changes from
 189  * NFS V2 to V3 that affect the NLM protocol are that all file offsets
 190  * and sizes are now unsigned 64-bit ints, and file handles are now
 191  * variable length.  In NLM V1 and V3, the fixed-length V2 file handle
 192  * was encoded as a 'netobj', which is a count followed by the data
 193  * bytes.  For NLM 4, the file handle is already a count followed by
 194  * data bytes, so the handle is copied directly into the netobj, rather
 195  * than being encoded with an additional byte count.
 196  */
 197 
 198 /*
 199  * Status of a call to the lock manager.
 200  */
 201 
 202 enum nlm4_stats {
 203         nlm4_granted = 0,               /* lock was granted */
 204         nlm4_denied = 1,                /* lock was not granted, usually */
 205                                         /* due to conflicting lock */
 206         nlm4_denied_nolocks = 2,        /* not granted: out of resources */
 207         nlm4_blocked = 3,               /* not granted: expect callback */
 208                                         /* when granted */
 209         nlm4_denied_grace_period = 4,   /* not granted: server is */
 210                                         /* reestablishing old locks */
 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 */
 215                                         /* too big */
 216         nlm4_failed = 9                 /* not granted: some other error */
 217 };
 218 
 219 /*
 220  * The holder of a conflicting lock.
 221  */
 222 
 223 struct nlm4_holder {
 224         bool exclusive;
 225         int32 svid;
 226         netobj oh;
 227         uint64 l_offset;
 228         uint64 l_len;
 229 };
 230 
 231 union nlm4_testrply switch (nlm4_stats stat) {
 232         case nlm4_denied:
 233                 struct nlm4_holder holder;
 234         default:
 235                 void;
 236 };
 237 
 238 struct nlm4_stat {
 239         nlm4_stats stat;
 240 };
 241 
 242 struct nlm4_res {
 243         netobj cookie;
 244         nlm4_stat stat;
 245 };
 246 
 247 struct nlm4_testres {
 248         netobj cookie;
 249         nlm4_testrply stat;
 250 };
 251 
 252 struct nlm4_lock {


 268 };
 269 
 270 struct nlm4_cancargs {
 271         netobj cookie;
 272         bool block;
 273         bool exclusive;
 274         struct nlm4_lock alock;
 275 };
 276 
 277 struct nlm4_testargs {
 278         netobj cookie;
 279         bool exclusive;
 280         struct nlm4_lock alock;
 281 };
 282 
 283 struct nlm4_unlockargs {
 284         netobj cookie;
 285         struct nlm4_lock alock;
 286 };
 287 





















 288 struct  nlm4_share {
 289         string caller_name<LM_MAXSTRLEN>;
 290         netobj  fh;
 291         netobj  oh;
 292         fsh_mode        mode;
 293         fsh_access      access;
 294 };
 295 
 296 struct  nlm4_shareargs {
 297         netobj  cookie;
 298         nlm4_share      share;
 299         bool    reclaim;
 300 };
 301 
 302 struct  nlm4_shareres {
 303         netobj  cookie;
 304         nlm4_stats      stat;
 305         int32   sequence;
 306 };
 307 
 308 struct  nlm4_notify {
 309         string name<LM_MAXNAMELEN>;
 310         int32 state;
 311 };
 312 
 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 /*
 327  * Over-the-wire protocol used between the network lock managers
 328  */
 329 
 330 program NLM_PROG {
 331 
 332         version NLM_VERS {
 333 
 334                 void
 335                         NLM_NULL(void) =                        0;
 336 
 337                 nlm_testres
 338                         NLM_TEST(nlm_testargs) =                1;
 339 
 340                 nlm_res
 341                         NLM_LOCK(nlm_lockargs) =                2;
 342 
 343                 nlm_res
 344                         NLM_CANCEL(nlm_cancargs) =              3;
 345 
 346                 nlm_res
 347                         NLM_UNLOCK(nlm_unlockargs) =            4;
 348                 /*
 349                  * remote lock manager call-back to grant lock
 350                  */
 351                 nlm_res
 352                         NLM_GRANTED(nlm_testargs) =             5;
 353 
 354                 /*
 355                  * message passing style of requesting lock
 356                  */


 360                 void
 361                         NLM_LOCK_MSG(nlm_lockargs) =            7;
 362                 void
 363                         NLM_CANCEL_MSG(nlm_cancargs) =          8;
 364                 void
 365                         NLM_UNLOCK_MSG(nlm_unlockargs) =        9;
 366                 void
 367                         NLM_GRANTED_MSG(nlm_testargs) =         10;
 368                 void
 369                         NLM_TEST_RES(nlm_testres) =             11;
 370                 void
 371                         NLM_LOCK_RES(nlm_res) =                 12;
 372                 void
 373                         NLM_CANCEL_RES(nlm_res) =               13;
 374                 void
 375                         NLM_UNLOCK_RES(nlm_res) =               14;
 376                 void
 377                         NLM_GRANTED_RES(nlm_res) =              15;
 378         } = 1;
 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 
 391         version NLM_VERSX {
 392                 nlm_shareres
 393                         NLM_SHARE(nlm_shareargs) =              20;
 394                 nlm_shareres
 395                         NLM_UNSHARE(nlm_shareargs) =            21;
 396                 nlm_res
 397                         NLM_NM_LOCK(nlm_lockargs) =             22;
 398                 void
 399                         NLM_FREE_ALL(nlm_notify) =              23;
 400         } = 3;
 401 
 402         version NLM4_VERS {
 403                 void
 404                         NLM4_NULL(void) =                       0;
 405                 nlm4_testres
 406                         NLM4_TEST(nlm4_testargs) =              1;
 407                 nlm4_res
 408                         NLM4_LOCK(nlm4_lockargs) =              2;
 409                 nlm4_res
 410                         NLM4_CANCEL(nlm4_cancargs) =    3;
 411                 nlm4_res
 412                         NLM4_UNLOCK(nlm4_unlockargs) =  4;
 413                 /*
 414                  * remote lock manager call-back to grant lock
 415                  */
 416                 nlm4_res
 417                         NLM4_GRANTED(nlm4_testargs) =   5;
 418 
 419                 /*
 420                  * message passing style of requesting lock
 421                  */
 422 
 423                 void
 424                         NLM4_TEST_MSG(nlm4_testargs) =  6;
 425                 void
 426                         NLM4_LOCK_MSG(nlm4_lockargs) =  7;
 427                 void
 428                         NLM4_CANCEL_MSG(nlm4_cancargs) =        8;
 429                 void
 430                         NLM4_UNLOCK_MSG(nlm4_unlockargs) =      9;
 431                 void
 432                         NLM4_GRANTED_MSG(nlm4_testargs) =       10;
 433                 void
 434                         NLM4_TEST_RES(nlm4_testres) =   11;
 435                 void
 436                         NLM4_LOCK_RES(nlm4_res) =               12;
 437                 void
 438                         NLM4_CANCEL_RES(nlm4_res) =             13;
 439                 void
 440                         NLM4_UNLOCK_RES(nlm4_res) =             14;
 441                 void
 442                         NLM4_GRANTED_RES(nlm4_res) =    15;
 443 
 444                 /*
 445                  * DOS-style file sharing
 446                  */
 447 
 448                 nlm4_shareres
 449                         NLM4_SHARE(nlm4_shareargs) =    20;
 450                 nlm4_shareres
 451                         NLM4_UNSHARE(nlm4_shareargs) =  21;
 452                 nlm4_res
 453                         NLM4_NM_LOCK(nlm4_lockargs) =   22;
 454                 void
 455                         NLM4_FREE_ALL(nlm4_notify) =    23;
 456         } = 4;
 457 
 458 } = 100021;