1168404Spjd/* 2168404Spjd * CDDL HEADER START 3168404Spjd * 4168404Spjd * The contents of this file are subject to the terms of the 5168404Spjd * Common Development and Distribution License (the "License"). 6168404Spjd * You may not use this file except in compliance with the License. 7168404Spjd * 8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9168404Spjd * or http://www.opensolaris.org/os/licensing. 10168404Spjd * See the License for the specific language governing permissions 11168404Spjd * and limitations under the License. 12168404Spjd * 13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each 14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15168404Spjd * If applicable, add the following below this CDDL HEADER, with the 16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying 17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner] 18168404Spjd * 19168404Spjd * CDDL HEADER END 20168404Spjd */ 21168404Spjd/* 22219089Spjd * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23260763Savg * Copyright (c) 2013 by Delphix. All rights reserved. 24168404Spjd */ 25168404Spjd 26168404Spjd#ifndef _SYS_DSL_POOL_H 27168404Spjd#define _SYS_DSL_POOL_H 28168404Spjd 29168404Spjd#include <sys/spa.h> 30168404Spjd#include <sys/txg.h> 31168404Spjd#include <sys/txg_impl.h> 32168404Spjd#include <sys/zfs_context.h> 33185029Spjd#include <sys/zio.h> 34208047Smm#include <sys/dnode.h> 35219089Spjd#include <sys/ddt.h> 36219089Spjd#include <sys/arc.h> 37219089Spjd#include <sys/bpobj.h> 38236884Smm#include <sys/bptree.h> 39248571Smm#include <sys/rrwlock.h> 40168404Spjd 41168404Spjd#ifdef __cplusplus 42168404Spjdextern "C" { 43168404Spjd#endif 44168404Spjd 45168404Spjdstruct objset; 46168404Spjdstruct dsl_dir; 47185029Spjdstruct dsl_dataset; 48185029Spjdstruct dsl_pool; 49185029Spjdstruct dmu_tx; 50219089Spjdstruct dsl_scan; 51168404Spjd 52260763Savgextern uint64_t zfs_dirty_data_max; 53260763Savgextern uint64_t zfs_dirty_data_max_max; 54260763Savgextern uint64_t zfs_dirty_data_sync; 55260763Savgextern int zfs_dirty_data_max_percent; 56260763Savgextern int zfs_delay_min_dirty_percent; 57260763Savgextern uint64_t zfs_delay_scale; 58260763Savg 59208047Smm/* These macros are for indexing into the zfs_all_blkstats_t. */ 60208047Smm#define DMU_OT_DEFERRED DMU_OT_NONE 61236884Smm#define DMU_OT_OTHER DMU_OT_NUMTYPES /* place holder for DMU_OT() types */ 62236884Smm#define DMU_OT_TOTAL (DMU_OT_NUMTYPES + 1) 63185029Spjd 64208047Smmtypedef struct zfs_blkstat { 65208047Smm uint64_t zb_count; 66208047Smm uint64_t zb_asize; 67208047Smm uint64_t zb_lsize; 68208047Smm uint64_t zb_psize; 69208047Smm uint64_t zb_gangs; 70208047Smm uint64_t zb_ditto_2_of_2_samevdev; 71208047Smm uint64_t zb_ditto_2_of_3_samevdev; 72208047Smm uint64_t zb_ditto_3_of_3_samevdev; 73208047Smm} zfs_blkstat_t; 74208047Smm 75208047Smmtypedef struct zfs_all_blkstats { 76208047Smm zfs_blkstat_t zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1]; 77208047Smm} zfs_all_blkstats_t; 78208047Smm 79208047Smm 80168404Spjdtypedef struct dsl_pool { 81168404Spjd /* Immutable */ 82168404Spjd spa_t *dp_spa; 83168404Spjd struct objset *dp_meta_objset; 84168404Spjd struct dsl_dir *dp_root_dir; 85168404Spjd struct dsl_dir *dp_mos_dir; 86219089Spjd struct dsl_dir *dp_free_dir; 87268650Sdelphij struct dsl_dir *dp_leak_dir; 88185029Spjd struct dsl_dataset *dp_origin_snap; 89168404Spjd uint64_t dp_root_dir_obj; 90196307Spjd struct taskq *dp_vnrele_taskq; 91168404Spjd 92168404Spjd /* No lock needed - sync context only */ 93168404Spjd blkptr_t dp_meta_rootbp; 94219089Spjd uint64_t dp_tmp_userrefs_obj; 95219089Spjd bpobj_t dp_free_bpobj; 96236884Smm uint64_t dp_bptree_obj; 97239774Smm uint64_t dp_empty_bpobj; 98168404Spjd 99219089Spjd struct dsl_scan *dp_scan; 100219089Spjd 101185029Spjd /* Uses dp_lock */ 102185029Spjd kmutex_t dp_lock; 103260763Savg kcondvar_t dp_spaceavail_cv; 104260763Savg uint64_t dp_dirty_pertxg[TXG_SIZE]; 105260763Savg uint64_t dp_dirty_total; 106239620Smm uint64_t dp_mos_used_delta; 107239620Smm uint64_t dp_mos_compressed_delta; 108239620Smm uint64_t dp_mos_uncompressed_delta; 109185029Spjd 110260763Savg /* 111260763Savg * Time of most recently scheduled (furthest in the future) 112260763Savg * wakeup for delayed transactions. 113260763Savg */ 114260763Savg hrtime_t dp_last_wakeup; 115260763Savg 116168404Spjd /* Has its own locking */ 117168404Spjd tx_state_t dp_tx; 118168404Spjd txg_list_t dp_dirty_datasets; 119239620Smm txg_list_t dp_dirty_zilogs; 120168404Spjd txg_list_t dp_dirty_dirs; 121168404Spjd txg_list_t dp_sync_tasks; 122168404Spjd 123168404Spjd /* 124168404Spjd * Protects administrative changes (properties, namespace) 125251631Sdelphij * 126168404Spjd * It is only held for write in syncing context. Therefore 127168404Spjd * syncing context does not need to ever have it for read, since 128168404Spjd * nobody else could possibly have it for write. 129168404Spjd */ 130248571Smm rrwlock_t dp_config_rwlock; 131208047Smm 132208047Smm zfs_all_blkstats_t *dp_blkstats; 133168404Spjd} dsl_pool_t; 134168404Spjd 135236884Smmint dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp); 136236884Smmint dsl_pool_open(dsl_pool_t *dp); 137168404Spjdvoid dsl_pool_close(dsl_pool_t *dp); 138185029Spjddsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg); 139168404Spjdvoid dsl_pool_sync(dsl_pool_t *dp, uint64_t txg); 140219089Spjdvoid dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg); 141168404Spjdint dsl_pool_sync_context(dsl_pool_t *dp); 142168404Spjduint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree); 143219089Spjduint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree); 144260763Savgvoid dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx); 145260763Savgvoid dsl_pool_undirty_space(dsl_pool_t *dp, int64_t space, uint64_t txg); 146219089Spjdvoid dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp); 147219089Spjdvoid dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg, 148219089Spjd const blkptr_t *bpp); 149185029Spjdvoid dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx); 150185029Spjdvoid dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx); 151219089Spjdvoid dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx); 152239620Smmvoid dsl_pool_mos_diduse_space(dsl_pool_t *dp, 153239620Smm int64_t used, int64_t comp, int64_t uncomp); 154248571Smmvoid dsl_pool_config_enter(dsl_pool_t *dp, void *tag); 155288570Smavvoid dsl_pool_config_enter_prio(dsl_pool_t *dp, void *tag); 156248571Smmvoid dsl_pool_config_exit(dsl_pool_t *dp, void *tag); 157248571Smmboolean_t dsl_pool_config_held(dsl_pool_t *dp); 158288569Smavboolean_t dsl_pool_config_held_writer(dsl_pool_t *dp); 159260763Savgboolean_t dsl_pool_need_dirty_delay(dsl_pool_t *dp); 160168404Spjd 161196307Spjdtaskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp); 162196307Spjd 163248571Smmint dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj, 164248571Smm const char *tag, uint64_t now, dmu_tx_t *tx); 165248571Smmint dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj, 166219089Spjd const char *tag, dmu_tx_t *tx); 167248571Smmvoid dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp); 168219089Spjdint dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **); 169248571Smmint dsl_pool_hold(const char *name, void *tag, dsl_pool_t **dp); 170248571Smmvoid dsl_pool_rele(dsl_pool_t *dp, void *tag); 171219089Spjd 172168404Spjd#ifdef __cplusplus 173168404Spjd} 174168404Spjd#endif 175168404Spjd 176168404Spjd#endif /* _SYS_DSL_POOL_H */ 177