Inheritance diagram for TwoQPage:
Public Types | |
enum | DataStatus { DATA_INVALID, DATA_ERROR, DATA_CLEAN, DATA_DIRTY, DATA_WRITE, DATA_READ } |
Enumeration of possible status of page data. More... | |
enum | PageState { PAGE_STATE_POPULAR_PINNED, PAGE_STATE_POPULAR_UNPINNED, PAGE_STATE_FRESHMAN, PAGE_STATE_FREE } |
Enumeration of possible state values for a page when used with TwoQVictimPolicy. More... | |
Public Member Functions | |
TwoQPage (Cache &cache, PBuffer buffer) | |
Cache & | getCache () |
| |
bool | isDirty () const |
| |
bool | isTransferInProgress () const |
| |
bool | isDataValid () const |
| |
bool | isDataError () const |
| |
BlockId | getBlockId () const |
| |
PConstBuffer | getReadableData () const |
Obtains a const pointer to the page contents. | |
PBuffer | getWritableData () |
Obtains a writable pointer to the page contents, marking the page dirty. | |
bool | isScratchLocked () const |
| |
MappedPageListener * | getMappedPageListener () const |
| |
bool | tryUpgrade (TxnId txnId) |
Attempts to upgrade from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X. | |
void | upgrade (TxnId txnId) |
Upgrades from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X. | |
void | swapBuffers (CachePage &other) |
Swaps this page's buffer with another page. | |
PageState | getState () |
| |
void | setState (PageState newState) |
Sets a page's state. | |
TwoQDirtyPage & | getDirtyPageNode () |
| |
IntrusiveDListNode * | getNext () const |
IntrusiveDListNode * | getPrev () const |
void | detach () |
void | insertBefore (IntrusiveDListNode &newNext) |
void | insertAfter (IntrusiveDListNode &newPrev) |
Definition at line 42 of file Cache.cpp.
enum CachePage::DataStatus [inherited] |
Enumeration of possible status of page data.
Order matters (valid data states are grouped together, as are I/O states).
Definition at line 64 of file CachePage.h.
00064 { 00068 DATA_INVALID, 00069 00073 DATA_ERROR, 00074 00079 DATA_CLEAN, 00080 00084 DATA_DIRTY, 00085 00089 DATA_WRITE, 00090 00095 DATA_READ 00096 };
enum TwoQVictim::PageState [inherited] |
Enumeration of possible state values for a page when used with TwoQVictimPolicy.
Definition at line 294 of file TwoQVictimPolicy.h.
00294 { 00298 PAGE_STATE_POPULAR_PINNED, 00302 PAGE_STATE_POPULAR_UNPINNED, 00306 PAGE_STATE_FRESHMAN, 00310 PAGE_STATE_FREE 00311 };
Cache& CachePage::getCache | ( | ) | [inline, inherited] |
Definition at line 206 of file CachePage.h.
Referenced by DoubleBufferExecStream::execute(), CachePage::notifyTransferCompletion(), FlatFileExecStreamImpl::open(), ScratchBufferExecStream::open(), and DoubleBufferExecStream::open().
00207 { 00208 return cache; 00209 }
bool CachePage::isDirty | ( | ) | const [inline, inherited] |
Definition at line 215 of file CachePage.h.
Referenced by WALSegment::notifyPageUnmap(), and FuzzyCheckpointSet::operator()().
00216 { 00217 return dataStatus == DATA_DIRTY; 00218 }
bool CachePage::isTransferInProgress | ( | ) | const [inline, inherited] |
Definition at line 223 of file CachePage.h.
00224 { 00225 return (dataStatus >= DATA_WRITE); 00226 }
bool CachePage::isDataValid | ( | ) | const [inline, inherited] |
Definition at line 231 of file CachePage.h.
Referenced by CrcSegInputStream::lockBufferParanoid(), and CacheImpl< PageT, VictimPolicyT >::markPageDirty().
00232 { 00233 return (dataStatus >= DATA_CLEAN) && (dataStatus <= DATA_WRITE); 00234 }
bool CachePage::isDataError | ( | ) | const [inline, inherited] |
Definition at line 239 of file CachePage.h.
00240 { 00241 return (dataStatus == DATA_ERROR); 00242 }
BlockId CachePage::getBlockId | ( | ) | const [inline, inherited] |
Definition at line 247 of file CachePage.h.
Referenced by VersionedSegment::canFlushPage(), CachePage::isScratchLocked(), TracingSegment::notifyAfterPageCheckpointFlush(), WALSegment::notifyAfterPageFlush(), TracingSegment::notifyAfterPageFlush(), TracingSegment::notifyAfterPageRead(), TracingSegment::notifyBeforePageFlush(), WALSegment::notifyPageDirty(), VersionedSegment::notifyPageDirty(), TracingSegment::notifyPageDirty(), TracingSegment::notifyPageMap(), TracingSegment::notifyPageUnmap(), CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion(), and DeviceIdPagePredicate::operator()().
00248 { 00249 return blockId; 00250 }
PConstBuffer CachePage::getReadableData | ( | ) | const [inline, inherited] |
Obtains a const pointer to the page contents.
The page must be locked in shared or exclusive mode first. The number of valid bytes returned depends on the page size.
Definition at line 260 of file CachePage.h.
References LOCKMODE_S.
Referenced by VersionedRandomAllocationSegment::backupAllocationNodes(), SegNodeLock< Node >::checkMagicNumber(), SpillOutputStream::getInputStream(), SegNodeLock< Node >::getNodeForRead(), Segment::getReadableFooter(), SegNodeLock< Node >::isMagicNumberValid(), VersionedRandomAllocationSegment::locateDataPages(), VersionedSegment::notifyPageDirty(), SpillOutputStream::spill(), and PagingTestBase::verifyPage().
00261 { 00262 assert(isDataValid()); 00263 assert(lock.isLocked(LOCKMODE_S) || isExclusiveLockHeld()); 00264 return pBuffer; 00265 }
PBuffer CachePage::getWritableData | ( | ) | [inline, inherited] |
Obtains a writable pointer to the page contents, marking the page dirty.
The page must be locked in exclusive mode first. The number of valid bytes returned depends on the page size.
Definition at line 274 of file CachePage.h.
References Cache::getCache().
Referenced by LcsClusterNodeWriter::allocArrays(), LbmEntryTest::allocateBuf(), ExternalSortRunLoader::allocateBuffer(), BTreePrefetchSearchExecStream::allocateScratchPages(), LhxHashTable::allocBlock(), DoubleBufferExecStream::execute(), PagingTestBase::fillPage(), SegNodeLock< Node >::getNodeForWrite(), Segment::getWritableFooter(), LbmGeneratorExecStream::initBitmapTable(), LcsClusterAppendExecStream::initLoad(), SegPageBackupRestoreDevice::initScratchPages(), VersionedSegment::notifyPageDirty(), LbmUnionExecStream::open(), LbmChopperExecStream::open(), FlatFileExecStreamImpl::open(), ScratchBufferExecStream::open(), DoubleBufferExecStream::open(), VersionedSegment::recover(), SpillOutputStream::SpillOutputStream(), SegPageLock::swapBuffers(), and RandomAllocationSegmentTest::testAllocateAndDeallocate().
00275 { 00276 assert(isExclusiveLockHeld()); 00277 assert(!isDataError()); 00278 assert(!isTransferInProgress()); 00279 // REVIEW: is thread-safety ever an issue here? If so, it's also an 00280 // issue for the previous assertions. 00281 if (!isDirty()) { 00282 getCache().markPageDirty(*this); 00283 } 00284 return pBuffer; 00285 }
bool CachePage::isScratchLocked | ( | ) | const [inherited] |
Definition at line 72 of file CachePage.cpp.
References CachePage::getBlockId(), CompoundId::getDeviceId(), and Cache::NULL_DEVICE_ID.
00073 { 00074 return CompoundId::getDeviceId(getBlockId()) == Cache::NULL_DEVICE_ID; 00075 }
MappedPageListener* CachePage::getMappedPageListener | ( | ) | const [inline, inherited] |
Definition at line 295 of file CachePage.h.
Referenced by MappedPageListenerPredicate::operator()().
00296 { 00297 assert(hasBlockId()); 00298 return pMappedPageListener; 00299 }
bool CachePage::tryUpgrade | ( | TxnId | txnId | ) | [inline, inherited] |
Attempts to upgrade from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X.
This is a NOWAIT operation; it fails immediately if any other thread already holds a lock on the same page, or when a transfer is already in progress.
Definition at line 309 of file CachePage.h.
References CacheImpl< PageT, VictimPolicyT >::getAllocator(), Cache::getCache(), and Cache::getPageSize().
00310 { 00311 StrictMutexGuard pageGuard(mutex); 00312 if (isTransferInProgress()) { 00313 return false; 00314 } 00315 #ifdef DEBUG 00316 int errorCode; 00317 if (getCache().getAllocator().setProtection( 00318 pBuffer, getCache().getPageSize(), false, &errorCode)) 00319 { 00320 throw SysCallExcn("memory protection failed", errorCode); 00321 } 00322 #endif 00323 return lock.tryUpgrade(txnId); 00324 }
void CachePage::upgrade | ( | TxnId | txnId | ) | [inline, inherited] |
Upgrades from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X.
This is a WAIT operation if a page transfer is in progress. It's assumed that there are no other threads holding a lock on the same page.
Definition at line 332 of file CachePage.h.
References CacheImpl< PageT, VictimPolicyT >::getAllocator(), Cache::getCache(), and Cache::getPageSize().
00333 { 00334 StrictMutexGuard pageGuard(mutex); 00335 while (isTransferInProgress()) { 00336 waitForPendingIO(pageGuard); 00337 } 00338 #ifdef DEBUG 00339 int errorCode; 00340 if (getCache().getAllocator().setProtection( 00341 pBuffer, getCache().getPageSize(), false, &errorCode)) 00342 { 00343 throw SysCallExcn("memory protection failed", errorCode); 00344 } 00345 #endif 00346 bool rc = lock.tryUpgrade(txnId); 00347 assert(rc); 00348 }
void CachePage::swapBuffers | ( | CachePage & | other | ) | [inherited] |
Swaps this page's buffer with another page.
You almost certainly shouldn't be calling this directly (see SegPageLock::swapBuffers).
other | page to swap with |
Definition at line 65 of file CachePage.cpp.
References CachePage::isExclusiveLockHeld(), and CachePage::pBuffer.
00066 { 00067 assert(isExclusiveLockHeld()); 00068 assert(other.isExclusiveLockHeld()); 00069 std::swap(pBuffer,other.pBuffer); 00070 }
PageState TwoQVictim::getState | ( | ) | [inline, inherited] |
Definition at line 335 of file TwoQVictimPolicy.h.
00336 { 00337 return state; 00338 }
void TwoQVictim::setState | ( | PageState | newState | ) | [inline, inherited] |
Sets a page's state.
newState | the new state value for a page |
Definition at line 345 of file TwoQVictimPolicy.h.
00346 { 00347 state = newState; 00348 }
TwoQDirtyPage& TwoQVictim::getDirtyPageNode | ( | ) | [inline, inherited] |
Definition at line 353 of file TwoQVictimPolicy.h.
00354 { 00355 return dirtyPageNode; 00356 }
IntrusiveDListNode* IntrusiveDListNode::getNext | ( | ) | const [inline, inherited] |
Definition at line 45 of file IntrusiveDList.h.
Referenced by TwoQPageQueue::moveToTail(), TwoQPageQueue::remove(), and TwoQPageQueue::validateQueue().
00046 { 00047 return pNext; 00048 }
IntrusiveDListNode* IntrusiveDListNode::getPrev | ( | ) | const [inline, inherited] |
Definition at line 50 of file IntrusiveDList.h.
Referenced by TwoQPageQueue::moveToHead(), TwoQPageQueue::remove(), and TwoQPageQueue::validateQueue().
00051 { 00052 return pPrev; 00053 }
void IntrusiveDListNode::detach | ( | ) | [inline, inherited] |
Definition at line 55 of file IntrusiveDList.h.
Referenced by TwoQPageQueue::moveToHead(), TwoQPageQueue::moveToTail(), and TwoQPageQueue::remove().
00056 { 00057 if (pNext) { 00058 pNext->pPrev = pPrev; 00059 } 00060 if (pPrev) { 00061 pPrev->pNext = pNext; 00062 } 00063 pPrev = pNext = NULL; 00064 }
void IntrusiveDListNode::insertBefore | ( | IntrusiveDListNode & | newNext | ) | [inline, inherited] |
Definition at line 66 of file IntrusiveDList.h.
References IntrusiveDListNode::pNext, and IntrusiveDListNode::pPrev.
Referenced by TwoQPageQueue::insertAtHead(), and TwoQPageQueue::moveToHead().
00067 { 00068 pNext = &newNext; 00069 pPrev = pNext->pPrev; 00070 pNext->pPrev = this; 00071 if (pPrev) { 00072 pPrev->pNext = this; 00073 } 00074 }
void IntrusiveDListNode::insertAfter | ( | IntrusiveDListNode & | newPrev | ) | [inline, inherited] |
Definition at line 76 of file IntrusiveDList.h.
References IntrusiveDListNode::pNext, and IntrusiveDListNode::pPrev.
Referenced by TwoQPageQueue::insertAtTail(), and TwoQPageQueue::moveToTail().
00077 { 00078 pPrev = &newPrev; 00079 pNext = pPrev->pNext; 00080 pPrev->pNext = this; 00081 if (pNext) { 00082 pNext->pPrev = this; 00083 } 00084 }