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