xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dsl_pool.h (revision 1d452cf5123cb6ac0a013a4dbd4dcceeb0da314d)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
22ea8dc4b6Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23fa9e4066Sahrens  * Use is subject to license terms.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef	_SYS_DSL_POOL_H
27fa9e4066Sahrens #define	_SYS_DSL_POOL_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
30fa9e4066Sahrens 
31fa9e4066Sahrens #include <sys/spa.h>
32fa9e4066Sahrens #include <sys/txg.h>
33fa9e4066Sahrens #include <sys/txg_impl.h>
34fa9e4066Sahrens #include <sys/zfs_context.h>
35fa9e4066Sahrens 
36fa9e4066Sahrens #ifdef	__cplusplus
37fa9e4066Sahrens extern "C" {
38fa9e4066Sahrens #endif
39fa9e4066Sahrens 
40fa9e4066Sahrens struct objset;
41fa9e4066Sahrens struct dsl_dir;
42fa9e4066Sahrens 
43fa9e4066Sahrens typedef struct dsl_pool {
44fa9e4066Sahrens 	/* Immutable */
45fa9e4066Sahrens 	spa_t *dp_spa;
46fa9e4066Sahrens 	struct objset *dp_meta_objset;
47fa9e4066Sahrens 	struct dsl_dir *dp_root_dir;
48fa9e4066Sahrens 	struct dsl_dir *dp_mos_dir;
49fa9e4066Sahrens 	uint64_t dp_root_dir_obj;
50fa9e4066Sahrens 
51fa9e4066Sahrens 	/* No lock needed - sync context only */
52fa9e4066Sahrens 	blkptr_t dp_meta_rootbp;
53fa9e4066Sahrens 	list_t dp_synced_objsets;
54fa9e4066Sahrens 
55fa9e4066Sahrens 	/* Has its own locking */
56fa9e4066Sahrens 	tx_state_t dp_tx;
57fa9e4066Sahrens 	txg_list_t dp_dirty_datasets;
58fa9e4066Sahrens 	txg_list_t dp_dirty_dirs;
59*1d452cf5Sahrens 	txg_list_t dp_sync_tasks;
60fa9e4066Sahrens 
61fa9e4066Sahrens 	/*
62fa9e4066Sahrens 	 * Protects administrative changes (properties, namespace)
63fa9e4066Sahrens 	 * It is only held for write in syncing context.  Therefore
64fa9e4066Sahrens 	 * syncing context does not need to ever have it for read, since
65fa9e4066Sahrens 	 * nobody else could possibly have it for write.
66fa9e4066Sahrens 	 */
67fa9e4066Sahrens 	krwlock_t dp_config_rwlock;
68fa9e4066Sahrens } dsl_pool_t;
69fa9e4066Sahrens 
70ea8dc4b6Seschrock int dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
71fa9e4066Sahrens void dsl_pool_close(dsl_pool_t *dp);
72fa9e4066Sahrens dsl_pool_t *dsl_pool_create(spa_t *spa, uint64_t txg);
73fa9e4066Sahrens void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
74fa9e4066Sahrens void dsl_pool_zil_clean(dsl_pool_t *dp);
75fa9e4066Sahrens int dsl_pool_sync_context(dsl_pool_t *dp);
76fa9e4066Sahrens uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
77fa9e4066Sahrens 
78fa9e4066Sahrens #ifdef	__cplusplus
79fa9e4066Sahrens }
80fa9e4066Sahrens #endif
81fa9e4066Sahrens 
82fa9e4066Sahrens #endif /* _SYS_DSL_POOL_H */
83