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 2006 Sun Microsystems, Inc. All rights reserved. 00023 * Use is subject to license terms. 00024 */ 00025 00026 #ifndef _SYS_FS_ZFS_RLOCK_H 00027 #define _SYS_FS_ZFS_RLOCK_H 00028 00029 #pragma ident "%Z%%M% %I% %E% SMI" 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #ifdef _KERNEL 00036 00037 #include <sys/zfs_znode.h> 00038 00039 typedef enum { 00040 RL_READER, 00041 RL_WRITER, 00042 RL_APPEND 00043 } rl_type_t; 00044 00045 typedef struct rl { 00046 znode_t *r_zp; 00047 avl_node_t r_node; 00048 uint64_t r_off; 00049 uint64_t r_len; 00050 uint_t r_cnt; 00051 rl_type_t r_type; 00052 kcondvar_t r_wr_cv; 00053 kcondvar_t r_rd_cv; 00054 uint8_t r_proxy; 00055 uint8_t r_write_wanted; 00056 uint8_t r_read_wanted; 00057 } rl_t; 00058 00072 rl_t *zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len, rl_type_t type); 00073 00074 void zfs_range_unlock(rl_t *rl); 00075 00079 void zfs_range_reduce(rl_t *rl, uint64_t off, uint64_t len); 00080 00085 int zfs_range_compare(const void *arg1, const void *arg2); 00086 00087 #endif /* _KERNEL */ 00088 00089 #ifdef __cplusplus 00090 } 00091 #endif 00092 00093 #endif /* _SYS_FS_ZFS_RLOCK_H */