FreeBSD ZFS
The Zettabyte File System
|
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) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>. 00024 * All rights reserved. 00025 */ 00026 00027 #ifndef _SYS_DSL_DIR_H 00028 #define _SYS_DSL_DIR_H 00029 00030 #include <sys/dmu.h> 00031 #include <sys/dsl_pool.h> 00032 #include <sys/dsl_synctask.h> 00033 #include <sys/refcount.h> 00034 #include <sys/zfs_context.h> 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 struct dsl_dataset; 00041 00042 typedef enum dd_used { 00043 DD_USED_HEAD, 00044 DD_USED_SNAP, 00045 DD_USED_CHILD, 00046 DD_USED_CHILD_RSRV, 00047 DD_USED_REFRSRV, 00048 DD_USED_NUM 00049 } dd_used_t; 00050 00051 #define DD_FLAG_USED_BREAKDOWN (1<<0) 00052 00053 typedef struct dsl_dir_phys { 00054 uint64_t dd_creation_time; 00055 uint64_t dd_head_dataset_obj; 00056 uint64_t dd_parent_obj; 00057 uint64_t dd_origin_obj; 00058 uint64_t dd_child_dir_zapobj; 00063 uint64_t dd_used_bytes; 00064 uint64_t dd_compressed_bytes; 00065 uint64_t dd_uncompressed_bytes; 00067 uint64_t dd_quota; 00069 uint64_t dd_reserved; 00070 uint64_t dd_props_zapobj; 00071 uint64_t dd_deleg_zapobj; 00072 uint64_t dd_flags; 00073 uint64_t dd_used_breakdown[DD_USED_NUM]; 00074 uint64_t dd_clones; 00075 uint64_t dd_pad[13]; 00076 } dsl_dir_phys_t; 00077 00078 struct dsl_dir { 00082 uint64_t dd_object; 00083 dsl_dir_phys_t *dd_phys; 00084 dmu_buf_t *dd_dbuf; 00085 dsl_pool_t *dd_pool; 00086 00091 txg_node_t dd_dirty_link; 00092 00097 dsl_dir_t *dd_parent; 00098 00103 kmutex_t dd_lock; 00104 list_t dd_prop_cbs; 00105 timestruc_t dd_snap_cmtime; 00106 uint64_t dd_origin_txg; 00110 uint64_t dd_tempreserved[TXG_SIZE]; 00112 int64_t dd_space_towrite[TXG_SIZE]; 00113 00115 char dd_myname[MAXNAMELEN]; 00116 }; 00117 00118 void dsl_dir_close(dsl_dir_t *dd, void *tag); 00119 int dsl_dir_open(const char *name, void *tag, dsl_dir_t **, const char **tail); 00120 int dsl_dir_open_spa(spa_t *spa, const char *name, void *tag, dsl_dir_t **, 00121 const char **tailp); 00122 int dsl_dir_open_obj(dsl_pool_t *dp, uint64_t ddobj, 00123 const char *tail, void *tag, dsl_dir_t **); 00124 void dsl_dir_name(dsl_dir_t *dd, char *buf); 00125 int dsl_dir_namelen(dsl_dir_t *dd); 00126 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, 00127 const char *name, dmu_tx_t *tx); 00128 dsl_checkfunc_t dsl_dir_destroy_check; 00129 dsl_syncfunc_t dsl_dir_destroy_sync; 00130 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv); 00131 uint64_t dsl_dir_space_available(dsl_dir_t *dd, 00132 dsl_dir_t *ancestor, int64_t delta, int ondiskonly); 00133 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx); 00134 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx); 00135 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem, 00136 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep, 00137 dmu_tx_t *tx); 00138 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx); 00139 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx); 00140 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type, 00141 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx); 00142 void dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta, 00143 dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx); 00144 int dsl_dir_set_quota(const char *ddname, zprop_source_t source, 00145 uint64_t quota); 00146 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source, 00147 uint64_t reservation); 00148 int dsl_dir_rename(dsl_dir_t *dd, const char *newname, int flags); 00149 int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space); 00150 int dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx); 00151 boolean_t dsl_dir_is_clone(dsl_dir_t *dd); 00152 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds, 00153 uint64_t reservation, cred_t *cr, dmu_tx_t *tx); 00154 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd); 00155 timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd); 00156 00157 /* internal reserved dir name */ 00158 #define MOS_DIR_NAME "$MOS" 00159 #define ORIGIN_DIR_NAME "$ORIGIN" 00160 #define XLATION_DIR_NAME "$XLATION" 00161 #define FREE_DIR_NAME "$FREE" 00162 00163 #ifdef ZFS_DEBUG 00164 #define dprintf_dd(dd, fmt, ...) do { \ 00165 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \ 00166 char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \ 00167 KM_SLEEP); \ 00168 dsl_dir_name(dd, __ds_name); \ 00169 dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \ 00170 kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \ 00171 } \ 00172 _NOTE(CONSTCOND) } while (0) 00173 #else 00174 #define dprintf_dd(dd, fmt, ...) 00175 #endif 00176 00177 #ifdef __cplusplus 00178 } 00179 #endif 00180 00181 #endif /* _SYS_DSL_DIR_H */