xref: /onnv-gate/usr/src/uts/common/sys/nbmlock.h (revision 5331:3047ad28a67b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*5331Samw  * Common Development and Distribution License (the "License").
6*5331Samw  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*5331Samw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*5331Samw  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _NBMLOCK_H
270Sstevel@tonic-gate #define	_NBMLOCK_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * Non-blocking mandatory locking support.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <sys/vnode.h>
400Sstevel@tonic-gate #include <sys/rwlock.h>
410Sstevel@tonic-gate #include <sys/cred.h>
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * Type of operation; used when checking for lock/share conflict.
450Sstevel@tonic-gate  * NBL_READWRITE is used for checking for a conflict with an exclusive lock
460Sstevel@tonic-gate  * (F_WRLCK) or a read-write mmap request.  For checking an actual I/O
470Sstevel@tonic-gate  * request, use NBL_READ or NBL_WRITE.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate typedef enum {NBL_READ, NBL_WRITE, NBL_RENAME, NBL_REMOVE,
500Sstevel@tonic-gate 	    NBL_READWRITE} nbl_op_t;
510Sstevel@tonic-gate 
520Sstevel@tonic-gate /* critical region primitives */
530Sstevel@tonic-gate extern void nbl_start_crit(vnode_t *, krw_t);
540Sstevel@tonic-gate extern void nbl_end_crit(vnode_t *);
550Sstevel@tonic-gate extern int nbl_in_crit(vnode_t *);
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /* conflict checking */
580Sstevel@tonic-gate extern int nbl_need_check(vnode_t *);
59*5331Samw extern int nbl_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
60*5331Samw     caller_context_t *);
61*5331Samw extern int nbl_share_conflict(vnode_t *, nbl_op_t, caller_context_t *);
62*5331Samw extern int nbl_lock_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
63*5331Samw     caller_context_t *);
640Sstevel@tonic-gate extern int nbl_svmand(vnode_t *, cred_t *, int *);
650Sstevel@tonic-gate 
660Sstevel@tonic-gate extern nbl_op_t nbl_lock_to_op(int);
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #ifdef __cplusplus
690Sstevel@tonic-gate }
700Sstevel@tonic-gate #endif
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #endif /* _NBMLOCK_H */
73