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

Function dbuf_evict_one

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

* Evict the oldest eligible dbuf from the dbuf cache. */

Source from the content-addressed store, hash-verified

665 * Evict the oldest eligible dbuf from the dbuf cache.
666 */
667static void
668dbuf_evict_one(void)
669{
670 int idx = multilist_get_random_index(dbuf_caches[DB_DBUF_CACHE].cache);
671 multilist_sublist_t *mls = multilist_sublist_lock(
672 dbuf_caches[DB_DBUF_CACHE].cache, idx);
673
674 ASSERT(!MUTEX_HELD(&dbuf_evict_lock));
675
676 dmu_buf_impl_t *db = multilist_sublist_tail(mls);
677 while (db != NULL && mutex_tryenter(&db->db_mtx) == 0) {
678 db = multilist_sublist_prev(mls, db);
679 }
680
681 DTRACE_PROBE2(dbuf__evict__one, dmu_buf_impl_t *, db,
682 multilist_sublist_t *, mls);
683
684 if (db != NULL) {
685 multilist_sublist_remove(mls, db);
686 multilist_sublist_unlock(mls);
687 (void) zfs_refcount_remove_many(
688 &dbuf_caches[DB_DBUF_CACHE].size, db->db.db_size, db);
689 DBUF_STAT_BUMPDOWN(cache_levels[db->db_level]);
690 DBUF_STAT_BUMPDOWN(cache_count);
691 DBUF_STAT_DECR(cache_levels_bytes[db->db_level],
692 db->db.db_size);
693 ASSERT3U(db->db_caching_status, ==, DB_DBUF_CACHE);
694 db->db_caching_status = DB_NO_CACHE;
695 dbuf_destroy(db);
696 DBUF_STAT_BUMP(cache_total_evicts);
697 } else {
698 multilist_sublist_unlock(mls);
699 }
700}
701
702/*
703 * The dbuf evict thread is responsible for aging out dbufs from the

Callers 2

dbuf_evict_threadFunction · 0.85
dbuf_evict_notifyFunction · 0.85

Calls 9

multilist_sublist_lockFunction · 0.85
multilist_sublist_tailFunction · 0.85
mutex_tryenterFunction · 0.85
multilist_sublist_prevFunction · 0.85
multilist_sublist_removeFunction · 0.85
multilist_sublist_unlockFunction · 0.85
zfs_refcount_remove_manyFunction · 0.85
dbuf_destroyFunction · 0.85

Tested by

no test coverage detected