This commit is contained in:
kssenii 2024-04-02 19:04:02 +02:00
parent 9b74e246af
commit 607a9d761b

View File

@ -67,11 +67,11 @@ void EvictionCandidates::removeQueueEntries(const CachePriorityGuard::Lock & loc
{ {
for (const auto & candidate : key_candidates.candidates) for (const auto & candidate : key_candidates.candidates)
{ {
const auto & file_segment = candidate->file_segment; auto queue_iterator = candidate->getQueueIterator();
auto file_segment_lock = file_segment->lock(); queue_iterator->invalidate();
candidate->getQueueIterator()->remove(lock); candidate->file_segment->resetQueueIterator();
file_segment->setQueueIteratorUnlocked(nullptr, file_segment_lock); queue_iterator->remove(lock);
} }
} }
removed_queue_entries = true; removed_queue_entries = true;
@ -101,10 +101,14 @@ void EvictionCandidates::evict()
{ {
auto & candidate = key_candidates.candidates.back(); auto & candidate = key_candidates.candidates.back();
chassert(candidate->releasable()); chassert(candidate->releasable());
const auto segment = candidate->file_segment; const auto segment = candidate->file_segment;
auto iterator = segment->getQueueIterator();
IFileCachePriority::IteratorPtr iterator;
if (!removed_queue_entries)
{
iterator = segment->getQueueIterator();
chassert(iterator); chassert(iterator);
}
ProfileEvents::increment(ProfileEvents::FilesystemCacheEvictedFileSegments); ProfileEvents::increment(ProfileEvents::FilesystemCacheEvictedFileSegments);
ProfileEvents::increment(ProfileEvents::FilesystemCacheEvictedBytes, segment->range().size()); ProfileEvents::increment(ProfileEvents::FilesystemCacheEvictedBytes, segment->range().size());
@ -133,7 +137,7 @@ void EvictionCandidates::evict()
/// it was freed in favour of some reserver, so we can make it visibly /// it was freed in favour of some reserver, so we can make it visibly
/// free only for that particular reserver. /// free only for that particular reserver.
if (!removed_queue_entries) if (iterator)
queue_entries_to_invalidate.push_back(iterator); queue_entries_to_invalidate.push_back(iterator);
key_candidates.candidates.pop_back(); key_candidates.candidates.pop_back();