author | Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM> |
Tue, 19 May 2009 11:19:21 +0530 | |
changeset 9653 | a70048a304d1 |
parent 9396 | f41cf682d0d3 |
child 9873 | 8ddc892eca6e |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
873
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
873
diff
changeset
|
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 |
/* |
|
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/dmu.h> |
|
27 |
#include <sys/dmu_impl.h> |
|
28 |
#include <sys/dbuf.h> |
|
29 |
#include <sys/dmu_tx.h> |
|
30 |
#include <sys/dmu_objset.h> |
|
31 |
#include <sys/dsl_dataset.h> /* for dsl_dataset_block_freeable() */ |
|
32 |
#include <sys/dsl_dir.h> /* for dsl_dir_tempreserve_*() */ |
|
33 |
#include <sys/dsl_pool.h> |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
34 |
#include <sys/zap_impl.h> /* for fzap_default_block_shift */ |
789 | 35 |
#include <sys/spa.h> |
36 |
#include <sys/zfs_context.h> |
|
37 |
||
1544 | 38 |
typedef void (*dmu_tx_hold_func_t)(dmu_tx_t *tx, struct dnode *dn, |
39 |
uint64_t arg1, uint64_t arg2); |
|
40 |
||
789 | 41 |
|
42 |
dmu_tx_t * |
|
2199 | 43 |
dmu_tx_create_dd(dsl_dir_t *dd) |
789 | 44 |
{ |
45 |
dmu_tx_t *tx = kmem_zalloc(sizeof (dmu_tx_t), KM_SLEEP); |
|
46 |
tx->tx_dir = dd; |
|
47 |
if (dd) |
|
48 |
tx->tx_pool = dd->dd_pool; |
|
49 |
list_create(&tx->tx_holds, sizeof (dmu_tx_hold_t), |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
50 |
offsetof(dmu_tx_hold_t, txh_node)); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
51 |
#ifdef ZFS_DEBUG |
789 | 52 |
refcount_create(&tx->tx_space_written); |
53 |
refcount_create(&tx->tx_space_freed); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
54 |
#endif |
789 | 55 |
return (tx); |
56 |
} |
|
57 |
||
58 |
dmu_tx_t * |
|
59 |
dmu_tx_create(objset_t *os) |
|
60 |
{ |
|
2199 | 61 |
dmu_tx_t *tx = dmu_tx_create_dd(os->os->os_dsl_dataset->ds_dir); |
789 | 62 |
tx->tx_objset = os; |
1544 | 63 |
tx->tx_lastsnap_txg = dsl_dataset_prev_snap_txg(os->os->os_dsl_dataset); |
789 | 64 |
return (tx); |
65 |
} |
|
66 |
||
67 |
dmu_tx_t * |
|
68 |
dmu_tx_create_assigned(struct dsl_pool *dp, uint64_t txg) |
|
69 |
{ |
|
2199 | 70 |
dmu_tx_t *tx = dmu_tx_create_dd(NULL); |
789 | 71 |
|
72 |
ASSERT3U(txg, <=, dp->dp_tx.tx_open_txg); |
|
73 |
tx->tx_pool = dp; |
|
74 |
tx->tx_txg = txg; |
|
75 |
tx->tx_anyobj = TRUE; |
|
76 |
||
77 |
return (tx); |
|
78 |
} |
|
79 |
||
80 |
int |
|
81 |
dmu_tx_is_syncing(dmu_tx_t *tx) |
|
82 |
{ |
|
83 |
return (tx->tx_anyobj); |
|
84 |
} |
|
85 |
||
86 |
int |
|
87 |
dmu_tx_private_ok(dmu_tx_t *tx) |
|
88 |
{ |
|
1544 | 89 |
return (tx->tx_anyobj); |
789 | 90 |
} |
91 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
92 |
static dmu_tx_hold_t * |
789 | 93 |
dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object, |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
94 |
enum dmu_tx_hold_type type, uint64_t arg1, uint64_t arg2) |
789 | 95 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
96 |
dmu_tx_hold_t *txh; |
789 | 97 |
dnode_t *dn = NULL; |
1544 | 98 |
int err; |
789 | 99 |
|
100 |
if (object != DMU_NEW_OBJECT) { |
|
1544 | 101 |
err = dnode_hold(os->os, object, tx, &dn); |
102 |
if (err) { |
|
103 |
tx->tx_err = err; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
104 |
return (NULL); |
1544 | 105 |
} |
789 | 106 |
|
1544 | 107 |
if (err == 0 && tx->tx_txg != 0) { |
789 | 108 |
mutex_enter(&dn->dn_mtx); |
109 |
/* |
|
110 |
* dn->dn_assigned_txg == tx->tx_txg doesn't pose a |
|
111 |
* problem, but there's no way for it to happen (for |
|
112 |
* now, at least). |
|
113 |
*/ |
|
114 |
ASSERT(dn->dn_assigned_txg == 0); |
|
115 |
dn->dn_assigned_txg = tx->tx_txg; |
|
116 |
(void) refcount_add(&dn->dn_tx_holds, tx); |
|
117 |
mutex_exit(&dn->dn_mtx); |
|
118 |
} |
|
119 |
} |
|
120 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
121 |
txh = kmem_zalloc(sizeof (dmu_tx_hold_t), KM_SLEEP); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
122 |
txh->txh_tx = tx; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
123 |
txh->txh_dnode = dn; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
124 |
#ifdef ZFS_DEBUG |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
125 |
txh->txh_type = type; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
126 |
txh->txh_arg1 = arg1; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
127 |
txh->txh_arg2 = arg2; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
128 |
#endif |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
129 |
list_insert_tail(&tx->tx_holds, txh); |
1544 | 130 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
131 |
return (txh); |
789 | 132 |
} |
133 |
||
134 |
void |
|
135 |
dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, uint64_t object) |
|
136 |
{ |
|
137 |
/* |
|
138 |
* If we're syncing, they can manipulate any object anyhow, and |
|
139 |
* the hold on the dnode_t can cause problems. |
|
140 |
*/ |
|
141 |
if (!dmu_tx_is_syncing(tx)) { |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
142 |
(void) dmu_tx_hold_object_impl(tx, os, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
143 |
object, THT_NEWOBJECT, 0, 0); |
789 | 144 |
} |
145 |
} |
|
146 |
||
1544 | 147 |
static int |
148 |
dmu_tx_check_ioerr(zio_t *zio, dnode_t *dn, int level, uint64_t blkid) |
|
149 |
{ |
|
150 |
int err; |
|
151 |
dmu_buf_impl_t *db; |
|
152 |
||
153 |
rw_enter(&dn->dn_struct_rwlock, RW_READER); |
|
154 |
db = dbuf_hold_level(dn, level, blkid, FTAG); |
|
155 |
rw_exit(&dn->dn_struct_rwlock); |
|
156 |
if (db == NULL) |
|
157 |
return (EIO); |
|
6245
1a2a7cfb9f26
6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents:
5765
diff
changeset
|
158 |
err = dbuf_read(db, zio, DB_RF_CANFAIL | DB_RF_NOPREFETCH); |
1544 | 159 |
dbuf_rele(db, FTAG); |
160 |
return (err); |
|
161 |
} |
|
162 |
||
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
163 |
static void |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
164 |
dmu_tx_count_indirects(dmu_tx_hold_t *txh, dmu_buf_impl_t *db, |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
165 |
boolean_t freeable, dmu_buf_impl_t **history) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
166 |
{ |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
167 |
int i = db->db_level + 1; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
168 |
dnode_t *dn = db->db_dnode; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
169 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
170 |
if (i >= dn->dn_nlevels) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
171 |
return; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
172 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
173 |
db = db->db_parent; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
174 |
if (db == NULL) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
175 |
uint64_t lvls = dn->dn_nlevels - i; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
176 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
177 |
txh->txh_space_towrite += lvls << dn->dn_indblkshift; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
178 |
return; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
179 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
180 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
181 |
if (db != history[i]) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
182 |
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
183 |
uint64_t space = 1ULL << dn->dn_indblkshift; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
184 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
185 |
freeable = (db->db_blkptr && (freeable || |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
186 |
dsl_dataset_block_freeable(ds, db->db_blkptr->blk_birth))); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
187 |
if (freeable) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
188 |
txh->txh_space_tooverwrite += space; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
189 |
else |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
190 |
txh->txh_space_towrite += space; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
191 |
if (db->db_blkptr) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
192 |
txh->txh_space_tounref += space; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
193 |
history[i] = db; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
194 |
dmu_tx_count_indirects(txh, db, freeable, history); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
195 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
196 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
197 |
|
789 | 198 |
/* ARGSUSED */ |
199 |
static void |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
200 |
dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len) |
789 | 201 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
202 |
dnode_t *dn = txh->txh_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
203 |
uint64_t start, end, i; |
789 | 204 |
int min_bs, max_bs, min_ibs, max_ibs, epbs, bits; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
205 |
int err = 0; |
789 | 206 |
|
207 |
if (len == 0) |
|
208 |
return; |
|
209 |
||
210 |
min_bs = SPA_MINBLOCKSHIFT; |
|
211 |
max_bs = SPA_MAXBLOCKSHIFT; |
|
212 |
min_ibs = DN_MIN_INDBLKSHIFT; |
|
213 |
max_ibs = DN_MAX_INDBLKSHIFT; |
|
214 |
||
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
215 |
if (dn) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
216 |
dmu_buf_impl_t *last[DN_MAX_LEVELS]; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
217 |
int nlvls = dn->dn_nlevels; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
218 |
int delta; |
1544 | 219 |
|
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
220 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
221 |
* For i/o error checking, read the first and last level-0 |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
222 |
* blocks (if they are not aligned), and all the level-1 blocks. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
223 |
*/ |
1544 | 224 |
if (dn->dn_maxblkid == 0) { |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
225 |
delta = dn->dn_datablksz; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
226 |
start = (off < dn->dn_datablksz) ? 0 : 1; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
227 |
end = (off+len <= dn->dn_datablksz) ? 0 : 1; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
228 |
if (start == 0 && (off > 0 || len < dn->dn_datablksz)) { |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
229 |
err = dmu_tx_check_ioerr(NULL, dn, 0, 0); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
230 |
if (err) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
231 |
goto out; |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
232 |
delta -= off; |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
233 |
} |
1544 | 234 |
} else { |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
235 |
zio_t *zio = zio_root(dn->dn_objset->os_spa, |
1544 | 236 |
NULL, NULL, ZIO_FLAG_CANFAIL); |
237 |
||
238 |
/* first level-0 block */ |
|
2082 | 239 |
start = off >> dn->dn_datablkshift; |
240 |
if (P2PHASE(off, dn->dn_datablksz) || |
|
241 |
len < dn->dn_datablksz) { |
|
242 |
err = dmu_tx_check_ioerr(zio, dn, 0, start); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
243 |
if (err) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
244 |
goto out; |
1544 | 245 |
} |
246 |
||
247 |
/* last level-0 block */ |
|
2082 | 248 |
end = (off+len-1) >> dn->dn_datablkshift; |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7754
diff
changeset
|
249 |
if (end != start && end <= dn->dn_maxblkid && |
2082 | 250 |
P2PHASE(off+len, dn->dn_datablksz)) { |
1544 | 251 |
err = dmu_tx_check_ioerr(zio, dn, 0, end); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
252 |
if (err) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
253 |
goto out; |
1544 | 254 |
} |
255 |
||
256 |
/* level-1 blocks */ |
|
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
257 |
if (nlvls > 1) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
258 |
int shft = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
259 |
for (i = (start>>shft)+1; i < end>>shft; i++) { |
1544 | 260 |
err = dmu_tx_check_ioerr(zio, dn, 1, i); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
261 |
if (err) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
262 |
goto out; |
1544 | 263 |
} |
264 |
} |
|
265 |
||
266 |
err = zio_wait(zio); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
267 |
if (err) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
268 |
goto out; |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
269 |
delta = P2NPHASE(off, dn->dn_datablksz); |
1544 | 270 |
} |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
271 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
272 |
if (dn->dn_maxblkid > 0) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
273 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
274 |
* The blocksize can't change, |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
275 |
* so we can make a more precise estimate. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
276 |
*/ |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
277 |
ASSERT(dn->dn_datablkshift != 0); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
278 |
min_bs = max_bs = dn->dn_datablkshift; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
279 |
min_ibs = max_ibs = dn->dn_indblkshift; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
280 |
} else if (dn->dn_indblkshift > max_ibs) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
281 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
282 |
* This ensures that if we reduce DN_MAX_INDBLKSHIFT, |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
283 |
* the code will still work correctly on older pools. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
284 |
*/ |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
285 |
min_ibs = max_ibs = dn->dn_indblkshift; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
286 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
287 |
|
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
288 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
289 |
* If this write is not off the end of the file |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
290 |
* we need to account for overwrites/unref. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
291 |
*/ |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
292 |
if (start <= dn->dn_maxblkid) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
293 |
bzero(last, sizeof (dmu_buf_impl_t *) * DN_MAX_LEVELS); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
294 |
while (start <= dn->dn_maxblkid) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
295 |
spa_t *spa = txh->txh_tx->tx_pool->dp_spa; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
296 |
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
297 |
dmu_buf_impl_t *db; |
1544 | 298 |
|
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
299 |
rw_enter(&dn->dn_struct_rwlock, RW_READER); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
300 |
db = dbuf_hold_level(dn, 0, start, FTAG); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
301 |
rw_exit(&dn->dn_struct_rwlock); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
302 |
if (db->db_blkptr && dsl_dataset_block_freeable(ds, |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
303 |
db->db_blkptr->blk_birth)) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
304 |
dprintf_bp(db->db_blkptr, "can free old%s", ""); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
305 |
txh->txh_space_tooverwrite += dn->dn_datablksz; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
306 |
txh->txh_space_tounref += dn->dn_datablksz; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
307 |
dmu_tx_count_indirects(txh, db, TRUE, last); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
308 |
} else { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
309 |
txh->txh_space_towrite += dn->dn_datablksz; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
310 |
if (db->db_blkptr) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
311 |
txh->txh_space_tounref += |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
312 |
bp_get_dasize(spa, db->db_blkptr); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
313 |
dmu_tx_count_indirects(txh, db, FALSE, last); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
314 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
315 |
dbuf_rele(db, FTAG); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
316 |
if (++start > end) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
317 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
318 |
* Account for new indirects appearing |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
319 |
* before this IO gets assigned into a txg. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
320 |
*/ |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
321 |
bits = 64 - min_bs; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
322 |
epbs = min_ibs - SPA_BLKPTRSHIFT; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
323 |
for (bits -= epbs * (nlvls - 1); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
324 |
bits >= 0; bits -= epbs) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
325 |
txh->txh_fudge += 1ULL << max_ibs; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
326 |
goto out; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
327 |
} |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
328 |
off += delta; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
329 |
if (len >= delta) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
330 |
len -= delta; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
331 |
delta = dn->dn_datablksz; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
332 |
} |
789 | 333 |
} |
334 |
||
335 |
/* |
|
336 |
* 'end' is the last thing we will access, not one past. |
|
337 |
* This way we won't overflow when accessing the last byte. |
|
338 |
*/ |
|
339 |
start = P2ALIGN(off, 1ULL << max_bs); |
|
340 |
end = P2ROUNDUP(off + len, 1ULL << max_bs) - 1; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
341 |
txh->txh_space_towrite += end - start + 1; |
789 | 342 |
|
343 |
start >>= min_bs; |
|
344 |
end >>= min_bs; |
|
345 |
||
346 |
epbs = min_ibs - SPA_BLKPTRSHIFT; |
|
347 |
||
348 |
/* |
|
349 |
* The object contains at most 2^(64 - min_bs) blocks, |
|
350 |
* and each indirect level maps 2^epbs. |
|
351 |
*/ |
|
352 |
for (bits = 64 - min_bs; bits >= 0; bits -= epbs) { |
|
353 |
start >>= epbs; |
|
354 |
end >>= epbs; |
|
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
355 |
ASSERT3U(end, >=, start); |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
356 |
txh->txh_space_towrite += (end - start + 1) << max_ibs; |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
357 |
if (start != 0) { |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
358 |
/* |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
359 |
* We also need a new blkid=0 indirect block |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
360 |
* to reference any existing file data. |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
361 |
*/ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
362 |
txh->txh_space_towrite += 1ULL << max_ibs; |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
363 |
} |
789 | 364 |
} |
365 |
||
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
366 |
out: |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
367 |
if (txh->txh_space_towrite + txh->txh_space_tooverwrite > |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
368 |
2 * DMU_MAX_ACCESS) |
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
369 |
err = EFBIG; |
789 | 370 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
371 |
if (err) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
372 |
txh->txh_tx->tx_err = err; |
789 | 373 |
} |
374 |
||
375 |
static void |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
376 |
dmu_tx_count_dnode(dmu_tx_hold_t *txh) |
789 | 377 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
378 |
dnode_t *dn = txh->txh_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
379 |
dnode_t *mdn = txh->txh_tx->tx_objset->os->os_meta_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
380 |
uint64_t space = mdn->dn_datablksz + |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
381 |
((mdn->dn_nlevels-1) << mdn->dn_indblkshift); |
789 | 382 |
|
383 |
if (dn && dn->dn_dbuf->db_blkptr && |
|
384 |
dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, |
|
1544 | 385 |
dn->dn_dbuf->db_blkptr->blk_birth)) { |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
386 |
txh->txh_space_tooverwrite += space; |
8768
dfecfdbb27ed
6775697 oracle crashes when overwriting after hitting quota on zfs
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7872
diff
changeset
|
387 |
txh->txh_space_tounref += space; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
388 |
} else { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
389 |
txh->txh_space_towrite += space; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
390 |
if (dn && dn->dn_dbuf->db_blkptr) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
391 |
txh->txh_space_tounref += space; |
789 | 392 |
} |
393 |
} |
|
394 |
||
395 |
void |
|
396 |
dmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len) |
|
397 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
398 |
dmu_tx_hold_t *txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
399 |
|
789 | 400 |
ASSERT(tx->tx_txg == 0); |
1544 | 401 |
ASSERT(len < DMU_MAX_ACCESS); |
1819 | 402 |
ASSERT(len == 0 || UINT64_MAX - off >= len - 1); |
789 | 403 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
404 |
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
405 |
object, THT_WRITE, off, len); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
406 |
if (txh == NULL) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
407 |
return; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
408 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
409 |
dmu_tx_count_write(txh, off, len); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
410 |
dmu_tx_count_dnode(txh); |
789 | 411 |
} |
412 |
||
413 |
static void |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
414 |
dmu_tx_count_free(dmu_tx_hold_t *txh, uint64_t off, uint64_t len) |
789 | 415 |
{ |
6992 | 416 |
uint64_t blkid, nblks, lastblk; |
417 |
uint64_t space = 0, unref = 0, skipped = 0; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
418 |
dnode_t *dn = txh->txh_dnode; |
789 | 419 |
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
420 |
spa_t *spa = txh->txh_tx->tx_pool->dp_spa; |
6992 | 421 |
int epbs; |
789 | 422 |
|
6992 | 423 |
if (dn->dn_nlevels == 0) |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
424 |
return; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
425 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
426 |
/* |
6992 | 427 |
* The struct_rwlock protects us against dn_nlevels |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
428 |
* changing, in case (against all odds) we manage to dirty & |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
429 |
* sync out the changes after we check for being dirty. |
6992 | 430 |
* Also, dbuf_hold_level() wants us to have the struct_rwlock. |
789 | 431 |
*/ |
432 |
rw_enter(&dn->dn_struct_rwlock, RW_READER); |
|
6992 | 433 |
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
434 |
if (dn->dn_maxblkid == 0) { |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
435 |
if (off == 0 && len >= dn->dn_datablksz) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
436 |
blkid = 0; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
437 |
nblks = 1; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
438 |
} else { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
439 |
rw_exit(&dn->dn_struct_rwlock); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
440 |
return; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
441 |
} |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
442 |
} else { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
443 |
blkid = off >> dn->dn_datablkshift; |
6992 | 444 |
nblks = (len + dn->dn_datablksz - 1) >> dn->dn_datablkshift; |
789 | 445 |
|
6992 | 446 |
if (blkid >= dn->dn_maxblkid) { |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
447 |
rw_exit(&dn->dn_struct_rwlock); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
448 |
return; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
449 |
} |
6992 | 450 |
if (blkid + nblks > dn->dn_maxblkid) |
451 |
nblks = dn->dn_maxblkid - blkid; |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
452 |
|
1544 | 453 |
} |
6992 | 454 |
if (dn->dn_nlevels == 1) { |
789 | 455 |
int i; |
456 |
for (i = 0; i < nblks; i++) { |
|
457 |
blkptr_t *bp = dn->dn_phys->dn_blkptr; |
|
6992 | 458 |
ASSERT3U(blkid + i, <, dn->dn_nblkptr); |
789 | 459 |
bp += blkid + i; |
1544 | 460 |
if (dsl_dataset_block_freeable(ds, bp->blk_birth)) { |
789 | 461 |
dprintf_bp(bp, "can free old%s", ""); |
2082 | 462 |
space += bp_get_dasize(spa, bp); |
789 | 463 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
464 |
unref += BP_GET_ASIZE(bp); |
789 | 465 |
} |
1544 | 466 |
nblks = 0; |
789 | 467 |
} |
468 |
||
6992 | 469 |
/* |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
470 |
* Add in memory requirements of higher-level indirects. |
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
471 |
* This assumes a worst-possible scenario for dn_nlevels. |
6992 | 472 |
*/ |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
473 |
{ |
6992 | 474 |
uint64_t blkcnt = 1 + ((nblks >> epbs) >> epbs); |
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
475 |
int level = (dn->dn_nlevels > 1) ? 2 : 1; |
6992 | 476 |
|
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
477 |
while (level++ < DN_MAX_LEVELS) { |
6992 | 478 |
txh->txh_memory_tohold += blkcnt << dn->dn_indblkshift; |
479 |
blkcnt = 1 + (blkcnt >> epbs); |
|
480 |
} |
|
481 |
ASSERT(blkcnt <= dn->dn_nblkptr); |
|
482 |
} |
|
483 |
||
484 |
lastblk = blkid + nblks - 1; |
|
789 | 485 |
while (nblks) { |
486 |
dmu_buf_impl_t *dbuf; |
|
6992 | 487 |
uint64_t ibyte, new_blkid; |
488 |
int epb = 1 << epbs; |
|
489 |
int err, i, blkoff, tochk; |
|
490 |
blkptr_t *bp; |
|
789 | 491 |
|
6992 | 492 |
ibyte = blkid << dn->dn_datablkshift; |
493 |
err = dnode_next_offset(dn, |
|
494 |
DNODE_FIND_HAVELOCK, &ibyte, 2, 1, 0); |
|
495 |
new_blkid = ibyte >> dn->dn_datablkshift; |
|
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
496 |
if (err == ESRCH) { |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
497 |
skipped += (lastblk >> epbs) - (blkid >> epbs) + 1; |
6992 | 498 |
break; |
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
499 |
} |
6992 | 500 |
if (err) { |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
501 |
txh->txh_tx->tx_err = err; |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
502 |
break; |
789 | 503 |
} |
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
504 |
if (new_blkid > lastblk) { |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
505 |
skipped += (lastblk >> epbs) - (blkid >> epbs) + 1; |
6992 | 506 |
break; |
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
507 |
} |
6992 | 508 |
|
509 |
if (new_blkid > blkid) { |
|
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
510 |
ASSERT((new_blkid >> epbs) > (blkid >> epbs)); |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
511 |
skipped += (new_blkid >> epbs) - (blkid >> epbs) - 1; |
6992 | 512 |
nblks -= new_blkid - blkid; |
513 |
blkid = new_blkid; |
|
514 |
} |
|
515 |
blkoff = P2PHASE(blkid, epb); |
|
516 |
tochk = MIN(epb - blkoff, nblks); |
|
517 |
||
518 |
dbuf = dbuf_hold_level(dn, 1, blkid >> epbs, FTAG); |
|
519 |
||
520 |
txh->txh_memory_tohold += dbuf->db.db_size; |
|
521 |
if (txh->txh_memory_tohold > DMU_MAX_ACCESS) { |
|
522 |
txh->txh_tx->tx_err = E2BIG; |
|
523 |
dbuf_rele(dbuf, FTAG); |
|
524 |
break; |
|
525 |
} |
|
526 |
err = dbuf_read(dbuf, NULL, DB_RF_HAVESTRUCT | DB_RF_CANFAIL); |
|
527 |
if (err != 0) { |
|
528 |
txh->txh_tx->tx_err = err; |
|
529 |
dbuf_rele(dbuf, FTAG); |
|
530 |
break; |
|
531 |
} |
|
532 |
||
533 |
bp = dbuf->db.db_data; |
|
534 |
bp += blkoff; |
|
535 |
||
536 |
for (i = 0; i < tochk; i++) { |
|
537 |
if (dsl_dataset_block_freeable(ds, bp[i].blk_birth)) { |
|
538 |
dprintf_bp(&bp[i], "can free old%s", ""); |
|
539 |
space += bp_get_dasize(spa, &bp[i]); |
|
540 |
} |
|
541 |
unref += BP_GET_ASIZE(bp); |
|
542 |
} |
|
543 |
dbuf_rele(dbuf, FTAG); |
|
789 | 544 |
|
545 |
blkid += tochk; |
|
546 |
nblks -= tochk; |
|
547 |
} |
|
548 |
rw_exit(&dn->dn_struct_rwlock); |
|
549 |
||
6992 | 550 |
/* account for new level 1 indirect blocks that might show up */ |
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7016
diff
changeset
|
551 |
if (skipped > 0) { |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
552 |
txh->txh_fudge += skipped << dn->dn_indblkshift; |
6992 | 553 |
skipped = MIN(skipped, DMU_MAX_DELETEBLKCNT >> epbs); |
554 |
txh->txh_memory_tohold += skipped << dn->dn_indblkshift; |
|
555 |
} |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
556 |
txh->txh_space_tofree += space; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
557 |
txh->txh_space_tounref += unref; |
789 | 558 |
} |
559 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
560 |
void |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
561 |
dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len) |
789 | 562 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
563 |
dmu_tx_hold_t *txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
564 |
dnode_t *dn; |
1544 | 565 |
uint64_t start, end, i; |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
566 |
int err, shift; |
1544 | 567 |
zio_t *zio; |
789 | 568 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
569 |
ASSERT(tx->tx_txg == 0); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
570 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
571 |
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
572 |
object, THT_FREE, off, len); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
573 |
if (txh == NULL) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
574 |
return; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
575 |
dn = txh->txh_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
576 |
|
789 | 577 |
/* first block */ |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
578 |
if (off != 0) |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
579 |
dmu_tx_count_write(txh, off, 1); |
789 | 580 |
/* last block */ |
581 |
if (len != DMU_OBJECT_END) |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
582 |
dmu_tx_count_write(txh, off+len, 1); |
789 | 583 |
|
584 |
if (off >= (dn->dn_maxblkid+1) * dn->dn_datablksz) |
|
585 |
return; |
|
586 |
if (len == DMU_OBJECT_END) |
|
587 |
len = (dn->dn_maxblkid+1) * dn->dn_datablksz - off; |
|
588 |
||
1544 | 589 |
/* |
590 |
* For i/o error checking, read the first and last level-0 |
|
591 |
* blocks, and all the level-1 blocks. The above count_write's |
|
6992 | 592 |
* have already taken care of the level-0 blocks. |
1544 | 593 |
*/ |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
594 |
if (dn->dn_nlevels > 1) { |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
595 |
shift = dn->dn_datablkshift + dn->dn_indblkshift - |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
596 |
SPA_BLKPTRSHIFT; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
597 |
start = off >> shift; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
598 |
end = dn->dn_datablkshift ? ((off+len) >> shift) : 0; |
1544 | 599 |
|
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
600 |
zio = zio_root(tx->tx_pool->dp_spa, |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
601 |
NULL, NULL, ZIO_FLAG_CANFAIL); |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
602 |
for (i = start; i <= end; i++) { |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
603 |
uint64_t ibyte = i << shift; |
6992 | 604 |
err = dnode_next_offset(dn, 0, &ibyte, 2, 1, 0); |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
605 |
i = ibyte >> shift; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
606 |
if (err == ESRCH) |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
607 |
break; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
608 |
if (err) { |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
609 |
tx->tx_err = err; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
610 |
return; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
611 |
} |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
612 |
|
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
613 |
err = dmu_tx_check_ioerr(zio, dn, 1, i); |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
614 |
if (err) { |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
615 |
tx->tx_err = err; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
616 |
return; |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
617 |
} |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
618 |
} |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1758
diff
changeset
|
619 |
err = zio_wait(zio); |
1544 | 620 |
if (err) { |
621 |
tx->tx_err = err; |
|
622 |
return; |
|
623 |
} |
|
624 |
} |
|
625 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
626 |
dmu_tx_count_dnode(txh); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
627 |
dmu_tx_count_free(txh, off, len); |
789 | 628 |
} |
629 |
||
630 |
void |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8890
diff
changeset
|
631 |
dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name) |
789 | 632 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
633 |
dmu_tx_hold_t *txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
634 |
dnode_t *dn; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
635 |
uint64_t nblocks; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
636 |
int epbs, err; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
637 |
|
789 | 638 |
ASSERT(tx->tx_txg == 0); |
639 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
640 |
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
641 |
object, THT_ZAP, add, (uintptr_t)name); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
642 |
if (txh == NULL) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
643 |
return; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
644 |
dn = txh->txh_dnode; |
789 | 645 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
646 |
dmu_tx_count_dnode(txh); |
789 | 647 |
|
648 |
if (dn == NULL) { |
|
649 |
/* |
|
1544 | 650 |
* We will be able to fit a new object's entries into one leaf |
789 | 651 |
* block. So there will be at most 2 blocks total, |
652 |
* including the header block. |
|
653 |
*/ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
654 |
dmu_tx_count_write(txh, 0, 2 << fzap_default_block_shift); |
789 | 655 |
return; |
656 |
} |
|
657 |
||
658 |
ASSERT3P(dmu_ot[dn->dn_type].ot_byteswap, ==, zap_byteswap); |
|
659 |
||
1544 | 660 |
if (dn->dn_maxblkid == 0 && !add) { |
789 | 661 |
/* |
662 |
* If there is only one block (i.e. this is a micro-zap) |
|
1544 | 663 |
* and we are not adding anything, the accounting is simple. |
789 | 664 |
*/ |
1544 | 665 |
err = dmu_tx_check_ioerr(NULL, dn, 0, 0); |
666 |
if (err) { |
|
667 |
tx->tx_err = err; |
|
668 |
return; |
|
669 |
} |
|
670 |
||
3245
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
671 |
/* |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
672 |
* Use max block size here, since we don't know how much |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
673 |
* the size will change between now and the dbuf dirty call. |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
674 |
*/ |
789 | 675 |
if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
676 |
dn->dn_phys->dn_blkptr[0].blk_birth)) { |
3245
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
677 |
txh->txh_space_tooverwrite += SPA_MAXBLOCKSIZE; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
678 |
} else { |
3245
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3025
diff
changeset
|
679 |
txh->txh_space_towrite += SPA_MAXBLOCKSIZE; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
680 |
} |
8890
8c2bd5f17bf2
6798878 Unable to remove a file over NFS after hitting refquota limit
Chris Kirby <chris.kirby@sun.com>
parents:
8768
diff
changeset
|
681 |
if (dn->dn_phys->dn_blkptr[0].blk_birth) |
8c2bd5f17bf2
6798878 Unable to remove a file over NFS after hitting refquota limit
Chris Kirby <chris.kirby@sun.com>
parents:
8768
diff
changeset
|
682 |
txh->txh_space_tounref += SPA_MAXBLOCKSIZE; |
789 | 683 |
return; |
684 |
} |
|
685 |
||
1544 | 686 |
if (dn->dn_maxblkid > 0 && name) { |
687 |
/* |
|
688 |
* access the name in this fat-zap so that we'll check |
|
689 |
* for i/o errors to the leaf blocks, etc. |
|
690 |
*/ |
|
691 |
err = zap_lookup(&dn->dn_objset->os, dn->dn_object, name, |
|
692 |
8, 0, NULL); |
|
693 |
if (err == EIO) { |
|
694 |
tx->tx_err = err; |
|
695 |
return; |
|
696 |
} |
|
697 |
} |
|
698 |
||
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
699 |
err = zap_count_write(&dn->dn_objset->os, dn->dn_object, name, add, |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
700 |
&txh->txh_space_towrite, &txh->txh_space_tooverwrite, |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
701 |
txh->txh_dnode->dn_datablkshift); |
789 | 702 |
|
703 |
/* |
|
704 |
* If the modified blocks are scattered to the four winds, |
|
705 |
* we'll have to modify an indirect twig for each. |
|
706 |
*/ |
|
707 |
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
|
708 |
for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs) |
|
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
709 |
if (dn->dn_objset->os_dsl_dataset->ds_phys->ds_prev_snap_obj) |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
710 |
txh->txh_space_towrite += 3 << dn->dn_indblkshift; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
711 |
else |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
712 |
txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift; |
789 | 713 |
} |
714 |
||
715 |
void |
|
716 |
dmu_tx_hold_bonus(dmu_tx_t *tx, uint64_t object) |
|
717 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
718 |
dmu_tx_hold_t *txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
719 |
|
789 | 720 |
ASSERT(tx->tx_txg == 0); |
721 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
722 |
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
723 |
object, THT_BONUS, 0, 0); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
724 |
if (txh) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
725 |
dmu_tx_count_dnode(txh); |
789 | 726 |
} |
727 |
||
728 |
void |
|
729 |
dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space) |
|
730 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
731 |
dmu_tx_hold_t *txh; |
789 | 732 |
ASSERT(tx->tx_txg == 0); |
733 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
734 |
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
735 |
DMU_NEW_OBJECT, THT_SPACE, space, 0); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
736 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
737 |
txh->txh_space_towrite += space; |
789 | 738 |
} |
739 |
||
740 |
int |
|
741 |
dmu_tx_holds(dmu_tx_t *tx, uint64_t object) |
|
742 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
743 |
dmu_tx_hold_t *txh; |
789 | 744 |
int holds = 0; |
745 |
||
746 |
/* |
|
747 |
* By asserting that the tx is assigned, we're counting the |
|
748 |
* number of dn_tx_holds, which is the same as the number of |
|
749 |
* dn_holds. Otherwise, we'd be counting dn_holds, but |
|
750 |
* dn_tx_holds could be 0. |
|
751 |
*/ |
|
752 |
ASSERT(tx->tx_txg != 0); |
|
753 |
||
754 |
/* if (tx->tx_anyobj == TRUE) */ |
|
755 |
/* return (0); */ |
|
756 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
757 |
for (txh = list_head(&tx->tx_holds); txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
758 |
txh = list_next(&tx->tx_holds, txh)) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
759 |
if (txh->txh_dnode && txh->txh_dnode->dn_object == object) |
789 | 760 |
holds++; |
761 |
} |
|
762 |
||
763 |
return (holds); |
|
764 |
} |
|
765 |
||
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
766 |
#ifdef ZFS_DEBUG |
789 | 767 |
void |
768 |
dmu_tx_dirty_buf(dmu_tx_t *tx, dmu_buf_impl_t *db) |
|
769 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
770 |
dmu_tx_hold_t *txh; |
789 | 771 |
int match_object = FALSE, match_offset = FALSE; |
772 |
dnode_t *dn = db->db_dnode; |
|
773 |
||
774 |
ASSERT(tx->tx_txg != 0); |
|
775 |
ASSERT(tx->tx_objset == NULL || dn->dn_objset == tx->tx_objset->os); |
|
776 |
ASSERT3U(dn->dn_object, ==, db->db.db_object); |
|
777 |
||
778 |
if (tx->tx_anyobj) |
|
779 |
return; |
|
780 |
||
781 |
/* XXX No checking on the meta dnode for now */ |
|
1544 | 782 |
if (db->db.db_object == DMU_META_DNODE_OBJECT) |
789 | 783 |
return; |
784 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
785 |
for (txh = list_head(&tx->tx_holds); txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
786 |
txh = list_next(&tx->tx_holds, txh)) { |
789 | 787 |
ASSERT(dn == NULL || dn->dn_assigned_txg == tx->tx_txg); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
788 |
if (txh->txh_dnode == dn && txh->txh_type != THT_NEWOBJECT) |
789 | 789 |
match_object = TRUE; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
790 |
if (txh->txh_dnode == NULL || txh->txh_dnode == dn) { |
789 | 791 |
int datablkshift = dn->dn_datablkshift ? |
792 |
dn->dn_datablkshift : SPA_MAXBLOCKSHIFT; |
|
793 |
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
|
794 |
int shift = datablkshift + epbs * db->db_level; |
|
795 |
uint64_t beginblk = shift >= 64 ? 0 : |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
796 |
(txh->txh_arg1 >> shift); |
789 | 797 |
uint64_t endblk = shift >= 64 ? 0 : |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
798 |
((txh->txh_arg1 + txh->txh_arg2 - 1) >> shift); |
789 | 799 |
uint64_t blkid = db->db_blkid; |
800 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
801 |
/* XXX txh_arg2 better not be zero... */ |
789 | 802 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
803 |
dprintf("found txh type %x beginblk=%llx endblk=%llx\n", |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
804 |
txh->txh_type, beginblk, endblk); |
789 | 805 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
806 |
switch (txh->txh_type) { |
789 | 807 |
case THT_WRITE: |
808 |
if (blkid >= beginblk && blkid <= endblk) |
|
809 |
match_offset = TRUE; |
|
810 |
/* |
|
811 |
* We will let this hold work for the bonus |
|
812 |
* buffer so that we don't need to hold it |
|
813 |
* when creating a new object. |
|
814 |
*/ |
|
815 |
if (blkid == DB_BONUS_BLKID) |
|
816 |
match_offset = TRUE; |
|
817 |
/* |
|
818 |
* They might have to increase nlevels, |
|
819 |
* thus dirtying the new TLIBs. Or the |
|
820 |
* might have to change the block size, |
|
821 |
* thus dirying the new lvl=0 blk=0. |
|
822 |
*/ |
|
823 |
if (blkid == 0) |
|
824 |
match_offset = TRUE; |
|
825 |
break; |
|
826 |
case THT_FREE: |
|
6992 | 827 |
/* |
828 |
* We will dirty all the level 1 blocks in |
|
829 |
* the free range and perhaps the first and |
|
830 |
* last level 0 block. |
|
831 |
*/ |
|
832 |
if (blkid >= beginblk && (blkid <= endblk || |
|
833 |
txh->txh_arg2 == DMU_OBJECT_END)) |
|
789 | 834 |
match_offset = TRUE; |
835 |
break; |
|
836 |
case THT_BONUS: |
|
837 |
if (blkid == DB_BONUS_BLKID) |
|
838 |
match_offset = TRUE; |
|
839 |
break; |
|
840 |
case THT_ZAP: |
|
841 |
match_offset = TRUE; |
|
842 |
break; |
|
843 |
case THT_NEWOBJECT: |
|
844 |
match_object = TRUE; |
|
845 |
break; |
|
846 |
default: |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
847 |
ASSERT(!"bad txh_type"); |
789 | 848 |
} |
849 |
} |
|
850 |
if (match_object && match_offset) |
|
851 |
return; |
|
852 |
} |
|
853 |
panic("dirtying dbuf obj=%llx lvl=%u blkid=%llx but not tx_held\n", |
|
854 |
(u_longlong_t)db->db.db_object, db->db_level, |
|
855 |
(u_longlong_t)db->db_blkid); |
|
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
856 |
} |
789 | 857 |
#endif |
858 |
||
859 |
static int |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
860 |
dmu_tx_try_assign(dmu_tx_t *tx, uint64_t txg_how) |
789 | 861 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
862 |
dmu_tx_hold_t *txh; |
5329 | 863 |
spa_t *spa = tx->tx_pool->dp_spa; |
6992 | 864 |
uint64_t memory, asize, fsize, usize; |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
865 |
uint64_t towrite, tofree, tooverwrite, tounref, tohold, fudge; |
789 | 866 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
867 |
ASSERT3U(tx->tx_txg, ==, 0); |
5329 | 868 |
|
1544 | 869 |
if (tx->tx_err) |
870 |
return (tx->tx_err); |
|
789 | 871 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7161
diff
changeset
|
872 |
if (spa_suspended(spa)) { |
5329 | 873 |
/* |
874 |
* If the user has indicated a blocking failure mode |
|
875 |
* then return ERESTART which will block in dmu_tx_wait(). |
|
876 |
* Otherwise, return EIO so that an error can get |
|
877 |
* propagated back to the VOP calls. |
|
878 |
* |
|
879 |
* Note that we always honor the txg_how flag regardless |
|
880 |
* of the failuremode setting. |
|
881 |
*/ |
|
882 |
if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE && |
|
883 |
txg_how != TXG_WAIT) |
|
884 |
return (EIO); |
|
885 |
||
886 |
return (ERESTART); |
|
887 |
} |
|
888 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
889 |
tx->tx_txg = txg_hold_open(tx->tx_pool, &tx->tx_txgh); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
890 |
tx->tx_needassign_txh = NULL; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
891 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
892 |
/* |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
893 |
* NB: No error returns are allowed after txg_hold_open, but |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
894 |
* before processing the dnode holds, due to the |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
895 |
* dmu_tx_unassign() logic. |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
896 |
*/ |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
897 |
|
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
898 |
towrite = tofree = tooverwrite = tounref = tohold = fudge = 0; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
899 |
for (txh = list_head(&tx->tx_holds); txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
900 |
txh = list_next(&tx->tx_holds, txh)) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
901 |
dnode_t *dn = txh->txh_dnode; |
789 | 902 |
if (dn != NULL) { |
903 |
mutex_enter(&dn->dn_mtx); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
904 |
if (dn->dn_assigned_txg == tx->tx_txg - 1) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
905 |
mutex_exit(&dn->dn_mtx); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
906 |
tx->tx_needassign_txh = txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
907 |
return (ERESTART); |
789 | 908 |
} |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
909 |
if (dn->dn_assigned_txg == 0) |
789 | 910 |
dn->dn_assigned_txg = tx->tx_txg; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
911 |
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); |
789 | 912 |
(void) refcount_add(&dn->dn_tx_holds, tx); |
913 |
mutex_exit(&dn->dn_mtx); |
|
914 |
} |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
915 |
towrite += txh->txh_space_towrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
916 |
tofree += txh->txh_space_tofree; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
917 |
tooverwrite += txh->txh_space_tooverwrite; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
918 |
tounref += txh->txh_space_tounref; |
6992 | 919 |
tohold += txh->txh_memory_tohold; |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
920 |
fudge += txh->txh_fudge; |
1544 | 921 |
} |
922 |
||
923 |
/* |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
924 |
* NB: This check must be after we've held the dnodes, so that |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
925 |
* the dmu_tx_unassign() logic will work properly |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
926 |
*/ |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
927 |
if (txg_how >= TXG_INITIAL && txg_how != tx->tx_txg) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
928 |
return (ERESTART); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
929 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
930 |
/* |
1544 | 931 |
* If a snapshot has been taken since we made our estimates, |
932 |
* assume that we won't be able to free or overwrite anything. |
|
933 |
*/ |
|
934 |
if (tx->tx_objset && |
|
935 |
dsl_dataset_prev_snap_txg(tx->tx_objset->os->os_dsl_dataset) > |
|
936 |
tx->tx_lastsnap_txg) { |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
937 |
towrite += tooverwrite; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
938 |
tooverwrite = tofree = 0; |
789 | 939 |
} |
940 |
||
6992 | 941 |
/* needed allocation: worst-case estimate of write space */ |
942 |
asize = spa_get_asize(tx->tx_pool->dp_spa, towrite + tooverwrite); |
|
943 |
/* freed space estimate: worst-case overwrite + free estimate */ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
944 |
fsize = spa_get_asize(tx->tx_pool->dp_spa, tooverwrite) + tofree; |
6992 | 945 |
/* convert unrefd space to worst-case estimate */ |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
946 |
usize = spa_get_asize(tx->tx_pool->dp_spa, tounref); |
6992 | 947 |
/* calculate memory footprint estimate */ |
948 |
memory = towrite + tooverwrite + tohold; |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
949 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
950 |
#ifdef ZFS_DEBUG |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
951 |
/* |
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
952 |
* Add in 'tohold' to account for our dirty holds on this memory |
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
953 |
* XXX - the "fudge" factor is to account for skipped blocks that |
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
954 |
* we missed because dnode_next_offset() misses in-core-only blocks. |
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
955 |
*/ |
6992 | 956 |
tx->tx_space_towrite = asize + |
7016
8b85f8b0129c
6721941 dmu_tx_count_free() does not account for nlevels increasing
maybee
parents:
6992
diff
changeset
|
957 |
spa_get_asize(tx->tx_pool->dp_spa, tohold + fudge); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
958 |
tx->tx_space_tofree = tofree; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
959 |
tx->tx_space_tooverwrite = tooverwrite; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5329
diff
changeset
|
960 |
tx->tx_space_tounref = tounref; |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
961 |
#endif |
789 | 962 |
|
963 |
if (tx->tx_dir && asize != 0) { |
|
6992 | 964 |
int err = dsl_dir_tempreserve_space(tx->tx_dir, memory, |
965 |
asize, fsize, usize, &tx->tx_tempreserve_cookie, tx); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
966 |
if (err) |
789 | 967 |
return (err); |
968 |
} |
|
969 |
||
970 |
return (0); |
|
971 |
} |
|
972 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
973 |
static void |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
974 |
dmu_tx_unassign(dmu_tx_t *tx) |
789 | 975 |
{ |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
976 |
dmu_tx_hold_t *txh; |
789 | 977 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
978 |
if (tx->tx_txg == 0) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
979 |
return; |
789 | 980 |
|
981 |
txg_rele_to_quiesce(&tx->tx_txgh); |
|
982 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
983 |
for (txh = list_head(&tx->tx_holds); txh != tx->tx_needassign_txh; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
984 |
txh = list_next(&tx->tx_holds, txh)) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
985 |
dnode_t *dn = txh->txh_dnode; |
789 | 986 |
|
987 |
if (dn == NULL) |
|
988 |
continue; |
|
989 |
mutex_enter(&dn->dn_mtx); |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
990 |
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); |
789 | 991 |
|
992 |
if (refcount_remove(&dn->dn_tx_holds, tx) == 0) { |
|
993 |
dn->dn_assigned_txg = 0; |
|
994 |
cv_broadcast(&dn->dn_notxholds); |
|
995 |
} |
|
996 |
mutex_exit(&dn->dn_mtx); |
|
997 |
} |
|
998 |
||
999 |
txg_rele_to_sync(&tx->tx_txgh); |
|
1000 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1001 |
tx->tx_lasttried_txg = tx->tx_txg; |
789 | 1002 |
tx->tx_txg = 0; |
1003 |
} |
|
1004 |
||
1005 |
/* |
|
1006 |
* Assign tx to a transaction group. txg_how can be one of: |
|
1007 |
* |
|
1008 |
* (1) TXG_WAIT. If the current open txg is full, waits until there's |
|
1009 |
* a new one. This should be used when you're not holding locks. |
|
1010 |
* If will only fail if we're truly out of space (or over quota). |
|
1011 |
* |
|
1012 |
* (2) TXG_NOWAIT. If we can't assign into the current open txg without |
|
1013 |
* blocking, returns immediately with ERESTART. This should be used |
|
1014 |
* whenever you're holding locks. On an ERESTART error, the caller |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1015 |
* should drop locks, do a dmu_tx_wait(tx), and try again. |
789 | 1016 |
* |
1017 |
* (3) A specific txg. Use this if you need to ensure that multiple |
|
1018 |
* transactions all sync in the same txg. Like TXG_NOWAIT, it |
|
1019 |
* returns ERESTART if it can't assign you into the requested txg. |
|
1020 |
*/ |
|
1021 |
int |
|
1022 |
dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how) |
|
1023 |
{ |
|
1024 |
int err; |
|
1025 |
||
1026 |
ASSERT(tx->tx_txg == 0); |
|
1027 |
ASSERT(txg_how != 0); |
|
1028 |
ASSERT(!dsl_pool_sync_context(tx->tx_pool)); |
|
1029 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1030 |
while ((err = dmu_tx_try_assign(tx, txg_how)) != 0) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1031 |
dmu_tx_unassign(tx); |
789 | 1032 |
|
1033 |
if (err != ERESTART || txg_how != TXG_WAIT) |
|
1034 |
return (err); |
|
1035 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1036 |
dmu_tx_wait(tx); |
789 | 1037 |
} |
1038 |
||
1039 |
txg_rele_to_quiesce(&tx->tx_txgh); |
|
1040 |
||
1041 |
return (0); |
|
1042 |
} |
|
1043 |
||
1044 |
void |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1045 |
dmu_tx_wait(dmu_tx_t *tx) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1046 |
{ |
5329 | 1047 |
spa_t *spa = tx->tx_pool->dp_spa; |
1048 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1049 |
ASSERT(tx->tx_txg == 0); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1050 |
|
5329 | 1051 |
/* |
1052 |
* It's possible that the pool has become active after this thread |
|
1053 |
* has tried to obtain a tx. If that's the case then his |
|
1054 |
* tx_lasttried_txg would not have been assigned. |
|
1055 |
*/ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7161
diff
changeset
|
1056 |
if (spa_suspended(spa) || tx->tx_lasttried_txg == 0) { |
5329 | 1057 |
txg_wait_synced(tx->tx_pool, spa_last_synced_txg(spa) + 1); |
1058 |
} else if (tx->tx_needassign_txh) { |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1059 |
dnode_t *dn = tx->tx_needassign_txh->txh_dnode; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1060 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1061 |
mutex_enter(&dn->dn_mtx); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1062 |
while (dn->dn_assigned_txg == tx->tx_lasttried_txg - 1) |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1063 |
cv_wait(&dn->dn_notxholds, &dn->dn_mtx); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1064 |
mutex_exit(&dn->dn_mtx); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1065 |
tx->tx_needassign_txh = NULL; |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1066 |
} else { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1067 |
txg_wait_open(tx->tx_pool, tx->tx_lasttried_txg + 1); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1068 |
} |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1069 |
} |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1070 |
|
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1071 |
void |
789 | 1072 |
dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta) |
1073 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1074 |
#ifdef ZFS_DEBUG |
789 | 1075 |
if (tx->tx_dir == NULL || delta == 0) |
1076 |
return; |
|
1077 |
||
1078 |
if (delta > 0) { |
|
1079 |
ASSERT3U(refcount_count(&tx->tx_space_written) + delta, <=, |
|
1080 |
tx->tx_space_towrite); |
|
1081 |
(void) refcount_add_many(&tx->tx_space_written, delta, NULL); |
|
1082 |
} else { |
|
1083 |
(void) refcount_add_many(&tx->tx_space_freed, -delta, NULL); |
|
1084 |
} |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1085 |
#endif |
789 | 1086 |
} |
1087 |
||
1088 |
void |
|
1089 |
dmu_tx_commit(dmu_tx_t *tx) |
|
1090 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1091 |
dmu_tx_hold_t *txh; |
789 | 1092 |
|
1093 |
ASSERT(tx->tx_txg != 0); |
|
1094 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1095 |
while (txh = list_head(&tx->tx_holds)) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1096 |
dnode_t *dn = txh->txh_dnode; |
789 | 1097 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1098 |
list_remove(&tx->tx_holds, txh); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1099 |
kmem_free(txh, sizeof (dmu_tx_hold_t)); |
789 | 1100 |
if (dn == NULL) |
1101 |
continue; |
|
1102 |
mutex_enter(&dn->dn_mtx); |
|
1103 |
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); |
|
1104 |
||
1105 |
if (refcount_remove(&dn->dn_tx_holds, tx) == 0) { |
|
1106 |
dn->dn_assigned_txg = 0; |
|
1107 |
cv_broadcast(&dn->dn_notxholds); |
|
1108 |
} |
|
1109 |
mutex_exit(&dn->dn_mtx); |
|
1110 |
dnode_rele(dn, tx); |
|
1111 |
} |
|
1112 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1113 |
if (tx->tx_tempreserve_cookie) |
789 | 1114 |
dsl_dir_tempreserve_clear(tx->tx_tempreserve_cookie, tx); |
1115 |
||
1116 |
if (tx->tx_anyobj == FALSE) |
|
1117 |
txg_rele_to_sync(&tx->tx_txgh); |
|
5765
86c482ef4a34
6646545 Condvars in tx_cpu aren't being initialized/destroyed
ek110237
parents:
5378
diff
changeset
|
1118 |
list_destroy(&tx->tx_holds); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1119 |
#ifdef ZFS_DEBUG |
789 | 1120 |
dprintf("towrite=%llu written=%llu tofree=%llu freed=%llu\n", |
1121 |
tx->tx_space_towrite, refcount_count(&tx->tx_space_written), |
|
1122 |
tx->tx_space_tofree, refcount_count(&tx->tx_space_freed)); |
|
1123 |
refcount_destroy_many(&tx->tx_space_written, |
|
1124 |
refcount_count(&tx->tx_space_written)); |
|
1125 |
refcount_destroy_many(&tx->tx_space_freed, |
|
1126 |
refcount_count(&tx->tx_space_freed)); |
|
1127 |
#endif |
|
1128 |
kmem_free(tx, sizeof (dmu_tx_t)); |
|
1129 |
} |
|
1130 |
||
1131 |
void |
|
1132 |
dmu_tx_abort(dmu_tx_t *tx) |
|
1133 |
{ |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1134 |
dmu_tx_hold_t *txh; |
789 | 1135 |
|
1136 |
ASSERT(tx->tx_txg == 0); |
|
1137 |
||
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1138 |
while (txh = list_head(&tx->tx_holds)) { |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1139 |
dnode_t *dn = txh->txh_dnode; |
789 | 1140 |
|
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1141 |
list_remove(&tx->tx_holds, txh); |
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1142 |
kmem_free(txh, sizeof (dmu_tx_hold_t)); |
789 | 1143 |
if (dn != NULL) |
1144 |
dnode_rele(dn, tx); |
|
1145 |
} |
|
5765
86c482ef4a34
6646545 Condvars in tx_cpu aren't being initialized/destroyed
ek110237
parents:
5378
diff
changeset
|
1146 |
list_destroy(&tx->tx_holds); |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
2082
diff
changeset
|
1147 |
#ifdef ZFS_DEBUG |
789 | 1148 |
refcount_destroy_many(&tx->tx_space_written, |
1149 |
refcount_count(&tx->tx_space_written)); |
|
1150 |
refcount_destroy_many(&tx->tx_space_freed, |
|
1151 |
refcount_count(&tx->tx_space_freed)); |
|
1152 |
#endif |
|
1153 |
kmem_free(tx, sizeof (dmu_tx_t)); |
|
1154 |
} |
|
1155 |
||
1156 |
uint64_t |
|
1157 |
dmu_tx_get_txg(dmu_tx_t *tx) |
|
1158 |
{ |
|
1159 |
ASSERT(tx->tx_txg != 0); |
|
1160 |
return (tx->tx_txg); |
|
1161 |
} |