dsl_pool.h revision 288570
1139823Simp/* 2157170Srwatson * CDDL HEADER START 3157170Srwatson * 4194905Srwatson * The contents of this file are subject to the terms of the 5157170Srwatson * Common Development and Distribution License (the "License"). 611819Sjulian * You may not use this file except in compliance with the License. 711819Sjulian * 811819Sjulian * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 911819Sjulian * or http://www.opensolaris.org/os/licensing. 1011819Sjulian * See the License for the specific language governing permissions 1111819Sjulian * and limitations under the License. 1211819Sjulian * 1311819Sjulian * When distributing Covered Code, include this CDDL HEADER in each 1411819Sjulian * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15165899Srwatson * If applicable, add the following below this CDDL HEADER, with the 16165899Srwatson * fields enclosed by brackets "[]" replaced with your own identifying 17165899Srwatson * information: Portions Copyright [yyyy] [name of copyright owner] 18165899Srwatson * 19165899Srwatson * CDDL HEADER END 20165899Srwatson */ 21165899Srwatson/* 22165899Srwatson * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23165899Srwatson * Copyright (c) 2013 by Delphix. All rights reserved. 24165899Srwatson */ 25165899Srwatson 26165899Srwatson#ifndef _SYS_DSL_POOL_H 27165899Srwatson#define _SYS_DSL_POOL_H 28165899Srwatson 29165899Srwatson#include <sys/spa.h> 30165899Srwatson#include <sys/txg.h> 31165899Srwatson#include <sys/txg_impl.h> 32165899Srwatson#include <sys/zfs_context.h> 33165899Srwatson#include <sys/zio.h> 34165899Srwatson#include <sys/dnode.h> 35165899Srwatson#include <sys/ddt.h> 36165899Srwatson#include <sys/arc.h> 37165899Srwatson#include <sys/bpobj.h> 38165899Srwatson#include <sys/bptree.h> 39165899Srwatson#include <sys/rrwlock.h> 40165899Srwatson 41165899Srwatson#ifdef __cplusplus 4211819Sjulianextern "C" { 4311819Sjulian#endif 4411819Sjulian 4511819Sjulianstruct objset; 4611819Sjulianstruct dsl_dir; 4711819Sjulianstruct dsl_dataset; 4811819Sjulianstruct dsl_pool; 4911819Sjulianstruct dmu_tx; 5011819Sjulianstruct dsl_scan; 5111819Sjulian 5211819Sjulianextern uint64_t zfs_dirty_data_max; 5311819Sjulianextern uint64_t zfs_dirty_data_max_max; 5411819Sjulianextern uint64_t zfs_dirty_data_sync; 5511819Sjulianextern int zfs_dirty_data_max_percent; 5611819Sjulianextern int zfs_delay_min_dirty_percent; 5711819Sjulianextern uint64_t zfs_delay_scale; 5811819Sjulian 5911819Sjulian/* These macros are for indexing into the zfs_all_blkstats_t. */ 6011819Sjulian#define DMU_OT_DEFERRED DMU_OT_NONE 6111819Sjulian#define DMU_OT_OTHER DMU_OT_NUMTYPES /* place holder for DMU_OT() types */ 6212057Sjulian#define DMU_OT_TOTAL (DMU_OT_NUMTYPES + 1) 6311819Sjulian 6411819Sjuliantypedef struct zfs_blkstat { 65116189Sobrien uint64_t zb_count; 66116189Sobrien uint64_t zb_asize; 67116189Sobrien uint64_t zb_lsize; 6811819Sjulian uint64_t zb_psize; 6911819Sjulian uint64_t zb_gangs; 7011819Sjulian uint64_t zb_ditto_2_of_2_samevdev; 7111819Sjulian uint64_t zb_ditto_2_of_3_samevdev; 7211819Sjulian uint64_t zb_ditto_3_of_3_samevdev; 7311819Sjulian} zfs_blkstat_t; 7459604Sobrien 75194750Scognettypedef struct zfs_all_blkstats { 76194608Srwatson zfs_blkstat_t zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1]; 7713266Swollman} zfs_all_blkstats_t; 7811819Sjulian 7911819Sjulian 8011819Sjuliantypedef struct dsl_pool { 8111819Sjulian /* Immutable */ 8211819Sjulian spa_t *dp_spa; 8311819Sjulian struct objset *dp_meta_objset; 8411819Sjulian struct dsl_dir *dp_root_dir; 8511819Sjulian struct dsl_dir *dp_mos_dir; 8611819Sjulian struct dsl_dir *dp_free_dir; 8711819Sjulian struct dsl_dir *dp_leak_dir; 8811819Sjulian struct dsl_dataset *dp_origin_snap; 8925652Sjhay uint64_t dp_root_dir_obj; 9013266Swollman struct taskq *dp_vnrele_taskq; 91180816Strhodes 9211819Sjulian /* No lock needed - sync context only */ 9326965Sjhay blkptr_t dp_meta_rootbp; 9425652Sjhay uint64_t dp_tmp_userrefs_obj; 95180816Strhodes bpobj_t dp_free_bpobj; 9611819Sjulian uint64_t dp_bptree_obj; 9726965Sjhay uint64_t dp_empty_bpobj; 9813266Swollman 99180816Strhodes struct dsl_scan *dp_scan; 10013266Swollman 10126965Sjhay /* Uses dp_lock */ 10225652Sjhay kmutex_t dp_lock; 103180816Strhodes kcondvar_t dp_spaceavail_cv; 10411819Sjulian uint64_t dp_dirty_pertxg[TXG_SIZE]; 105193219Srwatson uint64_t dp_dirty_total; 106193219Srwatson uint64_t dp_mos_used_delta; 107193219Srwatson uint64_t dp_mos_compressed_delta; 108193219Srwatson uint64_t dp_mos_uncompressed_delta; 109193219Srwatson 110139442Srwatson /* 11111819Sjulian * Time of most recently scheduled (furthest in the future) 112139442Srwatson * wakeup for delayed transactions. 113139442Srwatson */ 114139442Srwatson hrtime_t dp_last_wakeup; 115139442Srwatson 116139442Srwatson /* Has its own locking */ 11711819Sjulian tx_state_t dp_tx; 11825652Sjhay txg_list_t dp_dirty_datasets; 11925652Sjhay txg_list_t dp_dirty_zilogs; 12011819Sjulian txg_list_t dp_dirty_dirs; 121139444Srwatson txg_list_t dp_sync_tasks; 122139444Srwatson 123139444Srwatson /* 124139925Srwatson * Protects administrative changes (properties, namespace) 125139444Srwatson * 126139444Srwatson * It is only held for write in syncing context. Therefore 12711819Sjulian * syncing context does not need to ever have it for read, since 128193219Srwatson * nobody else could possibly have it for write. 129193219Srwatson */ 130193219Srwatson rrwlock_t dp_config_rwlock; 131193219Srwatson 132193219Srwatson zfs_all_blkstats_t *dp_blkstats; 133193219Srwatson} dsl_pool_t; 13411819Sjulian 135139930Srwatsonint dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp); 13611819Sjulianint dsl_pool_open(dsl_pool_t *dp); 13711819Sjulianvoid dsl_pool_close(dsl_pool_t *dp); 13811819Sjuliandsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg); 13911819Sjulianvoid dsl_pool_sync(dsl_pool_t *dp, uint64_t txg); 14011819Sjulianvoid dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg); 14111819Sjulianint dsl_pool_sync_context(dsl_pool_t *dp); 142169463Srwatsonuint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree); 14311819Sjulianuint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree); 14411819Sjulianvoid dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx); 14535060Sphkvoid dsl_pool_undirty_space(dsl_pool_t *dp, int64_t space, uint64_t txg); 14611819Sjulianvoid dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp); 147139444Srwatsonvoid dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg, 148139444Srwatson const blkptr_t *bpp); 149194905Srwatsonvoid dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx); 150139444Srwatsonvoid dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx); 151139925Srwatsonvoid dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx); 152194608Srwatsonvoid dsl_pool_mos_diduse_space(dsl_pool_t *dp, 153139925Srwatson int64_t used, int64_t comp, int64_t uncomp); 15411819Sjulianvoid dsl_pool_config_enter(dsl_pool_t *dp, void *tag); 15511819Sjulianvoid dsl_pool_config_enter_prio(dsl_pool_t *dp, void *tag); 15611819Sjulianvoid dsl_pool_config_exit(dsl_pool_t *dp, void *tag); 15711819Sjulianboolean_t dsl_pool_config_held(dsl_pool_t *dp); 15811819Sjulianboolean_t dsl_pool_config_held_writer(dsl_pool_t *dp); 15911819Sjulianboolean_t dsl_pool_need_dirty_delay(dsl_pool_t *dp); 16057178Speter 161193219Srwatsontaskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp); 16211819Sjulian 16311819Sjulianint dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj, 16411819Sjulian const char *tag, uint64_t now, dmu_tx_t *tx); 16511819Sjulianint dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj, 16611819Sjulian const char *tag, dmu_tx_t *tx); 167111888Sjlemonvoid dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp); 168111888Sjlemonint dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **); 16911819Sjulianint dsl_pool_hold(const char *name, void *tag, dsl_pool_t **dp); 170169463Srwatsonvoid dsl_pool_rele(dsl_pool_t *dp, void *tag); 171169463Srwatson 17225652Sjhay#ifdef __cplusplus 173111888Sjlemon} 17411819Sjulian#endif 17511819Sjulian 17625652Sjhay#endif /* _SYS_DSL_POOL_H */ 17725652Sjhay