@@ -463,9 +463,7 @@ void CacheAllocator<CacheTrait>::addChainedItem(WriteHandle& parent,
463463 // Parent will decrement the refcount upon release. Since this is an
464464 // internal refcount, we dont include it in active handle tracking.
465465 child->incRef ();
466- auto ref = child->getRefCount ();
467- // ref == 3 if child is moving
468- XDCHECK (ref == 2u || ref == 3 );
466+ XDCHECK_EQ (2u , child->getRefCount ());
469467
470468 invalidateNvm (*parent);
471469 if (auto eventTracker = getEventTracker ()) {
@@ -555,10 +553,7 @@ void CacheAllocator<CacheTrait>::transferChainLocked(WriteHandle& parent,
555553 ChainedItem* curr = &headHandle->asChainedItem ();
556554 const auto newParentPtr = compressor_.compress (newParent.get ());
557555 while (curr) {
558- if (!curr->isMoving ())
559- XDCHECK_EQ (curr == headHandle.get () ? 2u : 1u , curr->getRefCount ());
560- else
561- XDCHECK_EQ (curr == headHandle.get () ? 3u : 2u , curr->getRefCount ());
556+ XDCHECK_EQ (curr == headHandle.get () ? 2u : 1u , curr->getRefCount ());
562557 XDCHECK (curr->isInMMContainer ());
563558 curr->changeKey (newParentPtr);
564559 curr = curr->getNext (compressor_);
@@ -654,7 +649,7 @@ CacheAllocator<CacheTrait>::replaceChainedItemLocked(Item& oldItem,
654649 WriteHandle newItemHdl,
655650 const Item& parent) {
656651 XDCHECK (newItemHdl != nullptr );
657- XDCHECK_GE (2u , oldItem.getRefCount ());
652+ XDCHECK_GE (1u , oldItem.getRefCount ());
658653
659654 // grab the handle to the old item so that we can return this. Also, we need
660655 // to drop the refcount the parent holds on oldItem by manually calling
@@ -1157,7 +1152,7 @@ bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
11571152
11581153 // no one can add or remove chained items at this point
11591154 if (oldItem.hasChainedItem ()) {
1160- auto oldItemHdl = WriteHandle{ &oldItem, * this } ;
1155+ auto oldItemHdl = acquire ( &oldItem) ;
11611156 XDCHECK_EQ (1u , oldItemHdl->getRefCount ()) << oldItemHdl->toString ();
11621157 XDCHECK (!newItemHdl->hasChainedItem ()) << newItemHdl->toString ();
11631158 try {
@@ -1171,10 +1166,6 @@ bool CacheAllocator<CacheTrait>::moveRegularItem(Item& oldItem,
11711166
11721167 XDCHECK (!oldItem.hasChainedItem ());
11731168 XDCHECK (newItemHdl->hasChainedItem ());
1174-
1175- // drop the handle, no need to decRef since we relied on
1176- // item being moved
1177- oldItemHdl.release ();
11781169 }
11791170 newItemHdl.unmarkNascent ();
11801171 return true ;
0 commit comments