FreeBSD ZFS
The Zettabyte File System

sys/dsl_pool.h

Go to the documentation of this file.
00001 /*
00002  * CDDL HEADER START
00003  *
00004  * The contents of this file are subject to the terms of the
00005  * Common Development and Distribution License (the "License").
00006  * You may not use this file except in compliance with the License.
00007  *
00008  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
00009  * or http://www.opensolaris.org/os/licensing.
00010  * See the License for the specific language governing permissions
00011  * and limitations under the License.
00012  *
00013  * When distributing Covered Code, include this CDDL HEADER in each
00014  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
00015  * If applicable, add the following below this CDDL HEADER, with the
00016  * fields enclosed by brackets "[]" replaced with your own identifying
00017  * information: Portions Copyright [yyyy] [name of copyright owner]
00018  *
00019  * CDDL HEADER END
00020  */
00021 /*
00022  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
00023  * Copyright (c) 2012 by Delphix. All rights reserved.
00024  */
00025 
00026 #ifndef _SYS_DSL_POOL_H
00027 #define _SYS_DSL_POOL_H
00028 
00029 #include <sys/spa.h>
00030 #include <sys/txg.h>
00031 #include <sys/txg_impl.h>
00032 #include <sys/zfs_context.h>
00033 #include <sys/zio.h>
00034 #include <sys/dnode.h>
00035 #include <sys/ddt.h>
00036 #include <sys/arc.h>
00037 #include <sys/bpobj.h>
00038 #include <sys/bptree.h>
00039 
00040 #ifdef  __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 struct objset;
00045 struct dsl_dir;
00046 struct dsl_dataset;
00047 struct dsl_pool;
00048 struct dmu_tx;
00049 struct dsl_scan;
00050 
00051 /* For indexing into the zfs_all_blkstats_t. */
00052 #define DMU_OT_DEFERRED DMU_OT_NONE
00053 #define DMU_OT_OTHER    DMU_OT_NUMTYPES 
00054 #define DMU_OT_TOTAL    (DMU_OT_NUMTYPES + 1)
00055 
00056 typedef struct zfs_blkstat {
00057         uint64_t        zb_count;
00058         uint64_t        zb_asize;
00059         uint64_t        zb_lsize;
00060         uint64_t        zb_psize;
00061         uint64_t        zb_gangs;
00062         uint64_t        zb_ditto_2_of_2_samevdev;
00063         uint64_t        zb_ditto_2_of_3_samevdev;
00064         uint64_t        zb_ditto_3_of_3_samevdev;
00065 } zfs_blkstat_t;
00066 
00067 typedef struct zfs_all_blkstats {
00068         zfs_blkstat_t   zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1];
00069 } zfs_all_blkstats_t;
00070 
00071 
00072 typedef struct dsl_pool {
00076         spa_t *dp_spa;
00077         struct objset *dp_meta_objset;
00078         struct dsl_dir *dp_root_dir;
00079         struct dsl_dir *dp_mos_dir;
00080         struct dsl_dir *dp_free_dir;
00081         struct dsl_dataset *dp_origin_snap;
00082         uint64_t dp_root_dir_obj;
00083         struct taskq *dp_vnrele_taskq;
00084 
00090         blkptr_t dp_meta_rootbp;
00091         hrtime_t dp_read_overhead;
00092         uint64_t dp_throughput; 
00093         uint64_t dp_write_limit;
00094         uint64_t dp_tmp_userrefs_obj;
00095         bpobj_t dp_free_bpobj;
00096         uint64_t dp_bptree_obj;
00097         uint64_t dp_empty_bpobj;
00100         struct dsl_scan *dp_scan;
00101 
00105         kmutex_t dp_lock;
00106         uint64_t dp_space_towrite[TXG_SIZE];
00107         uint64_t dp_tempreserved[TXG_SIZE];
00108         uint64_t dp_mos_used_delta;
00109         uint64_t dp_mos_compressed_delta;
00110         uint64_t dp_mos_uncompressed_delta;
00111 
00116         tx_state_t dp_tx;
00117         txg_list_t dp_dirty_datasets;
00118         txg_list_t dp_dirty_zilogs;
00119         txg_list_t dp_dirty_dirs;
00120         txg_list_t dp_sync_tasks;
00121 
00130         krwlock_t dp_config_rwlock;
00131 
00132         zfs_all_blkstats_t *dp_blkstats;
00133 } dsl_pool_t;
00134 
00135 int dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
00136 int dsl_pool_open(dsl_pool_t *dp);
00137 void dsl_pool_close(dsl_pool_t *dp);
00138 dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
00139 void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
00140 void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
00141 int dsl_pool_sync_context(dsl_pool_t *dp);
00142 uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
00143 uint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree);
00144 int dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx);
00145 void dsl_pool_tempreserve_clear(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
00146 void dsl_pool_memory_pressure(dsl_pool_t *dp);
00147 void dsl_pool_willuse_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
00148 void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
00149 void dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg,
00150     const blkptr_t *bpp);
00151 int dsl_read(zio_t *pio, spa_t *spa, const blkptr_t *bpp, arc_buf_t *pbuf,
00152     arc_done_func_t *done, void *priv, int priority, int zio_flags,
00153     uint32_t *arc_flags, const zbookmark_t *zb);
00154 int dsl_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bpp,
00155     arc_done_func_t *done, void *priv, int priority, int zio_flags,
00156     uint32_t *arc_flags, const zbookmark_t *zb);
00157 void dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx);
00158 void dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx);
00159 void dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx);
00160 void dsl_pool_mos_diduse_space(dsl_pool_t *dp,
00161     int64_t used, int64_t comp, int64_t uncomp);
00162 
00163 taskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp);
00164 
00165 extern int dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj,
00166     const char *tag, uint64_t *now, dmu_tx_t *tx);
00167 extern int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj,
00168     const char *tag, dmu_tx_t *tx);
00169 extern void dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp);
00170 int dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **);
00171 
00172 #ifdef  __cplusplus
00173 }
00174 #endif
00175 
00176 #endif /* _SYS_DSL_POOL_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines