xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/dsl_pool.h (revision 12470:54258108784b)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
51544Seschrock  * Common Development and Distribution License (the "License").
61544Seschrock  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
2212295SGeorge.Wilson@Sun.COM  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23789Sahrens  */
24789Sahrens 
25789Sahrens #ifndef	_SYS_DSL_POOL_H
26789Sahrens #define	_SYS_DSL_POOL_H
27789Sahrens 
28789Sahrens #include <sys/spa.h>
29789Sahrens #include <sys/txg.h>
30789Sahrens #include <sys/txg_impl.h>
31789Sahrens #include <sys/zfs_context.h>
327046Sahrens #include <sys/zio.h>
337837SMatthew.Ahrens@Sun.COM #include <sys/dnode.h>
3411125SJeff.Bonwick@Sun.COM #include <sys/ddt.h>
3512296SLin.Ling@Sun.COM #include <sys/arc.h>
36*12470SMatthew.Ahrens@Sun.COM #include <sys/bpobj.h>
37789Sahrens 
38789Sahrens #ifdef	__cplusplus
39789Sahrens extern "C" {
40789Sahrens #endif
41789Sahrens 
42789Sahrens struct objset;
43789Sahrens struct dsl_dir;
447046Sahrens struct dsl_dataset;
457046Sahrens struct dsl_pool;
467046Sahrens struct dmu_tx;
4712296SLin.Ling@Sun.COM struct dsl_scan;
487046Sahrens 
497837SMatthew.Ahrens@Sun.COM /* These macros are for indexing into the zfs_all_blkstats_t. */
507837SMatthew.Ahrens@Sun.COM #define	DMU_OT_DEFERRED	DMU_OT_NONE
517837SMatthew.Ahrens@Sun.COM #define	DMU_OT_TOTAL	DMU_OT_NUMTYPES
527837SMatthew.Ahrens@Sun.COM 
537837SMatthew.Ahrens@Sun.COM typedef struct zfs_blkstat {
547837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_count;
557837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_asize;
567837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_lsize;
577837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_psize;
587837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_gangs;
597837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_ditto_2_of_2_samevdev;
607837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_ditto_2_of_3_samevdev;
617837SMatthew.Ahrens@Sun.COM 	uint64_t	zb_ditto_3_of_3_samevdev;
627837SMatthew.Ahrens@Sun.COM } zfs_blkstat_t;
637837SMatthew.Ahrens@Sun.COM 
647837SMatthew.Ahrens@Sun.COM typedef struct zfs_all_blkstats {
657837SMatthew.Ahrens@Sun.COM 	zfs_blkstat_t	zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1];
667837SMatthew.Ahrens@Sun.COM } zfs_all_blkstats_t;
677837SMatthew.Ahrens@Sun.COM 
68789Sahrens 
69789Sahrens typedef struct dsl_pool {
70789Sahrens 	/* Immutable */
71789Sahrens 	spa_t *dp_spa;
72789Sahrens 	struct objset *dp_meta_objset;
73789Sahrens 	struct dsl_dir *dp_root_dir;
74789Sahrens 	struct dsl_dir *dp_mos_dir;
75*12470SMatthew.Ahrens@Sun.COM 	struct dsl_dir *dp_free_dir;
767046Sahrens 	struct dsl_dataset *dp_origin_snap;
77789Sahrens 	uint64_t dp_root_dir_obj;
789321SNeil.Perrin@Sun.COM 	struct taskq *dp_vnrele_taskq;
79789Sahrens 
80789Sahrens 	/* No lock needed - sync context only */
81789Sahrens 	blkptr_t dp_meta_rootbp;
825367Sahrens 	list_t dp_synced_datasets;
837468SMark.Maybee@Sun.COM 	hrtime_t dp_read_overhead;
8411614SLin.Ling@Sun.COM 	uint64_t dp_throughput; /* bytes per millisec */
856245Smaybee 	uint64_t dp_write_limit;
8610342Schris.kirby@sun.com 	uint64_t dp_tmp_userrefs_obj;
87*12470SMatthew.Ahrens@Sun.COM 	bpobj_t dp_free_bpobj;
886245Smaybee 
8912296SLin.Ling@Sun.COM 	struct dsl_scan *dp_scan;
9012296SLin.Ling@Sun.COM 
916245Smaybee 	/* Uses dp_lock */
926245Smaybee 	kmutex_t dp_lock;
936245Smaybee 	uint64_t dp_space_towrite[TXG_SIZE];
946245Smaybee 	uint64_t dp_tempreserved[TXG_SIZE];
95789Sahrens 
96789Sahrens 	/* Has its own locking */
97789Sahrens 	tx_state_t dp_tx;
98789Sahrens 	txg_list_t dp_dirty_datasets;
99789Sahrens 	txg_list_t dp_dirty_dirs;
1002199Sahrens 	txg_list_t dp_sync_tasks;
101789Sahrens 
102789Sahrens 	/*
103789Sahrens 	 * Protects administrative changes (properties, namespace)
104789Sahrens 	 * It is only held for write in syncing context.  Therefore
105789Sahrens 	 * syncing context does not need to ever have it for read, since
106789Sahrens 	 * nobody else could possibly have it for write.
107789Sahrens 	 */
108789Sahrens 	krwlock_t dp_config_rwlock;
1097837SMatthew.Ahrens@Sun.COM 
1107837SMatthew.Ahrens@Sun.COM 	zfs_all_blkstats_t *dp_blkstats;
111789Sahrens } dsl_pool_t;
112789Sahrens 
1131544Seschrock int dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
114789Sahrens void dsl_pool_close(dsl_pool_t *dp);
1157184Stimh dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
116789Sahrens void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
11710922SJeff.Bonwick@Sun.COM void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
118789Sahrens int dsl_pool_sync_context(dsl_pool_t *dp);
119789Sahrens uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
12010921STim.Haley@Sun.COM uint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree);
1216245Smaybee int dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx);
1226245Smaybee void dsl_pool_tempreserve_clear(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
1236245Smaybee void dsl_pool_memory_pressure(dsl_pool_t *dp);
1246245Smaybee void dsl_pool_willuse_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
12510922SJeff.Bonwick@Sun.COM void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
12612295SGeorge.Wilson@Sun.COM void dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg,
12712295SGeorge.Wilson@Sun.COM     const blkptr_t *bpp);
12812296SLin.Ling@Sun.COM int dsl_read(zio_t *pio, spa_t *spa, const blkptr_t *bpp, arc_buf_t *pbuf,
12912296SLin.Ling@Sun.COM     arc_done_func_t *done, void *private, int priority, int zio_flags,
13012296SLin.Ling@Sun.COM     uint32_t *arc_flags, const zbookmark_t *zb);
13112296SLin.Ling@Sun.COM int dsl_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bpp,
13212296SLin.Ling@Sun.COM     arc_done_func_t *done, void *private, int priority, int zio_flags,
13312296SLin.Ling@Sun.COM     uint32_t *arc_flags, const zbookmark_t *zb);
1347046Sahrens void dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx);
1357046Sahrens void dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx);
136*12470SMatthew.Ahrens@Sun.COM void dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx);
1377046Sahrens 
1389321SNeil.Perrin@Sun.COM taskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp);
1399321SNeil.Perrin@Sun.COM 
14010342Schris.kirby@sun.com extern int dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj,
14110951SChris.Kirby@sun.com     const char *tag, uint64_t *now, dmu_tx_t *tx);
14210342Schris.kirby@sun.com extern int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj,
14310342Schris.kirby@sun.com     const char *tag, dmu_tx_t *tx);
14410342Schris.kirby@sun.com extern void dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp);
14512296SLin.Ling@Sun.COM int dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **);
14610342Schris.kirby@sun.com 
147789Sahrens #ifdef	__cplusplus
148789Sahrens }
149789Sahrens #endif
150789Sahrens 
151789Sahrens #endif /* _SYS_DSL_POOL_H */
152