xref: /titanic_52/usr/src/uts/common/sys/nbmlock.h (revision 00a3eaf3896a33935e11fd5c5fb5c1714225c067)
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 2008 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 /*
30  * Non-blocking mandatory locking support.
31  */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/vnode.h>
38 #include <sys/rwlock.h>
39 #include <sys/cred.h>
40 
41 /*
42  * Type of operation; used when checking for lock/share conflict.
43  * NBL_READWRITE is used for checking for a conflict with an exclusive lock
44  * (F_WRLCK) or a read-write mmap request.  For checking an actual I/O
45  * request, use NBL_READ or NBL_WRITE.
46  */
47 typedef enum {NBL_READ, NBL_WRITE, NBL_RENAME, NBL_REMOVE,
48 	    NBL_READWRITE} nbl_op_t;
49 
50 /* critical region primitives */
51 extern void nbl_start_crit(vnode_t *, krw_t);
52 extern void nbl_end_crit(vnode_t *);
53 extern int nbl_in_crit(vnode_t *);
54 
55 /* conflict checking */
56 extern int nbl_need_check(vnode_t *);
57 extern int nbl_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
58     caller_context_t *);
59 extern int nbl_share_conflict(vnode_t *, nbl_op_t, caller_context_t *);
60 extern int nbl_lock_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
61     caller_context_t *);
62 extern int nbl_svmand(vnode_t *, cred_t *, int *);
63 
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif /* _NBMLOCK_H */
70