Lines Matching defs:dn
40 dnode_increase_indirection(dnode_t *dn, dmu_tx_t *tx)
44 int nblkptr = dn->dn_phys->dn_nblkptr;
45 int old_toplvl = dn->dn_phys->dn_nlevels - 1;
46 int new_level = dn->dn_next_nlevels[txgoff];
49 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
52 ASSERT(dn->dn_phys->dn_type != DMU_OT_NONE);
53 ASSERT(RW_WRITE_HELD(&dn->dn_struct_rwlock));
54 ASSERT(new_level > 1 && dn->dn_phys->dn_nlevels > 0);
56 db = dbuf_hold_level(dn, dn->dn_phys->dn_nlevels, 0, FTAG);
59 dn->dn_phys->dn_nlevels = new_level;
60 dprintf("os=%p obj=%llu, increase to %d\n", dn->dn_objset,
61 dn->dn_object, dn->dn_phys->dn_nlevels);
68 bcopy(dn->dn_phys->dn_blkptr, db->db.db_data,
75 dbuf_find(dn->dn_objset, dn->dn_object, old_toplvl, i);
81 ASSERT3P(DB_DNODE(child), ==, dn);
84 if (child->db_parent && child->db_parent != dn->dn_dbuf) {
87 &dn->dn_phys->dn_blkptr[child->db_blkid]);
92 child->db_parent == dn->dn_dbuf);
106 bzero(dn->dn_phys->dn_blkptr, sizeof (blkptr_t) * nblkptr);
110 rw_exit(&dn->dn_struct_rwlock);
114 free_blocks(dnode_t *dn, blkptr_t *bp, int num, dmu_tx_t *tx)
116 dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset;
119 dprintf("ds=%p obj=%llx num=%d\n", ds, dn->dn_object, num);
126 ASSERT3U(bytesfreed, <=, DN_USED_BYTES(dn->dn_phys));
142 if (spa_feature_is_active(dn->dn_objset->os_spa,
150 dnode_diduse_space(dn, -bytesfreed);
160 dnode_t *dn;
163 dn = DB_DNODE(db);
164 epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
171 ASSERT3U(db->db.db_size, ==, 1 << dn->dn_phys->dn_indblkshift);
183 rw_enter(&dn->dn_struct_rwlock, RW_READER);
184 err = dbuf_hold_impl(dn, db->db_level-1,
186 rw_exit(&dn->dn_struct_rwlock);
236 dnode_t *dn;
255 dn = DB_DNODE(db);
256 epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
275 free_blocks(dn, bp, end-start+1, tx);
280 rw_enter(&dn->dn_struct_rwlock, RW_READER);
281 VERIFY0(dbuf_hold_impl(dn, db->db_level - 1,
283 rw_exit(&dn->dn_struct_rwlock);
302 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
304 rw_exit(&dn->dn_struct_rwlock);
305 free_blocks(dn, db->db_blkptr, 1, tx);
323 dnode_sync_free_range_impl(dnode_t *dn, uint64_t blkid, uint64_t nblks,
326 blkptr_t *bp = dn->dn_phys->dn_blkptr;
327 int dnlevel = dn->dn_phys->dn_nlevels;
330 if (blkid > dn->dn_phys->dn_maxblkid)
333 ASSERT(dn->dn_phys->dn_maxblkid < UINT64_MAX);
334 if (blkid + nblks > dn->dn_phys->dn_maxblkid) {
335 nblks = dn->dn_phys->dn_maxblkid - blkid + 1;
341 if (blkid >= dn->dn_phys->dn_nblkptr) {
345 ASSERT3U(blkid + nblks, <=, dn->dn_phys->dn_nblkptr);
346 free_blocks(dn, bp + blkid, nblks, tx);
349 (dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT);
354 ASSERT(start < dn->dn_phys->dn_nblkptr);
359 rw_enter(&dn->dn_struct_rwlock, RW_READER);
360 VERIFY0(dbuf_hold_impl(dn, dnlevel - 1, i,
362 rw_exit(&dn->dn_struct_rwlock);
370 dn->dn_phys->dn_maxblkid = blkid == 0 ? 0 : blkid - 1;
372 uint64_t off = (dn->dn_phys->dn_maxblkid + 1) *
373 (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT);
374 ASSERT(off < dn->dn_phys->dn_maxblkid ||
375 dn->dn_phys->dn_maxblkid == 0 ||
376 dnode_next_offset(dn, 0, &off, 1, 1, 0) != 0);
389 dnode_t *dn = dsfra->dsfra_dnode;
391 mutex_exit(&dn->dn_mtx);
392 dnode_sync_free_range_impl(dn, blkid, nblks, dsfra->dsfra_tx);
393 mutex_enter(&dn->dn_mtx);
400 dnode_evict_dbufs(dnode_t *dn)
405 mutex_enter(&dn->dn_dbufs_mtx);
406 for (db = avl_first(&dn->dn_dbufs); db != NULL; db = db_next) {
410 ASSERT3P(DB_DNODE(db), ==, dn);
420 avl_insert_here(&dn->dn_dbufs, &db_marker, db,
425 db_next = AVL_NEXT(&dn->dn_dbufs, &db_marker);
426 avl_remove(&dn->dn_dbufs, &db_marker);
430 db_next = AVL_NEXT(&dn->dn_dbufs, db);
433 mutex_exit(&dn->dn_dbufs_mtx);
435 dnode_evict_bonus(dn);
439 dnode_evict_bonus(dnode_t *dn)
441 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
442 if (dn->dn_bonus != NULL) {
443 if (refcount_is_zero(&dn->dn_bonus->db_holds)) {
444 mutex_enter(&dn->dn_bonus->db_mtx);
445 dbuf_destroy(dn->dn_bonus);
446 dn->dn_bonus = NULL;
448 dn->dn_bonus->db_pending_evict = TRUE;
451 rw_exit(&dn->dn_struct_rwlock);
486 dnode_sync_free(dnode_t *dn, dmu_tx_t *tx)
496 ASSERT0(DN_USED_BYTES(dn->dn_phys));
497 ASSERT(BP_IS_HOLE(dn->dn_phys->dn_blkptr));
499 dnode_undirty_dbufs(&dn->dn_dirty_records[txgoff]);
500 dnode_evict_dbufs(dn);
509 * ASSERT3U(refcount_count(&dn->dn_holds), ==, 1);
513 dn->dn_next_nlevels[txgoff] = 0;
514 dn->dn_next_indblkshift[txgoff] = 0;
515 dn->dn_next_blksz[txgoff] = 0;
518 ASSERT(dn->dn_phys->dn_type != DMU_OT_NONE);
519 ASSERT(dn->dn_type != DMU_OT_NONE);
521 ASSERT(dn->dn_free_txg > 0);
522 if (dn->dn_allocated_txg != dn->dn_free_txg)
523 dmu_buf_will_dirty(&dn->dn_dbuf->db, tx);
524 bzero(dn->dn_phys, sizeof (dnode_phys_t));
526 mutex_enter(&dn->dn_mtx);
527 dn->dn_type = DMU_OT_NONE;
528 dn->dn_maxblkid = 0;
529 dn->dn_allocated_txg = 0;
530 dn->dn_free_txg = 0;
531 dn->dn_have_spill = B_FALSE;
532 mutex_exit(&dn->dn_mtx);
534 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT);
536 dnode_rele(dn, (void *)(uintptr_t)tx->tx_txg);
547 dnode_sync(dnode_t *dn, dmu_tx_t *tx)
549 dnode_phys_t *dnp = dn->dn_phys;
551 list_t *list = &dn->dn_dirty_records[txgoff];
556 ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg);
559 DNODE_VERIFY(dn);
561 ASSERT(dn->dn_dbuf == NULL || arc_released(dn->dn_dbuf->db_buf));
563 if (dmu_objset_userused_enabled(dn->dn_objset) &&
564 !DMU_OBJECT_IS_SPECIAL(dn->dn_object)) {
565 mutex_enter(&dn->dn_mtx);
566 dn->dn_oldused = DN_USED_BYTES(dn->dn_phys);
567 dn->dn_oldflags = dn->dn_phys->dn_flags;
568 dn->dn_phys->dn_flags |= DNODE_FLAG_USERUSED_ACCOUNTED;
569 mutex_exit(&dn->dn_mtx);
570 dmu_objset_userquota_get_ids(dn, B_FALSE, tx);
573 ASSERT(!(dn->dn_phys->dn_flags &
577 mutex_enter(&dn->dn_mtx);
578 if (dn->dn_allocated_txg == tx->tx_txg) {
583 dnp->dn_nblkptr = dn->dn_nblkptr;
586 dnp->dn_type = dn->dn_type;
587 dnp->dn_bonustype = dn->dn_bonustype;
588 dnp->dn_bonuslen = dn->dn_bonuslen;
599 if (dn->dn_next_type[txgoff] != 0) {
600 dnp->dn_type = dn->dn_type;
601 dn->dn_next_type[txgoff] = 0;
604 if (dn->dn_next_blksz[txgoff] != 0) {
605 ASSERT(P2PHASE(dn->dn_next_blksz[txgoff],
608 dn->dn_maxblkid == 0 || list_head(list) != NULL ||
609 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT ==
611 range_tree_space(dn->dn_free_ranges[txgoff]) != 0);
613 dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT;
614 dn->dn_next_blksz[txgoff] = 0;
617 if (dn->dn_next_bonuslen[txgoff] != 0) {
618 if (dn->dn_next_bonuslen[txgoff] == DN_ZERO_BONUSLEN)
621 dnp->dn_bonuslen = dn->dn_next_bonuslen[txgoff];
623 dn->dn_next_bonuslen[txgoff] = 0;
626 if (dn->dn_next_bonustype[txgoff] != 0) {
627 ASSERT(DMU_OT_IS_VALID(dn->dn_next_bonustype[txgoff]));
628 dnp->dn_bonustype = dn->dn_next_bonustype[txgoff];
629 dn->dn_next_bonustype[txgoff] = 0;
632 boolean_t freeing_dnode = dn->dn_free_txg > 0 &&
633 dn->dn_free_txg <= tx->tx_txg;
639 if (dn->dn_rm_spillblk[txgoff] || freeing_dnode) {
642 dn->dn_rm_spillblk[txgoff] = 0;
645 if (dn->dn_next_indblkshift[txgoff] != 0) {
647 dnp->dn_indblkshift = dn->dn_next_indblkshift[txgoff];
648 dn->dn_next_indblkshift[txgoff] = 0;
656 dnp->dn_checksum = dn->dn_checksum;
657 dnp->dn_compress = dn->dn_compress;
659 mutex_exit(&dn->dn_mtx);
662 free_blocks(dn, &dn->dn_phys->dn_spill, 1, tx);
663 mutex_enter(&dn->dn_mtx);
665 mutex_exit(&dn->dn_mtx);
669 if (dn->dn_free_ranges[txgoff] != NULL) {
671 dsfra.dsfra_dnode = dn;
673 mutex_enter(&dn->dn_mtx);
674 range_tree_vacate(dn->dn_free_ranges[txgoff],
676 range_tree_destroy(dn->dn_free_ranges[txgoff]);
677 dn->dn_free_ranges[txgoff] = NULL;
678 mutex_exit(&dn->dn_mtx);
682 dn->dn_objset->os_freed_dnodes++;
683 dnode_sync_free(dn, tx);
687 if (dn->dn_next_nlevels[txgoff]) {
688 dnode_increase_indirection(dn, tx);
689 dn->dn_next_nlevels[txgoff] = 0;
692 if (dn->dn_next_nblkptr[txgoff]) {
694 ASSERT(dn->dn_allocated_txg == tx->tx_txg);
695 if (dn->dn_next_nblkptr[txgoff] > dnp->dn_nblkptr) {
699 (dn->dn_next_nblkptr[txgoff] - dnp->dn_nblkptr));
703 ASSERT(dn->dn_next_nblkptr[txgoff] < dnp->dn_nblkptr);
705 for (i = dn->dn_next_nblkptr[txgoff];
710 mutex_enter(&dn->dn_mtx);
711 dnp->dn_nblkptr = dn->dn_next_nblkptr[txgoff];
712 dn->dn_next_nblkptr[txgoff] = 0;
713 mutex_exit(&dn->dn_mtx);
716 dbuf_sync_list(list, dn->dn_phys->dn_nlevels - 1, tx);
718 if (!DMU_OBJECT_IS_SPECIAL(dn->dn_object)) {
720 dnode_rele(dn, (void *)(uintptr_t)tx->tx_txg);