xref: /titanic_51/usr/src/uts/common/sys/nbmlock.h (revision b89a8333f5e1f75ec0c269b22524bd2eccb972ba)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*b89a8333Snatalie li - Sun Microsystems - Irvine United States  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23da6c28aaSamw  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _NBMLOCK_H
277c478bd9Sstevel@tonic-gate #define	_NBMLOCK_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Non-blocking mandatory locking support.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef __cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
387c478bd9Sstevel@tonic-gate #include <sys/rwlock.h>
397c478bd9Sstevel@tonic-gate #include <sys/cred.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Type of operation; used when checking for lock/share conflict.
437c478bd9Sstevel@tonic-gate  * NBL_READWRITE is used for checking for a conflict with an exclusive lock
447c478bd9Sstevel@tonic-gate  * (F_WRLCK) or a read-write mmap request.  For checking an actual I/O
457c478bd9Sstevel@tonic-gate  * request, use NBL_READ or NBL_WRITE.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate typedef enum {NBL_READ, NBL_WRITE, NBL_RENAME, NBL_REMOVE,
487c478bd9Sstevel@tonic-gate 	    NBL_READWRITE} nbl_op_t;
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /* critical region primitives */
517c478bd9Sstevel@tonic-gate extern void nbl_start_crit(vnode_t *, krw_t);
527c478bd9Sstevel@tonic-gate extern void nbl_end_crit(vnode_t *);
537c478bd9Sstevel@tonic-gate extern int nbl_in_crit(vnode_t *);
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /* conflict checking */
567c478bd9Sstevel@tonic-gate extern int nbl_need_check(vnode_t *);
57da6c28aaSamw extern int nbl_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
58da6c28aaSamw     caller_context_t *);
59da6c28aaSamw extern int nbl_share_conflict(vnode_t *, nbl_op_t, caller_context_t *);
60da6c28aaSamw extern int nbl_lock_conflict(vnode_t *, nbl_op_t, u_offset_t, ssize_t, int,
61da6c28aaSamw     caller_context_t *);
627c478bd9Sstevel@tonic-gate extern int nbl_svmand(vnode_t *, cred_t *, int *);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #ifdef __cplusplus
667c478bd9Sstevel@tonic-gate }
677c478bd9Sstevel@tonic-gate #endif
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #endif /* _NBMLOCK_H */
70