xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/txg_impl.h (revision 789d94c2889bedf502063bc22addcabfa798a438)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_TXG_IMPL_H
28 #define	_SYS_TXG_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/spa.h>
33 #include <sys/txg.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 struct tx_cpu {
40 	kmutex_t	tc_lock;
41 	kcondvar_t	tc_cv[TXG_SIZE];
42 	uint64_t	tc_count[TXG_SIZE];
43 	char		tc_pad[16];
44 };
45 
46 typedef struct tx_state {
47 	tx_cpu_t	*tx_cpu;	/* protects right to enter txg	*/
48 	kmutex_t	tx_sync_lock;	/* protects tx_state_t */
49 	krwlock_t	tx_suspend;
50 	uint64_t	tx_open_txg;	/* currently open txg id */
51 	uint64_t	tx_quiesced_txg; /* quiesced txg waiting for sync */
52 	uint64_t	tx_syncing_txg;	/* currently syncing txg id */
53 	uint64_t	tx_synced_txg;	/* last synced txg id */
54 
55 	uint64_t	tx_sync_txg_waiting; /* txg we're waiting to sync */
56 	uint64_t	tx_quiesce_txg_waiting; /* txg we're waiting to open */
57 
58 	kcondvar_t	tx_sync_more_cv;
59 	kcondvar_t	tx_sync_done_cv;
60 	kcondvar_t	tx_quiesce_more_cv;
61 	kcondvar_t	tx_quiesce_done_cv;
62 	kcondvar_t	tx_timeout_exit_cv;
63 	kcondvar_t	tx_exit_cv;	/* wait for all threads to exit */
64 
65 	uint8_t		tx_threads;	/* number of threads */
66 	uint8_t		tx_exiting;	/* set when we're exiting */
67 
68 	kthread_t	*tx_sync_thread;
69 	kthread_t	*tx_quiesce_thread;
70 	kthread_t	*tx_timelimit_thread;
71 } tx_state_t;
72 
73 #ifdef	__cplusplus
74 }
75 #endif
76 
77 #endif	/* _SYS_TXG_IMPL_H */
78