@@ -1421,14 +1421,15 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14211421 ? &toRecycle_->asChainedItem ().getParentItem (compressor_)
14221422 : toRecycle_;
14231423
1424- typename NvmCacheT::PutToken putToken;
1425- if (lastTier) {
1426- // if it's last tier, the item will be evicted
1427- // need to create put token before marking it exclusive
1428- putToken = createPutToken (*candidate_);
1429- }
1424+ // if it's last tier, the item will be evicted
1425+ // need to create put token before marking it exclusive
1426+ const bool evictToNvmCache = lastTier && shouldWriteToNvmCache (*candidate_);
1427+
1428+ auto token_ = evictToNvmCache
1429+ ? nvmCache_->createPutToken (candidate_->getKey ())
1430+ : typename NvmCacheT::PutToken{};
14301431
1431- if (lastTier && shouldWriteToNvmCache (*candidate_) && !putToken .isValid ()) {
1432+ if (evictToNvmCache && !token_ .isValid ()) {
14321433 stats_.evictFailConcurrentFill .inc ();
14331434 ++itr;
14341435 continue ;
@@ -1451,7 +1452,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
14511452 // since we won't be moving the item to the next tier
14521453 toRecycle = toRecycle_;
14531454 candidate = candidate_;
1454- token = std::move (putToken );
1455+ token = std::move (token_ );
14551456
14561457 // Check if parent changed for chained items - if yes, we cannot
14571458 // remove the child from the mmContainer as we will not be evicting
0 commit comments