BOOLEAN InitCachePool (PCACHE_POOL CachePool #ifndef USE_DRAM ,ULONG DiskNum ,ULONG PartitionNum #endif ) { BOOLEAN ret; CachePool->Size = CachePool->Used = 0; CachePool->ReadHit = CachePool->WriteHit = 0; CachePool->Size = CACHE_POOL_NUM_BLOCKS; CachePool->HotSize = CachePool->Size / HOT_RATIO; CachePool->ColdSize = CachePool->Size - CachePool->HotSize; ret = InitStoragePool(&CachePool->Storage, CachePool->Size #ifndef USE_DRAM ,DiskNum ,PartitionNum #endif ); if (ret == FALSE) goto l_error; CachePool->hot_bpt_root = NULL; CachePool->cold_bpt_root = NULL; InitList(&CachePool->HotList); InitList(&CachePool->ColdList); return TRUE; l_error: DestroyStoragePool(&CachePool->Storage); return FALSE; }
VOID DestroyCachePool ( PCACHE_POOL CachePool ) { CachePool->Cache_Ops->Destroy(CachePool->Extend); DestroyStoragePool(&CachePool->Storage); ZERO(CachePool, sizeof(CACHE_POOL)); }
VOID DestroyCachePool(PCACHE_POOL CachePool) { DestroyList(&CachePool->HotList); DestroyList(&CachePool->ColdList); // B+ Tree Destroy Destroy_Tree(CachePool->hot_bpt_root); Destroy_Tree(CachePool->cold_bpt_root); CachePool->hot_bpt_root = NULL; CachePool->cold_bpt_root = NULL; DestroyStoragePool(&CachePool->Storage); }
VOID DestroyCachePool(PCACHE_POOL CachePool) { // B+ Tree Destroy DestroyList(&CachePool->ProtectedList); DestroyList(&CachePool->ProbationaryList); Destroy_Tree(CachePool->Protected_bpt_root); Destroy_Tree(CachePool->Probationary_bpt_root); CachePool->Protected_bpt_root = NULL; CachePool->Probationary_bpt_root = NULL; DestroyStoragePool(&CachePool->Storage); }
BOOLEAN InitCachePool ( PCACHE_POOL CachePool, CACHE_SIZE_T Size, Cache_Operations *Cache_Ops, PVOID Extend, const char *name ) { ZERO(CachePool, sizeof(CACHE_POOL)); if (InitStoragePool(&CachePool->Storage, Size) == FALSE) return FALSE; CachePool->Size = Size; CachePool->Cache_Ops = Cache_Ops; CachePool->Extend = Extend; CachePool->name = name; if (CachePool->Cache_Ops->Init(Extend, Size) == FALSE) goto l_error; return TRUE; l_error: DestroyStoragePool(&CachePool->Storage); return FALSE; }