2008-11-20 23:01:55 +03:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
2010-05-29 00:45:14 +04:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2012-12-14 03:24:15 +04:00
|
|
|
* Copyright (c) 2012 by Delphix. All rights reserved.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_DSL_POOL_H
|
|
|
|
#define _SYS_DSL_POOL_H
|
|
|
|
|
|
|
|
#include <sys/spa.h>
|
|
|
|
#include <sys/txg.h>
|
|
|
|
#include <sys/txg_impl.h>
|
|
|
|
#include <sys/zfs_context.h>
|
2008-12-03 23:09:06 +03:00
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/dnode.h>
|
2010-05-29 00:45:14 +04:00
|
|
|
#include <sys/ddt.h>
|
|
|
|
#include <sys/arc.h>
|
|
|
|
#include <sys/bpobj.h>
|
2012-12-14 03:24:15 +04:00
|
|
|
#include <sys/bptree.h>
|
2013-09-04 16:00:57 +04:00
|
|
|
#include <sys/rrwlock.h>
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-04-30 02:49:23 +04:00
|
|
|
extern int zfs_txg_synctime_ms;
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
struct objset;
|
|
|
|
struct dsl_dir;
|
2008-12-03 23:09:06 +03:00
|
|
|
struct dsl_dataset;
|
|
|
|
struct dsl_pool;
|
|
|
|
struct dmu_tx;
|
2010-05-29 00:45:14 +04:00
|
|
|
struct dsl_scan;
|
2008-12-03 23:09:06 +03:00
|
|
|
|
|
|
|
/* These macros are for indexing into the zfs_all_blkstats_t. */
|
|
|
|
#define DMU_OT_DEFERRED DMU_OT_NONE
|
2012-12-14 03:24:15 +04:00
|
|
|
#define DMU_OT_OTHER DMU_OT_NUMTYPES /* place holder for DMU_OT() types */
|
|
|
|
#define DMU_OT_TOTAL (DMU_OT_NUMTYPES + 1)
|
2008-12-03 23:09:06 +03:00
|
|
|
|
|
|
|
typedef struct zfs_blkstat {
|
|
|
|
uint64_t zb_count;
|
|
|
|
uint64_t zb_asize;
|
|
|
|
uint64_t zb_lsize;
|
|
|
|
uint64_t zb_psize;
|
|
|
|
uint64_t zb_gangs;
|
|
|
|
uint64_t zb_ditto_2_of_2_samevdev;
|
|
|
|
uint64_t zb_ditto_2_of_3_samevdev;
|
|
|
|
uint64_t zb_ditto_3_of_3_samevdev;
|
|
|
|
} zfs_blkstat_t;
|
|
|
|
|
|
|
|
typedef struct zfs_all_blkstats {
|
|
|
|
zfs_blkstat_t zab_type[DN_MAX_LEVELS + 1][DMU_OT_TOTAL + 1];
|
|
|
|
} zfs_all_blkstats_t;
|
|
|
|
|
2012-10-24 00:48:22 +04:00
|
|
|
typedef struct txg_history {
|
|
|
|
kstat_txg_t th_kstat;
|
|
|
|
vdev_stat_t th_vs1;
|
|
|
|
vdev_stat_t th_vs2;
|
|
|
|
kmutex_t th_lock;
|
|
|
|
list_node_t th_link;
|
|
|
|
} txg_history_t;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
typedef struct dsl_pool {
|
|
|
|
/* Immutable */
|
|
|
|
spa_t *dp_spa;
|
|
|
|
struct objset *dp_meta_objset;
|
|
|
|
struct dsl_dir *dp_root_dir;
|
|
|
|
struct dsl_dir *dp_mos_dir;
|
2010-05-29 00:45:14 +04:00
|
|
|
struct dsl_dir *dp_free_dir;
|
2008-12-03 23:09:06 +03:00
|
|
|
struct dsl_dataset *dp_origin_snap;
|
2008-11-20 23:01:55 +03:00
|
|
|
uint64_t dp_root_dir_obj;
|
2011-02-08 22:16:06 +03:00
|
|
|
struct taskq *dp_iput_taskq;
|
2012-10-24 00:48:22 +04:00
|
|
|
kstat_t *dp_txg_kstat;
|
2013-07-11 02:53:48 +04:00
|
|
|
kstat_t *dp_tx_assign_kstat;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/* No lock needed - sync context only */
|
|
|
|
blkptr_t dp_meta_rootbp;
|
2008-12-03 23:09:06 +03:00
|
|
|
hrtime_t dp_read_overhead;
|
2010-05-29 00:45:14 +04:00
|
|
|
uint64_t dp_throughput; /* bytes per millisec */
|
2008-11-20 23:01:55 +03:00
|
|
|
uint64_t dp_write_limit;
|
2010-05-29 00:45:14 +04:00
|
|
|
uint64_t dp_tmp_userrefs_obj;
|
|
|
|
bpobj_t dp_free_bpobj;
|
2012-12-14 03:24:15 +04:00
|
|
|
uint64_t dp_bptree_obj;
|
2012-12-24 03:57:14 +04:00
|
|
|
uint64_t dp_empty_bpobj;
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
struct dsl_scan *dp_scan;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/* Uses dp_lock */
|
|
|
|
kmutex_t dp_lock;
|
|
|
|
uint64_t dp_space_towrite[TXG_SIZE];
|
|
|
|
uint64_t dp_tempreserved[TXG_SIZE];
|
2012-12-15 04:13:40 +04:00
|
|
|
uint64_t dp_mos_used_delta;
|
|
|
|
uint64_t dp_mos_compressed_delta;
|
|
|
|
uint64_t dp_mos_uncompressed_delta;
|
2012-10-24 00:48:22 +04:00
|
|
|
uint64_t dp_txg_history_size;
|
|
|
|
list_t dp_txg_history;
|
2013-07-11 02:53:48 +04:00
|
|
|
uint64_t dp_tx_assign_size;
|
|
|
|
kstat_named_t *dp_tx_assign_buckets;
|
2012-10-24 00:48:22 +04:00
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/* Has its own locking */
|
|
|
|
tx_state_t dp_tx;
|
|
|
|
txg_list_t dp_dirty_datasets;
|
2012-12-15 04:13:40 +04:00
|
|
|
txg_list_t dp_dirty_zilogs;
|
2008-11-20 23:01:55 +03:00
|
|
|
txg_list_t dp_dirty_dirs;
|
|
|
|
txg_list_t dp_sync_tasks;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Protects administrative changes (properties, namespace)
|
|
|
|
* It is only held for write in syncing context. Therefore
|
|
|
|
* syncing context does not need to ever have it for read, since
|
|
|
|
* nobody else could possibly have it for write.
|
|
|
|
*/
|
2013-09-04 16:00:57 +04:00
|
|
|
rrwlock_t dp_config_rwlock;
|
2008-12-03 23:09:06 +03:00
|
|
|
|
|
|
|
zfs_all_blkstats_t *dp_blkstats;
|
2008-11-20 23:01:55 +03:00
|
|
|
} dsl_pool_t;
|
|
|
|
|
2012-12-14 03:24:15 +04:00
|
|
|
int dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
|
|
|
|
int dsl_pool_open(dsl_pool_t *dp);
|
2008-11-20 23:01:55 +03:00
|
|
|
void dsl_pool_close(dsl_pool_t *dp);
|
2008-12-03 23:09:06 +03:00
|
|
|
dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
|
2008-11-20 23:01:55 +03:00
|
|
|
void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
|
2010-05-29 00:45:14 +04:00
|
|
|
void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
|
2008-11-20 23:01:55 +03:00
|
|
|
int dsl_pool_sync_context(dsl_pool_t *dp);
|
|
|
|
uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
|
2010-05-29 00:45:14 +04:00
|
|
|
uint64_t dsl_pool_adjustedfree(dsl_pool_t *dp, boolean_t netfree);
|
2008-11-20 23:01:55 +03:00
|
|
|
int dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx);
|
|
|
|
void dsl_pool_tempreserve_clear(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
|
|
|
|
void dsl_pool_memory_pressure(dsl_pool_t *dp);
|
|
|
|
void dsl_pool_willuse_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
|
2010-05-29 00:45:14 +04:00
|
|
|
void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
|
|
|
|
void dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg,
|
|
|
|
const blkptr_t *bpp);
|
2008-12-03 23:09:06 +03:00
|
|
|
void dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx);
|
|
|
|
void dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx);
|
2010-05-29 00:45:14 +04:00
|
|
|
void dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx);
|
2012-12-15 04:13:40 +04:00
|
|
|
void dsl_pool_mos_diduse_space(dsl_pool_t *dp,
|
|
|
|
int64_t used, int64_t comp, int64_t uncomp);
|
2013-09-04 16:00:57 +04:00
|
|
|
void dsl_pool_config_enter(dsl_pool_t *dp, void *tag);
|
|
|
|
void dsl_pool_config_exit(dsl_pool_t *dp, void *tag);
|
|
|
|
boolean_t dsl_pool_config_held(dsl_pool_t *dp);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2011-02-08 22:16:06 +03:00
|
|
|
taskq_t *dsl_pool_iput_taskq(dsl_pool_t *dp);
|
2009-07-03 02:44:48 +04:00
|
|
|
|
2013-09-04 16:00:57 +04:00
|
|
|
int dsl_pool_user_hold(dsl_pool_t *dp, uint64_t dsobj,
|
|
|
|
const char *tag, uint64_t now, dmu_tx_t *tx);
|
|
|
|
int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj,
|
2010-05-29 00:45:14 +04:00
|
|
|
const char *tag, dmu_tx_t *tx);
|
2013-09-04 16:00:57 +04:00
|
|
|
void dsl_pool_clean_tmp_userrefs(dsl_pool_t *dp);
|
2010-05-29 00:45:14 +04:00
|
|
|
int dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **);
|
2013-09-04 16:00:57 +04:00
|
|
|
int dsl_pool_hold(const char *name, void *tag, dsl_pool_t **dp);
|
|
|
|
void dsl_pool_rele(dsl_pool_t *dp, void *tag);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2013-07-11 02:53:48 +04:00
|
|
|
void dsl_pool_tx_assign_add_usecs(dsl_pool_t *dp, uint64_t usecs);
|
|
|
|
|
2012-10-24 00:48:22 +04:00
|
|
|
txg_history_t *dsl_pool_txg_history_add(dsl_pool_t *dp, uint64_t txg);
|
|
|
|
txg_history_t *dsl_pool_txg_history_get(dsl_pool_t *dp, uint64_t txg);
|
|
|
|
void dsl_pool_txg_history_put(txg_history_t *th);
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_DSL_POOL_H */
|