FreeBSD ZFS
The Zettabyte File System

sys/zrlock.h

Go to the documentation of this file.
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
00023  */
00024 
00025 #ifndef _SYS_ZRLOCK_H
00026 #define _SYS_ZRLOCK_H
00027 
00028 #include <sys/zfs_context.h>
00029 
00030 #ifdef  __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 typedef struct zrlock {
00035         kmutex_t zr_mtx;
00036         volatile int32_t zr_refcount;
00037         kcondvar_t zr_cv;
00038         uint16_t zr_pad;
00039 #ifdef  ZFS_DEBUG
00040         kthread_t *zr_owner;
00041         const char *zr_caller;
00042 #endif
00043 } zrlock_t;
00044 
00045 extern void zrl_init(zrlock_t *);
00046 extern void zrl_destroy(zrlock_t *);
00047 #ifdef  ZFS_DEBUG
00048 #define zrl_add(_z)     zrl_add_debug((_z), __func__)
00049 extern void zrl_add_debug(zrlock_t *, const char *);
00050 #else
00051 extern void zrl_add(zrlock_t *);
00052 #endif
00053 extern void zrl_remove(zrlock_t *);
00054 extern int zrl_tryenter(zrlock_t *);
00055 extern void zrl_exit(zrlock_t *);
00056 extern int zrl_is_zero(zrlock_t *);
00057 extern int zrl_is_locked(zrlock_t *);
00058 #ifdef  ZFS_DEBUG
00059 extern kthread_t *zrl_owner(zrlock_t *);
00060 #endif
00061 
00062 #ifdef  __cplusplus
00063 }
00064 #endif
00065 
00066 #endif /* _SYS_ZRLOCK_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines