@@ -1600,14 +1600,15 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16001600 ? &toRecycle_->asChainedItem ().getParentItem (compressor_)
16011601 : toRecycle_;
16021602
1603- typename NvmCacheT::PutToken putToken;
1604- if (lastTier) {
1605- // if it's last tier, the item will be evicted
1606- // need to create put token before marking it exclusive
1607- putToken = createPutToken (*candidate_);
1608- }
1603+ // if it's last tier, the item will be evicted
1604+ // need to create put token before marking it exclusive
1605+ const bool evictToNvmCache = lastTier && shouldWriteToNvmCache (*candidate_);
1606+
1607+ auto token_ = evictToNvmCache
1608+ ? nvmCache_->createPutToken (candidate_->getKey ())
1609+ : typename NvmCacheT::PutToken{};
16091610
1610- if (lastTier && shouldWriteToNvmCache (*candidate_) && !putToken .isValid ()) {
1611+ if (evictToNvmCache && !token_ .isValid ()) {
16111612 stats_.evictFailConcurrentFill .inc ();
16121613 ++itr;
16131614 continue ;
@@ -1630,7 +1631,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
16301631 // since we won't be moving the item to the next tier
16311632 toRecycle = toRecycle_;
16321633 candidate = candidate_;
1633- token = std::move (putToken );
1634+ token = std::move (token_ );
16341635
16351636 // Check if parent changed for chained items - if yes, we cannot
16361637 // remove the child from the mmContainer as we will not be evicting
0 commit comments