| 353 | } |
| 354 | |
| 355 | void CacheShard::removeEntryLocked(AsyncDataCacheEntry* entry) { |
| 356 | if (!entry->key_.fileNum.hasValue()) { |
| 357 | return; |
| 358 | } |
| 359 | const auto it = entryMap_.find( |
| 360 | RawFileCacheKey{entry->key_.fileNum.id(), entry->key_.offset}); |
| 361 | BOLT_CHECK(it != entryMap_.end()); |
| 362 | entryMap_.erase(it); |
| 363 | entry->key_.fileNum.clear(); |
| 364 | entry->setSsdFile(nullptr, 0); |
| 365 | if (entry->isPrefetch()) { |
| 366 | entry->setPrefetch(false); |
| 367 | } |
| 368 | // An entry can have data allocated if we remove it after failing |
| 369 | // to fill it. Free the data and account for the difference. In |
| 370 | // eviction, the data of the evicted entries is moved away, so |
| 371 | // that freeing while holding the shard mutex is exceptional. |
| 372 | const auto numPages = entry->data().numPages(); |
| 373 | if (numPages > 0) { |
| 374 | cache_->incrementCachedPages(-numPages); |
| 375 | cache_->allocator()->freeNonContiguous(entry->data()); |
| 376 | } |
| 377 | entry->tinyData_.clear(); |
| 378 | entry->tinyData_.shrink_to_fit(); |
| 379 | entry->size_ = 0; |
| 380 | } |
| 381 | |
| 382 | uint64_t CacheShard::evict( |
| 383 | uint64_t bytesToFree, |
nothing calls this directly
no test coverage detected