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 2010 Sun Microsystems, Inc. All rights reserved. 00023 * Use is subject to license terms. 00024 */ 00025 /* 00026 * Copyright (c) 2012 by Delphix. All rights reserved. 00027 */ 00028 00029 #ifndef _SYS_TXG_H 00030 #define _SYS_TXG_H 00031 00032 #include <sys/spa.h> 00033 #include <sys/zfs_context.h> 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 #define TXG_CONCURRENT_STATES 3 00040 #define TXG_SIZE 4 00041 #define TXG_MASK (TXG_SIZE - 1) 00042 #define TXG_INITIAL TXG_SIZE 00043 #define TXG_IDX (txg & TXG_MASK) 00044 00046 #define TXG_DEFER_SIZE 2 00047 00048 #define TXG_WAIT 1ULL 00049 #define TXG_NOWAIT 2ULL 00050 00051 typedef struct tx_cpu tx_cpu_t; 00052 00053 typedef struct txg_handle { 00054 tx_cpu_t *th_cpu; 00055 uint64_t th_txg; 00056 } txg_handle_t; 00057 00058 typedef struct txg_node { 00059 struct txg_node *tn_next[TXG_SIZE]; 00060 uint8_t tn_member[TXG_SIZE]; 00061 } txg_node_t; 00062 00063 typedef struct txg_list { 00064 kmutex_t tl_lock; 00065 size_t tl_offset; 00066 txg_node_t *tl_head[TXG_SIZE]; 00067 } txg_list_t; 00068 00069 struct dsl_pool; 00070 00071 extern void txg_init(struct dsl_pool *dp, uint64_t txg); 00072 extern void txg_fini(struct dsl_pool *dp); 00073 extern void txg_sync_start(struct dsl_pool *dp); 00074 extern void txg_sync_stop(struct dsl_pool *dp); 00075 extern uint64_t txg_hold_open(struct dsl_pool *dp, txg_handle_t *txghp); 00076 extern void txg_rele_to_quiesce(txg_handle_t *txghp); 00077 extern void txg_rele_to_sync(txg_handle_t *txghp); 00078 extern void txg_register_callbacks(txg_handle_t *txghp, list_t *tx_callbacks); 00079 00086 extern void txg_delay(struct dsl_pool *dp, uint64_t txg, int ticks); 00087 00094 extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg); 00095 00102 extern void txg_wait_open(struct dsl_pool *dp, uint64_t txg); 00103 00111 extern boolean_t txg_stalled(struct dsl_pool *dp); 00112 00116 extern boolean_t txg_sync_waiting(struct dsl_pool *dp); 00117 00118 /* 00119 * Per-txg object lists. 00120 */ 00121 00122 #define TXG_CLEAN(txg) ((txg) - 1) 00123 00124 extern void txg_list_create(txg_list_t *tl, size_t offset); 00125 extern void txg_list_destroy(txg_list_t *tl); 00126 extern boolean_t txg_list_empty(txg_list_t *tl, uint64_t txg); 00127 extern int txg_list_add(txg_list_t *tl, void *p, uint64_t txg); 00128 extern int txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg); 00129 extern void *txg_list_remove(txg_list_t *tl, uint64_t txg); 00130 extern void *txg_list_remove_this(txg_list_t *tl, void *p, uint64_t txg); 00131 extern int txg_list_member(txg_list_t *tl, void *p, uint64_t txg); 00132 extern void *txg_list_head(txg_list_t *tl, uint64_t txg); 00133 extern void *txg_list_next(txg_list_t *tl, void *p, uint64_t txg); 00134 00135 #ifdef __cplusplus 00136 } 00137 #endif 00138 00139 #endif /* _SYS_TXG_H */