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>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/rpcsvc/nlm_prot.x
+++ new/usr/src/uts/common/rpcsvc/nlm_prot.x
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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ 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
50 49
51 50 /*
52 51 * Types for versions 1 and 3.
53 52 */
54 53
55 54 /*
56 55 * Status of a call to the lock manager. The lower case enums violate the
57 56 * current style guide, but we're stuck with 'em.
58 57 */
59 58
60 59 enum nlm_stats {
61 60 nlm_granted = 0,
62 61 nlm_denied = 1,
63 62 nlm_denied_nolocks = 2,
64 63 nlm_blocked = 3,
65 64 nlm_denied_grace_period = 4,
66 65 nlm_deadlck = 5
67 66 };
68 67
69 68 /*
70 69 * The holder of a conflicting lock.
71 70 */
72 71
73 72 struct nlm_holder {
74 73 bool exclusive;
75 74 int svid;
76 75 netobj oh;
77 76 unsigned l_offset;
78 77 unsigned l_len;
79 78 };
80 79
81 80 union nlm_testrply switch (nlm_stats stat) {
82 81 case nlm_denied:
83 82 struct nlm_holder holder;
84 83 default:
85 84 void;
86 85 };
87 86
88 87 struct nlm_stat {
89 88 nlm_stats stat;
90 89 };
91 90
92 91 struct nlm_res {
93 92 netobj cookie;
94 93 nlm_stat stat;
95 94 };
96 95
97 96 struct nlm_testres {
98 97 netobj cookie;
99 98 nlm_testrply stat;
100 99 };
101 100
102 101 struct nlm_lock {
103 102 string caller_name<LM_MAXSTRLEN>;
104 103 netobj fh; /* identify a file */
105 104 netobj oh; /* identify owner of a lock */
106 105 int svid; /* generated from pid for svid */
107 106 unsigned l_offset;
108 107 unsigned l_len;
109 108 };
110 109
111 110 struct nlm_lockargs {
112 111 netobj cookie;
113 112 bool block;
114 113 bool exclusive;
115 114 struct nlm_lock alock;
116 115 bool reclaim; /* used for recovering locks */
117 116 int state; /* specify local status monitor state */
118 117 };
119 118
120 119 struct nlm_cancargs {
121 120 netobj cookie;
122 121 bool block;
123 122 bool exclusive;
124 123 struct nlm_lock alock;
125 124 };
126 125
127 126 struct nlm_testargs {
128 127 netobj cookie;
129 128 bool exclusive;
130 129 struct nlm_lock alock;
131 130 };
132 131
133 132 struct nlm_unlockargs {
134 133 netobj cookie;
135 134 struct nlm_lock alock;
136 135 };
137 136
138 137 #ifdef RPC_HDR
139 138 %/*
140 139 % * The following enums are actually bit encoded for efficient
141 140 % * boolean algebra.... DON'T change them.....
142 141 % * The mixed-case enums violate the present style guide, but we're
143 142 % * stuck with 'em.
144 143 % */
145 144 #endif
146 145
147 146 enum fsh_mode {
148 147 fsm_DN = 0, /* deny none */
149 148 fsm_DR = 1, /* deny read */
150 149 fsm_DW = 2, /* deny write */
151 150 fsm_DRW = 3 /* deny read/write */
152 151 };
153 152
154 153 enum fsh_access {
155 154 fsa_NONE = 0, /* for completeness */
156 155 fsa_R = 1, /* read only */
157 156 fsa_W = 2, /* write only */
158 157 fsa_RW = 3 /* read/write */
159 158 };
160 159
161 160 struct nlm_share {
162 161 string caller_name<LM_MAXSTRLEN>;
163 162 netobj fh;
164 163 netobj oh;
165 164 fsh_mode mode;
166 165 fsh_access access;
167 166 };
168 167
169 168 struct nlm_shareargs {
170 169 netobj cookie;
171 170 nlm_share share;
172 171 bool reclaim;
173 172 };
174 173
175 174 struct nlm_shareres {
176 175 netobj cookie;
177 176 nlm_stats stat;
178 177 int sequence;
179 178 };
180 179
181 180 struct nlm_notify {
182 181 string name<LM_MAXNAMELEN>;
183 182 int state;
184 183 };
185 184
186 185 /*
187 186 * Types for version 4.
188 187 *
189 188 * This revision is designed to work with NFS V3. The main changes from
190 189 * NFS V2 to V3 that affect the NLM protocol are that all file offsets
191 190 * and sizes are now unsigned 64-bit ints, and file handles are now
192 191 * variable length. In NLM V1 and V3, the fixed-length V2 file handle
193 192 * was encoded as a 'netobj', which is a count followed by the data
↓ 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 {
244 243 netobj cookie;
245 244 nlm4_stat stat;
246 245 };
247 246
248 247 struct nlm4_testres {
249 248 netobj cookie;
250 249 nlm4_testrply stat;
251 250 };
252 251
253 252 struct nlm4_lock {
254 253 string caller_name<LM_MAXSTRLEN>;
255 254 netobj fh; /* identify a file */
256 255 netobj oh; /* identify owner of a lock */
257 256 int32 svid; /* generated from pid for svid */
258 257 uint64 l_offset;
259 258 uint64 l_len;
260 259 };
261 260
262 261 struct nlm4_lockargs {
263 262 netobj cookie;
264 263 bool block;
265 264 bool exclusive;
266 265 struct nlm4_lock alock;
267 266 bool reclaim; /* used for recovering locks */
268 267 int32 state; /* specify local status monitor state */
269 268 };
270 269
271 270 struct nlm4_cancargs {
272 271 netobj cookie;
273 272 bool block;
274 273 bool exclusive;
275 274 struct nlm4_lock alock;
276 275 };
277 276
278 277 struct nlm4_testargs {
↓ 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
352 347 NLM_UNLOCK(nlm_unlockargs) = 4;
353 348 /*
354 349 * remote lock manager call-back to grant lock
355 350 */
356 351 nlm_res
357 352 NLM_GRANTED(nlm_testargs) = 5;
358 353
359 354 /*
360 355 * message passing style of requesting lock
361 356 */
362 357
363 358 void
364 359 NLM_TEST_MSG(nlm_testargs) = 6;
365 360 void
366 361 NLM_LOCK_MSG(nlm_lockargs) = 7;
367 362 void
368 363 NLM_CANCEL_MSG(nlm_cancargs) = 8;
369 364 void
370 365 NLM_UNLOCK_MSG(nlm_unlockargs) = 9;
371 366 void
372 367 NLM_GRANTED_MSG(nlm_testargs) = 10;
373 368 void
374 369 NLM_TEST_RES(nlm_testres) = 11;
↓ 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