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
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.
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]
23 * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
26 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
28 * Protocol used between local lock manager and remote lock manager.
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
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.)
41 %#include <rpc/rpc_sztypes.h>
46 %#define LM_MAXSTRLEN 1024
47 %#define LM_MAXNAMELEN (LM_MAXSTRLEN + 1)
51 * Types for versions 1 and 3.
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.
62 nlm_denied_nolocks = 2,
64 nlm_denied_grace_period = 4,
69 * The holder of a conflicting lock.
80 union nlm_testrply switch (nlm_stats stat) {
82 struct nlm_holder holder;
102 string caller_name<LM_MAXSTRLEN>;
103 netobj fh; /* identify a file */
104 netobj oh; /* identify owner of a lock */
105 int svid; /* generated from pid for svid */
110 struct nlm_lockargs {
114 struct nlm_lock alock;
115 bool reclaim; /* used for recovering locks */
116 int state; /* specify local status monitor state */
119 struct nlm_cancargs {
123 struct nlm_lock alock;
126 struct nlm_testargs {
129 struct nlm_lock alock;
132 struct nlm_unlockargs {
134 struct nlm_lock alock;
139 % * The following enums are actually bit encoded for efficient
140 % * boolean algebra.... DON'T change them.....
141 % * The mixed-case enums violate the present style guide, but we're
147 fsm_DN = 0, /* deny none */
148 fsm_DR = 1, /* deny read */
149 fsm_DW = 2, /* deny write */
150 fsm_DRW = 3 /* deny read/write */
154 fsa_NONE = 0, /* for completeness */
155 fsa_R = 1, /* read only */
156 fsa_W = 2, /* write only */
157 fsa_RW = 3 /* read/write */
161 string caller_name<LM_MAXSTRLEN>;
168 struct nlm_shareargs {
174 struct nlm_shareres {
181 string name<LM_MAXNAMELEN>;
186 * Types for version 4.
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.
199 * Status of a call to the lock manager.
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 */
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 */
216 nlm4_failed = 9 /* not granted: some other error */
220 * The holder of a conflicting lock.
231 union nlm4_testrply switch (nlm4_stats stat) {
233 struct nlm4_holder holder;
247 struct nlm4_testres {
253 string caller_name<LM_MAXSTRLEN>;
254 netobj fh; /* identify a file */
255 netobj oh; /* identify owner of a lock */
256 int32 svid; /* generated from pid for svid */
261 struct nlm4_lockargs {
265 struct nlm4_lock alock;
266 bool reclaim; /* used for recovering locks */
267 int32 state; /* specify local status monitor state */
270 struct nlm4_cancargs {
274 struct nlm4_lock alock;
277 struct nlm4_testargs {
280 struct nlm4_lock alock;
283 struct nlm4_unlockargs {
285 struct nlm4_lock alock;
289 string caller_name<LM_MAXSTRLEN>;
296 struct nlm4_shareargs {
302 struct nlm4_shareres {
309 string name<LM_MAXNAMELEN>;
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
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 */
327 * Over-the-wire protocol used between the network lock managers
338 NLM_TEST(nlm_testargs) = 1;
341 NLM_LOCK(nlm_lockargs) = 2;
344 NLM_CANCEL(nlm_cancargs) = 3;
347 NLM_UNLOCK(nlm_unlockargs) = 4;
349 * remote lock manager call-back to grant lock
352 NLM_GRANTED(nlm_testargs) = 5;
355 * message passing style of requesting lock
359 NLM_TEST_MSG(nlm_testargs) = 6;
361 NLM_LOCK_MSG(nlm_lockargs) = 7;
363 NLM_CANCEL_MSG(nlm_cancargs) = 8;
365 NLM_UNLOCK_MSG(nlm_unlockargs) = 9;
367 NLM_GRANTED_MSG(nlm_testargs) = 10;
369 NLM_TEST_RES(nlm_testres) = 11;
371 NLM_LOCK_RES(nlm_res) = 12;
373 NLM_CANCEL_RES(nlm_res) = 13;
375 NLM_UNLOCK_RES(nlm_res) = 14;
377 NLM_GRANTED_RES(nlm_res) = 15;
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.)
387 void NLM_SM_NOTIFY1(struct nlm_sm_status) = 17;
388 void NLM_SM_NOTIFY2(struct nlm_sm_status) = 18;
393 NLM_SHARE(nlm_shareargs) = 20;
395 NLM_UNSHARE(nlm_shareargs) = 21;
397 NLM_NM_LOCK(nlm_lockargs) = 22;
399 NLM_FREE_ALL(nlm_notify) = 23;
406 NLM4_TEST(nlm4_testargs) = 1;
408 NLM4_LOCK(nlm4_lockargs) = 2;
410 NLM4_CANCEL(nlm4_cancargs) = 3;
412 NLM4_UNLOCK(nlm4_unlockargs) = 4;
414 * remote lock manager call-back to grant lock
417 NLM4_GRANTED(nlm4_testargs) = 5;
420 * message passing style of requesting lock
424 NLM4_TEST_MSG(nlm4_testargs) = 6;
426 NLM4_LOCK_MSG(nlm4_lockargs) = 7;
428 NLM4_CANCEL_MSG(nlm4_cancargs) = 8;
430 NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9;
432 NLM4_GRANTED_MSG(nlm4_testargs) = 10;
434 NLM4_TEST_RES(nlm4_testres) = 11;
436 NLM4_LOCK_RES(nlm4_res) = 12;
438 NLM4_CANCEL_RES(nlm4_res) = 13;
440 NLM4_UNLOCK_RES(nlm4_res) = 14;
442 NLM4_GRANTED_RES(nlm4_res) = 15;
445 * DOS-style file sharing
449 NLM4_SHARE(nlm4_shareargs) = 20;
451 NLM4_UNSHARE(nlm4_shareargs) = 21;
453 NLM4_NM_LOCK(nlm4_lockargs) = 22;
455 NLM4_FREE_ALL(nlm4_notify) = 23;