author | Chris Kirby <Chris.Kirby@oracle.com> |
Thu, 10 Jun 2010 15:46:47 -0600 | |
changeset 12605 | 6790e683d5a5 |
parent 12587 | 16aef3d16470 |
child 12684 | 397e44ebb8a9 |
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:
1199
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
1199
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 |
/* |
|
12178
93ec1371f750
6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11935
diff
changeset
|
22 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
789 | 23 |
*/ |
24 |
||
25 |
#include <sys/zfs_context.h> |
|
26 |
#include <sys/dmu.h> |
|
27 |
#include <sys/dmu_impl.h> |
|
28 |
#include <sys/dbuf.h> |
|
29 |
#include <sys/dmu_objset.h> |
|
30 |
#include <sys/dsl_dataset.h> |
|
31 |
#include <sys/dsl_dir.h> |
|
32 |
#include <sys/dmu_tx.h> |
|
33 |
#include <sys/spa.h> |
|
34 |
#include <sys/zio.h> |
|
35 |
#include <sys/dmu_zfetch.h> |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
36 |
#include <sys/sa.h> |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
37 |
#include <sys/sa_impl.h> |
789 | 38 |
|
39 |
static void dbuf_destroy(dmu_buf_impl_t *db); |
|
40 |
static int dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
41 |
static void dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx); |
789 | 42 |
|
43 |
/* |
|
44 |
* Global data structures and functions for the dbuf cache. |
|
45 |
*/ |
|
46 |
static kmem_cache_t *dbuf_cache; |
|
47 |
||
48 |
/* ARGSUSED */ |
|
49 |
static int |
|
50 |
dbuf_cons(void *vdb, void *unused, int kmflag) |
|
51 |
{ |
|
52 |
dmu_buf_impl_t *db = vdb; |
|
53 |
bzero(db, sizeof (dmu_buf_impl_t)); |
|
54 |
||
55 |
mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL); |
|
56 |
cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL); |
|
57 |
refcount_create(&db->db_holds); |
|
58 |
return (0); |
|
59 |
} |
|
60 |
||
61 |
/* ARGSUSED */ |
|
62 |
static void |
|
63 |
dbuf_dest(void *vdb, void *unused) |
|
64 |
{ |
|
65 |
dmu_buf_impl_t *db = vdb; |
|
66 |
mutex_destroy(&db->db_mtx); |
|
67 |
cv_destroy(&db->db_changed); |
|
68 |
refcount_destroy(&db->db_holds); |
|
69 |
} |
|
70 |
||
71 |
/* |
|
72 |
* dbuf hash table routines |
|
73 |
*/ |
|
74 |
static dbuf_hash_table_t dbuf_hash_table; |
|
75 |
||
76 |
static uint64_t dbuf_hash_count; |
|
77 |
||
78 |
static uint64_t |
|
79 |
dbuf_hash(void *os, uint64_t obj, uint8_t lvl, uint64_t blkid) |
|
80 |
{ |
|
81 |
uintptr_t osv = (uintptr_t)os; |
|
82 |
uint64_t crc = -1ULL; |
|
83 |
||
84 |
ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY); |
|
85 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (lvl)) & 0xFF]; |
|
86 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (osv >> 6)) & 0xFF]; |
|
87 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 0)) & 0xFF]; |
|
88 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 8)) & 0xFF]; |
|
89 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (blkid >> 0)) & 0xFF]; |
|
90 |
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (blkid >> 8)) & 0xFF]; |
|
91 |
||
92 |
crc ^= (osv>>14) ^ (obj>>16) ^ (blkid>>16); |
|
93 |
||
94 |
return (crc); |
|
95 |
} |
|
96 |
||
97 |
#define DBUF_HASH(os, obj, level, blkid) dbuf_hash(os, obj, level, blkid); |
|
98 |
||
99 |
#define DBUF_EQUAL(dbuf, os, obj, level, blkid) \ |
|
100 |
((dbuf)->db.db_object == (obj) && \ |
|
101 |
(dbuf)->db_objset == (os) && \ |
|
102 |
(dbuf)->db_level == (level) && \ |
|
103 |
(dbuf)->db_blkid == (blkid)) |
|
104 |
||
105 |
dmu_buf_impl_t * |
|
106 |
dbuf_find(dnode_t *dn, uint8_t level, uint64_t blkid) |
|
107 |
{ |
|
108 |
dbuf_hash_table_t *h = &dbuf_hash_table; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
109 |
objset_t *os = dn->dn_objset; |
789 | 110 |
uint64_t obj = dn->dn_object; |
111 |
uint64_t hv = DBUF_HASH(os, obj, level, blkid); |
|
112 |
uint64_t idx = hv & h->hash_table_mask; |
|
113 |
dmu_buf_impl_t *db; |
|
114 |
||
115 |
mutex_enter(DBUF_HASH_MUTEX(h, idx)); |
|
116 |
for (db = h->hash_table[idx]; db != NULL; db = db->db_hash_next) { |
|
117 |
if (DBUF_EQUAL(db, os, obj, level, blkid)) { |
|
118 |
mutex_enter(&db->db_mtx); |
|
1544 | 119 |
if (db->db_state != DB_EVICTING) { |
789 | 120 |
mutex_exit(DBUF_HASH_MUTEX(h, idx)); |
121 |
return (db); |
|
122 |
} |
|
123 |
mutex_exit(&db->db_mtx); |
|
124 |
} |
|
125 |
} |
|
126 |
mutex_exit(DBUF_HASH_MUTEX(h, idx)); |
|
127 |
return (NULL); |
|
128 |
} |
|
129 |
||
130 |
/* |
|
131 |
* Insert an entry into the hash table. If there is already an element |
|
132 |
* equal to elem in the hash table, then the already existing element |
|
133 |
* will be returned and the new element will not be inserted. |
|
134 |
* Otherwise returns NULL. |
|
135 |
*/ |
|
136 |
static dmu_buf_impl_t * |
|
137 |
dbuf_hash_insert(dmu_buf_impl_t *db) |
|
138 |
{ |
|
139 |
dbuf_hash_table_t *h = &dbuf_hash_table; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
140 |
objset_t *os = db->db_objset; |
789 | 141 |
uint64_t obj = db->db.db_object; |
142 |
int level = db->db_level; |
|
143 |
uint64_t blkid = db->db_blkid; |
|
144 |
uint64_t hv = DBUF_HASH(os, obj, level, blkid); |
|
145 |
uint64_t idx = hv & h->hash_table_mask; |
|
146 |
dmu_buf_impl_t *dbf; |
|
147 |
||
148 |
mutex_enter(DBUF_HASH_MUTEX(h, idx)); |
|
149 |
for (dbf = h->hash_table[idx]; dbf != NULL; dbf = dbf->db_hash_next) { |
|
150 |
if (DBUF_EQUAL(dbf, os, obj, level, blkid)) { |
|
151 |
mutex_enter(&dbf->db_mtx); |
|
1544 | 152 |
if (dbf->db_state != DB_EVICTING) { |
789 | 153 |
mutex_exit(DBUF_HASH_MUTEX(h, idx)); |
154 |
return (dbf); |
|
155 |
} |
|
156 |
mutex_exit(&dbf->db_mtx); |
|
157 |
} |
|
158 |
} |
|
159 |
||
160 |
mutex_enter(&db->db_mtx); |
|
161 |
db->db_hash_next = h->hash_table[idx]; |
|
162 |
h->hash_table[idx] = db; |
|
163 |
mutex_exit(DBUF_HASH_MUTEX(h, idx)); |
|
164 |
atomic_add_64(&dbuf_hash_count, 1); |
|
165 |
||
166 |
return (NULL); |
|
167 |
} |
|
168 |
||
169 |
/* |
|
170 |
* Remove an entry from the hash table. This operation will |
|
171 |
* fail if there are any existing holds on the db. |
|
172 |
*/ |
|
173 |
static void |
|
174 |
dbuf_hash_remove(dmu_buf_impl_t *db) |
|
175 |
{ |
|
176 |
dbuf_hash_table_t *h = &dbuf_hash_table; |
|
177 |
uint64_t hv = DBUF_HASH(db->db_objset, db->db.db_object, |
|
178 |
db->db_level, db->db_blkid); |
|
179 |
uint64_t idx = hv & h->hash_table_mask; |
|
180 |
dmu_buf_impl_t *dbf, **dbp; |
|
181 |
||
182 |
/* |
|
183 |
* We musn't hold db_mtx to maintin lock ordering: |
|
184 |
* DBUF_HASH_MUTEX > db_mtx. |
|
185 |
*/ |
|
186 |
ASSERT(refcount_is_zero(&db->db_holds)); |
|
1544 | 187 |
ASSERT(db->db_state == DB_EVICTING); |
789 | 188 |
ASSERT(!MUTEX_HELD(&db->db_mtx)); |
189 |
||
190 |
mutex_enter(DBUF_HASH_MUTEX(h, idx)); |
|
191 |
dbp = &h->hash_table[idx]; |
|
192 |
while ((dbf = *dbp) != db) { |
|
193 |
dbp = &dbf->db_hash_next; |
|
194 |
ASSERT(dbf != NULL); |
|
195 |
} |
|
196 |
*dbp = db->db_hash_next; |
|
197 |
db->db_hash_next = NULL; |
|
198 |
mutex_exit(DBUF_HASH_MUTEX(h, idx)); |
|
199 |
atomic_add_64(&dbuf_hash_count, -1); |
|
200 |
} |
|
201 |
||
1544 | 202 |
static arc_evict_func_t dbuf_do_evict; |
789 | 203 |
|
204 |
static void |
|
205 |
dbuf_evict_user(dmu_buf_impl_t *db) |
|
206 |
{ |
|
207 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
208 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
209 |
if (db->db_level != 0 || db->db_evict_func == NULL) |
789 | 210 |
return; |
211 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
212 |
if (db->db_user_data_ptr_ptr) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
213 |
*db->db_user_data_ptr_ptr = db->db.db_data; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
214 |
db->db_evict_func(&db->db, db->db_user_ptr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
215 |
db->db_user_ptr = NULL; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
216 |
db->db_user_data_ptr_ptr = NULL; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
217 |
db->db_evict_func = NULL; |
789 | 218 |
} |
219 |
||
220 |
void |
|
1544 | 221 |
dbuf_evict(dmu_buf_impl_t *db) |
222 |
{ |
|
223 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
224 |
ASSERT(db->db_buf == NULL); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
225 |
ASSERT(db->db_data_pending == NULL); |
1544 | 226 |
|
227 |
dbuf_clear(db); |
|
228 |
dbuf_destroy(db); |
|
229 |
} |
|
230 |
||
231 |
void |
|
789 | 232 |
dbuf_init(void) |
233 |
{ |
|
1544 | 234 |
uint64_t hsize = 1ULL << 16; |
789 | 235 |
dbuf_hash_table_t *h = &dbuf_hash_table; |
236 |
int i; |
|
237 |
||
238 |
/* |
|
239 |
* The hash table is big enough to fill all of physical memory |
|
1544 | 240 |
* with an average 4K block size. The table will take up |
241 |
* totalmem*sizeof(void*)/4K (i.e. 2MB/GB with 8-byte pointers). |
|
789 | 242 |
*/ |
1544 | 243 |
while (hsize * 4096 < physmem * PAGESIZE) |
789 | 244 |
hsize <<= 1; |
245 |
||
1544 | 246 |
retry: |
789 | 247 |
h->hash_table_mask = hsize - 1; |
1544 | 248 |
h->hash_table = kmem_zalloc(hsize * sizeof (void *), KM_NOSLEEP); |
249 |
if (h->hash_table == NULL) { |
|
250 |
/* XXX - we should really return an error instead of assert */ |
|
251 |
ASSERT(hsize > (1ULL << 10)); |
|
252 |
hsize >>= 1; |
|
253 |
goto retry; |
|
254 |
} |
|
789 | 255 |
|
256 |
dbuf_cache = kmem_cache_create("dmu_buf_impl_t", |
|
257 |
sizeof (dmu_buf_impl_t), |
|
258 |
0, dbuf_cons, dbuf_dest, NULL, NULL, NULL, 0); |
|
259 |
||
260 |
for (i = 0; i < DBUF_MUTEXES; i++) |
|
261 |
mutex_init(&h->hash_mutexes[i], NULL, MUTEX_DEFAULT, NULL); |
|
262 |
} |
|
263 |
||
264 |
void |
|
265 |
dbuf_fini(void) |
|
266 |
{ |
|
267 |
dbuf_hash_table_t *h = &dbuf_hash_table; |
|
268 |
int i; |
|
269 |
||
270 |
for (i = 0; i < DBUF_MUTEXES; i++) |
|
271 |
mutex_destroy(&h->hash_mutexes[i]); |
|
272 |
kmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *)); |
|
273 |
kmem_cache_destroy(dbuf_cache); |
|
274 |
} |
|
275 |
||
276 |
/* |
|
277 |
* Other stuff. |
|
278 |
*/ |
|
279 |
||
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
280 |
#ifdef ZFS_DEBUG |
789 | 281 |
static void |
282 |
dbuf_verify(dmu_buf_impl_t *db) |
|
283 |
{ |
|
284 |
dnode_t *dn = db->db_dnode; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
285 |
dbuf_dirty_record_t *dr; |
789 | 286 |
|
287 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
288 |
||
289 |
if (!(zfs_flags & ZFS_DEBUG_DBUF_VERIFY)) |
|
290 |
return; |
|
291 |
||
292 |
ASSERT(db->db_objset != NULL); |
|
293 |
if (dn == NULL) { |
|
294 |
ASSERT(db->db_parent == NULL); |
|
295 |
ASSERT(db->db_blkptr == NULL); |
|
296 |
} else { |
|
297 |
ASSERT3U(db->db.db_object, ==, dn->dn_object); |
|
298 |
ASSERT3P(db->db_objset, ==, dn->dn_objset); |
|
299 |
ASSERT3U(db->db_level, <, dn->dn_nlevels); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
300 |
ASSERT(db->db_blkid == DMU_BONUS_BLKID || db->db_blkid == |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
301 |
DMU_SPILL_BLKID || list_head(&dn->dn_dbufs)); |
789 | 302 |
} |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
303 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
789 | 304 |
ASSERT(dn != NULL); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
305 |
ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
306 |
ASSERT3U(db->db.db_offset, ==, DMU_BONUS_BLKID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
307 |
} else if (db->db_blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
308 |
ASSERT(dn != NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
309 |
ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
310 |
ASSERT3U(db->db.db_offset, ==, 0); |
789 | 311 |
} else { |
312 |
ASSERT3U(db->db.db_offset, ==, db->db_blkid * db->db.db_size); |
|
313 |
} |
|
314 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
315 |
for (dr = db->db_data_pending; dr != NULL; dr = dr->dr_next) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
316 |
ASSERT(dr->dr_dbuf == db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
317 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
318 |
for (dr = db->db_last_dirty; dr != NULL; dr = dr->dr_next) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
319 |
ASSERT(dr->dr_dbuf == db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
320 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
321 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
322 |
* We can't assert that db_size matches dn_datablksz because it |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
323 |
* can be momentarily different when another thread is doing |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
324 |
* dnode_set_blksz(). |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
325 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
326 |
if (db->db_level == 0 && db->db.db_object == DMU_META_DNODE_OBJECT) { |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
327 |
dr = db->db_data_pending; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
328 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
329 |
* It should only be modified in syncing context, so |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
330 |
* make sure we only have one copy of the data. |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
331 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7762
diff
changeset
|
332 |
ASSERT(dr == NULL || dr->dt.dl.dr_data == db->db_buf); |
789 | 333 |
} |
334 |
||
335 |
/* verify db->db_blkptr */ |
|
336 |
if (db->db_blkptr) { |
|
337 |
if (db->db_parent == dn->dn_dbuf) { |
|
338 |
/* db is pointed to by the dnode */ |
|
339 |
/* ASSERT3U(db->db_blkid, <, dn->dn_nblkptr); */ |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
340 |
if (DMU_OBJECT_IS_SPECIAL(db->db.db_object)) |
789 | 341 |
ASSERT(db->db_parent == NULL); |
342 |
else |
|
343 |
ASSERT(db->db_parent != NULL); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
344 |
if (db->db_blkid != DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
345 |
ASSERT3P(db->db_blkptr, ==, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
346 |
&dn->dn_phys->dn_blkptr[db->db_blkid]); |
789 | 347 |
} else { |
348 |
/* db is pointed to by an indirect block */ |
|
349 |
int epb = db->db_parent->db.db_size >> SPA_BLKPTRSHIFT; |
|
350 |
ASSERT3U(db->db_parent->db_level, ==, db->db_level+1); |
|
351 |
ASSERT3U(db->db_parent->db.db_object, ==, |
|
352 |
db->db.db_object); |
|
353 |
/* |
|
354 |
* dnode_grow_indblksz() can make this fail if we don't |
|
355 |
* have the struct_rwlock. XXX indblksz no longer |
|
356 |
* grows. safe to do this now? |
|
357 |
*/ |
|
358 |
if (RW_WRITE_HELD(&db->db_dnode->dn_struct_rwlock)) { |
|
359 |
ASSERT3P(db->db_blkptr, ==, |
|
360 |
((blkptr_t *)db->db_parent->db.db_data + |
|
361 |
db->db_blkid % epb)); |
|
362 |
} |
|
363 |
} |
|
364 |
} |
|
365 |
if ((db->db_blkptr == NULL || BP_IS_HOLE(db->db_blkptr)) && |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
366 |
(db->db_buf == NULL || db->db_buf->b_data) && |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
367 |
db->db.db_data && db->db_blkid != DMU_BONUS_BLKID && |
789 | 368 |
db->db_state != DB_FILL && !dn->dn_free_txg) { |
369 |
/* |
|
370 |
* If the blkptr isn't set but they have nonzero data, |
|
371 |
* it had better be dirty, otherwise we'll lose that |
|
372 |
* data when we evict this buffer. |
|
373 |
*/ |
|
374 |
if (db->db_dirtycnt == 0) { |
|
375 |
uint64_t *buf = db->db.db_data; |
|
376 |
int i; |
|
377 |
||
378 |
for (i = 0; i < db->db.db_size >> 3; i++) { |
|
379 |
ASSERT(buf[i] == 0); |
|
380 |
} |
|
381 |
} |
|
382 |
} |
|
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
383 |
} |
789 | 384 |
#endif |
385 |
||
386 |
static void |
|
387 |
dbuf_update_data(dmu_buf_impl_t *db) |
|
388 |
{ |
|
389 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
390 |
if (db->db_level == 0 && db->db_user_data_ptr_ptr) { |
789 | 391 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
392 |
*db->db_user_data_ptr_ptr = db->db.db_data; |
789 | 393 |
} |
394 |
} |
|
395 |
||
396 |
static void |
|
397 |
dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf) |
|
398 |
{ |
|
399 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
1544 | 400 |
ASSERT(db->db_buf == NULL || !arc_has_callback(db->db_buf)); |
789 | 401 |
db->db_buf = buf; |
1544 | 402 |
if (buf != NULL) { |
403 |
ASSERT(buf->b_data != NULL); |
|
404 |
db->db.db_data = buf->b_data; |
|
405 |
if (!arc_released(buf)) |
|
406 |
arc_set_callback(buf, dbuf_do_evict, db); |
|
407 |
dbuf_update_data(db); |
|
408 |
} else { |
|
409 |
dbuf_evict_user(db); |
|
410 |
db->db.db_data = NULL; |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
411 |
if (db->db_state != DB_NOFILL) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
412 |
db->db_state = DB_UNCACHED; |
1544 | 413 |
} |
789 | 414 |
} |
415 |
||
11539
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
416 |
/* |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
417 |
* Loan out an arc_buf for read. Return the loaned arc_buf. |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
418 |
*/ |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
419 |
arc_buf_t * |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
420 |
dbuf_loan_arcbuf(dmu_buf_impl_t *db) |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
421 |
{ |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
422 |
arc_buf_t *abuf; |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
423 |
|
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
424 |
mutex_enter(&db->db_mtx); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
425 |
if (arc_released(db->db_buf) || refcount_count(&db->db_holds) > 1) { |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
426 |
int blksz = db->db.db_size; |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
427 |
mutex_exit(&db->db_mtx); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
428 |
abuf = arc_loan_buf(db->db_dnode->dn_objset->os_spa, blksz); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
429 |
bcopy(db->db.db_data, abuf->b_data, blksz); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
430 |
} else { |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
431 |
abuf = db->db_buf; |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
432 |
arc_loan_inuse_buf(abuf, db); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
433 |
dbuf_set_data(db, NULL); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
434 |
mutex_exit(&db->db_mtx); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
435 |
} |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
436 |
return (abuf); |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
437 |
} |
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
438 |
|
789 | 439 |
uint64_t |
440 |
dbuf_whichblock(dnode_t *dn, uint64_t offset) |
|
441 |
{ |
|
442 |
if (dn->dn_datablkshift) { |
|
443 |
return (offset >> dn->dn_datablkshift); |
|
444 |
} else { |
|
445 |
ASSERT3U(offset, <, dn->dn_datablksz); |
|
446 |
return (0); |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
static void |
|
451 |
dbuf_read_done(zio_t *zio, arc_buf_t *buf, void *vdb) |
|
452 |
{ |
|
453 |
dmu_buf_impl_t *db = vdb; |
|
454 |
||
455 |
mutex_enter(&db->db_mtx); |
|
456 |
ASSERT3U(db->db_state, ==, DB_READ); |
|
457 |
/* |
|
458 |
* All reads are synchronous, so we must have a hold on the dbuf |
|
459 |
*/ |
|
460 |
ASSERT(refcount_count(&db->db_holds) > 0); |
|
1544 | 461 |
ASSERT(db->db_buf == NULL); |
789 | 462 |
ASSERT(db->db.db_data == NULL); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
463 |
if (db->db_level == 0 && db->db_freed_in_flight) { |
789 | 464 |
/* we were freed in flight; disregard any error */ |
465 |
arc_release(buf, db); |
|
466 |
bzero(buf->b_data, db->db.db_size); |
|
3093
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2986
diff
changeset
|
467 |
arc_buf_freeze(buf); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
468 |
db->db_freed_in_flight = FALSE; |
789 | 469 |
dbuf_set_data(db, buf); |
470 |
db->db_state = DB_CACHED; |
|
471 |
} else if (zio == NULL || zio->io_error == 0) { |
|
472 |
dbuf_set_data(db, buf); |
|
473 |
db->db_state = DB_CACHED; |
|
474 |
} else { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
475 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
1544 | 476 |
ASSERT3P(db->db_buf, ==, NULL); |
477 |
VERIFY(arc_buf_remove_ref(buf, db) == 1); |
|
789 | 478 |
db->db_state = DB_UNCACHED; |
479 |
} |
|
480 |
cv_broadcast(&db->db_changed); |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
481 |
dbuf_rele_and_unlock(db, NULL); |
789 | 482 |
} |
483 |
||
1544 | 484 |
static void |
2391 | 485 |
dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags) |
789 | 486 |
{ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
487 |
dnode_t *dn = db->db_dnode; |
1544 | 488 |
zbookmark_t zb; |
2391 | 489 |
uint32_t aflags = ARC_NOWAIT; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
490 |
arc_buf_t *pbuf; |
789 | 491 |
|
492 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
493 |
/* We need the struct_rwlock to prevent db_blkptr from changing. */ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
494 |
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock)); |
1544 | 495 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
496 |
ASSERT(db->db_state == DB_UNCACHED); |
|
497 |
ASSERT(db->db_buf == NULL); |
|
789 | 498 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
499 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
9299
8809e849f63e
6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8746
diff
changeset
|
500 |
int bonuslen = MIN(dn->dn_bonuslen, dn->dn_phys->dn_bonuslen); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
501 |
|
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
502 |
ASSERT3U(bonuslen, <=, db->db.db_size); |
1544 | 503 |
db->db.db_data = zio_buf_alloc(DN_MAX_BONUSLEN); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
504 |
arc_space_consume(DN_MAX_BONUSLEN, ARC_SPACE_OTHER); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
505 |
if (bonuslen < DN_MAX_BONUSLEN) |
1544 | 506 |
bzero(db->db.db_data, DN_MAX_BONUSLEN); |
9299
8809e849f63e
6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8746
diff
changeset
|
507 |
if (bonuslen) |
8809e849f63e
6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8746
diff
changeset
|
508 |
bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen); |
1544 | 509 |
dbuf_update_data(db); |
789 | 510 |
db->db_state = DB_CACHED; |
511 |
mutex_exit(&db->db_mtx); |
|
512 |
return; |
|
513 |
} |
|
514 |
||
7385
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
515 |
/* |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
516 |
* Recheck BP_IS_HOLE() after dnode_block_freed() in case dnode_sync() |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
517 |
* processes the delete record and clears the bp while we are waiting |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
518 |
* for the dn_mtx (resulting in a "no" from block_freed). |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
519 |
*/ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
520 |
if (db->db_blkptr == NULL || BP_IS_HOLE(db->db_blkptr) || |
7385
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
521 |
(db->db_level == 0 && (dnode_block_freed(dn, db->db_blkid) || |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
522 |
BP_IS_HOLE(db->db_blkptr)))) { |
3290 | 523 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
524 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
525 |
dbuf_set_data(db, arc_buf_alloc(dn->dn_objset->os_spa, |
3290 | 526 |
db->db.db_size, db, type)); |
789 | 527 |
bzero(db->db.db_data, db->db.db_size); |
528 |
db->db_state = DB_CACHED; |
|
2391 | 529 |
*flags |= DB_RF_CACHED; |
789 | 530 |
mutex_exit(&db->db_mtx); |
531 |
return; |
|
532 |
} |
|
533 |
||
534 |
db->db_state = DB_READ; |
|
535 |
mutex_exit(&db->db_mtx); |
|
536 |
||
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
537 |
if (DBUF_IS_L2CACHEABLE(db)) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
538 |
aflags |= ARC_L2CACHE; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
539 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
540 |
SET_BOOKMARK(&zb, db->db_objset->os_dsl_dataset ? |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
541 |
db->db_objset->os_dsl_dataset->ds_object : DMU_META_OBJSET, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
542 |
db->db.db_object, db->db_level, db->db_blkid); |
1544 | 543 |
|
544 |
dbuf_add_ref(db, NULL); |
|
789 | 545 |
/* ZIO_FLAG_CANFAIL callers have to check the parent zio's error */ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
546 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
547 |
if (db->db_parent) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
548 |
pbuf = db->db_parent->db_buf; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
549 |
else |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
550 |
pbuf = db->db_objset->os_phys_buf; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
551 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
552 |
(void) dsl_read(zio, dn->dn_objset->os_spa, db->db_blkptr, pbuf, |
789 | 553 |
dbuf_read_done, db, ZIO_PRIORITY_SYNC_READ, |
2391 | 554 |
(*flags & DB_RF_CANFAIL) ? ZIO_FLAG_CANFAIL : ZIO_FLAG_MUSTSUCCEED, |
555 |
&aflags, &zb); |
|
556 |
if (aflags & ARC_CACHED) |
|
557 |
*flags |= DB_RF_CACHED; |
|
789 | 558 |
} |
559 |
||
1544 | 560 |
int |
561 |
dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags) |
|
789 | 562 |
{ |
1544 | 563 |
int err = 0; |
564 |
int havepzio = (zio != NULL); |
|
2391 | 565 |
int prefetch; |
789 | 566 |
|
567 |
/* |
|
568 |
* We don't have to hold the mutex to check db_state because it |
|
569 |
* can't be freed while we have a hold on the buffer. |
|
570 |
*/ |
|
571 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
572 |
||
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
573 |
if (db->db_state == DB_NOFILL) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
574 |
return (EIO); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
575 |
|
1544 | 576 |
if ((flags & DB_RF_HAVESTRUCT) == 0) |
577 |
rw_enter(&db->db_dnode->dn_struct_rwlock, RW_READER); |
|
789 | 578 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
579 |
prefetch = db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID && |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
580 |
(flags & DB_RF_NOPREFETCH) == 0 && db->db_dnode != NULL && |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
581 |
DBUF_IS_CACHEABLE(db); |
2391 | 582 |
|
789 | 583 |
mutex_enter(&db->db_mtx); |
1544 | 584 |
if (db->db_state == DB_CACHED) { |
585 |
mutex_exit(&db->db_mtx); |
|
2391 | 586 |
if (prefetch) |
587 |
dmu_zfetch(&db->db_dnode->dn_zfetch, db->db.db_offset, |
|
588 |
db->db.db_size, TRUE); |
|
1544 | 589 |
if ((flags & DB_RF_HAVESTRUCT) == 0) |
590 |
rw_exit(&db->db_dnode->dn_struct_rwlock); |
|
591 |
} else if (db->db_state == DB_UNCACHED) { |
|
592 |
if (zio == NULL) { |
|
593 |
zio = zio_root(db->db_dnode->dn_objset->os_spa, |
|
594 |
NULL, NULL, ZIO_FLAG_CANFAIL); |
|
595 |
} |
|
2391 | 596 |
dbuf_read_impl(db, zio, &flags); |
597 |
||
1544 | 598 |
/* dbuf_read_impl has dropped db_mtx for us */ |
789 | 599 |
|
2391 | 600 |
if (prefetch) |
1544 | 601 |
dmu_zfetch(&db->db_dnode->dn_zfetch, db->db.db_offset, |
2391 | 602 |
db->db.db_size, flags & DB_RF_CACHED); |
789 | 603 |
|
1544 | 604 |
if ((flags & DB_RF_HAVESTRUCT) == 0) |
605 |
rw_exit(&db->db_dnode->dn_struct_rwlock); |
|
789 | 606 |
|
1544 | 607 |
if (!havepzio) |
608 |
err = zio_wait(zio); |
|
609 |
} else { |
|
2391 | 610 |
mutex_exit(&db->db_mtx); |
611 |
if (prefetch) |
|
612 |
dmu_zfetch(&db->db_dnode->dn_zfetch, db->db.db_offset, |
|
613 |
db->db.db_size, TRUE); |
|
1544 | 614 |
if ((flags & DB_RF_HAVESTRUCT) == 0) |
615 |
rw_exit(&db->db_dnode->dn_struct_rwlock); |
|
2391 | 616 |
|
617 |
mutex_enter(&db->db_mtx); |
|
1544 | 618 |
if ((flags & DB_RF_NEVERWAIT) == 0) { |
619 |
while (db->db_state == DB_READ || |
|
620 |
db->db_state == DB_FILL) { |
|
621 |
ASSERT(db->db_state == DB_READ || |
|
622 |
(flags & DB_RF_HAVESTRUCT) == 0); |
|
623 |
cv_wait(&db->db_changed, &db->db_mtx); |
|
624 |
} |
|
625 |
if (db->db_state == DB_UNCACHED) |
|
626 |
err = EIO; |
|
627 |
} |
|
628 |
mutex_exit(&db->db_mtx); |
|
629 |
} |
|
789 | 630 |
|
1544 | 631 |
ASSERT(err || havepzio || db->db_state == DB_CACHED); |
632 |
return (err); |
|
789 | 633 |
} |
634 |
||
635 |
static void |
|
636 |
dbuf_noread(dmu_buf_impl_t *db) |
|
637 |
{ |
|
638 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
639 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
789 | 640 |
mutex_enter(&db->db_mtx); |
641 |
while (db->db_state == DB_READ || db->db_state == DB_FILL) |
|
642 |
cv_wait(&db->db_changed, &db->db_mtx); |
|
643 |
if (db->db_state == DB_UNCACHED) { |
|
3290 | 644 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
645 |
||
1544 | 646 |
ASSERT(db->db_buf == NULL); |
789 | 647 |
ASSERT(db->db.db_data == NULL); |
648 |
dbuf_set_data(db, arc_buf_alloc(db->db_dnode->dn_objset->os_spa, |
|
3290 | 649 |
db->db.db_size, db, type)); |
789 | 650 |
db->db_state = DB_FILL; |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
651 |
} else if (db->db_state == DB_NOFILL) { |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
652 |
dbuf_set_data(db, NULL); |
789 | 653 |
} else { |
654 |
ASSERT3U(db->db_state, ==, DB_CACHED); |
|
655 |
} |
|
656 |
mutex_exit(&db->db_mtx); |
|
657 |
} |
|
658 |
||
659 |
/* |
|
660 |
* This is our just-in-time copy function. It makes a copy of |
|
661 |
* buffers, that have been modified in a previous transaction |
|
662 |
* group, before we modify them in the current active group. |
|
663 |
* |
|
664 |
* This function is used in two places: when we are dirtying a |
|
665 |
* buffer for the first time in a txg, and when we are freeing |
|
666 |
* a range in a dnode that includes this buffer. |
|
667 |
* |
|
668 |
* Note that when we are called from dbuf_free_range() we do |
|
669 |
* not put a hold on the buffer, we just traverse the active |
|
670 |
* dbuf list for the dnode. |
|
671 |
*/ |
|
672 |
static void |
|
673 |
dbuf_fix_old_data(dmu_buf_impl_t *db, uint64_t txg) |
|
674 |
{ |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
675 |
dbuf_dirty_record_t *dr = db->db_last_dirty; |
789 | 676 |
|
677 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
678 |
ASSERT(db->db.db_data != NULL); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
679 |
ASSERT(db->db_level == 0); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
680 |
ASSERT(db->db.db_object != DMU_META_DNODE_OBJECT); |
789 | 681 |
|
3711
2226ffbe7873
6526196 ZFS: assertion failed: zp->z_phys->zp_links > zp_is_dir
maybee
parents:
3689
diff
changeset
|
682 |
if (dr == NULL || |
2226ffbe7873
6526196 ZFS: assertion failed: zp->z_phys->zp_links > zp_is_dir
maybee
parents:
3689
diff
changeset
|
683 |
(dr->dt.dl.dr_data != |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
684 |
((db->db_blkid == DMU_BONUS_BLKID) ? db->db.db_data : db->db_buf))) |
789 | 685 |
return; |
686 |
||
687 |
/* |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
688 |
* If the last dirty record for this dbuf has not yet synced |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
689 |
* and its referencing the dbuf data, either: |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
690 |
* reset the reference to point to a new copy, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
691 |
* or (if there a no active holders) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
692 |
* just null out the current db_data pointer. |
789 | 693 |
*/ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
694 |
ASSERT(dr->dr_txg >= txg - 2); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
695 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
696 |
/* Note that the data bufs here are zio_bufs */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
697 |
dr->dt.dl.dr_data = zio_buf_alloc(DN_MAX_BONUSLEN); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
698 |
arc_space_consume(DN_MAX_BONUSLEN, ARC_SPACE_OTHER); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
699 |
bcopy(db->db.db_data, dr->dt.dl.dr_data, DN_MAX_BONUSLEN); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
700 |
} else if (refcount_count(&db->db_holds) > db->db_dirtycnt) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
701 |
int size = db->db.db_size; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
702 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
703 |
dr->dt.dl.dr_data = arc_buf_alloc( |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
704 |
db->db_dnode->dn_objset->os_spa, size, db, type); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
705 |
bcopy(db->db.db_data, dr->dt.dl.dr_data->b_data, size); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
706 |
} else { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
707 |
dbuf_set_data(db, NULL); |
1544 | 708 |
} |
709 |
} |
|
710 |
||
789 | 711 |
void |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
712 |
dbuf_unoverride(dbuf_dirty_record_t *dr) |
789 | 713 |
{ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
714 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
715 |
blkptr_t *bp = &dr->dt.dl.dr_overridden_by; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
716 |
uint64_t txg = dr->dr_txg; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
717 |
|
789 | 718 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
719 |
ASSERT(dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
720 |
ASSERT(db->db_level == 0); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
721 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
722 |
if (db->db_blkid == DMU_BONUS_BLKID || |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
723 |
dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
724 |
return; |
2237 | 725 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
726 |
ASSERT(db->db_data_pending != dr); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
727 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
728 |
/* free this block */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
729 |
if (!BP_IS_HOLE(bp)) |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
730 |
zio_free(db->db_dnode->dn_objset->os_spa, txg, bp); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
731 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
732 |
dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
733 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
734 |
* Release the already-written buffer, so we leave it in |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
735 |
* a consistent dirty state. Note that all callers are |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
736 |
* modifying the buffer, so they will immediately do |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
737 |
* another (redundant) arc_release(). Therefore, leave |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
738 |
* the buf thawed to save the effort of freezing & |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
739 |
* immediately re-thawing it. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
740 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
741 |
arc_release(dr->dt.dl.dr_data, db); |
789 | 742 |
} |
743 |
||
6992 | 744 |
/* |
745 |
* Evict (if its unreferenced) or clear (if its referenced) any level-0 |
|
746 |
* data blocks in the free range, so that any future readers will find |
|
747 |
* empty blocks. Also, if we happen accross any level-1 dbufs in the |
|
748 |
* range that have not already been marked dirty, mark them dirty so |
|
749 |
* they stay in memory. |
|
750 |
*/ |
|
789 | 751 |
void |
6992 | 752 |
dbuf_free_range(dnode_t *dn, uint64_t start, uint64_t end, dmu_tx_t *tx) |
789 | 753 |
{ |
754 |
dmu_buf_impl_t *db, *db_next; |
|
755 |
uint64_t txg = tx->tx_txg; |
|
6992 | 756 |
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
757 |
uint64_t first_l1 = start >> epbs; |
|
758 |
uint64_t last_l1 = end >> epbs; |
|
789 | 759 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
760 |
if (end > dn->dn_maxblkid && (end != DMU_SPILL_BLKID)) { |
6992 | 761 |
end = dn->dn_maxblkid; |
762 |
last_l1 = end >> epbs; |
|
763 |
} |
|
764 |
dprintf_dnode(dn, "start=%llu end=%llu\n", start, end); |
|
789 | 765 |
mutex_enter(&dn->dn_dbufs_mtx); |
766 |
for (db = list_head(&dn->dn_dbufs); db; db = db_next) { |
|
767 |
db_next = list_next(&dn->dn_dbufs, db); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
768 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
6992 | 769 |
|
770 |
if (db->db_level == 1 && |
|
771 |
db->db_blkid >= first_l1 && db->db_blkid <= last_l1) { |
|
772 |
mutex_enter(&db->db_mtx); |
|
773 |
if (db->db_last_dirty && |
|
774 |
db->db_last_dirty->dr_txg < txg) { |
|
775 |
dbuf_add_ref(db, FTAG); |
|
776 |
mutex_exit(&db->db_mtx); |
|
777 |
dbuf_will_dirty(db, tx); |
|
778 |
dbuf_rele(db, FTAG); |
|
779 |
} else { |
|
780 |
mutex_exit(&db->db_mtx); |
|
781 |
} |
|
782 |
} |
|
783 |
||
1544 | 784 |
if (db->db_level != 0) |
789 | 785 |
continue; |
786 |
dprintf_dbuf(db, "found buf %s\n", ""); |
|
6992 | 787 |
if (db->db_blkid < start || db->db_blkid > end) |
789 | 788 |
continue; |
789 |
||
790 |
/* found a level 0 buffer in the range */ |
|
791 |
if (dbuf_undirty(db, tx)) |
|
792 |
continue; |
|
793 |
||
794 |
mutex_enter(&db->db_mtx); |
|
1544 | 795 |
if (db->db_state == DB_UNCACHED || |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
796 |
db->db_state == DB_NOFILL || |
1544 | 797 |
db->db_state == DB_EVICTING) { |
789 | 798 |
ASSERT(db->db.db_data == NULL); |
799 |
mutex_exit(&db->db_mtx); |
|
800 |
continue; |
|
801 |
} |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
802 |
if (db->db_state == DB_READ || db->db_state == DB_FILL) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
803 |
/* will be handled in dbuf_read_done or dbuf_rele */ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
804 |
db->db_freed_in_flight = TRUE; |
789 | 805 |
mutex_exit(&db->db_mtx); |
806 |
continue; |
|
807 |
} |
|
1544 | 808 |
if (refcount_count(&db->db_holds) == 0) { |
809 |
ASSERT(db->db_buf); |
|
810 |
dbuf_clear(db); |
|
811 |
continue; |
|
812 |
} |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
813 |
/* The dbuf is referenced */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
814 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
815 |
if (db->db_last_dirty != NULL) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
816 |
dbuf_dirty_record_t *dr = db->db_last_dirty; |
789 | 817 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
818 |
if (dr->dr_txg == txg) { |
2688
12e2ad22b970
6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents:
2417
diff
changeset
|
819 |
/* |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
820 |
* This buffer is "in-use", re-adjust the file |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
821 |
* size to reflect that this buffer may |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
822 |
* contain new data when we sync. |
2688
12e2ad22b970
6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents:
2417
diff
changeset
|
823 |
*/ |
12178
93ec1371f750
6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11935
diff
changeset
|
824 |
if (db->db_blkid != DMU_SPILL_BLKID && |
93ec1371f750
6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11935
diff
changeset
|
825 |
db->db_blkid > dn->dn_maxblkid) |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
826 |
dn->dn_maxblkid = db->db_blkid; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
827 |
dbuf_unoverride(dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
828 |
} else { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
829 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
830 |
* This dbuf is not dirty in the open context. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
831 |
* Either uncache it (if its not referenced in |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
832 |
* the open context) or reset its contents to |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
833 |
* empty. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
834 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
835 |
dbuf_fix_old_data(db, txg); |
2688
12e2ad22b970
6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents:
2417
diff
changeset
|
836 |
} |
1544 | 837 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
838 |
/* clear the contents if its cached */ |
1544 | 839 |
if (db->db_state == DB_CACHED) { |
840 |
ASSERT(db->db.db_data != NULL); |
|
789 | 841 |
arc_release(db->db_buf, db); |
842 |
bzero(db->db.db_data, db->db.db_size); |
|
3093
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2986
diff
changeset
|
843 |
arc_buf_freeze(db->db_buf); |
789 | 844 |
} |
1544 | 845 |
|
789 | 846 |
mutex_exit(&db->db_mtx); |
847 |
} |
|
848 |
mutex_exit(&dn->dn_dbufs_mtx); |
|
849 |
} |
|
850 |
||
851 |
static int |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
852 |
dbuf_block_freeable(dmu_buf_impl_t *db) |
789 | 853 |
{ |
854 |
dsl_dataset_t *ds = db->db_objset->os_dsl_dataset; |
|
855 |
uint64_t birth_txg = 0; |
|
856 |
||
857 |
/* |
|
858 |
* We don't need any locking to protect db_blkptr: |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
859 |
* If it's syncing, then db_last_dirty will be set |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
860 |
* so we'll ignore db_blkptr. |
789 | 861 |
*/ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
862 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
863 |
if (db->db_last_dirty) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
864 |
birth_txg = db->db_last_dirty->dr_txg; |
789 | 865 |
else if (db->db_blkptr) |
866 |
birth_txg = db->db_blkptr->blk_birth; |
|
867 |
||
12587
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
868 |
/* |
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
869 |
* If we don't exist or are in a snapshot, we can't be freed. |
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
870 |
* Don't pass the bp to dsl_dataset_block_freeable() since we |
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
871 |
* are holding the db_mtx lock and might deadlock if we are |
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
872 |
* prefetching a dedup-ed block. |
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
873 |
*/ |
789 | 874 |
if (birth_txg) |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
875 |
return (ds == NULL || |
12587
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
876 |
dsl_dataset_block_freeable(ds, NULL, birth_txg)); |
789 | 877 |
else |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
878 |
return (FALSE); |
789 | 879 |
} |
880 |
||
881 |
void |
|
882 |
dbuf_new_size(dmu_buf_impl_t *db, int size, dmu_tx_t *tx) |
|
883 |
{ |
|
884 |
arc_buf_t *buf, *obuf; |
|
885 |
int osize = db->db.db_size; |
|
3290 | 886 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
789 | 887 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
888 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
1544 | 889 |
|
789 | 890 |
/* XXX does *this* func really need the lock? */ |
891 |
ASSERT(RW_WRITE_HELD(&db->db_dnode->dn_struct_rwlock)); |
|
892 |
||
893 |
/* |
|
894 |
* This call to dbuf_will_dirty() with the dn_struct_rwlock held |
|
895 |
* is OK, because there can be no other references to the db |
|
896 |
* when we are changing its size, so no concurrent DB_FILL can |
|
897 |
* be happening. |
|
898 |
*/ |
|
1544 | 899 |
/* |
900 |
* XXX we should be doing a dbuf_read, checking the return |
|
901 |
* value and returning that up to our callers |
|
902 |
*/ |
|
789 | 903 |
dbuf_will_dirty(db, tx); |
904 |
||
905 |
/* create the data buffer for the new block */ |
|
3290 | 906 |
buf = arc_buf_alloc(db->db_dnode->dn_objset->os_spa, size, db, type); |
789 | 907 |
|
908 |
/* copy old block data to the new block */ |
|
909 |
obuf = db->db_buf; |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
1199
diff
changeset
|
910 |
bcopy(obuf->b_data, buf->b_data, MIN(osize, size)); |
789 | 911 |
/* zero the remainder */ |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
1199
diff
changeset
|
912 |
if (size > osize) |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
1199
diff
changeset
|
913 |
bzero((uint8_t *)buf->b_data + osize, size - osize); |
789 | 914 |
|
915 |
mutex_enter(&db->db_mtx); |
|
916 |
dbuf_set_data(db, buf); |
|
1544 | 917 |
VERIFY(arc_buf_remove_ref(obuf, db) == 1); |
789 | 918 |
db->db.db_size = size; |
919 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
920 |
if (db->db_level == 0) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
921 |
ASSERT3U(db->db_last_dirty->dr_txg, ==, tx->tx_txg); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
922 |
db->db_last_dirty->dt.dl.dr_data = buf; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
923 |
} |
789 | 924 |
mutex_exit(&db->db_mtx); |
925 |
||
926 |
dnode_willuse_space(db->db_dnode, size-osize, tx); |
|
927 |
} |
|
928 |
||
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
929 |
void |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
930 |
dbuf_release_bp(dmu_buf_impl_t *db) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
931 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
932 |
objset_t *os = db->db_dnode->dn_objset; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
933 |
zbookmark_t zb; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
934 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
935 |
ASSERT(dsl_pool_sync_context(dmu_objset_pool(os))); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
936 |
ASSERT(arc_released(os->os_phys_buf) || |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
937 |
list_link_active(&os->os_dsl_dataset->ds_synced_link)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
938 |
ASSERT(db->db_parent == NULL || arc_released(db->db_parent->db_buf)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
939 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
940 |
zb.zb_objset = os->os_dsl_dataset ? |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
941 |
os->os_dsl_dataset->ds_object : 0; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
942 |
zb.zb_object = db->db.db_object; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
943 |
zb.zb_level = db->db_level; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
944 |
zb.zb_blkid = db->db_blkid; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
945 |
(void) arc_release_bp(db->db_buf, db, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
946 |
db->db_blkptr, os->os_spa, &zb); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
947 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
948 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
949 |
dbuf_dirty_record_t * |
789 | 950 |
dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx) |
951 |
{ |
|
952 |
dnode_t *dn = db->db_dnode; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
953 |
objset_t *os = dn->dn_objset; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
954 |
dbuf_dirty_record_t **drp, *dr; |
789 | 955 |
int drop_struct_lock = FALSE; |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
956 |
boolean_t do_free_accounting = B_FALSE; |
789 | 957 |
int txgoff = tx->tx_txg & TXG_MASK; |
958 |
||
959 |
ASSERT(tx->tx_txg != 0); |
|
960 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
961 |
DMU_TX_DIRTY_BUF(tx, db); |
789 | 962 |
|
963 |
/* |
|
964 |
* Shouldn't dirty a regular buffer in syncing context. Private |
|
965 |
* objects may be dirtied in syncing context, but only if they |
|
966 |
* were already pre-dirtied in open context. |
|
967 |
*/ |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
968 |
ASSERT(!dmu_tx_is_syncing(tx) || |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
969 |
BP_IS_HOLE(dn->dn_objset->os_rootbp) || |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
970 |
DMU_OBJECT_IS_SPECIAL(dn->dn_object) || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
971 |
dn->dn_objset->os_dsl_dataset == NULL); |
789 | 972 |
/* |
973 |
* We make this assert for private objects as well, but after we |
|
974 |
* check if we're already dirty. They are allowed to re-dirty |
|
975 |
* in syncing context. |
|
976 |
*/ |
|
1544 | 977 |
ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
978 |
dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == |
789 | 979 |
(dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); |
980 |
||
981 |
mutex_enter(&db->db_mtx); |
|
982 |
/* |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
983 |
* XXX make this true for indirects too? The problem is that |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
984 |
* transactions created with dmu_tx_create_assigned() from |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
985 |
* syncing context don't bother holding ahead. |
789 | 986 |
*/ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
987 |
ASSERT(db->db_level != 0 || |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
988 |
db->db_state == DB_CACHED || db->db_state == DB_FILL || |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
989 |
db->db_state == DB_NOFILL); |
789 | 990 |
|
991 |
mutex_enter(&dn->dn_mtx); |
|
992 |
/* |
|
993 |
* Don't set dirtyctx to SYNC if we're just modifying this as we |
|
994 |
* initialize the objset. |
|
995 |
*/ |
|
996 |
if (dn->dn_dirtyctx == DN_UNDIRTIED && |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
997 |
!BP_IS_HOLE(dn->dn_objset->os_rootbp)) { |
789 | 998 |
dn->dn_dirtyctx = |
999 |
(dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN); |
|
1000 |
ASSERT(dn->dn_dirtyctx_firstset == NULL); |
|
1001 |
dn->dn_dirtyctx_firstset = kmem_alloc(1, KM_SLEEP); |
|
1002 |
} |
|
1003 |
mutex_exit(&dn->dn_mtx); |
|
1004 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1005 |
if (db->db_blkid == DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1006 |
dn->dn_have_spill = B_TRUE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1007 |
|
789 | 1008 |
/* |
1009 |
* If this buffer is already dirty, we're done. |
|
1010 |
*/ |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1011 |
drp = &db->db_last_dirty; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1012 |
ASSERT(*drp == NULL || (*drp)->dr_txg <= tx->tx_txg || |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1013 |
db->db.db_object == DMU_META_DNODE_OBJECT); |
5370
eb153afce98e
6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents:
4944
diff
changeset
|
1014 |
while ((dr = *drp) != NULL && dr->dr_txg > tx->tx_txg) |
eb153afce98e
6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents:
4944
diff
changeset
|
1015 |
drp = &dr->dr_next; |
eb153afce98e
6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents:
4944
diff
changeset
|
1016 |
if (dr && dr->dr_txg == tx->tx_txg) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1017 |
if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1018 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1019 |
* If this buffer has already been written out, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1020 |
* we now need to reset its state. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1021 |
*/ |
5370
eb153afce98e
6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents:
4944
diff
changeset
|
1022 |
dbuf_unoverride(dr); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1023 |
if (db->db.db_object != DMU_META_DNODE_OBJECT && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1024 |
db->db_state != DB_NOFILL) |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1025 |
arc_buf_thaw(db->db_buf); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1026 |
} |
789 | 1027 |
mutex_exit(&db->db_mtx); |
5370
eb153afce98e
6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents:
4944
diff
changeset
|
1028 |
return (dr); |
789 | 1029 |
} |
1030 |
||
1031 |
/* |
|
1032 |
* Only valid if not already dirty. |
|
1033 |
*/ |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1034 |
ASSERT(dn->dn_object == 0 || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1035 |
dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx == |
789 | 1036 |
(dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN)); |
1037 |
||
1038 |
ASSERT3U(dn->dn_nlevels, >, db->db_level); |
|
1039 |
ASSERT((dn->dn_phys->dn_nlevels == 0 && db->db_level == 0) || |
|
1040 |
dn->dn_phys->dn_nlevels > db->db_level || |
|
1041 |
dn->dn_next_nlevels[txgoff] > db->db_level || |
|
1042 |
dn->dn_next_nlevels[(tx->tx_txg-1) & TXG_MASK] > db->db_level || |
|
1043 |
dn->dn_next_nlevels[(tx->tx_txg-2) & TXG_MASK] > db->db_level); |
|
1044 |
||
1045 |
/* |
|
1046 |
* We should only be dirtying in syncing context if it's the |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1047 |
* mos or we're initializing the os or it's a special object. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1048 |
* However, we are allowed to dirty in syncing context provided |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1049 |
* we already dirtied it in open context. Hence we must make |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1050 |
* this assertion only if we're not already dirty. |
789 | 1051 |
*/ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1052 |
ASSERT(!dmu_tx_is_syncing(tx) || DMU_OBJECT_IS_SPECIAL(dn->dn_object) || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9299
diff
changeset
|
1053 |
os->os_dsl_dataset == NULL || BP_IS_HOLE(os->os_rootbp)); |
789 | 1054 |
ASSERT(db->db.db_size != 0); |
1055 |
||
1056 |
dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size); |
|
1057 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1058 |
if (db->db_blkid != DMU_BONUS_BLKID) { |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1059 |
/* |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1060 |
* Update the accounting. |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1061 |
* Note: we delay "free accounting" until after we drop |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1062 |
* the db_mtx. This keeps us from grabbing other locks |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1063 |
* (and possibly deadlocking) in bp_get_dsize() while |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1064 |
* also holding the db_mtx. |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1065 |
*/ |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1066 |
dnode_willuse_space(dn, db->db.db_size, tx); |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1067 |
do_free_accounting = dbuf_block_freeable(db); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1068 |
} |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1069 |
|
1544 | 1070 |
/* |
1071 |
* If this buffer is dirty in an old transaction group we need |
|
1072 |
* to make a copy of it so that the changes we make in this |
|
1073 |
* transaction group won't leak out when we sync the older txg. |
|
1074 |
*/ |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1075 |
dr = kmem_zalloc(sizeof (dbuf_dirty_record_t), KM_SLEEP); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1076 |
if (db->db_level == 0) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1077 |
void *data_old = db->db_buf; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1078 |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1079 |
if (db->db_state != DB_NOFILL) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1080 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1081 |
dbuf_fix_old_data(db, tx->tx_txg); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1082 |
data_old = db->db.db_data; |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1083 |
} else if (db->db.db_object != DMU_META_DNODE_OBJECT) { |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1084 |
/* |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1085 |
* Release the data buffer from the cache so |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1086 |
* that we can modify it without impacting |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1087 |
* possible other users of this cached data |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1088 |
* block. Note that indirect blocks and |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1089 |
* private objects are not released until the |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1090 |
* syncing state (since they are only modified |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1091 |
* then). |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1092 |
*/ |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1093 |
arc_release(db->db_buf, db); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1094 |
dbuf_fix_old_data(db, tx->tx_txg); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1095 |
data_old = db->db_buf; |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1096 |
} |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1097 |
ASSERT(data_old != NULL); |
789 | 1098 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1099 |
dr->dt.dl.dr_data = data_old; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1100 |
} else { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1101 |
mutex_init(&dr->dt.di.dr_mtx, NULL, MUTEX_DEFAULT, NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1102 |
list_create(&dr->dt.di.dr_children, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1103 |
sizeof (dbuf_dirty_record_t), |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1104 |
offsetof(dbuf_dirty_record_t, dr_dirty_node)); |
789 | 1105 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1106 |
dr->dr_dbuf = db; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1107 |
dr->dr_txg = tx->tx_txg; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1108 |
dr->dr_next = *drp; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1109 |
*drp = dr; |
789 | 1110 |
|
1111 |
/* |
|
1112 |
* We could have been freed_in_flight between the dbuf_noread |
|
1113 |
* and dbuf_dirty. We win, as though the dbuf_noread() had |
|
1114 |
* happened after the free. |
|
1115 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1116 |
if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1117 |
db->db_blkid != DMU_SPILL_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1118 |
mutex_enter(&dn->dn_mtx); |
789 | 1119 |
dnode_clear_range(dn, db->db_blkid, 1, tx); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1120 |
mutex_exit(&dn->dn_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1121 |
db->db_freed_in_flight = FALSE; |
789 | 1122 |
} |
1123 |
||
1124 |
/* |
|
1125 |
* This buffer is now part of this txg |
|
1126 |
*/ |
|
1127 |
dbuf_add_ref(db, (void *)(uintptr_t)tx->tx_txg); |
|
1128 |
db->db_dirtycnt += 1; |
|
1129 |
ASSERT3U(db->db_dirtycnt, <=, 3); |
|
1130 |
||
1131 |
mutex_exit(&db->db_mtx); |
|
1132 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1133 |
if (db->db_blkid == DMU_BONUS_BLKID || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1134 |
db->db_blkid == DMU_SPILL_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1135 |
mutex_enter(&dn->dn_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1136 |
ASSERT(!list_link_active(&dr->dr_dirty_node)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1137 |
list_insert_tail(&dn->dn_dirty_records[txgoff], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1138 |
mutex_exit(&dn->dn_mtx); |
789 | 1139 |
dnode_setdirty(dn, tx); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1140 |
return (dr); |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1141 |
} else if (do_free_accounting) { |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1142 |
blkptr_t *bp = db->db_blkptr; |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1143 |
int64_t willfree = (bp && !BP_IS_HOLE(bp)) ? |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1144 |
bp_get_dsize(os->os_spa, bp) : db->db.db_size; |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1145 |
/* |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1146 |
* This is only a guess -- if the dbuf is dirty |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1147 |
* in a previous txg, we don't know how much |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1148 |
* space it will use on disk yet. We should |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1149 |
* really have the struct_rwlock to access |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1150 |
* db_blkptr, but since this is just a guess, |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1151 |
* it's OK if we get an odd answer. |
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1152 |
*/ |
12587
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12450
diff
changeset
|
1153 |
ddt_prefetch(os->os_spa, bp); |
7467
4106f22dda16
6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7385
diff
changeset
|
1154 |
dnode_willuse_space(dn, -willfree, tx); |
789 | 1155 |
} |
1156 |
||
1157 |
if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { |
|
1158 |
rw_enter(&dn->dn_struct_rwlock, RW_READER); |
|
1159 |
drop_struct_lock = TRUE; |
|
1160 |
} |
|
1161 |
||
7332
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7237
diff
changeset
|
1162 |
if (db->db_level == 0) { |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7237
diff
changeset
|
1163 |
dnode_new_blkid(dn, db->db_blkid, tx, drop_struct_lock); |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7237
diff
changeset
|
1164 |
ASSERT(dn->dn_maxblkid >= db->db_blkid); |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7237
diff
changeset
|
1165 |
} |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7237
diff
changeset
|
1166 |
|
2688
12e2ad22b970
6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents:
2417
diff
changeset
|
1167 |
if (db->db_level+1 < dn->dn_nlevels) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1168 |
dmu_buf_impl_t *parent = db->db_parent; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1169 |
dbuf_dirty_record_t *di; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1170 |
int parent_held = FALSE; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1171 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1172 |
if (db->db_parent == NULL || db->db_parent == dn->dn_dbuf) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1173 |
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1174 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1175 |
parent = dbuf_hold_level(dn, db->db_level+1, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1176 |
db->db_blkid >> epbs, FTAG); |
12411
3e9af067a727
6911391 panic in dmu_tx_count_write()
John Harres <John.Harres@Sun.COM>
parents:
12296
diff
changeset
|
1177 |
ASSERT(parent != NULL); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1178 |
parent_held = TRUE; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1179 |
} |
789 | 1180 |
if (drop_struct_lock) |
1181 |
rw_exit(&dn->dn_struct_rwlock); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1182 |
ASSERT3U(db->db_level+1, ==, parent->db_level); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1183 |
di = dbuf_dirty(parent, tx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1184 |
if (parent_held) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1185 |
dbuf_rele(parent, FTAG); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1186 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1187 |
mutex_enter(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1188 |
/* possible race with dbuf_undirty() */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1189 |
if (db->db_last_dirty == dr || |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1190 |
dn->dn_object == DMU_META_DNODE_OBJECT) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1191 |
mutex_enter(&di->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1192 |
ASSERT3U(di->dr_txg, ==, tx->tx_txg); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1193 |
ASSERT(!list_link_active(&dr->dr_dirty_node)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1194 |
list_insert_tail(&di->dt.di.dr_children, dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1195 |
mutex_exit(&di->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1196 |
dr->dr_parent = di; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1197 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1198 |
mutex_exit(&db->db_mtx); |
789 | 1199 |
} else { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1200 |
ASSERT(db->db_level+1 == dn->dn_nlevels); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1201 |
ASSERT(db->db_blkid < dn->dn_nblkptr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1202 |
ASSERT(db->db_parent == NULL || |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1203 |
db->db_parent == db->db_dnode->dn_dbuf); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1204 |
mutex_enter(&dn->dn_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1205 |
ASSERT(!list_link_active(&dr->dr_dirty_node)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1206 |
list_insert_tail(&dn->dn_dirty_records[txgoff], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1207 |
mutex_exit(&dn->dn_mtx); |
789 | 1208 |
if (drop_struct_lock) |
1209 |
rw_exit(&dn->dn_struct_rwlock); |
|
1210 |
} |
|
1211 |
||
1212 |
dnode_setdirty(dn, tx); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1213 |
return (dr); |
789 | 1214 |
} |
1215 |
||
1216 |
static int |
|
1217 |
dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx) |
|
1218 |
{ |
|
1219 |
dnode_t *dn = db->db_dnode; |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1220 |
uint64_t txg = tx->tx_txg; |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
1221 |
dbuf_dirty_record_t *dr, **drp; |
789 | 1222 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1223 |
ASSERT(txg != 0); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1224 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
789 | 1225 |
|
1226 |
mutex_enter(&db->db_mtx); |
|
1227 |
/* |
|
1228 |
* If this buffer is not dirty, we're done. |
|
1229 |
*/ |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
1230 |
for (drp = &db->db_last_dirty; (dr = *drp) != NULL; drp = &dr->dr_next) |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1231 |
if (dr->dr_txg <= txg) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1232 |
break; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1233 |
if (dr == NULL || dr->dr_txg < txg) { |
789 | 1234 |
mutex_exit(&db->db_mtx); |
1235 |
return (0); |
|
1236 |
} |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1237 |
ASSERT(dr->dr_txg == txg); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1238 |
ASSERT(dr->dr_dbuf == db); |
789 | 1239 |
|
1240 |
/* |
|
1241 |
* If this buffer is currently held, we cannot undirty |
|
1242 |
* it, since one of the current holders may be in the |
|
1243 |
* middle of an update. Note that users of dbuf_undirty() |
|
1244 |
* should not place a hold on the dbuf before the call. |
|
1245 |
*/ |
|
1246 |
if (refcount_count(&db->db_holds) > db->db_dirtycnt) { |
|
1247 |
mutex_exit(&db->db_mtx); |
|
2688
12e2ad22b970
6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents:
2417
diff
changeset
|
1248 |
/* Make sure we don't toss this buffer at sync phase */ |
789 | 1249 |
mutex_enter(&dn->dn_mtx); |
1250 |
dnode_clear_range(dn, db->db_blkid, 1, tx); |
|
1251 |
mutex_exit(&dn->dn_mtx); |
|
1252 |
return (0); |
|
1253 |
} |
|
1254 |
||
1255 |
dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size); |
|
1256 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1257 |
ASSERT(db->db.db_size != 0); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1258 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1259 |
/* XXX would be nice to fix up dn_towrite_space[] */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1260 |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
1261 |
*drp = dr->dr_next; |
789 | 1262 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1263 |
if (dr->dr_parent) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1264 |
mutex_enter(&dr->dr_parent->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1265 |
list_remove(&dr->dr_parent->dt.di.dr_children, dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1266 |
mutex_exit(&dr->dr_parent->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1267 |
} else if (db->db_level+1 == dn->dn_nlevels) { |
6992 | 1268 |
ASSERT(db->db_blkptr == NULL || db->db_parent == dn->dn_dbuf); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1269 |
mutex_enter(&dn->dn_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1270 |
list_remove(&dn->dn_dirty_records[txg & TXG_MASK], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1271 |
mutex_exit(&dn->dn_mtx); |
789 | 1272 |
} |
1273 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1274 |
if (db->db_level == 0) { |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1275 |
if (db->db_state != DB_NOFILL) { |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1276 |
dbuf_unoverride(dr); |
789 | 1277 |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1278 |
ASSERT(db->db_buf != NULL); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1279 |
ASSERT(dr->dt.dl.dr_data != NULL); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1280 |
if (dr->dt.dl.dr_data != db->db_buf) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1281 |
VERIFY(arc_buf_remove_ref(dr->dt.dl.dr_data, |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1282 |
db) == 1); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1283 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1284 |
} else { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1285 |
ASSERT(db->db_buf != NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1286 |
ASSERT(list_head(&dr->dt.di.dr_children) == NULL); |
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4506
diff
changeset
|
1287 |
mutex_destroy(&dr->dt.di.dr_mtx); |
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4506
diff
changeset
|
1288 |
list_destroy(&dr->dt.di.dr_children); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1289 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1290 |
kmem_free(dr, sizeof (dbuf_dirty_record_t)); |
789 | 1291 |
|
1292 |
ASSERT(db->db_dirtycnt > 0); |
|
1293 |
db->db_dirtycnt -= 1; |
|
1294 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1295 |
if (refcount_remove(&db->db_holds, (void *)(uintptr_t)txg) == 0) { |
1544 | 1296 |
arc_buf_t *buf = db->db_buf; |
789 | 1297 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1298 |
ASSERT(db->db_state == DB_NOFILL || arc_released(buf)); |
1544 | 1299 |
dbuf_set_data(db, NULL); |
1300 |
VERIFY(arc_buf_remove_ref(buf, db) == 1); |
|
789 | 1301 |
dbuf_evict(db); |
1302 |
return (1); |
|
1303 |
} |
|
1304 |
||
1305 |
mutex_exit(&db->db_mtx); |
|
1306 |
return (0); |
|
1307 |
} |
|
1308 |
||
1309 |
#pragma weak dmu_buf_will_dirty = dbuf_will_dirty |
|
1310 |
void |
|
1311 |
dbuf_will_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx) |
|
1312 |
{ |
|
6245
1a2a7cfb9f26
6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents:
5688
diff
changeset
|
1313 |
int rf = DB_RF_MUST_SUCCEED | DB_RF_NOPREFETCH; |
789 | 1314 |
|
1315 |
ASSERT(tx->tx_txg != 0); |
|
1316 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
1317 |
||
1318 |
if (RW_WRITE_HELD(&db->db_dnode->dn_struct_rwlock)) |
|
1319 |
rf |= DB_RF_HAVESTRUCT; |
|
1544 | 1320 |
(void) dbuf_read(db, NULL, rf); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1321 |
(void) dbuf_dirty(db, tx); |
789 | 1322 |
} |
1323 |
||
1324 |
void |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1325 |
dmu_buf_will_not_fill(dmu_buf_t *db_fake, dmu_tx_t *tx) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1326 |
{ |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1327 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1328 |
|
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1329 |
db->db_state = DB_NOFILL; |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1330 |
|
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1331 |
dmu_buf_will_fill(db_fake, tx); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1332 |
} |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1333 |
|
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1334 |
void |
1544 | 1335 |
dmu_buf_will_fill(dmu_buf_t *db_fake, dmu_tx_t *tx) |
789 | 1336 |
{ |
1544 | 1337 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
1338 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1339 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
789 | 1340 |
ASSERT(tx->tx_txg != 0); |
1341 |
ASSERT(db->db_level == 0); |
|
1342 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
1343 |
||
1544 | 1344 |
ASSERT(db->db.db_object != DMU_META_DNODE_OBJECT || |
789 | 1345 |
dmu_tx_private_ok(tx)); |
1346 |
||
1347 |
dbuf_noread(db); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1348 |
(void) dbuf_dirty(db, tx); |
789 | 1349 |
} |
1350 |
||
1351 |
#pragma weak dmu_buf_fill_done = dbuf_fill_done |
|
1352 |
/* ARGSUSED */ |
|
1353 |
void |
|
1354 |
dbuf_fill_done(dmu_buf_impl_t *db, dmu_tx_t *tx) |
|
1355 |
{ |
|
1356 |
mutex_enter(&db->db_mtx); |
|
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1357 |
DBUF_VERIFY(db); |
789 | 1358 |
|
1359 |
if (db->db_state == DB_FILL) { |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1360 |
if (db->db_level == 0 && db->db_freed_in_flight) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1361 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
789 | 1362 |
/* we were freed while filling */ |
1363 |
/* XXX dbuf_undirty? */ |
|
1364 |
bzero(db->db.db_data, db->db.db_size); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1365 |
db->db_freed_in_flight = FALSE; |
789 | 1366 |
} |
1367 |
db->db_state = DB_CACHED; |
|
1368 |
cv_broadcast(&db->db_changed); |
|
1369 |
} |
|
1370 |
mutex_exit(&db->db_mtx); |
|
1371 |
} |
|
1372 |
||
1544 | 1373 |
/* |
9412
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1374 |
* Directly assign a provided arc buf to a given dbuf if it's not referenced |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1375 |
* by anybody except our caller. Otherwise copy arcbuf's contents to dbuf. |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1376 |
*/ |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1377 |
void |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1378 |
dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx) |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1379 |
{ |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1380 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1381 |
ASSERT(db->db_dnode->dn_object != DMU_META_DNODE_OBJECT); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1382 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
9412
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1383 |
ASSERT(db->db_level == 0); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1384 |
ASSERT(DBUF_GET_BUFC_TYPE(db) == ARC_BUFC_DATA); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1385 |
ASSERT(buf != NULL); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1386 |
ASSERT(arc_buf_size(buf) == db->db.db_size); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1387 |
ASSERT(tx->tx_txg != 0); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1388 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1389 |
arc_return_buf(buf, db); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1390 |
ASSERT(arc_released(buf)); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1391 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1392 |
mutex_enter(&db->db_mtx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1393 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1394 |
while (db->db_state == DB_READ || db->db_state == DB_FILL) |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1395 |
cv_wait(&db->db_changed, &db->db_mtx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1396 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1397 |
ASSERT(db->db_state == DB_CACHED || db->db_state == DB_UNCACHED); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1398 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1399 |
if (db->db_state == DB_CACHED && |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1400 |
refcount_count(&db->db_holds) - 1 > db->db_dirtycnt) { |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1401 |
mutex_exit(&db->db_mtx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1402 |
(void) dbuf_dirty(db, tx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1403 |
bcopy(buf->b_data, db->db.db_data, db->db.db_size); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1404 |
VERIFY(arc_buf_remove_ref(buf, db) == 1); |
11539
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
1405 |
xuio_stat_wbuf_copied(); |
9412
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1406 |
return; |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1407 |
} |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1408 |
|
11539
10d35fc3d7fd
6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents:
10922
diff
changeset
|
1409 |
xuio_stat_wbuf_nocopy(); |
9412
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1410 |
if (db->db_state == DB_CACHED) { |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1411 |
dbuf_dirty_record_t *dr = db->db_last_dirty; |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1412 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1413 |
ASSERT(db->db_buf != NULL); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1414 |
if (dr != NULL && dr->dr_txg == tx->tx_txg) { |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1415 |
ASSERT(dr->dt.dl.dr_data == db->db_buf); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1416 |
if (!arc_released(db->db_buf)) { |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1417 |
ASSERT(dr->dt.dl.dr_override_state == |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1418 |
DR_OVERRIDDEN); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1419 |
arc_release(db->db_buf, db); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1420 |
} |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1421 |
dr->dt.dl.dr_data = buf; |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1422 |
VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1423 |
} else if (dr == NULL || dr->dt.dl.dr_data != db->db_buf) { |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1424 |
arc_release(db->db_buf, db); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1425 |
VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1426 |
} |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1427 |
db->db_buf = NULL; |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1428 |
} |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1429 |
ASSERT(db->db_buf == NULL); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1430 |
dbuf_set_data(db, buf); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1431 |
db->db_state = DB_FILL; |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1432 |
mutex_exit(&db->db_mtx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1433 |
(void) dbuf_dirty(db, tx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1434 |
dbuf_fill_done(db, tx); |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1435 |
} |
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1436 |
|
4aefd8704ce0
6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents:
9396
diff
changeset
|
1437 |
/* |
1544 | 1438 |
* "Clear" the contents of this dbuf. This will mark the dbuf |
1439 |
* EVICTING and clear *most* of its references. Unfortunetely, |
|
1440 |
* when we are not holding the dn_dbufs_mtx, we can't clear the |
|
1441 |
* entry in the dn_dbufs list. We have to wait until dbuf_destroy() |
|
1442 |
* in this case. For callers from the DMU we will usually see: |
|
1443 |
* dbuf_clear()->arc_buf_evict()->dbuf_do_evict()->dbuf_destroy() |
|
1444 |
* For the arc callback, we will usually see: |
|
1445 |
* dbuf_do_evict()->dbuf_clear();dbuf_destroy() |
|
1446 |
* Sometimes, though, we will get a mix of these two: |
|
1447 |
* DMU: dbuf_clear()->arc_buf_evict() |
|
1448 |
* ARC: dbuf_do_evict()->dbuf_destroy() |
|
1449 |
*/ |
|
1450 |
void |
|
789 | 1451 |
dbuf_clear(dmu_buf_impl_t *db) |
1452 |
{ |
|
1453 |
dnode_t *dn = db->db_dnode; |
|
1544 | 1454 |
dmu_buf_impl_t *parent = db->db_parent; |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1455 |
dmu_buf_impl_t *dndb = dn->dn_dbuf; |
1544 | 1456 |
int dbuf_gone = FALSE; |
789 | 1457 |
|
1458 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
|
1459 |
ASSERT(refcount_is_zero(&db->db_holds)); |
|
1460 |
||
1544 | 1461 |
dbuf_evict_user(db); |
1462 |
||
789 | 1463 |
if (db->db_state == DB_CACHED) { |
1544 | 1464 |
ASSERT(db->db.db_data != NULL); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1465 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
1544 | 1466 |
zio_buf_free(db->db.db_data, DN_MAX_BONUSLEN); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
1467 |
arc_space_return(DN_MAX_BONUSLEN, ARC_SPACE_OTHER); |
4309
3dfde0f4662d
6542676 ARC needs to track meta-data memory overhead
maybee
parents:
3897
diff
changeset
|
1468 |
} |
789 | 1469 |
db->db.db_data = NULL; |
1470 |
db->db_state = DB_UNCACHED; |
|
1471 |
} |
|
1472 |
||
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1473 |
ASSERT(db->db_state == DB_UNCACHED || db->db_state == DB_NOFILL); |
789 | 1474 |
ASSERT(db->db_data_pending == NULL); |
1475 |
||
1544 | 1476 |
db->db_state = DB_EVICTING; |
1477 |
db->db_blkptr = NULL; |
|
1478 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1479 |
if (db->db_blkid != DMU_BONUS_BLKID && MUTEX_HELD(&dn->dn_dbufs_mtx)) { |
1544 | 1480 |
list_remove(&dn->dn_dbufs, db); |
1481 |
dnode_rele(dn, db); |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1482 |
db->db_dnode = NULL; |
1544 | 1483 |
} |
1484 |
||
1485 |
if (db->db_buf) |
|
1486 |
dbuf_gone = arc_buf_evict(db->db_buf); |
|
1487 |
||
1488 |
if (!dbuf_gone) |
|
1489 |
mutex_exit(&db->db_mtx); |
|
789 | 1490 |
|
1491 |
/* |
|
1492 |
* If this dbuf is referened from an indirect dbuf, |
|
1493 |
* decrement the ref count on the indirect dbuf. |
|
1494 |
*/ |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1495 |
if (parent && parent != dndb) |
1544 | 1496 |
dbuf_rele(parent, db); |
789 | 1497 |
} |
1498 |
||
1499 |
static int |
|
1500 |
dbuf_findbp(dnode_t *dn, int level, uint64_t blkid, int fail_sparse, |
|
1501 |
dmu_buf_impl_t **parentp, blkptr_t **bpp) |
|
1502 |
{ |
|
1503 |
int nlevels, epbs; |
|
1504 |
||
2417 | 1505 |
*parentp = NULL; |
1506 |
*bpp = NULL; |
|
1507 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1508 |
ASSERT(blkid != DMU_BONUS_BLKID); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1509 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1510 |
if (blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1511 |
mutex_enter(&dn->dn_mtx); |
12178
93ec1371f750
6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11935
diff
changeset
|
1512 |
if (dn->dn_have_spill && |
93ec1371f750
6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11935
diff
changeset
|
1513 |
(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1514 |
*bpp = &dn->dn_phys->dn_spill; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1515 |
else |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1516 |
*bpp = NULL; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1517 |
dbuf_add_ref(dn->dn_dbuf, NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1518 |
*parentp = dn->dn_dbuf; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1519 |
mutex_exit(&dn->dn_mtx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1520 |
return (0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1521 |
} |
1544 | 1522 |
|
789 | 1523 |
if (dn->dn_phys->dn_nlevels == 0) |
1524 |
nlevels = 1; |
|
1525 |
else |
|
1526 |
nlevels = dn->dn_phys->dn_nlevels; |
|
1527 |
||
1528 |
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; |
|
1529 |
||
1530 |
ASSERT3U(level * epbs, <, 64); |
|
1531 |
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock)); |
|
1544 | 1532 |
if (level >= nlevels || |
789 | 1533 |
(blkid > (dn->dn_phys->dn_maxblkid >> (level * epbs)))) { |
1534 |
/* the buffer has no parent yet */ |
|
1535 |
return (ENOENT); |
|
1536 |
} else if (level < nlevels-1) { |
|
1537 |
/* this block is referenced from an indirect block */ |
|
1538 |
int err = dbuf_hold_impl(dn, level+1, |
|
1539 |
blkid >> epbs, fail_sparse, NULL, parentp); |
|
1540 |
if (err) |
|
1541 |
return (err); |
|
1544 | 1542 |
err = dbuf_read(*parentp, NULL, |
1543 |
(DB_RF_HAVESTRUCT | DB_RF_NOPREFETCH | DB_RF_CANFAIL)); |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1544 |
if (err) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1545 |
dbuf_rele(*parentp, NULL); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1546 |
*parentp = NULL; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1547 |
return (err); |
1544 | 1548 |
} |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1549 |
*bpp = ((blkptr_t *)(*parentp)->db.db_data) + |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1550 |
(blkid & ((1ULL << epbs) - 1)); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1551 |
return (0); |
789 | 1552 |
} else { |
1553 |
/* the block is referenced from the dnode */ |
|
1554 |
ASSERT3U(level, ==, nlevels-1); |
|
1555 |
ASSERT(dn->dn_phys->dn_nblkptr == 0 || |
|
1556 |
blkid < dn->dn_phys->dn_nblkptr); |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1557 |
if (dn->dn_dbuf) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1558 |
dbuf_add_ref(dn->dn_dbuf, NULL); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1559 |
*parentp = dn->dn_dbuf; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1560 |
} |
789 | 1561 |
*bpp = &dn->dn_phys->dn_blkptr[blkid]; |
1562 |
return (0); |
|
1563 |
} |
|
1564 |
} |
|
1565 |
||
1566 |
static dmu_buf_impl_t * |
|
1567 |
dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid, |
|
1568 |
dmu_buf_impl_t *parent, blkptr_t *blkptr) |
|
1569 |
{ |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1570 |
objset_t *os = dn->dn_objset; |
789 | 1571 |
dmu_buf_impl_t *db, *odb; |
1572 |
||
1573 |
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock)); |
|
1574 |
ASSERT(dn->dn_type != DMU_OT_NONE); |
|
1575 |
||
1576 |
db = kmem_cache_alloc(dbuf_cache, KM_SLEEP); |
|
1577 |
||
1578 |
db->db_objset = os; |
|
1579 |
db->db.db_object = dn->dn_object; |
|
1580 |
db->db_level = level; |
|
1581 |
db->db_blkid = blkid; |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1582 |
db->db_last_dirty = NULL; |
1544 | 1583 |
db->db_dirtycnt = 0; |
1584 |
db->db_dnode = dn; |
|
1585 |
db->db_parent = parent; |
|
1586 |
db->db_blkptr = blkptr; |
|
789 | 1587 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1588 |
db->db_user_ptr = NULL; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1589 |
db->db_user_data_ptr_ptr = NULL; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1590 |
db->db_evict_func = NULL; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1591 |
db->db_immediate_evict = 0; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1592 |
db->db_freed_in_flight = 0; |
1544 | 1593 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1594 |
if (blkid == DMU_BONUS_BLKID) { |
1544 | 1595 |
ASSERT3P(parent, ==, dn->dn_dbuf); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1596 |
db->db.db_size = DN_MAX_BONUSLEN - |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1597 |
(dn->dn_nblkptr-1) * sizeof (blkptr_t); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1598 |
ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1599 |
db->db.db_offset = DMU_BONUS_BLKID; |
1544 | 1600 |
db->db_state = DB_UNCACHED; |
1601 |
/* the bonus dbuf is not placed in the hash table */ |
|
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
1602 |
arc_space_consume(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER); |
1544 | 1603 |
return (db); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1604 |
} else if (blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1605 |
db->db.db_size = (blkptr != NULL) ? |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1606 |
BP_GET_LSIZE(blkptr) : SPA_MINBLOCKSIZE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1607 |
db->db.db_offset = 0; |
789 | 1608 |
} else { |
1609 |
int blocksize = |
|
1610 |
db->db_level ? 1<<dn->dn_indblkshift : dn->dn_datablksz; |
|
1611 |
db->db.db_size = blocksize; |
|
1612 |
db->db.db_offset = db->db_blkid * blocksize; |
|
1613 |
} |
|
1614 |
||
1615 |
/* |
|
1616 |
* Hold the dn_dbufs_mtx while we get the new dbuf |
|
1617 |
* in the hash table *and* added to the dbufs list. |
|
1618 |
* This prevents a possible deadlock with someone |
|
1619 |
* trying to look up this dbuf before its added to the |
|
1620 |
* dn_dbufs list. |
|
1621 |
*/ |
|
1622 |
mutex_enter(&dn->dn_dbufs_mtx); |
|
1544 | 1623 |
db->db_state = DB_EVICTING; |
789 | 1624 |
if ((odb = dbuf_hash_insert(db)) != NULL) { |
1625 |
/* someone else inserted it first */ |
|
1626 |
kmem_cache_free(dbuf_cache, db); |
|
1627 |
mutex_exit(&dn->dn_dbufs_mtx); |
|
1628 |
return (odb); |
|
1629 |
} |
|
1630 |
list_insert_head(&dn->dn_dbufs, db); |
|
1544 | 1631 |
db->db_state = DB_UNCACHED; |
789 | 1632 |
mutex_exit(&dn->dn_dbufs_mtx); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
1633 |
arc_space_consume(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER); |
789 | 1634 |
|
1635 |
if (parent && parent != dn->dn_dbuf) |
|
1636 |
dbuf_add_ref(parent, db); |
|
1637 |
||
1544 | 1638 |
ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || |
1639 |
refcount_count(&dn->dn_holds) > 0); |
|
789 | 1640 |
(void) refcount_add(&dn->dn_holds, db); |
1641 |
||
1642 |
dprintf_dbuf(db, "db=%p\n", db); |
|
1643 |
||
1644 |
return (db); |
|
1645 |
} |
|
1646 |
||
1647 |
static int |
|
1544 | 1648 |
dbuf_do_evict(void *private) |
789 | 1649 |
{ |
1544 | 1650 |
arc_buf_t *buf = private; |
1651 |
dmu_buf_impl_t *db = buf->b_private; |
|
789 | 1652 |
|
1544 | 1653 |
if (!MUTEX_HELD(&db->db_mtx)) |
1654 |
mutex_enter(&db->db_mtx); |
|
789 | 1655 |
|
1544 | 1656 |
ASSERT(refcount_is_zero(&db->db_holds)); |
789 | 1657 |
|
1544 | 1658 |
if (db->db_state != DB_EVICTING) { |
1659 |
ASSERT(db->db_state == DB_CACHED); |
|
1660 |
DBUF_VERIFY(db); |
|
1661 |
db->db_buf = NULL; |
|
1662 |
dbuf_evict(db); |
|
1663 |
} else { |
|
1664 |
mutex_exit(&db->db_mtx); |
|
1665 |
dbuf_destroy(db); |
|
789 | 1666 |
} |
1544 | 1667 |
return (0); |
789 | 1668 |
} |
1669 |
||
1670 |
static void |
|
1671 |
dbuf_destroy(dmu_buf_impl_t *db) |
|
1672 |
{ |
|
1673 |
ASSERT(refcount_is_zero(&db->db_holds)); |
|
1674 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1675 |
if (db->db_blkid != DMU_BONUS_BLKID) { |
1544 | 1676 |
/* |
1677 |
* If this dbuf is still on the dn_dbufs list, |
|
1678 |
* remove it from that list. |
|
1679 |
*/ |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1680 |
if (db->db_dnode) { |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1681 |
dnode_t *dn = db->db_dnode; |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1682 |
|
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1683 |
mutex_enter(&dn->dn_dbufs_mtx); |
1544 | 1684 |
list_remove(&dn->dn_dbufs, db); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1685 |
mutex_exit(&dn->dn_dbufs_mtx); |
1544 | 1686 |
|
1687 |
dnode_rele(dn, db); |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1688 |
db->db_dnode = NULL; |
1544 | 1689 |
} |
1690 |
dbuf_hash_remove(db); |
|
1691 |
} |
|
1692 |
db->db_parent = NULL; |
|
1693 |
db->db_buf = NULL; |
|
1694 |
||
4312
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
1695 |
ASSERT(!list_link_active(&db->db_link)); |
789 | 1696 |
ASSERT(db->db.db_data == NULL); |
1697 |
ASSERT(db->db_hash_next == NULL); |
|
1698 |
ASSERT(db->db_blkptr == NULL); |
|
1699 |
ASSERT(db->db_data_pending == NULL); |
|
1700 |
||
1701 |
kmem_cache_free(dbuf_cache, db); |
|
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
1702 |
arc_space_return(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER); |
789 | 1703 |
} |
1704 |
||
1705 |
void |
|
1706 |
dbuf_prefetch(dnode_t *dn, uint64_t blkid) |
|
1707 |
{ |
|
2391 | 1708 |
dmu_buf_impl_t *db = NULL; |
789 | 1709 |
blkptr_t *bp = NULL; |
1710 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1711 |
ASSERT(blkid != DMU_BONUS_BLKID); |
789 | 1712 |
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock)); |
1713 |
||
1714 |
if (dnode_block_freed(dn, blkid)) |
|
1715 |
return; |
|
1716 |
||
1717 |
/* dbuf_find() returns with db_mtx held */ |
|
1718 |
if (db = dbuf_find(dn, 0, blkid)) { |
|
2391 | 1719 |
if (refcount_count(&db->db_holds) > 0) { |
1720 |
/* |
|
1721 |
* This dbuf is active. We assume that it is |
|
1722 |
* already CACHED, or else about to be either |
|
1723 |
* read or filled. |
|
1724 |
*/ |
|
1725 |
mutex_exit(&db->db_mtx); |
|
1726 |
return; |
|
1727 |
} |
|
789 | 1728 |
mutex_exit(&db->db_mtx); |
2417 | 1729 |
db = NULL; |
789 | 1730 |
} |
1731 |
||
2391 | 1732 |
if (dbuf_findbp(dn, 0, blkid, TRUE, &db, &bp) == 0) { |
789 | 1733 |
if (bp && !BP_IS_HOLE(bp)) { |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12411
diff
changeset
|
1734 |
int priority = dn->dn_type == DMU_OT_DDT_ZAP ? |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12411
diff
changeset
|
1735 |
ZIO_PRIORITY_DDT_PREFETCH : ZIO_PRIORITY_ASYNC_READ; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1736 |
arc_buf_t *pbuf; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1737 |
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; |
2391 | 1738 |
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH; |
1544 | 1739 |
zbookmark_t zb; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1740 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1741 |
SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1742 |
dn->dn_object, 0, blkid); |
1544 | 1743 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1744 |
if (db) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1745 |
pbuf = db->db_buf; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1746 |
else |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1747 |
pbuf = dn->dn_objset->os_phys_buf; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1748 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
1749 |
(void) dsl_read(NULL, dn->dn_objset->os_spa, |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12411
diff
changeset
|
1750 |
bp, pbuf, NULL, NULL, priority, |
789 | 1751 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE, |
2391 | 1752 |
&aflags, &zb); |
789 | 1753 |
} |
2391 | 1754 |
if (db) |
1755 |
dbuf_rele(db, NULL); |
|
789 | 1756 |
} |
1757 |
} |
|
1758 |
||
1759 |
/* |
|
1760 |
* Returns with db_holds incremented, and db_mtx not held. |
|
1761 |
* Note: dn_struct_rwlock must be held. |
|
1762 |
*/ |
|
1763 |
int |
|
1764 |
dbuf_hold_impl(dnode_t *dn, uint8_t level, uint64_t blkid, int fail_sparse, |
|
1765 |
void *tag, dmu_buf_impl_t **dbp) |
|
1766 |
{ |
|
1767 |
dmu_buf_impl_t *db, *parent = NULL; |
|
1768 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1769 |
ASSERT(blkid != DMU_BONUS_BLKID); |
789 | 1770 |
ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock)); |
1771 |
ASSERT3U(dn->dn_nlevels, >, level); |
|
1772 |
||
1773 |
*dbp = NULL; |
|
1544 | 1774 |
top: |
789 | 1775 |
/* dbuf_find() returns with db_mtx held */ |
1776 |
db = dbuf_find(dn, level, blkid); |
|
1777 |
||
1778 |
if (db == NULL) { |
|
1779 |
blkptr_t *bp = NULL; |
|
1780 |
int err; |
|
1781 |
||
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1782 |
ASSERT3P(parent, ==, NULL); |
789 | 1783 |
err = dbuf_findbp(dn, level, blkid, fail_sparse, &parent, &bp); |
1784 |
if (fail_sparse) { |
|
1785 |
if (err == 0 && bp && BP_IS_HOLE(bp)) |
|
1786 |
err = ENOENT; |
|
1787 |
if (err) { |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1788 |
if (parent) |
1544 | 1789 |
dbuf_rele(parent, NULL); |
789 | 1790 |
return (err); |
1791 |
} |
|
1792 |
} |
|
1544 | 1793 |
if (err && err != ENOENT) |
1794 |
return (err); |
|
789 | 1795 |
db = dbuf_create(dn, level, blkid, parent, bp); |
1796 |
} |
|
1797 |
||
1544 | 1798 |
if (db->db_buf && refcount_is_zero(&db->db_holds)) { |
1799 |
arc_buf_add_ref(db->db_buf, db); |
|
1800 |
if (db->db_buf->b_data == NULL) { |
|
1801 |
dbuf_clear(db); |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1802 |
if (parent) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1803 |
dbuf_rele(parent, NULL); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1804 |
parent = NULL; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1805 |
} |
1544 | 1806 |
goto top; |
1807 |
} |
|
1808 |
ASSERT3P(db->db.db_data, ==, db->db_buf->b_data); |
|
1809 |
} |
|
1810 |
||
1811 |
ASSERT(db->db_buf == NULL || arc_referenced(db->db_buf)); |
|
1812 |
||
789 | 1813 |
/* |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1814 |
* If this buffer is currently syncing out, and we are are |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1815 |
* still referencing it from db_data, we need to make a copy |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1816 |
* of it in case we decide we want to dirty it again in this txg. |
789 | 1817 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1818 |
if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID && |
1544 | 1819 |
dn->dn_object != DMU_META_DNODE_OBJECT && |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1820 |
db->db_state == DB_CACHED && db->db_data_pending) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1821 |
dbuf_dirty_record_t *dr = db->db_data_pending; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1822 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1823 |
if (dr->dt.dl.dr_data == db->db_buf) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1824 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
789 | 1825 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1826 |
dbuf_set_data(db, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1827 |
arc_buf_alloc(db->db_dnode->dn_objset->os_spa, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1828 |
db->db.db_size, db, type)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1829 |
bcopy(dr->dt.dl.dr_data->b_data, db->db.db_data, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1830 |
db->db.db_size); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1831 |
} |
789 | 1832 |
} |
1833 |
||
1544 | 1834 |
(void) refcount_add(&db->db_holds, tag); |
789 | 1835 |
dbuf_update_data(db); |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1836 |
DBUF_VERIFY(db); |
789 | 1837 |
mutex_exit(&db->db_mtx); |
1838 |
||
1839 |
/* NOTE: we can't rele the parent until after we drop the db_mtx */ |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1840 |
if (parent) |
1544 | 1841 |
dbuf_rele(parent, NULL); |
789 | 1842 |
|
1843 |
ASSERT3P(db->db_dnode, ==, dn); |
|
1844 |
ASSERT3U(db->db_blkid, ==, blkid); |
|
1845 |
ASSERT3U(db->db_level, ==, level); |
|
1846 |
*dbp = db; |
|
1847 |
||
1848 |
return (0); |
|
1849 |
} |
|
1850 |
||
1851 |
dmu_buf_impl_t * |
|
1544 | 1852 |
dbuf_hold(dnode_t *dn, uint64_t blkid, void *tag) |
789 | 1853 |
{ |
1854 |
dmu_buf_impl_t *db; |
|
1544 | 1855 |
int err = dbuf_hold_impl(dn, 0, blkid, FALSE, tag, &db); |
1856 |
return (err ? NULL : db); |
|
789 | 1857 |
} |
1858 |
||
1859 |
dmu_buf_impl_t * |
|
1860 |
dbuf_hold_level(dnode_t *dn, int level, uint64_t blkid, void *tag) |
|
1861 |
{ |
|
1862 |
dmu_buf_impl_t *db; |
|
1544 | 1863 |
int err = dbuf_hold_impl(dn, level, blkid, FALSE, tag, &db); |
1864 |
return (err ? NULL : db); |
|
789 | 1865 |
} |
1866 |
||
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
1867 |
void |
1544 | 1868 |
dbuf_create_bonus(dnode_t *dn) |
789 | 1869 |
{ |
1544 | 1870 |
ASSERT(RW_WRITE_HELD(&dn->dn_struct_rwlock)); |
1871 |
||
1872 |
ASSERT(dn->dn_bonus == NULL); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1873 |
dn->dn_bonus = dbuf_create(dn, 0, DMU_BONUS_BLKID, dn->dn_dbuf, NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1874 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1875 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1876 |
int |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1877 |
dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1878 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1879 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1880 |
if (db->db_blkid != DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1881 |
return (ENOTSUP); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1882 |
if (blksz == 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1883 |
blksz = SPA_MINBLOCKSIZE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1884 |
if (blksz > SPA_MAXBLOCKSIZE) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1885 |
blksz = SPA_MAXBLOCKSIZE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1886 |
else |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1887 |
blksz = P2ROUNDUP(blksz, SPA_MINBLOCKSIZE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1888 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1889 |
rw_enter(&db->db_dnode->dn_struct_rwlock, RW_WRITER); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1890 |
dbuf_new_size(db, blksz, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1891 |
rw_exit(&db->db_dnode->dn_struct_rwlock); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1892 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1893 |
return (0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1894 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1895 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1896 |
void |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1897 |
dbuf_rm_spill(dnode_t *dn, dmu_tx_t *tx) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1898 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1899 |
dbuf_free_range(dn, DMU_SPILL_BLKID, DMU_SPILL_BLKID, tx); |
789 | 1900 |
} |
1901 |
||
1544 | 1902 |
#pragma weak dmu_buf_add_ref = dbuf_add_ref |
789 | 1903 |
void |
1904 |
dbuf_add_ref(dmu_buf_impl_t *db, void *tag) |
|
1905 |
{ |
|
1544 | 1906 |
int64_t holds = refcount_add(&db->db_holds, tag); |
1907 |
ASSERT(holds > 1); |
|
789 | 1908 |
} |
1909 |
||
1544 | 1910 |
#pragma weak dmu_buf_rele = dbuf_rele |
789 | 1911 |
void |
1544 | 1912 |
dbuf_rele(dmu_buf_impl_t *db, void *tag) |
789 | 1913 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1914 |
mutex_enter(&db->db_mtx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1915 |
dbuf_rele_and_unlock(db, tag); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1916 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1917 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1918 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1919 |
* dbuf_rele() for an already-locked dbuf. This is necessary to allow |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1920 |
* db_dirtycnt and db_holds to be updated atomically. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1921 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1922 |
void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1923 |
dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1924 |
{ |
789 | 1925 |
int64_t holds; |
1926 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
1927 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1928 |
DBUF_VERIFY(db); |
789 | 1929 |
|
1930 |
holds = refcount_remove(&db->db_holds, tag); |
|
1544 | 1931 |
ASSERT(holds >= 0); |
1932 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1933 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1934 |
* We can't freeze indirects if there is a possibility that they |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1935 |
* may be modified in the current syncing context. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1936 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1937 |
if (db->db_buf && holds == (db->db_level == 0 ? db->db_dirtycnt : 0)) |
3093
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2986
diff
changeset
|
1938 |
arc_buf_freeze(db->db_buf); |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2986
diff
changeset
|
1939 |
|
1544 | 1940 |
if (holds == db->db_dirtycnt && |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1941 |
db->db_level == 0 && db->db_immediate_evict) |
1544 | 1942 |
dbuf_evict_user(db); |
789 | 1943 |
|
1944 |
if (holds == 0) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
1945 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
1544 | 1946 |
mutex_exit(&db->db_mtx); |
1947 |
dnode_rele(db->db_dnode, db); |
|
1948 |
} else if (db->db_buf == NULL) { |
|
1949 |
/* |
|
1950 |
* This is a special case: we never associated this |
|
1951 |
* dbuf with any data allocated from the ARC. |
|
1952 |
*/ |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1953 |
ASSERT(db->db_state == DB_UNCACHED || |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
1954 |
db->db_state == DB_NOFILL); |
1544 | 1955 |
dbuf_evict(db); |
3093
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2986
diff
changeset
|
1956 |
} else if (arc_released(db->db_buf)) { |
1544 | 1957 |
arc_buf_t *buf = db->db_buf; |
1958 |
/* |
|
1959 |
* This dbuf has anonymous data associated with it. |
|
1960 |
*/ |
|
1961 |
dbuf_set_data(db, NULL); |
|
1962 |
VERIFY(arc_buf_remove_ref(buf, db) == 1); |
|
1963 |
dbuf_evict(db); |
|
1964 |
} else { |
|
1965 |
VERIFY(arc_buf_remove_ref(db->db_buf, db) == 0); |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
1966 |
if (!DBUF_IS_CACHEABLE(db)) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
1967 |
dbuf_clear(db); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
1968 |
else |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
1969 |
mutex_exit(&db->db_mtx); |
1544 | 1970 |
} |
789 | 1971 |
} else { |
1972 |
mutex_exit(&db->db_mtx); |
|
1973 |
} |
|
1974 |
} |
|
1975 |
||
1976 |
#pragma weak dmu_buf_refcount = dbuf_refcount |
|
1977 |
uint64_t |
|
1978 |
dbuf_refcount(dmu_buf_impl_t *db) |
|
1979 |
{ |
|
1980 |
return (refcount_count(&db->db_holds)); |
|
1981 |
} |
|
1982 |
||
1983 |
void * |
|
1984 |
dmu_buf_set_user(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr, |
|
1985 |
dmu_buf_evict_func_t *evict_func) |
|
1986 |
{ |
|
1987 |
return (dmu_buf_update_user(db_fake, NULL, user_ptr, |
|
1988 |
user_data_ptr_ptr, evict_func)); |
|
1989 |
} |
|
1990 |
||
1991 |
void * |
|
1992 |
dmu_buf_set_user_ie(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr, |
|
1993 |
dmu_buf_evict_func_t *evict_func) |
|
1994 |
{ |
|
1995 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
|
1996 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1997 |
db->db_immediate_evict = TRUE; |
789 | 1998 |
return (dmu_buf_update_user(db_fake, NULL, user_ptr, |
1999 |
user_data_ptr_ptr, evict_func)); |
|
2000 |
} |
|
2001 |
||
2002 |
void * |
|
2003 |
dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr, |
|
2004 |
void *user_data_ptr_ptr, dmu_buf_evict_func_t *evict_func) |
|
2005 |
{ |
|
2006 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
|
2007 |
ASSERT(db->db_level == 0); |
|
2008 |
||
2009 |
ASSERT((user_ptr == NULL) == (evict_func == NULL)); |
|
2010 |
||
2011 |
mutex_enter(&db->db_mtx); |
|
2012 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2013 |
if (db->db_user_ptr == old_user_ptr) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2014 |
db->db_user_ptr = user_ptr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2015 |
db->db_user_data_ptr_ptr = user_data_ptr_ptr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2016 |
db->db_evict_func = evict_func; |
789 | 2017 |
|
2018 |
dbuf_update_data(db); |
|
2019 |
} else { |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2020 |
old_user_ptr = db->db_user_ptr; |
789 | 2021 |
} |
2022 |
||
2023 |
mutex_exit(&db->db_mtx); |
|
2024 |
return (old_user_ptr); |
|
2025 |
} |
|
2026 |
||
2027 |
void * |
|
2028 |
dmu_buf_get_user(dmu_buf_t *db_fake) |
|
2029 |
{ |
|
2030 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake; |
|
2031 |
ASSERT(!refcount_is_zero(&db->db_holds)); |
|
2032 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2033 |
return (db->db_user_ptr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2034 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2035 |
|
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2036 |
boolean_t |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2037 |
dmu_buf_freeable(dmu_buf_t *dbuf) |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2038 |
{ |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2039 |
boolean_t res = B_FALSE; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2040 |
dmu_buf_impl_t *db = (dmu_buf_impl_t *)dbuf; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2041 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2042 |
if (db->db_blkptr) |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2043 |
res = dsl_dataset_block_freeable(db->db_objset->os_dsl_dataset, |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12411
diff
changeset
|
2044 |
db->db_blkptr, db->db_blkptr->blk_birth); |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2045 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2046 |
return (res); |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2047 |
} |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9412
diff
changeset
|
2048 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2049 |
static void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2050 |
dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2051 |
{ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2052 |
/* ASSERT(dmu_tx_is_syncing(tx) */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2053 |
ASSERT(MUTEX_HELD(&db->db_mtx)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2054 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2055 |
if (db->db_blkptr != NULL) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2056 |
return; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2057 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2058 |
if (db->db_blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2059 |
db->db_blkptr = &dn->dn_phys->dn_spill; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2060 |
BP_ZERO(db->db_blkptr); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2061 |
return; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2062 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2063 |
if (db->db_level == dn->dn_phys->dn_nlevels-1) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2064 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2065 |
* This buffer was allocated at a time when there was |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2066 |
* no available blkptrs from the dnode, or it was |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2067 |
* inappropriate to hook it in (i.e., nlevels mis-match). |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2068 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2069 |
ASSERT(db->db_blkid < dn->dn_phys->dn_nblkptr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2070 |
ASSERT(db->db_parent == NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2071 |
db->db_parent = dn->dn_dbuf; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2072 |
db->db_blkptr = &dn->dn_phys->dn_blkptr[db->db_blkid]; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2073 |
DBUF_VERIFY(db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2074 |
} else { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2075 |
dmu_buf_impl_t *parent = db->db_parent; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2076 |
int epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2077 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2078 |
ASSERT(dn->dn_phys->dn_nlevels > 1); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2079 |
if (parent == NULL) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2080 |
mutex_exit(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2081 |
rw_enter(&dn->dn_struct_rwlock, RW_READER); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2082 |
(void) dbuf_hold_impl(dn, db->db_level+1, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2083 |
db->db_blkid >> epbs, FALSE, db, &parent); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2084 |
rw_exit(&dn->dn_struct_rwlock); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2085 |
mutex_enter(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2086 |
db->db_parent = parent; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2087 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2088 |
db->db_blkptr = (blkptr_t *)parent->db.db_data + |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2089 |
(db->db_blkid & ((1ULL << epbs) - 1)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2090 |
DBUF_VERIFY(db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2091 |
} |
789 | 2092 |
} |
2093 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2094 |
static void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2095 |
dbuf_sync_indirect(dbuf_dirty_record_t *dr, dmu_tx_t *tx) |
789 | 2096 |
{ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2097 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2098 |
dnode_t *dn = db->db_dnode; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2099 |
zio_t *zio; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2100 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2101 |
ASSERT(dmu_tx_is_syncing(tx)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2102 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2103 |
dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2104 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2105 |
mutex_enter(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2106 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2107 |
ASSERT(db->db_level > 0); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2108 |
DBUF_VERIFY(db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2109 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2110 |
if (db->db_buf == NULL) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2111 |
mutex_exit(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2112 |
(void) dbuf_read(db, NULL, DB_RF_MUST_SUCCEED); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2113 |
mutex_enter(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2114 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2115 |
ASSERT3U(db->db_state, ==, DB_CACHED); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2116 |
ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2117 |
ASSERT(db->db_buf != NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2118 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2119 |
dbuf_check_blkptr(dn, db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2120 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2121 |
db->db_data_pending = dr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2122 |
|
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3882
diff
changeset
|
2123 |
mutex_exit(&db->db_mtx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2124 |
dbuf_write(dr, db->db_buf, tx); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2125 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2126 |
zio = dr->dr_zio; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2127 |
mutex_enter(&dr->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2128 |
dbuf_sync_list(&dr->dt.di.dr_children, tx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2129 |
ASSERT(list_head(&dr->dt.di.dr_children) == NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2130 |
mutex_exit(&dr->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2131 |
zio_nowait(zio); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2132 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2133 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2134 |
static void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2135 |
dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2136 |
{ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2137 |
arc_buf_t **datap = &dr->dt.dl.dr_data; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2138 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
789 | 2139 |
dnode_t *dn = db->db_dnode; |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
2140 |
objset_t *os = dn->dn_objset; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2141 |
uint64_t txg = tx->tx_txg; |
789 | 2142 |
|
2143 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
2144 |
||
2145 |
dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr); |
|
2146 |
||
2147 |
mutex_enter(&db->db_mtx); |
|
2148 |
/* |
|
2149 |
* To be synced, we must be dirtied. But we |
|
2150 |
* might have been freed after the dirty. |
|
2151 |
*/ |
|
2152 |
if (db->db_state == DB_UNCACHED) { |
|
2153 |
/* This buffer has been freed since it was dirtied */ |
|
2154 |
ASSERT(db->db.db_data == NULL); |
|
2155 |
} else if (db->db_state == DB_FILL) { |
|
2156 |
/* This buffer was freed and is now being re-filled */ |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2157 |
ASSERT(db->db.db_data != dr->dt.dl.dr_data); |
789 | 2158 |
} else { |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2159 |
ASSERT(db->db_state == DB_CACHED || db->db_state == DB_NOFILL); |
789 | 2160 |
} |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
2161 |
DBUF_VERIFY(db); |
789 | 2162 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2163 |
if (db->db_blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2164 |
mutex_enter(&dn->dn_mtx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2165 |
dn->dn_phys->dn_flags |= DNODE_FLAG_SPILL_BLKPTR; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2166 |
mutex_exit(&dn->dn_mtx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2167 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2168 |
|
789 | 2169 |
/* |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2170 |
* If this is a bonus buffer, simply copy the bonus data into the |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2171 |
* dnode. It will be written out when the dnode is synced (and it |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2172 |
* will be synced, since it must have been dirty for dbuf_sync to |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2173 |
* be called). |
789 | 2174 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2175 |
if (db->db_blkid == DMU_BONUS_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2176 |
dbuf_dirty_record_t **drp; |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4831
diff
changeset
|
2177 |
|
1544 | 2178 |
ASSERT(*datap != NULL); |
2179 |
ASSERT3U(db->db_level, ==, 0); |
|
2180 |
ASSERT3U(dn->dn_phys->dn_bonuslen, <=, DN_MAX_BONUSLEN); |
|
2181 |
bcopy(*datap, DN_BONUS(dn->dn_phys), dn->dn_phys->dn_bonuslen); |
|
4309
3dfde0f4662d
6542676 ARC needs to track meta-data memory overhead
maybee
parents:
3897
diff
changeset
|
2182 |
if (*datap != db->db.db_data) { |
1544 | 2183 |
zio_buf_free(*datap, DN_MAX_BONUSLEN); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
7872
diff
changeset
|
2184 |
arc_space_return(DN_MAX_BONUSLEN, ARC_SPACE_OTHER); |
4309
3dfde0f4662d
6542676 ARC needs to track meta-data memory overhead
maybee
parents:
3897
diff
changeset
|
2185 |
} |
1544 | 2186 |
db->db_data_pending = NULL; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2187 |
drp = &db->db_last_dirty; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2188 |
while (*drp != dr) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2189 |
drp = &(*drp)->dr_next; |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2190 |
ASSERT(dr->dr_next == NULL); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2191 |
ASSERT(dr->dr_dbuf == db); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2192 |
*drp = dr->dr_next; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2193 |
kmem_free(dr, sizeof (dbuf_dirty_record_t)); |
1544 | 2194 |
ASSERT(db->db_dirtycnt > 0); |
2195 |
db->db_dirtycnt -= 1; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2196 |
dbuf_rele_and_unlock(db, (void *)(uintptr_t)txg); |
1544 | 2197 |
return; |
2198 |
} |
|
2199 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2200 |
/* |
4312
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2201 |
* This function may have dropped the db_mtx lock allowing a dmu_sync |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2202 |
* operation to sneak in. As a result, we need to ensure that we |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2203 |
* don't check the dr_override_state until we have returned from |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2204 |
* dbuf_check_blkptr. |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2205 |
*/ |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2206 |
dbuf_check_blkptr(dn, db); |
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2207 |
|
4fef416ca8cb
6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents:
4309
diff
changeset
|
2208 |
/* |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2209 |
* If this buffer is in the middle of an immdiate write, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2210 |
* wait for the synchronous IO to complete. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2211 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2212 |
while (dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2213 |
ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2214 |
cv_wait(&db->db_changed, &db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2215 |
ASSERT(dr->dt.dl.dr_override_state != DR_NOT_OVERRIDDEN); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2216 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2217 |
|
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2218 |
if (db->db_state != DB_NOFILL && |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2219 |
dn->dn_object != DMU_META_DNODE_OBJECT && |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2220 |
refcount_count(&db->db_holds) > 1 && |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2221 |
dr->dt.dl.dr_override_state != DR_OVERRIDDEN && |
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2222 |
*datap == db->db_buf) { |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2223 |
/* |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2224 |
* If this buffer is currently "in use" (i.e., there |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2225 |
* are active holds and db_data still references it), |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2226 |
* then make a copy before we start the write so that |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2227 |
* any modifications from the open txg will not leak |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2228 |
* into this write. |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2229 |
* |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2230 |
* NOTE: this copy does not need to be made for |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2231 |
* objects only modified in the syncing context (e.g. |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2232 |
* DNONE_DNODE blocks). |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2233 |
*/ |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2234 |
int blksz = arc_buf_size(*datap); |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2235 |
arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2236 |
*datap = arc_buf_alloc(os->os_spa, blksz, db, type); |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8582
diff
changeset
|
2237 |
bcopy(db->db.db_data, (*datap)->b_data, blksz); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2238 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2239 |
db->db_data_pending = dr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2240 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2241 |
mutex_exit(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2242 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2243 |
dbuf_write(dr, *datap, tx); |
789 | 2244 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2245 |
ASSERT(!list_link_active(&dr->dr_dirty_node)); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2246 |
if (dn->dn_object == DMU_META_DNODE_OBJECT) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2247 |
list_insert_tail(&dn->dn_dirty_records[txg&TXG_MASK], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2248 |
else |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2249 |
zio_nowait(dr->dr_zio); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2250 |
} |
789 | 2251 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2252 |
void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2253 |
dbuf_sync_list(list_t *list, dmu_tx_t *tx) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2254 |
{ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2255 |
dbuf_dirty_record_t *dr; |
789 | 2256 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2257 |
while (dr = list_head(list)) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2258 |
if (dr->dr_zio != NULL) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2259 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2260 |
* If we find an already initialized zio then we |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2261 |
* are processing the meta-dnode, and we have finished. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2262 |
* The dbufs for all dnodes are put back on the list |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2263 |
* during processing, so that we can zio_wait() |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2264 |
* these IOs after initiating all child IOs. |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2265 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2266 |
ASSERT3U(dr->dr_dbuf->db.db_object, ==, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2267 |
DMU_META_DNODE_OBJECT); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2268 |
break; |
1163
4ba797920cc2
6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents:
982
diff
changeset
|
2269 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2270 |
list_remove(list, dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2271 |
if (dr->dr_dbuf->db_level > 0) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2272 |
dbuf_sync_indirect(dr, tx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2273 |
else |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2274 |
dbuf_sync_leaf(dr, tx); |
1163
4ba797920cc2
6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents:
982
diff
changeset
|
2275 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2276 |
} |
1163
4ba797920cc2
6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents:
982
diff
changeset
|
2277 |
|
789 | 2278 |
/* ARGSUSED */ |
2279 |
static void |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2280 |
dbuf_write_ready(zio_t *zio, arc_buf_t *buf, void *vdb) |
789 | 2281 |
{ |
2282 |
dmu_buf_impl_t *db = vdb; |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2283 |
blkptr_t *bp = zio->io_bp; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2284 |
blkptr_t *bp_orig = &zio->io_bp_orig; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2285 |
dnode_t *dn = db->db_dnode; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2286 |
spa_t *spa = zio->io_spa; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2287 |
int64_t delta; |
789 | 2288 |
uint64_t fill = 0; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2289 |
int i; |
789 | 2290 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2291 |
ASSERT(db->db_blkptr == bp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2292 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2293 |
delta = bp_get_dsize_sync(spa, bp) - bp_get_dsize_sync(spa, bp_orig); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2294 |
dnode_diduse_space(dn, delta - zio->io_prev_space_delta); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2295 |
zio->io_prev_space_delta = delta; |
789 | 2296 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2297 |
if (BP_IS_HOLE(bp)) { |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2298 |
ASSERT(bp->blk_fill == 0); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2299 |
return; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2300 |
} |
2237 | 2301 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2302 |
ASSERT((db->db_blkid != DMU_SPILL_BLKID && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2303 |
BP_GET_TYPE(bp) == dn->dn_type) || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2304 |
(db->db_blkid == DMU_SPILL_BLKID && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2305 |
BP_GET_TYPE(bp) == dn->dn_bonustype)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2306 |
ASSERT(BP_GET_LEVEL(bp) == db->db_level); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2307 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2308 |
mutex_enter(&db->db_mtx); |
789 | 2309 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2310 |
#ifdef ZFS_DEBUG |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2311 |
if (db->db_blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2312 |
dnode_t *dn = db->db_dnode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2313 |
ASSERT(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2314 |
ASSERT(!(BP_IS_HOLE(db->db_blkptr)) && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2315 |
db->db_blkptr == &dn->dn_phys->dn_spill); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2316 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2317 |
#endif |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2318 |
|
789 | 2319 |
if (db->db_level == 0) { |
2320 |
mutex_enter(&dn->dn_mtx); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2321 |
if (db->db_blkid > dn->dn_phys->dn_maxblkid && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2322 |
db->db_blkid != DMU_SPILL_BLKID) |
789 | 2323 |
dn->dn_phys->dn_maxblkid = db->db_blkid; |
2324 |
mutex_exit(&dn->dn_mtx); |
|
2325 |
||
2326 |
if (dn->dn_type == DMU_OT_DNODE) { |
|
2327 |
dnode_phys_t *dnp = db->db.db_data; |
|
2328 |
for (i = db->db.db_size >> DNODE_SHIFT; i > 0; |
|
2329 |
i--, dnp++) { |
|
2330 |
if (dnp->dn_type != DMU_OT_NONE) |
|
2331 |
fill++; |
|
2332 |
} |
|
2333 |
} else { |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2334 |
fill = 1; |
789 | 2335 |
} |
2336 |
} else { |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2337 |
blkptr_t *ibp = db->db.db_data; |
789 | 2338 |
ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2339 |
for (i = db->db.db_size >> SPA_BLKPTRSHIFT; i > 0; i--, ibp++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2340 |
if (BP_IS_HOLE(ibp)) |
789 | 2341 |
continue; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2342 |
fill += ibp->blk_fill; |
789 | 2343 |
} |
2344 |
} |
|
2345 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7467
diff
changeset
|
2346 |
bp->blk_fill = fill; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2347 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2348 |
mutex_exit(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2349 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2350 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2351 |
/* ARGSUSED */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2352 |
static void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2353 |
dbuf_write_done(zio_t *zio, arc_buf_t *buf, void *vdb) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2354 |
{ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2355 |
dmu_buf_impl_t *db = vdb; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2356 |
blkptr_t *bp = zio->io_bp; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2357 |
blkptr_t *bp_orig = &zio->io_bp_orig; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2358 |
dnode_t *dn = db->db_dnode; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2359 |
objset_t *os = dn->dn_objset; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2360 |
uint64_t txg = zio->io_txg; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2361 |
dbuf_dirty_record_t **drp, *dr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2362 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2363 |
ASSERT3U(zio->io_error, ==, 0); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2364 |
ASSERT(db->db_blkptr == bp); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2365 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2366 |
if (zio->io_flags & ZIO_FLAG_IO_REWRITE) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2367 |
ASSERT(BP_EQUAL(bp, bp_orig)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2368 |
} else { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2369 |
dsl_dataset_t *ds = os->os_dsl_dataset; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2370 |
dmu_tx_t *tx = os->os_synctx; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2371 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2372 |
(void) dsl_dataset_block_kill(ds, bp_orig, tx, B_TRUE); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2373 |
dsl_dataset_block_born(ds, bp, tx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2374 |
} |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2375 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2376 |
mutex_enter(&db->db_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2377 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2378 |
DBUF_VERIFY(db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2379 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2380 |
drp = &db->db_last_dirty; |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2381 |
while ((dr = *drp) != db->db_data_pending) |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2382 |
drp = &dr->dr_next; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2383 |
ASSERT(!list_link_active(&dr->dr_dirty_node)); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2384 |
ASSERT(dr->dr_txg == txg); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2385 |
ASSERT(dr->dr_dbuf == db); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2386 |
ASSERT(dr->dr_next == NULL); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5370
diff
changeset
|
2387 |
*drp = dr->dr_next; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2388 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2389 |
#ifdef ZFS_DEBUG |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2390 |
if (db->db_blkid == DMU_SPILL_BLKID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2391 |
dnode_t *dn = db->db_dnode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2392 |
ASSERT(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2393 |
ASSERT(!(BP_IS_HOLE(db->db_blkptr)) && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2394 |
db->db_blkptr == &dn->dn_phys->dn_spill); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2395 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2396 |
#endif |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2397 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2398 |
if (db->db_level == 0) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2399 |
ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2400 |
ASSERT(dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN); |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2401 |
if (db->db_state != DB_NOFILL) { |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2402 |
if (dr->dt.dl.dr_data != db->db_buf) |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2403 |
VERIFY(arc_buf_remove_ref(dr->dt.dl.dr_data, |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2404 |
db) == 1); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2405 |
else if (!arc_released(db->db_buf)) |
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2406 |
arc_set_callback(db->db_buf, dbuf_do_evict, db); |
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
2407 |
} |
789 | 2408 |
} else { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2409 |
ASSERT(list_head(&dr->dt.di.dr_children) == NULL); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2410 |
ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2411 |
if (!BP_IS_HOLE(db->db_blkptr)) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2412 |
int epbs = |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2413 |
dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2414 |
ASSERT3U(BP_GET_LSIZE(db->db_blkptr), ==, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2415 |
db->db.db_size); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2416 |
ASSERT3U(dn->dn_phys->dn_maxblkid |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2417 |
>> (db->db_level * epbs), >=, db->db_blkid); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2418 |
arc_set_callback(db->db_buf, dbuf_do_evict, db); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2419 |
} |
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4506
diff
changeset
|
2420 |
mutex_destroy(&dr->dt.di.dr_mtx); |
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4506
diff
changeset
|
2421 |
list_destroy(&dr->dt.di.dr_children); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2422 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2423 |
kmem_free(dr, sizeof (dbuf_dirty_record_t)); |
789 | 2424 |
|
2425 |
cv_broadcast(&db->db_changed); |
|
2426 |
ASSERT(db->db_dirtycnt > 0); |
|
2427 |
db->db_dirtycnt -= 1; |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
2428 |
db->db_data_pending = NULL; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2429 |
dbuf_rele_and_unlock(db, (void *)(uintptr_t)txg); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2430 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2431 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2432 |
static void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2433 |
dbuf_write_nofill_ready(zio_t *zio) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2434 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2435 |
dbuf_write_ready(zio, NULL, zio->io_private); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2436 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2437 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2438 |
static void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2439 |
dbuf_write_nofill_done(zio_t *zio) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2440 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2441 |
dbuf_write_done(zio, NULL, zio->io_private); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2442 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2443 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2444 |
static void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2445 |
dbuf_write_override_ready(zio_t *zio) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2446 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2447 |
dbuf_dirty_record_t *dr = zio->io_private; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2448 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2449 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2450 |
dbuf_write_ready(zio, NULL, db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2451 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2452 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2453 |
static void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2454 |
dbuf_write_override_done(zio_t *zio) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2455 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2456 |
dbuf_dirty_record_t *dr = zio->io_private; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2457 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2458 |
blkptr_t *obp = &dr->dt.dl.dr_overridden_by; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2459 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2460 |
mutex_enter(&db->db_mtx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2461 |
if (!BP_EQUAL(zio->io_bp, obp)) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2462 |
if (!BP_IS_HOLE(obp)) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2463 |
dsl_free(spa_get_dsl(zio->io_spa), zio->io_txg, obp); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2464 |
arc_release(dr->dt.dl.dr_data, db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2465 |
} |
789 | 2466 |
mutex_exit(&db->db_mtx); |
2467 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2468 |
dbuf_write_done(zio, NULL, db); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2469 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2470 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2471 |
static void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2472 |
dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2473 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2474 |
dmu_buf_impl_t *db = dr->dr_dbuf; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2475 |
dnode_t *dn = db->db_dnode; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2476 |
objset_t *os = dn->dn_objset; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2477 |
dmu_buf_impl_t *parent = db->db_parent; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2478 |
uint64_t txg = tx->tx_txg; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2479 |
zbookmark_t zb; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2480 |
zio_prop_t zp; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2481 |
zio_t *zio; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2482 |
int wp_flag = 0; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2483 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2484 |
if (db->db_state != DB_NOFILL) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2485 |
if (db->db_level > 0 || dn->dn_type == DMU_OT_DNODE) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2486 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2487 |
* Private object buffers are released here rather |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2488 |
* than in dbuf_dirty() since they are only modified |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2489 |
* in the syncing context and we don't want the |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2490 |
* overhead of making multiple copies of the data. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2491 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2492 |
if (BP_IS_HOLE(db->db_blkptr)) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2493 |
arc_buf_thaw(data); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2494 |
} else { |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12178
diff
changeset
|
2495 |
dbuf_release_bp(db); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2496 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2497 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2498 |
} |
789 | 2499 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2500 |
if (parent != dn->dn_dbuf) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2501 |
ASSERT(parent && parent->db_data_pending); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2502 |
ASSERT(db->db_level == parent->db_level-1); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2503 |
ASSERT(arc_released(parent->db_buf)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2504 |
zio = parent->db_data_pending->dr_zio; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2505 |
} else { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2506 |
ASSERT((db->db_level == dn->dn_phys->dn_nlevels-1 && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2507 |
db->db_blkid != DMU_SPILL_BLKID) || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2508 |
(db->db_blkid == DMU_SPILL_BLKID && db->db_level == 0)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2509 |
if (db->db_blkid != DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2510 |
ASSERT3P(db->db_blkptr, ==, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2511 |
&dn->dn_phys->dn_blkptr[db->db_blkid]); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2512 |
zio = dn->dn_zio; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2513 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2514 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2515 |
ASSERT(db->db_level == 0 || data == db->db_buf); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2516 |
ASSERT3U(db->db_blkptr->blk_birth, <=, txg); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2517 |
ASSERT(zio); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2518 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2519 |
SET_BOOKMARK(&zb, os->os_dsl_dataset ? |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2520 |
os->os_dsl_dataset->ds_object : DMU_META_OBJSET, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2521 |
db->db.db_object, db->db_level, db->db_blkid); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2522 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2523 |
if (db->db_blkid == DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2524 |
wp_flag = WP_SPILL; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2525 |
wp_flag |= (db->db_state == DB_NOFILL) ? WP_NOFILL : 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2526 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11609
diff
changeset
|
2527 |
dmu_write_policy(os, dn, db->db_level, wp_flag, &zp); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2528 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2529 |
if (db->db_level == 0 && dr->dt.dl.dr_override_state == DR_OVERRIDDEN) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2530 |
ASSERT(db->db_state != DB_NOFILL); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2531 |
dr->dr_zio = zio_write(zio, os->os_spa, txg, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2532 |
db->db_blkptr, data->b_data, arc_buf_size(data), &zp, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2533 |
dbuf_write_override_ready, dbuf_write_override_done, dr, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2534 |
ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2535 |
mutex_enter(&db->db_mtx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2536 |
dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2537 |
zio_write_override(dr->dr_zio, &dr->dt.dl.dr_overridden_by, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2538 |
dr->dt.dl.dr_copies); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2539 |
mutex_exit(&db->db_mtx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2540 |
} else if (db->db_state == DB_NOFILL) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2541 |
ASSERT(zp.zp_checksum == ZIO_CHECKSUM_OFF); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2542 |
dr->dr_zio = zio_write(zio, os->os_spa, txg, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2543 |
db->db_blkptr, NULL, db->db.db_size, &zp, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2544 |
dbuf_write_nofill_ready, dbuf_write_nofill_done, db, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2545 |
ZIO_PRIORITY_ASYNC_WRITE, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2546 |
ZIO_FLAG_MUSTSUCCEED | ZIO_FLAG_NODATA, &zb); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2547 |
} else { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2548 |
ASSERT(arc_released(data)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2549 |
dr->dr_zio = arc_write(zio, os->os_spa, txg, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2550 |
db->db_blkptr, data, DBUF_IS_L2CACHEABLE(db), &zp, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2551 |
dbuf_write_ready, dbuf_write_done, db, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2552 |
ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10298
diff
changeset
|
2553 |
} |
789 | 2554 |
} |