1*744947dcSTom Erickson /* 2*744947dcSTom Erickson * CDDL HEADER START 3*744947dcSTom Erickson * 4*744947dcSTom Erickson * The contents of this file are subject to the terms of the 5*744947dcSTom Erickson * Common Development and Distribution License (the "License"). 6*744947dcSTom Erickson * You may not use this file except in compliance with the License. 7*744947dcSTom Erickson * 8*744947dcSTom Erickson * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*744947dcSTom Erickson * or http://www.opensolaris.org/os/licensing. 10*744947dcSTom Erickson * See the License for the specific language governing permissions 11*744947dcSTom Erickson * and limitations under the License. 12*744947dcSTom Erickson * 13*744947dcSTom Erickson * When distributing Covered Code, include this CDDL HEADER in each 14*744947dcSTom Erickson * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*744947dcSTom Erickson * If applicable, add the following below this CDDL HEADER, with the 16*744947dcSTom Erickson * fields enclosed by brackets "[]" replaced with your own identifying 17*744947dcSTom Erickson * information: Portions Copyright [yyyy] [name of copyright owner] 18*744947dcSTom Erickson * 19*744947dcSTom Erickson * CDDL HEADER END 20*744947dcSTom Erickson */ 21*744947dcSTom Erickson /* 22*744947dcSTom Erickson * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23*744947dcSTom Erickson */ 24*744947dcSTom Erickson 25*744947dcSTom Erickson #ifndef _SYS_ZRLOCK_H 26*744947dcSTom Erickson #define _SYS_ZRLOCK_H 27*744947dcSTom Erickson 28*744947dcSTom Erickson #include <sys/zfs_context.h> 29*744947dcSTom Erickson 30*744947dcSTom Erickson #ifdef __cplusplus 31*744947dcSTom Erickson extern "C" { 32*744947dcSTom Erickson #endif 33*744947dcSTom Erickson 34*744947dcSTom Erickson typedef struct zrlock { 35*744947dcSTom Erickson kmutex_t zr_mtx; 36*744947dcSTom Erickson volatile int32_t zr_refcount; 37*744947dcSTom Erickson kcondvar_t zr_cv; 38*744947dcSTom Erickson uint16_t zr_pad; 39*744947dcSTom Erickson #ifdef ZFS_DEBUG 40*744947dcSTom Erickson kthread_t *zr_owner; 41*744947dcSTom Erickson const char *zr_caller; 42*744947dcSTom Erickson #endif 43*744947dcSTom Erickson } zrlock_t; 44*744947dcSTom Erickson 45*744947dcSTom Erickson extern void zrl_init(zrlock_t *); 46*744947dcSTom Erickson extern void zrl_destroy(zrlock_t *); 47*744947dcSTom Erickson #ifdef ZFS_DEBUG 48*744947dcSTom Erickson #define zrl_add(_z) zrl_add_debug((_z), __func__) 49*744947dcSTom Erickson extern void zrl_add_debug(zrlock_t *, const char *); 50*744947dcSTom Erickson #else 51*744947dcSTom Erickson extern void zrl_add(zrlock_t *); 52*744947dcSTom Erickson #endif 53*744947dcSTom Erickson extern void zrl_remove(zrlock_t *); 54*744947dcSTom Erickson extern int zrl_tryenter(zrlock_t *); 55*744947dcSTom Erickson extern void zrl_exit(zrlock_t *); 56*744947dcSTom Erickson extern int zrl_is_zero(zrlock_t *); 57*744947dcSTom Erickson extern int zrl_is_locked(zrlock_t *); 58*744947dcSTom Erickson #ifdef ZFS_DEBUG 59*744947dcSTom Erickson extern kthread_t *zrl_owner(zrlock_t *); 60*744947dcSTom Erickson #endif 61*744947dcSTom Erickson 62*744947dcSTom Erickson #ifdef __cplusplus 63*744947dcSTom Erickson } 64*744947dcSTom Erickson #endif 65*744947dcSTom Erickson 66*744947dcSTom Erickson #endif /* _SYS_ZRLOCK_H */ 67