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

Function dbuf_destroy

freebsd/contrib/openzfs/module/zfs/dbuf.c:2727–2843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2725}
2726
2727void
2728dbuf_destroy(dmu_buf_impl_t *db)
2729{
2730 dnode_t *dn;
2731 dmu_buf_impl_t *parent = db->db_parent;
2732 dmu_buf_impl_t *dndb;
2733
2734 ASSERT(MUTEX_HELD(&db->db_mtx));
2735 ASSERT(zfs_refcount_is_zero(&db->db_holds));
2736
2737 if (db->db_buf != NULL) {
2738 arc_buf_destroy(db->db_buf, db);
2739 db->db_buf = NULL;
2740 }
2741
2742 if (db->db_blkid == DMU_BONUS_BLKID) {
2743 int slots = DB_DNODE(db)->dn_num_slots;
2744 int bonuslen = DN_SLOTS_TO_BONUSLEN(slots);
2745 if (db->db.db_data != NULL) {
2746 kmem_free(db->db.db_data, bonuslen);
2747 arc_space_return(bonuslen, ARC_SPACE_BONUS);
2748 db->db_state = DB_UNCACHED;
2749 DTRACE_SET_STATE(db, "buffer cleared");
2750 }
2751 }
2752
2753 dbuf_clear_data(db);
2754
2755 if (multilist_link_active(&db->db_cache_link)) {
2756 ASSERT(db->db_caching_status == DB_DBUF_CACHE ||
2757 db->db_caching_status == DB_DBUF_METADATA_CACHE);
2758
2759 multilist_remove(dbuf_caches[db->db_caching_status].cache, db);
2760 (void) zfs_refcount_remove_many(
2761 &dbuf_caches[db->db_caching_status].size,
2762 db->db.db_size, db);
2763
2764 if (db->db_caching_status == DB_DBUF_METADATA_CACHE) {
2765 DBUF_STAT_BUMPDOWN(metadata_cache_count);
2766 } else {
2767 DBUF_STAT_BUMPDOWN(cache_levels[db->db_level]);
2768 DBUF_STAT_BUMPDOWN(cache_count);
2769 DBUF_STAT_DECR(cache_levels_bytes[db->db_level],
2770 db->db.db_size);
2771 }
2772 db->db_caching_status = DB_NO_CACHE;
2773 }
2774
2775 ASSERT(db->db_state == DB_UNCACHED || db->db_state == DB_NOFILL);
2776 ASSERT(db->db_data_pending == NULL);
2777 ASSERT(list_is_empty(&db->db_dirty_records));
2778
2779 db->db_state = DB_EVICTING;
2780 DTRACE_SET_STATE(db, "buffer eviction started");
2781 db->db_blkptr = NULL;
2782
2783 /*
2784 * Now that db_state is DB_EVICTING, nobody else can find this via

Callers 7

dbuf_evict_oneFunction · 0.85
dbuf_free_rangeFunction · 0.85
dbuf_undirtyFunction · 0.85
dbuf_rele_and_unlockFunction · 0.85
dnode_destroyFunction · 0.85
dnode_evict_dbufsFunction · 0.85
dnode_evict_bonusFunction · 0.85

Calls 15

zfs_refcount_is_zeroFunction · 0.85
arc_buf_destroyFunction · 0.85
arc_space_returnFunction · 0.85
dbuf_clear_dataFunction · 0.85
multilist_link_activeFunction · 0.85
multilist_removeFunction · 0.85
zfs_refcount_remove_manyFunction · 0.85
mutex_exitFunction · 0.85
avl_removeFunction · 0.85
membar_producerFunction · 0.85
mutex_enterFunction · 0.85
dnode_rele_and_unlockFunction · 0.85

Tested by

no test coverage detected