Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/overlaybd/cache/full_file_cache/cache_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,21 @@ void FileCachePool::eviction() {
evictByCache = totalUsed_ - waterMark_;
}

auto actualEvict = static_cast<int64_t>(std::max(evictByCache, evictByDisk));
auto actualEvict = std::min(
static_cast<int64_t>(std::max(evictByCache, evictByDisk)),
totalUsed_
);
Comment on lines +206 to +209
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior (capping actualEvict by totalUsed_) fixes a previously-reported infinite-loop scenario; please add a regression test to prevent reintroduction. There are existing gtest-based cache tests under src/overlaybd/cache/test/; consider adding a case that forces evictByDisk > totalUsed_ (e.g., via an IFileSystem wrapper that overrides statvfs) and verifies FileCachePool::eviction() terminates even when the LRU contains entries with openCount > 0 and size == 0.

Copilot uses AI. Check for mistakes.

if (actualEvict <= 0) {
return;
}

isFull_ = true;

if (!lru_.empty() && !exit_) {
LOG_AUDIT("eviction", VALUE(actualEvict), VALUE(evictByCache), VALUE(evictByDisk), VALUE(totalUsed_));
}

while (actualEvict > 0 && !lru_.empty() && !exit_) {
auto fileIter = lru_.back();
const auto &fileName = fileIter->first;
Expand Down
Loading