MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dnode_allocate

Function dnode_allocate

freebsd/contrib/openzfs/module/zfs/dnode.c:573–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573void
574dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
575 dmu_object_type_t bonustype, int bonuslen, int dn_slots, dmu_tx_t *tx)
576{
577 int i;
578
579 ASSERT3U(dn_slots, >, 0);
580 ASSERT3U(dn_slots << DNODE_SHIFT, <=,
581 spa_maxdnodesize(dmu_objset_spa(dn->dn_objset)));
582 ASSERT3U(blocksize, <=,
583 spa_maxblocksize(dmu_objset_spa(dn->dn_objset)));
584 if (blocksize == 0)
585 blocksize = 1 << zfs_default_bs;
586 else
587 blocksize = P2ROUNDUP(blocksize, SPA_MINBLOCKSIZE);
588
589 if (ibs == 0)
590 ibs = zfs_default_ibs;
591
592 ibs = MIN(MAX(ibs, DN_MIN_INDBLKSHIFT), DN_MAX_INDBLKSHIFT);
593
594 dprintf("os=%p obj=%llu txg=%llu blocksize=%d ibs=%d dn_slots=%d\n",
595 dn->dn_objset, dn->dn_object, tx->tx_txg, blocksize, ibs, dn_slots);
596 DNODE_STAT_BUMP(dnode_allocate);
597
598 ASSERT(dn->dn_type == DMU_OT_NONE);
599 ASSERT(bcmp(dn->dn_phys, &dnode_phys_zero, sizeof (dnode_phys_t)) == 0);
600 ASSERT(dn->dn_phys->dn_type == DMU_OT_NONE);
601 ASSERT(ot != DMU_OT_NONE);
602 ASSERT(DMU_OT_IS_VALID(ot));
603 ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) ||
604 (bonustype == DMU_OT_SA && bonuslen == 0) ||
605 (bonustype != DMU_OT_NONE && bonuslen != 0));
606 ASSERT(DMU_OT_IS_VALID(bonustype));
607 ASSERT3U(bonuslen, <=, DN_SLOTS_TO_BONUSLEN(dn_slots));
608 ASSERT(dn->dn_type == DMU_OT_NONE);
609 ASSERT0(dn->dn_maxblkid);
610 ASSERT0(dn->dn_allocated_txg);
611 ASSERT0(dn->dn_assigned_txg);
612 ASSERT(zfs_refcount_is_zero(&dn->dn_tx_holds));
613 ASSERT3U(zfs_refcount_count(&dn->dn_holds), <=, 1);
614 ASSERT(avl_is_empty(&dn->dn_dbufs));
615
616 for (i = 0; i < TXG_SIZE; i++) {
617 ASSERT0(dn->dn_next_nblkptr[i]);
618 ASSERT0(dn->dn_next_nlevels[i]);
619 ASSERT0(dn->dn_next_indblkshift[i]);
620 ASSERT0(dn->dn_next_bonuslen[i]);
621 ASSERT0(dn->dn_next_bonustype[i]);
622 ASSERT0(dn->dn_rm_spillblk[i]);
623 ASSERT0(dn->dn_next_blksz[i]);
624 ASSERT0(dn->dn_next_maxblkid[i]);
625 ASSERT(!multilist_link_active(&dn->dn_dirty_link[i]));
626 ASSERT3P(list_head(&dn->dn_dirty_records[i]), ==, NULL);
627 ASSERT3P(dn->dn_free_ranges[i], ==, NULL);
628 }
629
630 dn->dn_type = ot;

Callers 3

dmu_object_alloc_implFunction · 0.85
dmu_object_claim_dnsizeFunction · 0.85

Calls 10

spa_maxdnodesizeFunction · 0.85
dmu_objset_spaFunction · 0.85
spa_maxblocksizeFunction · 0.85
zfs_refcount_is_zeroFunction · 0.85
zfs_refcount_countFunction · 0.85
avl_is_emptyFunction · 0.85
multilist_link_activeFunction · 0.85
dnode_setdblkszFunction · 0.85
dnode_setdirtyFunction · 0.85
list_headFunction · 0.50

Tested by

no test coverage detected