@@ -1309,7 +1309,7 @@ class CacheAllocator : public CacheBase {
1309
1309
1310
1310
private:
1311
1311
// 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);
1313
1313
FOLLY_ALWAYS_INLINE RefcountWithFlags::Value decRef (Item& it);
1314
1314
1315
1315
// drops the refcount and if needed, frees the allocation back to the memory
@@ -1360,6 +1360,12 @@ class CacheAllocator : public CacheBase {
1360
1360
bool nascent = false ,
1361
1361
const Item* toRecycle = nullptr );
1362
1362
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
+
1363
1369
// acquires an handle on the item. returns an empty handle if it is null.
1364
1370
// @param it pointer to an item
1365
1371
// @return WriteHandle return a handle to this item
@@ -1449,17 +1455,17 @@ class CacheAllocator : public CacheBase {
1449
1455
// @return handle to the parent item if the validations pass
1450
1456
// otherwise, an empty Handle is returned.
1451
1457
//
1452
- ReadHandle validateAndGetParentHandleForChainedMoveLocked (
1458
+ WriteHandle validateAndGetParentHandleForChainedMoveLocked (
1453
1459
const ChainedItem& item, const Key& parentKey);
1454
1460
1455
1461
// Given an existing item, allocate a new one for the
1456
1462
// existing one to later be moved into.
1457
1463
//
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
1459
1465
//
1460
1466
// @return handle to the newly allocated item
1461
1467
//
1462
- WriteHandle allocateNewItemForOldItem (const Item& oldItem );
1468
+ WriteHandle allocateNewItemForOldItem (const Item& item );
1463
1469
1464
1470
// internal helper that grabs a refcounted handle to the item. This does
1465
1471
// not record the access to reflect in the mmContainer.
@@ -1513,7 +1519,7 @@ class CacheAllocator : public CacheBase {
1513
1519
// callback is responsible for copying the contents and fixing the semantics
1514
1520
// of chained item.
1515
1521
//
1516
- // @param oldItem Reference to the item being moved
1522
+ // @param oldItem item being moved
1517
1523
// @param newItemHdl Reference to the handle of the new item being moved into
1518
1524
//
1519
1525
// @return true If the move was completed, and the containers were updated
@@ -1663,25 +1669,6 @@ class CacheAllocator : public CacheBase {
1663
1669
1664
1670
using EvictionIterator = typename MMContainer::Iterator;
1665
1671
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
-
1685
1672
// Deserializer CacheAllocatorMetadata and verify the version
1686
1673
//
1687
1674
// @param deserializer Deserializer object
@@ -1757,22 +1744,23 @@ class CacheAllocator : public CacheBase {
1757
1744
1758
1745
// @return true when successfully marked as moving,
1759
1746
// 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);
1763
1750
1764
1751
// "Move" (by copying) the content in this item to another memory
1765
1752
// location by invoking the move callback.
1766
1753
//
1767
1754
//
1768
1755
// @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)
1770
1758
// @param throttler slow this function down as not to take too much cpu
1771
1759
//
1772
1760
// @return true if the item has been moved
1773
1761
// false if we have exhausted moving attempts
1774
1762
bool moveForSlabRelease (const SlabReleaseContext& ctx,
1775
- Item& item ,
1763
+ Item& oldItem ,
1776
1764
util::Throttler& throttler);
1777
1765
1778
1766
// "Move" (by copying) the content in this item to another memory
@@ -1795,18 +1783,7 @@ class CacheAllocator : public CacheBase {
1795
1783
Item& item,
1796
1784
util::Throttler& throttler);
1797
1785
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);
1810
1787
1811
1788
// Helper function to remove a item if expired.
1812
1789
//
@@ -1928,18 +1905,14 @@ class CacheAllocator : public CacheBase {
1928
1905
std::optional<bool > saveNvmCache ();
1929
1906
void saveRamCache ();
1930
1907
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 ;
1933
1910
}
1934
1911
1935
1912
static bool itemExpiryPredicate (const Item& item) {
1936
1913
return item.getRefCount () == 1 && item.isExpired ();
1937
1914
}
1938
1915
1939
- static bool parentEvictForSlabReleasePredicate (const Item& item) {
1940
- return item.getRefCount () == 1 && !item.isExclusive ();
1941
- }
1942
-
1943
1916
std::unique_ptr<Deserializer> createDeserializer ();
1944
1917
1945
1918
// Execute func on each item. `func` can throw exception but must ensure
0 commit comments