@@ -1308,7 +1308,7 @@ class CacheAllocator : public CacheBase {
13081308
13091309 private:
13101310 // wrapper around Item's refcount and active handle tracking
1311- FOLLY_ALWAYS_INLINE void incRef (Item& it);
1311+ FOLLY_ALWAYS_INLINE bool incRef (Item& it);
13121312 FOLLY_ALWAYS_INLINE RefcountWithFlags::Value decRef (Item& it);
13131313
13141314 // drops the refcount and if needed, frees the allocation back to the memory
@@ -1359,6 +1359,12 @@ class CacheAllocator : public CacheBase {
13591359 bool nascent = false ,
13601360 const Item* toRecycle = nullptr );
13611361
1362+ // Must be called by the thread which called markForEviction and
1363+ // succeeded. After this call, the item is unlinked from Access and
1364+ // MM Containers. The item is no longer marked as exclusive and it's
1365+ // ref count is 0 - it's available for recycling.
1366+ void unlinkItemForEviction (Item& it);
1367+
13621368 // acquires an handle on the item. returns an empty handle if it is null.
13631369 // @param it pointer to an item
13641370 // @return WriteHandle return a handle to this item
@@ -1448,17 +1454,17 @@ class CacheAllocator : public CacheBase {
14481454 // @return handle to the parent item if the validations pass
14491455 // otherwise, an empty Handle is returned.
14501456 //
1451- ReadHandle validateAndGetParentHandleForChainedMoveLocked (
1457+ WriteHandle validateAndGetParentHandleForChainedMoveLocked (
14521458 const ChainedItem& item, const Key& parentKey);
14531459
14541460 // Given an existing item, allocate a new one for the
14551461 // existing one to later be moved into.
14561462 //
1457- // @param oldItem the item we want to allocate a new item for
1463+ // @param item reference to the item we want to allocate a new item for
14581464 //
14591465 // @return handle to the newly allocated item
14601466 //
1461- WriteHandle allocateNewItemForOldItem (const Item& oldItem );
1467+ WriteHandle allocateNewItemForOldItem (const Item& item );
14621468
14631469 // internal helper that grabs a refcounted handle to the item. This does
14641470 // not record the access to reflect in the mmContainer.
@@ -1512,7 +1518,7 @@ class CacheAllocator : public CacheBase {
15121518 // callback is responsible for copying the contents and fixing the semantics
15131519 // of chained item.
15141520 //
1515- // @param oldItem Reference to the item being moved
1521+ // @param oldItem item being moved
15161522 // @param newItemHdl Reference to the handle of the new item being moved into
15171523 //
15181524 // @return true If the move was completed, and the containers were updated
@@ -1662,25 +1668,6 @@ class CacheAllocator : public CacheBase {
16621668
16631669 using EvictionIterator = typename MMContainer::LockedIterator;
16641670
1665- // Advance the current iterator and try to evict a regular item
1666- //
1667- // @param mmContainer the container to look for evictions.
1668- // @param itr iterator holding the item
1669- //
1670- // @return valid handle to regular item on success. This will be the last
1671- // handle to the item. On failure an empty handle.
1672- WriteHandle advanceIteratorAndTryEvictRegularItem (MMContainer& mmContainer,
1673- EvictionIterator& itr);
1674-
1675- // Advance the current iterator and try to evict a chained item
1676- // Iterator may also be reset during the course of this function
1677- //
1678- // @param itr iterator holding the item
1679- //
1680- // @return valid handle to the parent item on success. This will be the last
1681- // handle to the item
1682- WriteHandle advanceIteratorAndTryEvictChainedItem (EvictionIterator& itr);
1683-
16841671 // Deserializer CacheAllocatorMetadata and verify the version
16851672 //
16861673 // @param deserializer Deserializer object
@@ -1765,13 +1752,14 @@ class CacheAllocator : public CacheBase {
17651752 //
17661753 //
17671754 // @param ctx slab release context
1768- // @param item old item to be moved elsewhere
1755+ // @param oldItem old item to be moved elsewhere
1756+ // @param handle handle to the item or to it's parent (if chained)
17691757 // @param throttler slow this function down as not to take too much cpu
17701758 //
17711759 // @return true if the item has been moved
17721760 // false if we have exhausted moving attempts
17731761 bool moveForSlabRelease (const SlabReleaseContext& ctx,
1774- Item& item ,
1762+ Item& oldItem ,
17751763 util::Throttler& throttler);
17761764
17771765 // "Move" (by copying) the content in this item to another memory
@@ -1794,18 +1782,7 @@ class CacheAllocator : public CacheBase {
17941782 Item& item,
17951783 util::Throttler& throttler);
17961784
1797- // Helper function to evict a normal item for slab release
1798- //
1799- // @return last handle for corresponding to item on success. empty handle on
1800- // failure. caller can retry if needed.
1801- WriteHandle evictNormalItemForSlabRelease (Item& item);
1802-
1803- // Helper function to evict a child item for slab release
1804- // As a side effect, the parent item is also evicted
1805- //
1806- // @return last handle to the parent item of the child on success. empty
1807- // handle on failure. caller can retry.
1808- WriteHandle evictChainedItemForSlabRelease (ChainedItem& item);
1785+ typename NvmCacheT::PutToken createPutToken (Item& item);
18091786
18101787 // Helper function to remove a item if expired.
18111788 //
@@ -1927,18 +1904,14 @@ class CacheAllocator : public CacheBase {
19271904 std::optional<bool > saveNvmCache ();
19281905 void saveRamCache ();
19291906
1930- static bool itemExclusivePredicate (const Item& item) {
1931- return item.getRefCount () == 0 ;
1907+ static bool itemSlabMovePredicate (const Item& item) {
1908+ return item.isMoving () && item. getRefCount () == 0 ;
19321909 }
19331910
19341911 static bool itemExpiryPredicate (const Item& item) {
19351912 return item.getRefCount () == 1 && item.isExpired ();
19361913 }
19371914
1938- static bool parentEvictForSlabReleasePredicate (const Item& item) {
1939- return item.getRefCount () == 1 && !item.isMoving ();
1940- }
1941-
19421915 std::unique_ptr<Deserializer> createDeserializer ();
19431916
19441917 // Execute func on each item. `func` can throw exception but must ensure
0 commit comments