xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dsl_synctask.h (revision 3d393ee6c37fa10ac512ed6d36109ad616dc7c1a)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DSL_SYNCTASK_H
27 #define	_SYS_DSL_SYNCTASK_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/txg.h>
32 #include <sys/zfs_context.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 struct dsl_pool;
39 
40 typedef int (dsl_checkfunc_t)(void *, void *, dmu_tx_t *);
41 typedef void (dsl_syncfunc_t)(void *, void *, cred_t *, dmu_tx_t *);
42 
43 typedef struct dsl_sync_task {
44 	list_node_t dst_node;
45 	dsl_checkfunc_t *dst_checkfunc;
46 	dsl_syncfunc_t *dst_syncfunc;
47 	void *dst_arg1;
48 	void *dst_arg2;
49 	int dst_err;
50 } dsl_sync_task_t;
51 
52 typedef struct dsl_sync_task_group {
53 	txg_node_t dstg_node;
54 	list_t dstg_tasks;
55 	struct dsl_pool *dstg_pool;
56 	cred_t *dstg_cr;
57 	uint64_t dstg_txg;
58 	int dstg_err;
59 	int dstg_space;
60 	boolean_t dstg_nowaiter;
61 } dsl_sync_task_group_t;
62 
63 dsl_sync_task_group_t *dsl_sync_task_group_create(struct dsl_pool *dp);
64 void dsl_sync_task_create(dsl_sync_task_group_t *dstg,
65     dsl_checkfunc_t *, dsl_syncfunc_t *,
66     void *arg1, void *arg2, int blocks_modified);
67 int dsl_sync_task_group_wait(dsl_sync_task_group_t *dstg);
68 void dsl_sync_task_group_nowait(dsl_sync_task_group_t *dstg, dmu_tx_t *tx);
69 void dsl_sync_task_group_destroy(dsl_sync_task_group_t *dstg);
70 void dsl_sync_task_group_sync(dsl_sync_task_group_t *dstg, dmu_tx_t *tx);
71 
72 int dsl_sync_task_do(struct dsl_pool *dp,
73     dsl_checkfunc_t *checkfunc, dsl_syncfunc_t *syncfunc,
74     void *arg1, void *arg2, int blocks_modified);
75 void dsl_sync_task_do_nowait(struct dsl_pool *dp,
76     dsl_checkfunc_t *checkfunc, dsl_syncfunc_t *syncfunc,
77     void *arg1, void *arg2, int blocks_modified, dmu_tx_t *tx);
78 
79 #ifdef	__cplusplus
80 }
81 #endif
82 
83 #endif /* _SYS_DSL_SYNCTASK_H */
84