@@ -1309,7 +1309,7 @@ class CacheAllocator : public CacheBase {
13091309
13101310 private:
13111311 // wrapper around Item's refcount and active handle tracking
1312- FOLLY_ALWAYS_INLINE void incRef (Item& it);
1312+ FOLLY_ALWAYS_INLINE bool incRef (Item& it);
13131313 FOLLY_ALWAYS_INLINE RefcountWithFlags::Value decRef (Item& it);
13141314
13151315 // drops the refcount and if needed, frees the allocation back to the memory
@@ -1360,6 +1360,12 @@ class CacheAllocator : public CacheBase {
13601360 bool nascent = false ,
13611361 const Item* toRecycle = nullptr );
13621362
1363+ // Must be called by the thread which called markExclusive and
1364+ // succeeded. After this call, the item is unlinked from Access and
1365+ // MM Containers. The item is no longer marked as exclusive and it's
1366+ // ref count is 0 - it's available for recycling.
1367+ void unlinkItemExclusive (Item& it);
1368+
13631369 // acquires an handle on the item. returns an empty handle if it is null.
13641370 // @param it pointer to an item
13651371 // @return WriteHandle return a handle to this item
@@ -1449,17 +1455,17 @@ class CacheAllocator : public CacheBase {
14491455 // @return handle to the parent item if the validations pass
14501456 // otherwise, an empty Handle is returned.
14511457 //
1452- ReadHandle validateAndGetParentHandleForChainedMoveLocked (
1458+ WriteHandle validateAndGetParentHandleForChainedMoveLocked (
14531459 const ChainedItem& item, const Key& parentKey);
14541460
14551461 // Given an existing item, allocate a new one for the
14561462 // existing one to later be moved into.
14571463 //
1458- // @param oldItem the item we want to allocate a new item for
1464+ // @param item reference to the item we want to allocate a new item for
14591465 //
14601466 // @return handle to the newly allocated item
14611467 //
1462- WriteHandle allocateNewItemForOldItem (const Item& oldItem );
1468+ WriteHandle allocateNewItemForOldItem (const Item& item );
14631469
14641470 // internal helper that grabs a refcounted handle to the item. This does
14651471 // not record the access to reflect in the mmContainer.
@@ -1513,7 +1519,7 @@ class CacheAllocator : public CacheBase {
15131519 // callback is responsible for copying the contents and fixing the semantics
15141520 // of chained item.
15151521 //
1516- // @param oldItem Reference to the item being moved
1522+ // @param oldItem item being moved
15171523 // @param newItemHdl Reference to the handle of the new item being moved into
15181524 //
15191525 // @return true If the move was completed, and the containers were updated
@@ -1663,25 +1669,6 @@ class CacheAllocator : public CacheBase {
16631669
16641670 using EvictionIterator = typename MMContainer::Iterator;
16651671
1666- // Advance the current iterator and try to evict a regular item
1667- //
1668- // @param mmContainer the container to look for evictions.
1669- // @param itr iterator holding the item
1670- //
1671- // @return valid handle to regular item on success. This will be the last
1672- // handle to the item. On failure an empty handle.
1673- WriteHandle advanceIteratorAndTryEvictRegularItem (MMContainer& mmContainer,
1674- EvictionIterator& itr);
1675-
1676- // Advance the current iterator and try to evict a chained item
1677- // Iterator may also be reset during the course of this function
1678- //
1679- // @param itr iterator holding the item
1680- //
1681- // @return valid handle to the parent item on success. This will be the last
1682- // handle to the item
1683- WriteHandle advanceIteratorAndTryEvictChainedItem (EvictionIterator& itr);
1684-
16851672 // Deserializer CacheAllocatorMetadata and verify the version
16861673 //
16871674 // @param deserializer Deserializer object
@@ -1757,22 +1744,23 @@ class CacheAllocator : public CacheBase {
17571744
17581745 // @return true when successfully marked as moving,
17591746 // fasle when this item has already been freed
1760- bool markExclusiveForSlabRelease (const SlabReleaseContext& ctx,
1761- void * alloc,
1762- util::Throttler& throttler);
1747+ bool markMovingForSlabRelease (const SlabReleaseContext& ctx,
1748+ void * alloc,
1749+ util::Throttler& throttler);
17631750
17641751 // "Move" (by copying) the content in this item to another memory
17651752 // location by invoking the move callback.
17661753 //
17671754 //
17681755 // @param ctx slab release context
1769- // @param item old item to be moved elsewhere
1756+ // @param oldItem old item to be moved elsewhere
1757+ // @param handle handle to the item or to it's parent (if chained)
17701758 // @param throttler slow this function down as not to take too much cpu
17711759 //
17721760 // @return true if the item has been moved
17731761 // false if we have exhausted moving attempts
17741762 bool moveForSlabRelease (const SlabReleaseContext& ctx,
1775- Item& item ,
1763+ Item& oldItem ,
17761764 util::Throttler& throttler);
17771765
17781766 // "Move" (by copying) the content in this item to another memory
@@ -1795,18 +1783,7 @@ class CacheAllocator : public CacheBase {
17951783 Item& item,
17961784 util::Throttler& throttler);
17971785
1798- // Helper function to evict a normal item for slab release
1799- //
1800- // @return last handle for corresponding to item on success. empty handle on
1801- // failure. caller can retry if needed.
1802- WriteHandle evictNormalItemForSlabRelease (Item& item);
1803-
1804- // Helper function to evict a child item for slab release
1805- // As a side effect, the parent item is also evicted
1806- //
1807- // @return last handle to the parent item of the child on success. empty
1808- // handle on failure. caller can retry.
1809- WriteHandle evictChainedItemForSlabRelease (ChainedItem& item);
1786+ typename NvmCacheT::PutToken createPutToken (Item& item);
18101787
18111788 // Helper function to remove a item if expired.
18121789 //
@@ -1928,18 +1905,14 @@ class CacheAllocator : public CacheBase {
19281905 std::optional<bool > saveNvmCache ();
19291906 void saveRamCache ();
19301907
1931- static bool itemExclusivePredicate (const Item& item) {
1932- return item.getRefCount () == 0 ;
1908+ static bool itemSlabMovePredicate (const Item& item) {
1909+ return item.isMoving () && item. getRefCount () == 1 ;
19331910 }
19341911
19351912 static bool itemExpiryPredicate (const Item& item) {
19361913 return item.getRefCount () == 1 && item.isExpired ();
19371914 }
19381915
1939- static bool parentEvictForSlabReleasePredicate (const Item& item) {
1940- return item.getRefCount () == 1 && !item.isExclusive ();
1941- }
1942-
19431916 std::unique_ptr<Deserializer> createDeserializer ();
19441917
19451918 // Execute func on each item. `func` can throw exception but must ensure
0 commit comments