FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 00023 * Use is subject to license terms. 00024 */ 00025 00026 #ifndef _SYS_RR_RW_LOCK_H 00027 #define _SYS_RR_RW_LOCK_H 00028 00029 #pragma ident "%Z%%M% %I% %E% SMI" 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #include <sys/zfs_context.h> 00036 #include <sys/refcount.h> 00037 00052 typedef struct rrwlock { 00053 kmutex_t rr_lock; 00054 kcondvar_t rr_cv; 00055 kthread_t *rr_writer; 00056 refcount_t rr_anon_rcount; 00057 refcount_t rr_linked_rcount; 00058 boolean_t rr_writer_wanted; 00059 } rrwlock_t; 00060 00061 /* 00062 * 'tag' is used in reference counting tracking. The 00063 * 'tag' must be the same in a rrw_enter() as in its 00064 * corresponding rrw_exit(). 00065 */ 00066 void rrw_init(rrwlock_t *rrl); 00067 void rrw_destroy(rrwlock_t *rrl); 00068 void rrw_enter(rrwlock_t *rrl, krw_t rw, void *tag); 00069 void rrw_exit(rrwlock_t *rrl, void *tag); 00070 boolean_t rrw_held(rrwlock_t *rrl, krw_t rw); 00071 00072 #define RRW_READ_HELD(x) rrw_held(x, RW_READER) 00073 #define RRW_WRITE_HELD(x) rrw_held(x, RW_WRITER) 00074 00075 #ifdef __cplusplus 00076 } 00077 #endif 00078 00079 #endif /* _SYS_RR_RW_LOCK_H */