Lines Matching defs:dl

70 dsl_deadlist_load_tree(dsl_deadlist_t *dl)
75 ASSERT(!dl->dl_oldfmt);
76 if (dl->dl_havetree)
79 avl_create(&dl->dl_tree, dsl_deadlist_compare,
82 for (zap_cursor_init(&zc, dl->dl_os, dl->dl_object);
87 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os,
89 avl_add(&dl->dl_tree, dle);
92 dl->dl_havetree = B_TRUE;
96 dsl_deadlist_open(dsl_deadlist_t *dl, objset_t *os, uint64_t object)
100 mutex_init(&dl->dl_lock, NULL, MUTEX_DEFAULT, NULL);
101 dl->dl_os = os;
102 dl->dl_object = object;
103 VERIFY3U(0, ==, dmu_bonus_hold(os, object, dl, &dl->dl_dbuf));
104 dmu_object_info_from_db(dl->dl_dbuf, &doi);
106 dmu_buf_rele(dl->dl_dbuf, dl);
107 dl->dl_dbuf = NULL;
108 dl->dl_oldfmt = B_TRUE;
109 VERIFY3U(0, ==, bpobj_open(&dl->dl_bpobj, os, object));
113 dl->dl_oldfmt = B_FALSE;
114 dl->dl_phys = dl->dl_dbuf->db_data;
115 dl->dl_havetree = B_FALSE;
119 dsl_deadlist_close(dsl_deadlist_t *dl)
124 dl->dl_os = NULL;
126 if (dl->dl_oldfmt) {
127 dl->dl_oldfmt = B_FALSE;
128 bpobj_close(&dl->dl_bpobj);
132 if (dl->dl_havetree) {
133 while ((dle = avl_destroy_nodes(&dl->dl_tree, &cookie))
138 avl_destroy(&dl->dl_tree);
140 dmu_buf_rele(dl->dl_dbuf, dl);
141 mutex_destroy(&dl->dl_lock);
142 dl->dl_dbuf = NULL;
143 dl->dl_phys = NULL;
182 dle_enqueue(dsl_deadlist_t *dl, dsl_deadlist_entry_t *dle,
186 dmu_objset_pool(dl->dl_os)->dp_empty_bpobj) {
187 uint64_t obj = bpobj_alloc(dl->dl_os, SPA_OLD_MAXBLOCKSIZE, tx);
189 bpobj_decr_empty(dl->dl_os, tx);
190 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
191 VERIFY3U(0, ==, zap_update_int_key(dl->dl_os, dl->dl_object,
198 dle_enqueue_subobj(dsl_deadlist_t *dl, dsl_deadlist_entry_t *dle,
202 dmu_objset_pool(dl->dl_os)->dp_empty_bpobj) {
206 bpobj_decr_empty(dl->dl_os, tx);
207 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
208 VERIFY3U(0, ==, zap_update_int_key(dl->dl_os, dl->dl_object,
214 dsl_deadlist_insert(dsl_deadlist_t *dl, const blkptr_t *bp, dmu_tx_t *tx)
220 if (dl->dl_oldfmt) {
221 bpobj_enqueue(&dl->dl_bpobj, bp, tx);
225 dsl_deadlist_load_tree(dl);
227 dmu_buf_will_dirty(dl->dl_dbuf, tx);
228 mutex_enter(&dl->dl_lock);
229 dl->dl_phys->dl_used +=
230 bp_get_dsize_sync(dmu_objset_spa(dl->dl_os), bp);
231 dl->dl_phys->dl_comp += BP_GET_PSIZE(bp);
232 dl->dl_phys->dl_uncomp += BP_GET_UCSIZE(bp);
233 mutex_exit(&dl->dl_lock);
236 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
238 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
240 dle = AVL_PREV(&dl->dl_tree, dle);
241 dle_enqueue(dl, dle, bp, tx);
249 dsl_deadlist_add_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx)
254 if (dl->dl_oldfmt)
257 dsl_deadlist_load_tree(dl);
261 obj = bpobj_alloc_empty(dl->dl_os, SPA_OLD_MAXBLOCKSIZE, tx);
262 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
263 avl_add(&dl->dl_tree, dle);
265 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, dl->dl_object,
273 dsl_deadlist_remove_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx)
278 if (dl->dl_oldfmt)
281 dsl_deadlist_load_tree(dl);
284 dle = avl_find(&dl->dl_tree, &dle_tofind, NULL);
285 dle_prev = AVL_PREV(&dl->dl_tree, dle);
287 dle_enqueue_subobj(dl, dle_prev, dle->dle_bpobj.bpo_object, tx);
289 avl_remove(&dl->dl_tree, dle);
293 VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object, mintxg, tx));
303 dsl_deadlist_t dl;
306 dsl_deadlist_open(&dl, os, dlobj);
307 if (dl.dl_oldfmt) {
308 dsl_deadlist_close(&dl);
315 dsl_deadlist_add_key(&dl,
320 dsl_deadlist_close(&dl);
324 dsl_deadlist_clone(dsl_deadlist_t *dl, uint64_t maxtxg,
330 newobj = dsl_deadlist_alloc(dl->dl_os, tx);
332 if (dl->dl_oldfmt) {
333 dsl_deadlist_regenerate(dl->dl_os, newobj, mrs_obj, tx);
337 dsl_deadlist_load_tree(dl);
339 for (dle = avl_first(&dl->dl_tree); dle;
340 dle = AVL_NEXT(&dl->dl_tree, dle)) {
346 obj = bpobj_alloc_empty(dl->dl_os, SPA_OLD_MAXBLOCKSIZE, tx);
347 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, newobj,
354 dsl_deadlist_space(dsl_deadlist_t *dl,
357 if (dl->dl_oldfmt) {
358 VERIFY3U(0, ==, bpobj_space(&dl->dl_bpobj,
363 mutex_enter(&dl->dl_lock);
364 *usedp = dl->dl_phys->dl_used;
365 *compp = dl->dl_phys->dl_comp;
366 *uncompp = dl->dl_phys->dl_uncomp;
367 mutex_exit(&dl->dl_lock);
377 dsl_deadlist_space_range(dsl_deadlist_t *dl, uint64_t mintxg, uint64_t maxtxg,
384 if (dl->dl_oldfmt) {
385 VERIFY3U(0, ==, bpobj_space_range(&dl->dl_bpobj,
392 mutex_enter(&dl->dl_lock);
393 dsl_deadlist_load_tree(dl);
395 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
401 avl_nearest(&dl->dl_tree, where, AVL_AFTER) == NULL);
404 dle = AVL_NEXT(&dl->dl_tree, dle)) {
414 mutex_exit(&dl->dl_lock);
418 dsl_deadlist_insert_bpobj(dsl_deadlist_t *dl, uint64_t obj, uint64_t birth,
427 VERIFY3U(0, ==, bpobj_open(&bpo, dl->dl_os, obj));
431 dsl_deadlist_load_tree(dl);
433 dmu_buf_will_dirty(dl->dl_dbuf, tx);
434 mutex_enter(&dl->dl_lock);
435 dl->dl_phys->dl_used += used;
436 dl->dl_phys->dl_comp += comp;
437 dl->dl_phys->dl_uncomp += uncomp;
438 mutex_exit(&dl->dl_lock);
441 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
443 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
444 dle_enqueue_subobj(dl, dle, obj, tx);
450 dsl_deadlist_t *dl = arg;
451 dsl_deadlist_insert(dl, bp, tx);
456 * Merge the deadlist pointed to by 'obj' into dl. obj will be left as
460 dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
468 VERIFY3U(0, ==, dmu_object_info(dl->dl_os, obj, &doi));
471 VERIFY3U(0, ==, bpobj_open(&bpo, dl->dl_os, obj));
473 dsl_deadlist_insert_cb, dl, tx));
478 for (zap_cursor_init(&zc, dl->dl_os, obj);
482 dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx);
483 VERIFY3U(0, ==, zap_remove_int(dl->dl_os, obj, mintxg, tx));
487 VERIFY3U(0, ==, dmu_bonus_hold(dl->dl_os, obj, FTAG, &bonus));
495 * Remove entries on dl that are >= mintxg, and put them on the bpobj.
498 dsl_deadlist_move_bpobj(dsl_deadlist_t *dl, bpobj_t *bpo, uint64_t mintxg,
505 ASSERT(!dl->dl_oldfmt);
506 dmu_buf_will_dirty(dl->dl_dbuf, tx);
507 dsl_deadlist_load_tree(dl);
510 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
512 dle = avl_nearest(&dl->dl_tree, where, AVL_AFTER);
521 mutex_enter(&dl->dl_lock);
522 ASSERT3U(dl->dl_phys->dl_used, >=, used);
523 ASSERT3U(dl->dl_phys->dl_comp, >=, comp);
524 ASSERT3U(dl->dl_phys->dl_uncomp, >=, uncomp);
525 dl->dl_phys->dl_used -= used;
526 dl->dl_phys->dl_comp -= comp;
527 dl->dl_phys->dl_uncomp -= uncomp;
528 mutex_exit(&dl->dl_lock);
530 VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object,
533 dle_next = AVL_NEXT(&dl->dl_tree, dle);
534 avl_remove(&dl->dl_tree, dle);