@@ -1600,14 +1600,15 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1600
1600
? &toRecycle_->asChainedItem ().getParentItem (compressor_)
1601
1601
: toRecycle_;
1602
1602
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{};
1609
1610
1610
- if (lastTier && shouldWriteToNvmCache (*candidate_) && !putToken .isValid ()) {
1611
+ if (evictToNvmCache && !token_ .isValid ()) {
1611
1612
stats_.evictFailConcurrentFill .inc ();
1612
1613
++itr;
1613
1614
continue ;
@@ -1630,7 +1631,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1630
1631
// since we won't be moving the item to the next tier
1631
1632
toRecycle = toRecycle_;
1632
1633
candidate = candidate_;
1633
- token = std::move (putToken );
1634
+ token = std::move (token_ );
1634
1635
1635
1636
// Check if parent changed for chained items - if yes, we cannot
1636
1637
// remove the child from the mmContainer as we will not be evicting
0 commit comments