FreeBSD ZFS
The Zettabyte File System

sys/dmu_tx.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 2010 Sun Microsystems, Inc.  All rights reserved.
00023  * Use is subject to license terms.
00024  */
00025 
00026 #ifndef _SYS_DMU_TX_H
00027 #define _SYS_DMU_TX_H
00028 
00029 #include <sys/dmu.h>
00030 #include <sys/txg.h>
00031 #include <sys/refcount.h>
00032 
00033 #ifdef  __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 struct dmu_buf_impl;
00038 struct dmu_tx_hold;
00039 struct dnode_link;
00040 struct dsl_pool;
00041 struct dnode;
00042 struct dsl_dir;
00043 
00048 struct dmu_tx {
00049         list_t tx_holds; 
00050         objset_t *tx_objset;
00051         struct dsl_dir *tx_dir;
00052         struct dsl_pool *tx_pool;
00053         uint64_t tx_txg;
00054         uint64_t tx_lastsnap_txg;
00055         uint64_t tx_lasttried_txg;
00056         txg_handle_t tx_txgh;
00057         void *tx_tempreserve_cookie;
00058         struct dmu_tx_hold *tx_needassign_txh;
00059         list_t tx_callbacks; 
00060         uint8_t tx_anyobj;
00061         int tx_err;
00062 #ifdef ZFS_DEBUG
00063         uint64_t tx_space_towrite;
00064         uint64_t tx_space_tofree;
00065         uint64_t tx_space_tooverwrite;
00066         uint64_t tx_space_tounref;
00067         refcount_t tx_space_written;
00068         refcount_t tx_space_freed;
00069 #endif
00070 };
00071 
00072 enum dmu_tx_hold_type {
00073         THT_NEWOBJECT,
00074         THT_WRITE,
00075         THT_BONUS,
00076         THT_FREE,
00077         THT_ZAP,
00078         THT_SPACE,
00079         THT_SPILL,
00080         THT_NUMTYPES
00081 };
00082 
00083 typedef struct dmu_tx_hold {
00084         dmu_tx_t *txh_tx;
00085         list_node_t txh_node;
00086         struct dnode *txh_dnode;
00087         uint64_t txh_space_towrite;
00088         uint64_t txh_space_tofree;
00089         uint64_t txh_space_tooverwrite;
00090         uint64_t txh_space_tounref;
00091         uint64_t txh_memory_tohold;
00092         uint64_t txh_fudge;
00093 #ifdef ZFS_DEBUG
00094         enum dmu_tx_hold_type txh_type;
00095         uint64_t txh_arg1;
00096         uint64_t txh_arg2;
00097 #endif
00098 } dmu_tx_hold_t;
00099 
00100 typedef struct dmu_tx_callback {
00101         list_node_t             dcb_node;    
00102         dmu_tx_callback_func_t  *dcb_func;   
00103         void                    *dcb_data;   
00104 } dmu_tx_callback_t;
00105 
00106 /*
00107  * These routines are defined in dmu.h, and are called by the user.
00108  */
00109 dmu_tx_t *dmu_tx_create(objset_t *dd);
00110 int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how);
00111 void dmu_tx_commit(dmu_tx_t *tx);
00112 void dmu_tx_abort(dmu_tx_t *tx);
00113 uint64_t dmu_tx_get_txg(dmu_tx_t *tx);
00114 void dmu_tx_wait(dmu_tx_t *tx);
00115 
00116 void dmu_tx_do_callbacks(list_t *cb_list, int error);
00117 
00118 /*
00119  * These routines are defined in dmu_spa.h, and are called by the SPA.
00120  */
00121 extern dmu_tx_t *dmu_tx_create_assigned(struct dsl_pool *dp, uint64_t txg);
00122 
00123 /*
00124  * These routines are only called by the DMU.
00125  */
00126 dmu_tx_t *dmu_tx_create_dd(dsl_dir_t *dd);
00127 int dmu_tx_is_syncing(dmu_tx_t *tx);
00128 int dmu_tx_private_ok(dmu_tx_t *tx);
00129 void dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, uint64_t object);
00130 void dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta);
00131 void dmu_tx_dirty_buf(dmu_tx_t *tx, struct dmu_buf_impl *db);
00132 int dmu_tx_holds(dmu_tx_t *tx, uint64_t object);
00133 void dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space);
00134 
00135 #ifdef ZFS_DEBUG
00136 #define DMU_TX_DIRTY_BUF(tx, db)        dmu_tx_dirty_buf(tx, db)
00137 #else
00138 #define DMU_TX_DIRTY_BUF(tx, db)
00139 #endif
00140 
00141 #ifdef  __cplusplus
00142 }
00143 #endif
00144 
00145 #endif  /* _SYS_DMU_TX_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines