Inheritance diagram for LRUPage:
Public Types | |
enum | DataStatus { DATA_INVALID, DATA_ERROR, DATA_CLEAN, DATA_DIRTY, DATA_WRITE, DATA_READ } |
Enumeration of possible status of page data. More... | |
Public Member Functions | |
LRUPage (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. |
Definition at line 52 of file CacheTestBase.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 };
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 }