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; }
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; }