1744947dcSTom Erickson /* 2744947dcSTom Erickson * CDDL HEADER START 3744947dcSTom Erickson * 4744947dcSTom Erickson * The contents of this file are subject to the terms of the 5744947dcSTom Erickson * Common Development and Distribution License (the "License"). 6744947dcSTom Erickson * You may not use this file except in compliance with the License. 7744947dcSTom Erickson * 8744947dcSTom Erickson * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9744947dcSTom Erickson * or http://www.opensolaris.org/os/licensing. 10744947dcSTom Erickson * See the License for the specific language governing permissions 11744947dcSTom Erickson * and limitations under the License. 12744947dcSTom Erickson * 13744947dcSTom Erickson * When distributing Covered Code, include this CDDL HEADER in each 14744947dcSTom Erickson * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15744947dcSTom Erickson * If applicable, add the following below this CDDL HEADER, with the 16744947dcSTom Erickson * fields enclosed by brackets "[]" replaced with your own identifying 17744947dcSTom Erickson * information: Portions Copyright [yyyy] [name of copyright owner] 18744947dcSTom Erickson * 19744947dcSTom Erickson * CDDL HEADER END 20744947dcSTom Erickson */ 21744947dcSTom Erickson /* 22744947dcSTom Erickson * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23*9a686fbcSPaul Dagnelie * Copyright (c) 2015 by Delphix. All rights reserved. 24744947dcSTom Erickson */ 25744947dcSTom Erickson 26744947dcSTom Erickson #ifndef _SYS_ZRLOCK_H 27744947dcSTom Erickson #define _SYS_ZRLOCK_H 28744947dcSTom Erickson 29744947dcSTom Erickson #include <sys/zfs_context.h> 30744947dcSTom Erickson 31744947dcSTom Erickson #ifdef __cplusplus 32744947dcSTom Erickson extern "C" { 33744947dcSTom Erickson #endif 34744947dcSTom Erickson 35744947dcSTom Erickson typedef struct zrlock { 36744947dcSTom Erickson kmutex_t zr_mtx; 37744947dcSTom Erickson volatile int32_t zr_refcount; 38744947dcSTom Erickson kcondvar_t zr_cv; 39744947dcSTom Erickson uint16_t zr_pad; 40744947dcSTom Erickson #ifdef ZFS_DEBUG 41744947dcSTom Erickson kthread_t *zr_owner; 42744947dcSTom Erickson const char *zr_caller; 43744947dcSTom Erickson #endif 44744947dcSTom Erickson } zrlock_t; 45744947dcSTom Erickson 46744947dcSTom Erickson extern void zrl_init(zrlock_t *); 47744947dcSTom Erickson extern void zrl_destroy(zrlock_t *); 48*9a686fbcSPaul Dagnelie #define zrl_add(_z) zrl_add_impl((_z), __func__) 49*9a686fbcSPaul Dagnelie extern void zrl_add_impl(zrlock_t *, const char *); 50744947dcSTom Erickson extern void zrl_remove(zrlock_t *); 51744947dcSTom Erickson extern int zrl_tryenter(zrlock_t *); 52744947dcSTom Erickson extern void zrl_exit(zrlock_t *); 53744947dcSTom Erickson extern int zrl_is_zero(zrlock_t *); 54744947dcSTom Erickson extern int zrl_is_locked(zrlock_t *); 55744947dcSTom Erickson #ifdef ZFS_DEBUG 56744947dcSTom Erickson extern kthread_t *zrl_owner(zrlock_t *); 57744947dcSTom Erickson #endif 58744947dcSTom Erickson 59744947dcSTom Erickson #ifdef __cplusplus 60744947dcSTom Erickson } 61744947dcSTom Erickson #endif 62744947dcSTom Erickson 63744947dcSTom Erickson #endif /* _SYS_ZRLOCK_H */ 64