dsl_dir.h revision 74e7dc986c89efca1f2e4451c7a572e05e4a6e4f
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _SYS_DSL_DIR_H
2N/A#define _SYS_DSL_DIR_H
2N/A
2N/A#include <sys/dmu.h>
2N/A#include <sys/dsl_pool.h>
2N/A#include <sys/dsl_synctask.h>
2N/A#include <sys/refcount.h>
2N/A#include <sys/zfs_context.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/Astruct dsl_dataset;
2N/A
2N/Atypedef enum dd_used {
2N/A DD_USED_HEAD,
2N/A DD_USED_SNAP,
2N/A DD_USED_CHILD,
2N/A DD_USED_CHILD_RSRV,
2N/A DD_USED_REFRSRV,
2N/A DD_USED_NUM
2N/A} dd_used_t;
2N/A
2N/A#define DD_FLAG_USED_BREAKDOWN (1<<0)
2N/A
2N/Atypedef struct dsl_dir_phys {
2N/A uint64_t dd_creation_time; /* not actually used */
2N/A uint64_t dd_head_dataset_obj;
2N/A uint64_t dd_parent_obj;
2N/A uint64_t dd_origin_obj;
2N/A uint64_t dd_child_dir_zapobj;
2N/A /*
2N/A * how much space our children are accounting for; for leaf
2N/A * datasets, == physical space used by fs + snaps
2N/A */
2N/A uint64_t dd_used_bytes;
2N/A uint64_t dd_compressed_bytes;
2N/A uint64_t dd_uncompressed_bytes;
2N/A /* Administrative quota setting */
2N/A uint64_t dd_quota;
2N/A /* Administrative reservation setting */
2N/A uint64_t dd_reserved;
2N/A uint64_t dd_props_zapobj;
2N/A uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
2N/A uint64_t dd_flags;
2N/A uint64_t dd_used_breakdown[DD_USED_NUM];
2N/A uint64_t dd_pad[14]; /* pad out to 256 bytes for good measure */
2N/A} dsl_dir_phys_t;
2N/A
2N/Astruct dsl_dir {
2N/A /* These are immutable; no lock needed: */
2N/A uint64_t dd_object;
2N/A dsl_dir_phys_t *dd_phys;
2N/A dmu_buf_t *dd_dbuf;
2N/A dsl_pool_t *dd_pool;
2N/A
2N/A /* protected by lock on pool's dp_dirty_dirs list */
2N/A txg_node_t dd_dirty_link;
2N/A
2N/A /* protected by dp_config_rwlock */
2N/A dsl_dir_t *dd_parent;
2N/A
2N/A /* Protected by dd_lock */
2N/A kmutex_t dd_lock;
2N/A list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
2N/A
2N/A /* gross estimate of space used by in-flight tx's */
2N/A uint64_t dd_tempreserved[TXG_SIZE];
2N/A /* amount of space we expect to write; == amount of dirty data */
2N/A int64_t dd_space_towrite[TXG_SIZE];
2N/A
2N/A /* protected by dd_lock; keep at end of struct for better locality */
2N/A char dd_myname[MAXNAMELEN];
2N/A};
2N/A
2N/Avoid dsl_dir_close(dsl_dir_t *dd, void *tag);
2N/Aint dsl_dir_open(const char *name, void *tag, dsl_dir_t **, const char **tail);
2N/Aint dsl_dir_open_spa(spa_t *spa, const char *name, void *tag, dsl_dir_t **,
2N/A const char **tailp);
2N/Aint dsl_dir_open_obj(dsl_pool_t *dp, uint64_t ddobj,
2N/A const char *tail, void *tag, dsl_dir_t **);
2N/Avoid dsl_dir_name(dsl_dir_t *dd, char *buf);
2N/Aint dsl_dir_namelen(dsl_dir_t *dd);
2N/Aint dsl_dir_is_private(dsl_dir_t *dd);
2N/Auint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
2N/A const char *name, dmu_tx_t *tx);
2N/Adsl_checkfunc_t dsl_dir_destroy_check;
2N/Adsl_syncfunc_t dsl_dir_destroy_sync;
2N/Avoid dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
2N/Auint64_t dsl_dir_space_available(dsl_dir_t *dd,
2N/A dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
2N/Avoid dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
2N/Avoid dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
2N/Aint dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
2N/A uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
2N/A dmu_tx_t *tx);
2N/Avoid dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
2N/Avoid dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
2N/Avoid dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
2N/A int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
2N/Avoid dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
2N/A dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx);
2N/Aint dsl_dir_set_quota(const char *ddname, uint64_t quota);
2N/Aint dsl_dir_set_reservation(const char *ddname, uint64_t reservation);
2N/Aint dsl_dir_rename(dsl_dir_t *dd, const char *newname);
2N/Aint dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space);
2N/Aint dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx);
2N/Aboolean_t dsl_dir_is_clone(dsl_dir_t *dd);
2N/A
2N/A/* internal reserved dir name */
2N/A#define MOS_DIR_NAME "$MOS"
2N/A#define ORIGIN_DIR_NAME "$ORIGIN"
2N/A
2N/A#ifdef ZFS_DEBUG
2N/A#define dprintf_dd(dd, fmt, ...) do { \
2N/A if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
2N/A char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
2N/A KM_SLEEP); \
2N/A dsl_dir_name(dd, __ds_name); \
2N/A dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
2N/A kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \
2N/A } \
2N/A_NOTE(CONSTCOND) } while (0)
2N/A#else
2N/A#define dprintf_dd(dd, fmt, ...)
2N/A#endif
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SYS_DSL_DIR_H */
2N/A