@@ -1421,14 +1421,15 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1421
1421
? &toRecycle_->asChainedItem ().getParentItem (compressor_)
1422
1422
: toRecycle_;
1423
1423
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{};
1430
1431
1431
- if (lastTier && shouldWriteToNvmCache (*candidate_) && !putToken .isValid ()) {
1432
+ if (evictToNvmCache && !token_ .isValid ()) {
1432
1433
stats_.evictFailConcurrentFill .inc ();
1433
1434
++itr;
1434
1435
continue ;
@@ -1451,7 +1452,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
1451
1452
// since we won't be moving the item to the next tier
1452
1453
toRecycle = toRecycle_;
1453
1454
candidate = candidate_;
1454
- token = std::move (putToken );
1455
+ token = std::move (token_ );
1455
1456
1456
1457
// Check if parent changed for chained items - if yes, we cannot
1457
1458
// remove the child from the mmContainer as we will not be evicting
0 commit comments