dsl_pool.h revision 3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
3113f7cee6785cfe8d9e78c535cf9e2a79283275George Wilson * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifndef _SYS_DSL_POOL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define _SYS_DSL_POOL_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/spa.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/txg.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/txg_impl.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zfs_context.h>
088f389458728c464569a5506b58070254fa4f7dahrens#include <sys/zio.h>
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens#include <sys/dnode.h>
bbfd46c40e81c7d954cec28db66453ec5ab44613Jeff Bonwick#include <sys/ddt.h>
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling#include <sys/arc.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstruct objset;
fa9e4066f08beec538e775443c5be79dd423fcabahrensstruct dsl_dir;
088f389458728c464569a5506b58070254fa4f7dahrensstruct dsl_dataset;
088f389458728c464569a5506b58070254fa4f7dahrensstruct dsl_pool;
088f389458728c464569a5506b58070254fa4f7dahrensstruct dmu_tx;
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingstruct dsl_scan;
088f389458728c464569a5506b58070254fa4f7dahrens
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens/* These macros are for indexing into the zfs_all_blkstats_t. */
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens#define DMU_OT_DEFERRED DMU_OT_NONE
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens#define DMU_OT_TOTAL DMU_OT_NUMTYPES
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrenstypedef struct zfs_blkstat {
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_count;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_asize;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_lsize;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_psize;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_gangs;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_ditto_2_of_2_samevdev;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_ditto_2_of_3_samevdev;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens uint64_t zb_ditto_3_of_3_samevdev;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens} zfs_blkstat_t;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrenstypedef struct zfs_all_blkstats {
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens zfs_blkstat_t zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1];
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens} zfs_all_blkstats_t;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct dsl_pool {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Immutable */
fa9e4066f08beec538e775443c5be79dd423fcabahrens spa_t *dp_spa;
fa9e4066f08beec538e775443c5be79dd423fcabahrens struct objset *dp_meta_objset;
fa9e4066f08beec538e775443c5be79dd423fcabahrens struct dsl_dir *dp_root_dir;
fa9e4066f08beec538e775443c5be79dd423fcabahrens struct dsl_dir *dp_mos_dir;
088f389458728c464569a5506b58070254fa4f7dahrens struct dsl_dataset *dp_origin_snap;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t dp_root_dir_obj;
9d3574bff0b382b89dd380c1e23d742ebc156772Neil Perrin struct taskq *dp_vnrele_taskq;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* No lock needed - sync context only */
fa9e4066f08beec538e775443c5be79dd423fcabahrens blkptr_t dp_meta_rootbp;
3cb34c601f3ef3016f638574f5982e80c3735c71ahrens list_t dp_synced_datasets;
05715f945c5c007fc4bb6a4e7cf4a749c9b30038Mark Maybee hrtime_t dp_read_overhead;
fb5dd802b9c6917629172c7c7fade7ee9d39cd71Lin Ling uint64_t dp_throughput; /* bytes per millisec */
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee uint64_t dp_write_limit;
ca45db4129beff691dc46576c328149443788af2Chris Kirby uint64_t dp_tmp_userrefs_obj;
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling struct dsl_scan *dp_scan;
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee /* Uses dp_lock */
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee kmutex_t dp_lock;
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee uint64_t dp_space_towrite[TXG_SIZE];
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybee uint64_t dp_tempreserved[TXG_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Has its own locking */
fa9e4066f08beec538e775443c5be79dd423fcabahrens tx_state_t dp_tx;
fa9e4066f08beec538e775443c5be79dd423fcabahrens txg_list_t dp_dirty_datasets;
fa9e4066f08beec538e775443c5be79dd423fcabahrens txg_list_t dp_dirty_dirs;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens txg_list_t dp_sync_tasks;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Protects administrative changes (properties, namespace)
fa9e4066f08beec538e775443c5be79dd423fcabahrens * It is only held for write in syncing context. Therefore
fa9e4066f08beec538e775443c5be79dd423fcabahrens * syncing context does not need to ever have it for read, since
fa9e4066f08beec538e775443c5be79dd423fcabahrens * nobody else could possibly have it for write.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens krwlock_t dp_config_rwlock;
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens
88b7b0f29b20b808b9e06071885b1d6a3ddb6328Matthew Ahrens zfs_all_blkstats_t *dp_blkstats;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} dsl_pool_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockint dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid dsl_pool_close(dsl_pool_t *dp);
0a48a24e663a04e34e2ed4e55390ad96f178dbeatimhdsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickvoid dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
fa9e4066f08beec538e775443c5be79dd423fcabahrensint dsl_pool_sync_context(dsl_pool_t *dp);
fa9e4066f08beec538e775443c5be79dd423fcabahrensuint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
468c413a79615e77179e8d98f22a7e513a8135bdTim Haleyuint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree);
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybeeint dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx);
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybeevoid dsl_pool_tempreserve_clear(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybeevoid dsl_pool_memory_pressure(dsl_pool_t *dp);
1ab7f2ded02e7a1bc3c73516eb27efa79bf2a2ffmaybeevoid dsl_pool_willuse_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickvoid dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
3113f7cee6785cfe8d9e78c535cf9e2a79283275George Wilsonvoid dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg,
3113f7cee6785cfe8d9e78c535cf9e2a79283275George Wilson const blkptr_t *bpp);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint dsl_read(zio_t *pio, spa_t *spa, const blkptr_t *bpp, arc_buf_t *pbuf,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling arc_done_func_t *done, void *private, int priority, int zio_flags,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling uint32_t *arc_flags, const zbookmark_t *zb);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint dsl_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bpp,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling arc_done_func_t *done, void *private, int priority, int zio_flags,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling uint32_t *arc_flags, const zbookmark_t *zb);
088f389458728c464569a5506b58070254fa4f7dahrensvoid dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrensvoid dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrens
9d3574bff0b382b89dd380c1e23d742ebc156772Neil Perrintaskq_t *dsl_pool_vnrele_taskq(dsl_pool_t *dp);
9d3574bff0b382b89dd380c1e23d742ebc156772Neil Perrin
ca45db4129beff691dc46576c328149443788af2Chris Kirbyextern int dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj,
15508ac067f2fb55a439711838b971c02d42316fChris Kirby const char *tag, uint64_t *now, dmu_tx_t *tx);
ca45db4129beff691dc46576c328149443788af2Chris Kirbyextern int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj,
ca45db4129beff691dc46576c328149443788af2Chris Kirby const char *tag, dmu_tx_t *tx);
ca45db4129beff691dc46576c328149443788af2Chris Kirbyextern void dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **);
ca45db4129beff691dc46576c328149443788af2Chris Kirby
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _SYS_DSL_POOL_H */