author | ahrens |
Wed, 14 Jun 2006 23:16:39 -0700 | |
changeset 2199 | 712a788c2dfd |
parent 2113 | 0510bb40c993 |
child 5378 | 111aa1baa84a |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
1544 | 22 |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#ifndef _SYS_DMU_TX_H |
|
27 |
#define _SYS_DMU_TX_H |
|
28 |
||
29 |
#pragma ident "%Z%%M% %I% %E% SMI" |
|
30 |
||
31 |
#include <sys/inttypes.h> |
|
32 |
#include <sys/dmu.h> |
|
33 |
#include <sys/txg.h> |
|
34 |
#include <sys/refcount.h> |
|
35 |
||
36 |
#ifdef __cplusplus |
|
37 |
extern "C" { |
|
38 |
#endif |
|
39 |
||
40 |
struct dmu_buf_impl; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
41 |
struct dmu_tx_hold; |
789 | 42 |
struct dnode_link; |
43 |
struct dsl_pool; |
|
44 |
struct dnode; |
|
45 |
struct dsl_dir; |
|
46 |
||
47 |
struct dmu_tx { |
|
48 |
/* |
|
49 |
* No synchronization is needed because a tx can only be handled |
|
50 |
* by one thread. |
|
51 |
*/ |
|
52 |
list_t tx_holds; /* list of dmu_tx_hold_t */ |
|
53 |
objset_t *tx_objset; |
|
54 |
struct dsl_dir *tx_dir; |
|
55 |
struct dsl_pool *tx_pool; |
|
56 |
uint64_t tx_txg; |
|
1544 | 57 |
uint64_t tx_lastsnap_txg; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
58 |
uint64_t tx_lasttried_txg; |
789 | 59 |
txg_handle_t tx_txgh; |
60 |
void *tx_tempreserve_cookie; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
61 |
struct dmu_tx_hold *tx_needassign_txh; |
789 | 62 |
uint8_t tx_anyobj; |
1544 | 63 |
int tx_err; |
789 | 64 |
#ifdef ZFS_DEBUG |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
65 |
uint64_t tx_space_towrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
66 |
uint64_t tx_space_tofree; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
67 |
uint64_t tx_space_tooverwrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
68 |
refcount_t tx_space_written; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
69 |
refcount_t tx_space_freed; |
789 | 70 |
#endif |
71 |
}; |
|
72 |
||
73 |
enum dmu_tx_hold_type { |
|
74 |
THT_NEWOBJECT, |
|
75 |
THT_WRITE, |
|
76 |
THT_BONUS, |
|
77 |
THT_FREE, |
|
78 |
THT_ZAP, |
|
79 |
THT_SPACE, |
|
80 |
THT_NUMTYPES |
|
81 |
}; |
|
82 |
||
83 |
typedef struct dmu_tx_hold { |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
84 |
dmu_tx_t *txh_tx; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
85 |
list_node_t txh_node; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
86 |
struct dnode *txh_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
87 |
uint64_t txh_space_towrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
88 |
uint64_t txh_space_tofree; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
89 |
uint64_t txh_space_tooverwrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
90 |
#ifdef ZFS_DEBUG |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
91 |
enum dmu_tx_hold_type txh_type; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
92 |
uint64_t txh_arg1; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
93 |
uint64_t txh_arg2; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
94 |
#endif |
789 | 95 |
} dmu_tx_hold_t; |
96 |
||
97 |
||
98 |
/* |
|
99 |
* These routines are defined in dmu.h, and are called by the user. |
|
100 |
*/ |
|
101 |
dmu_tx_t *dmu_tx_create(objset_t *dd); |
|
102 |
int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how); |
|
103 |
void dmu_tx_commit(dmu_tx_t *tx); |
|
104 |
void dmu_tx_abort(dmu_tx_t *tx); |
|
105 |
uint64_t dmu_tx_get_txg(dmu_tx_t *tx); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1544
diff
changeset
|
106 |
void dmu_tx_wait(dmu_tx_t *tx); |
789 | 107 |
|
108 |
/* |
|
109 |
* These routines are defined in dmu_spa.h, and are called by the SPA. |
|
110 |
*/ |
|
111 |
extern dmu_tx_t *dmu_tx_create_assigned(struct dsl_pool *dp, uint64_t txg); |
|
112 |
||
113 |
/* |
|
114 |
* These routines are only called by the DMU. |
|
115 |
*/ |
|
2199 | 116 |
dmu_tx_t *dmu_tx_create_dd(dsl_dir_t *dd); |
789 | 117 |
int dmu_tx_is_syncing(dmu_tx_t *tx); |
118 |
int dmu_tx_private_ok(dmu_tx_t *tx); |
|
119 |
void dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, uint64_t object); |
|
120 |
void dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta); |
|
121 |
void dmu_tx_dirty_buf(dmu_tx_t *tx, struct dmu_buf_impl *db); |
|
122 |
int dmu_tx_holds(dmu_tx_t *tx, uint64_t object); |
|
123 |
void dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space); |
|
124 |
||
125 |
#ifdef ZFS_DEBUG |
|
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
126 |
#define DMU_TX_DIRTY_BUF(tx, db) dmu_tx_dirty_buf(tx, db) |
789 | 127 |
#else |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
128 |
#define DMU_TX_DIRTY_BUF(tx, db) |
789 | 129 |
#endif |
130 |
||
131 |
#ifdef __cplusplus |
|
132 |
} |
|
133 |
#endif |
|
134 |
||
135 |
#endif /* _SYS_DMU_TX_H */ |