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 /* 223113f7ceSGeorge Wilson * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23fa9e4066Sahrens */ 24fa9e4066Sahrens 25fa9e4066Sahrens #ifndef _SYS_DSL_POOL_H 26fa9e4066Sahrens #define _SYS_DSL_POOL_H 27fa9e4066Sahrens 28fa9e4066Sahrens #include <sys/spa.h> 29fa9e4066Sahrens #include <sys/txg.h> 30fa9e4066Sahrens #include <sys/txg_impl.h> 31fa9e4066Sahrens #include <sys/zfs_context.h> 32088f3894Sahrens #include <sys/zio.h> 3388b7b0f2SMatthew Ahrens #include <sys/dnode.h> 34bbfd46c4SJeff Bonwick #include <sys/ddt.h> 35*3f9d6ad7SLin Ling #include <sys/arc.h> 36fa9e4066Sahrens 37fa9e4066Sahrens #ifdef __cplusplus 38fa9e4066Sahrens extern "C" { 39fa9e4066Sahrens #endif 40fa9e4066Sahrens 41fa9e4066Sahrens struct objset; 42fa9e4066Sahrens struct dsl_dir; 43088f3894Sahrens struct dsl_dataset; 44088f3894Sahrens struct dsl_pool; 45088f3894Sahrens struct dmu_tx; 46*3f9d6ad7SLin Ling struct dsl_scan; 47088f3894Sahrens 4888b7b0f2SMatthew Ahrens /* These macros are for indexing into the zfs_all_blkstats_t. */ 4988b7b0f2SMatthew Ahrens #define DMU_OT_DEFERRED DMU_OT_NONE 5088b7b0f2SMatthew Ahrens #define DMU_OT_TOTAL DMU_OT_NUMTYPES 5188b7b0f2SMatthew Ahrens 5288b7b0f2SMatthew Ahrens typedef struct zfs_blkstat { 5388b7b0f2SMatthew Ahrens uint64_t zb_count; 5488b7b0f2SMatthew Ahrens uint64_t zb_asize; 5588b7b0f2SMatthew Ahrens uint64_t zb_lsize; 5688b7b0f2SMatthew Ahrens uint64_t zb_psize; 5788b7b0f2SMatthew Ahrens uint64_t zb_gangs; 5888b7b0f2SMatthew Ahrens uint64_t zb_ditto_2_of_2_samevdev; 5988b7b0f2SMatthew Ahrens uint64_t zb_ditto_2_of_3_samevdev; 6088b7b0f2SMatthew Ahrens uint64_t zb_ditto_3_of_3_samevdev; 6188b7b0f2SMatthew Ahrens } zfs_blkstat_t; 6288b7b0f2SMatthew Ahrens 6388b7b0f2SMatthew Ahrens typedef struct zfs_all_blkstats { 6488b7b0f2SMatthew Ahrens zfs_blkstat_t zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1]; 6588b7b0f2SMatthew Ahrens } zfs_all_blkstats_t; 6688b7b0f2SMatthew Ahrens 67fa9e4066Sahrens 68fa9e4066Sahrens typedef struct dsl_pool { 69fa9e4066Sahrens /* Immutable */ 70fa9e4066Sahrens spa_t *dp_spa; 71fa9e4066Sahrens struct objset *dp_meta_objset; 72fa9e4066Sahrens struct dsl_dir *dp_root_dir; 73fa9e4066Sahrens struct dsl_dir *dp_mos_dir; 74088f3894Sahrens struct dsl_dataset *dp_origin_snap; 75fa9e4066Sahrens uint64_t dp_root_dir_obj; 769d3574bfSNeil Perrin struct taskq *dp_vnrele_taskq; 77fa9e4066Sahrens 78fa9e4066Sahrens /* No lock needed - sync context only */ 79fa9e4066Sahrens blkptr_t dp_meta_rootbp; 803cb34c60Sahrens list_t dp_synced_datasets; 8105715f94SMark Maybee hrtime_t dp_read_overhead; 82fb5dd802SLin Ling uint64_t dp_throughput; /* bytes per millisec */ 831ab7f2deSmaybee uint64_t dp_write_limit; 84ca45db41SChris Kirby uint64_t dp_tmp_userrefs_obj; 851ab7f2deSmaybee 86*3f9d6ad7SLin Ling struct dsl_scan *dp_scan; 87*3f9d6ad7SLin Ling 881ab7f2deSmaybee /* Uses dp_lock */ 891ab7f2deSmaybee kmutex_t dp_lock; 901ab7f2deSmaybee uint64_t dp_space_towrite[TXG_SIZE]; 911ab7f2deSmaybee uint64_t dp_tempreserved[TXG_SIZE]; 92fa9e4066Sahrens 93fa9e4066Sahrens /* Has its own locking */ 94fa9e4066Sahrens tx_state_t dp_tx; 95fa9e4066Sahrens txg_list_t dp_dirty_datasets; 96fa9e4066Sahrens txg_list_t dp_dirty_dirs; 971d452cf5Sahrens txg_list_t dp_sync_tasks; 98fa9e4066Sahrens 99fa9e4066Sahrens /* 100fa9e4066Sahrens * Protects administrative changes (properties, namespace) 101fa9e4066Sahrens * It is only held for write in syncing context. Therefore 102fa9e4066Sahrens * syncing context does not need to ever have it for read, since 103fa9e4066Sahrens * nobody else could possibly have it for write. 104fa9e4066Sahrens */ 105fa9e4066Sahrens krwlock_t dp_config_rwlock; 10688b7b0f2SMatthew Ahrens 10788b7b0f2SMatthew Ahrens zfs_all_blkstats_t *dp_blkstats; 108fa9e4066Sahrens } dsl_pool_t; 109fa9e4066Sahrens 110ea8dc4b6Seschrock int dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp); 111fa9e4066Sahrens void dsl_pool_close(dsl_pool_t *dp); 1120a48a24eStimh dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg); 113fa9e4066Sahrens void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg); 114b24ab676SJeff Bonwick void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg); 115fa9e4066Sahrens int dsl_pool_sync_context(dsl_pool_t *dp); 116fa9e4066Sahrens uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree); 117468c413aSTim Haley uint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree); 1181ab7f2deSmaybee int dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx); 1191ab7f2deSmaybee void dsl_pool_tempreserve_clear(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx); 1201ab7f2deSmaybee void dsl_pool_memory_pressure(dsl_pool_t *dp); 1211ab7f2deSmaybee void dsl_pool_willuse_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx); 122b24ab676SJeff Bonwick void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp); 1233113f7ceSGeorge Wilson void dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg, 1243113f7ceSGeorge Wilson const blkptr_t *bpp); 125*3f9d6ad7SLin Ling int dsl_read(zio_t *pio, spa_t *spa, const blkptr_t *bpp, arc_buf_t *pbuf, 126*3f9d6ad7SLin Ling arc_done_func_t *done, void *private, int priority, int zio_flags, 127*3f9d6ad7SLin Ling uint32_t *arc_flags, const zbookmark_t *zb); 128*3f9d6ad7SLin Ling int dsl_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bpp, 129*3f9d6ad7SLin Ling arc_done_func_t *done, void *private, int priority, int zio_flags, 130*3f9d6ad7SLin Ling uint32_t *arc_flags, const zbookmark_t *zb); 131088f3894Sahrens void dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx); 132088f3894Sahrens void dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx); 133088f3894Sahrens 1349d3574bfSNeil Perrin taskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp); 1359d3574bfSNeil Perrin 136ca45db41SChris Kirby extern int dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj, 13715508ac0SChris Kirby const char *tag, uint64_t *now, dmu_tx_t *tx); 138ca45db41SChris Kirby extern int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj, 139ca45db41SChris Kirby const char *tag, dmu_tx_t *tx); 140ca45db41SChris Kirby extern void dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp); 141*3f9d6ad7SLin Ling int dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **); 142ca45db41SChris Kirby 143fa9e4066Sahrens #ifdef __cplusplus 144fa9e4066Sahrens } 145fa9e4066Sahrens #endif 146fa9e4066Sahrens 147fa9e4066Sahrens #endif /* _SYS_DSL_POOL_H */ 148