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