xref: /titanic_51/usr/src/uts/common/sys/nbmlock.h (revision 98157a7002f4f2cf7978f3084ca5577f0a1d72b2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _NBMLOCK_H
27 #define	_NBMLOCK_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Non-blocking mandatory locking support.
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <sys/vnode.h>
40 #include <sys/rwlock.h>
41 #include <sys/cred.h>
42 
43 /*
44  * Type of operation; used when checking for lock/share conflict.
45  * NBL_READWRITE is used for checking for a conflict with an exclusive lock
46  * (F_WRLCK) or a read-write mmap request.  For checking an actual I/O
47  * request, use NBL_READ or NBL_WRITE.
48  */
49 typedef enum {NBL_READ, NBL_WRITE, NBL_RENAME, NBL_REMOVE,
50 	    NBL_READWRITE} nbl_op_t;
51 
52 /* critical region primitives */
53 extern void nbl_start_crit(vnode_t *, krw_t);
54 extern void nbl_end_crit(vnode_t *);
55 extern int nbl_in_crit(vnode_t *);
56 
57 /* conflict checking */
58 extern int nbl_need_check(vnode_t *);
59 extern int nbl_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
60     caller_context_t *);
61 extern int nbl_share_conflict(vnode_t *, nbl_op_t, caller_context_t *);
62 extern int nbl_lock_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
63     caller_context_t *);
64 extern int nbl_svmand(vnode_t *, cred_t *, int *);
65 
66 extern nbl_op_t nbl_lock_to_op(int);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _NBMLOCK_H */
73