diff options
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp | 90 |
1 files changed, 46 insertions, 44 deletions
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp index 6f4d3993cbe..3872e4bccd0 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp @@ -68,7 +68,7 @@ const DiskLoc& DummyRecordStoreV1MetaData::capExtent() const { return _capExtent; } -void DummyRecordStoreV1MetaData::setCapExtent(OperationContext* txn, const DiskLoc& loc) { +void DummyRecordStoreV1MetaData::setCapExtent(OperationContext* opCtx, const DiskLoc& loc) { _capExtent = loc; } @@ -76,7 +76,7 @@ const DiskLoc& DummyRecordStoreV1MetaData::capFirstNewRecord() const { return _capFirstNewRecord; } -void DummyRecordStoreV1MetaData::setCapFirstNewRecord(OperationContext* txn, const DiskLoc& loc) { +void DummyRecordStoreV1MetaData::setCapFirstNewRecord(OperationContext* opCtx, const DiskLoc& loc) { _capFirstNewRecord = loc; } @@ -88,14 +88,14 @@ long long DummyRecordStoreV1MetaData::numRecords() const { return _numRecords; } -void DummyRecordStoreV1MetaData::incrementStats(OperationContext* txn, +void DummyRecordStoreV1MetaData::incrementStats(OperationContext* opCtx, long long dataSizeIncrement, long long numRecordsIncrement) { _dataSize += dataSizeIncrement; _numRecords += numRecordsIncrement; } -void DummyRecordStoreV1MetaData::setStats(OperationContext* txn, +void DummyRecordStoreV1MetaData::setStats(OperationContext* opCtx, long long dataSize, long long numRecords) { _dataSize = dataSize; @@ -113,7 +113,7 @@ DiskLoc DummyRecordStoreV1MetaData::deletedListEntry(int bucket) const { return _deletedLists[bucket]; } -void DummyRecordStoreV1MetaData::setDeletedListEntry(OperationContext* txn, +void DummyRecordStoreV1MetaData::setDeletedListEntry(OperationContext* opCtx, int bucket, const DiskLoc& loc) { invariant(bucket >= 0); @@ -127,29 +127,29 @@ DiskLoc DummyRecordStoreV1MetaData::deletedListLegacyGrabBag() const { return _deletedListLegacyGrabBag; } -void DummyRecordStoreV1MetaData::setDeletedListLegacyGrabBag(OperationContext* txn, +void DummyRecordStoreV1MetaData::setDeletedListLegacyGrabBag(OperationContext* opCtx, const DiskLoc& loc) { _deletedListLegacyGrabBag = loc; } -void DummyRecordStoreV1MetaData::orphanDeletedList(OperationContext* txn) { +void DummyRecordStoreV1MetaData::orphanDeletedList(OperationContext* opCtx) { // They will be recreated on demand. _deletedLists.clear(); } -const DiskLoc& DummyRecordStoreV1MetaData::firstExtent(OperationContext* txn) const { +const DiskLoc& DummyRecordStoreV1MetaData::firstExtent(OperationContext* opCtx) const { return _firstExtent; } -void DummyRecordStoreV1MetaData::setFirstExtent(OperationContext* txn, const DiskLoc& loc) { +void DummyRecordStoreV1MetaData::setFirstExtent(OperationContext* opCtx, const DiskLoc& loc) { _firstExtent = loc; } -const DiskLoc& DummyRecordStoreV1MetaData::lastExtent(OperationContext* txn) const { +const DiskLoc& DummyRecordStoreV1MetaData::lastExtent(OperationContext* opCtx) const { return _lastExtent; } -void DummyRecordStoreV1MetaData::setLastExtent(OperationContext* txn, const DiskLoc& loc) { +void DummyRecordStoreV1MetaData::setLastExtent(OperationContext* opCtx, const DiskLoc& loc) { _lastExtent = loc; } @@ -161,21 +161,21 @@ bool DummyRecordStoreV1MetaData::isUserFlagSet(int flag) const { return _userFlags & flag; } -bool DummyRecordStoreV1MetaData::setUserFlag(OperationContext* txn, int flag) { +bool DummyRecordStoreV1MetaData::setUserFlag(OperationContext* opCtx, int flag) { if ((_userFlags & flag) == flag) return false; _userFlags |= flag; return true; } -bool DummyRecordStoreV1MetaData::clearUserFlag(OperationContext* txn, int flag) { +bool DummyRecordStoreV1MetaData::clearUserFlag(OperationContext* opCtx, int flag) { if ((_userFlags & flag) == 0) return false; _userFlags &= ~flag; return true; } -bool DummyRecordStoreV1MetaData::replaceUserFlags(OperationContext* txn, int flags) { +bool DummyRecordStoreV1MetaData::replaceUserFlags(OperationContext* opCtx, int flags) { if (_userFlags == flags) return false; _userFlags = flags; @@ -183,11 +183,11 @@ bool DummyRecordStoreV1MetaData::replaceUserFlags(OperationContext* txn, int fla } -int DummyRecordStoreV1MetaData::lastExtentSize(OperationContext* txn) const { +int DummyRecordStoreV1MetaData::lastExtentSize(OperationContext* opCtx) const { return _lastExtentSize; } -void DummyRecordStoreV1MetaData::setLastExtentSize(OperationContext* txn, int newMax) { +void DummyRecordStoreV1MetaData::setLastExtentSize(OperationContext* opCtx, int newMax) { _lastExtentSize = newMax; } @@ -204,9 +204,9 @@ DummyExtentManager::~DummyExtentManager() { } } -void DummyExtentManager::close(OperationContext* txn) {} +void DummyExtentManager::close(OperationContext* opCtx) {} -Status DummyExtentManager::init(OperationContext* txn) { +Status DummyExtentManager::init(OperationContext* opCtx) { return Status::OK(); } @@ -219,7 +219,7 @@ long long DummyExtentManager::fileSize() const { return -1; } -DiskLoc DummyExtentManager::allocateExtent(OperationContext* txn, +DiskLoc DummyExtentManager::allocateExtent(OperationContext* opCtx, bool capped, int size, bool enforceQuota) { @@ -244,14 +244,14 @@ DiskLoc DummyExtentManager::allocateExtent(OperationContext* txn, return loc; } -void DummyExtentManager::freeExtents(OperationContext* txn, DiskLoc firstExt, DiskLoc lastExt) { +void DummyExtentManager::freeExtents(OperationContext* opCtx, DiskLoc firstExt, DiskLoc lastExt) { // XXX } -void DummyExtentManager::freeExtent(OperationContext* txn, DiskLoc extent) { +void DummyExtentManager::freeExtent(OperationContext* opCtx, DiskLoc extent) { // XXX } -void DummyExtentManager::freeListStats(OperationContext* txn, +void DummyExtentManager::freeListStats(OperationContext* opCtx, int* numExtents, int64_t* totalFreeSizeBytes) const { invariant(false); @@ -297,11 +297,11 @@ DummyExtentManager::CacheHint* DummyExtentManager::cacheHint(const DiskLoc& exte return new CacheHint(); } -DataFileVersion DummyExtentManager::getFileFormat(OperationContext* txn) const { +DataFileVersion DummyExtentManager::getFileFormat(OperationContext* opCtx) const { return DataFileVersion::defaultForNewFiles(); } -void DummyExtentManager::setFileFormat(OperationContext* txn, DataFileVersion newVersion) {} +void DummyExtentManager::setFileFormat(OperationContext* opCtx, DataFileVersion newVersion) {} const DataFile* DummyExtentManager::getOpenFile(int n) const { return nullptr; @@ -324,9 +324,11 @@ void accumulateExtentSizeRequirements(const LocAndSize* las, std::map<int, size_ } } -void printRecList(OperationContext* txn, const ExtentManager* em, const RecordStoreV1MetaData* md) { +void printRecList(OperationContext* opCtx, + const ExtentManager* em, + const RecordStoreV1MetaData* md) { log() << " *** BEGIN ACTUAL RECORD LIST *** "; - DiskLoc extLoc = md->firstExtent(txn); + DiskLoc extLoc = md->firstExtent(opCtx); std::set<DiskLoc> seenLocs; while (!extLoc.isNull()) { Extent* ext = em->getExtent(extLoc, true); @@ -380,7 +382,7 @@ void printDRecList(const ExtentManager* em, const RecordStoreV1MetaData* md) { } } -void initializeV1RS(OperationContext* txn, +void initializeV1RS(OperationContext* opCtx, const LocAndSize* records, const LocAndSize* drecs, const LocAndSize* legacyGrabBag, @@ -390,7 +392,7 @@ void initializeV1RS(OperationContext* txn, // Need to start with a blank slate invariant(em->numFiles() == 0); - invariant(md->firstExtent(txn).isNull()); + invariant(md->firstExtent(opCtx).isNull()); // pre-allocate extents (even extents that aren't part of this RS) { @@ -404,7 +406,7 @@ void initializeV1RS(OperationContext* txn, const int maxExtent = extentSizes.rbegin()->first; for (int i = 0; i <= maxExtent; i++) { const size_t size = extentSizes.count(i) ? extentSizes[i] : 0; - const DiskLoc loc = em->allocateExtent(txn, md->isCapped(), size, 0); + const DiskLoc loc = em->allocateExtent(opCtx, md->isCapped(), size, 0); // This function and assertState depend on these details of DummyExtentManager invariant(loc.a() == i); @@ -412,8 +414,8 @@ void initializeV1RS(OperationContext* txn, } // link together extents that should be part of this RS - md->setFirstExtent(txn, DiskLoc(extentSizes.begin()->first, 0)); - md->setLastExtent(txn, DiskLoc(extentSizes.rbegin()->first, 0)); + md->setFirstExtent(opCtx, DiskLoc(extentSizes.begin()->first, 0)); + md->setLastExtent(opCtx, DiskLoc(extentSizes.rbegin()->first, 0)); for (ExtentSizes::iterator it = extentSizes.begin(); boost::next(it) != extentSizes.end(); /* ++it */) { const int a = it->first; @@ -425,12 +427,12 @@ void initializeV1RS(OperationContext* txn, // This signals "done allocating new extents". if (md->isCapped()) - md->setDeletedListEntry(txn, 1, DiskLoc()); + md->setDeletedListEntry(opCtx, 1, DiskLoc()); } if (records && !records[0].loc.isNull()) { int recIdx = 0; - DiskLoc extLoc = md->firstExtent(txn); + DiskLoc extLoc = md->firstExtent(opCtx); while (!extLoc.isNull()) { Extent* ext = em->getExtent(extLoc); int prevOfs = DiskLoc::NullOfs; @@ -440,7 +442,7 @@ void initializeV1RS(OperationContext* txn, ; invariant(size >= MmapV1RecordHeader::HeaderSize); - md->incrementStats(txn, size - MmapV1RecordHeader::HeaderSize, 1); + md->incrementStats(opCtx, size - MmapV1RecordHeader::HeaderSize, 1); if (ext->firstRecord.isNull()) ext->firstRecord = loc; @@ -480,7 +482,7 @@ void initializeV1RS(OperationContext* txn, if (md->isCapped()) { // All drecs form a single list in bucket 0 if (prevNextPtr == NULL) { - md->setDeletedListEntry(txn, 0, loc); + md->setDeletedListEntry(opCtx, 0, loc); } else { *prevNextPtr = loc; } @@ -488,11 +490,11 @@ void initializeV1RS(OperationContext* txn, if (loc.a() < md->capExtent().a() && drecs[drecIdx + 1].loc.a() == md->capExtent().a()) { // Bucket 1 is known as cappedLastDelRecLastExtent - md->setDeletedListEntry(txn, 1, loc); + md->setDeletedListEntry(opCtx, 1, loc); } } else if (bucket != lastBucket) { invariant(bucket > lastBucket); // if this fails, drecs weren't sorted by bucket - md->setDeletedListEntry(txn, bucket, loc); + md->setDeletedListEntry(opCtx, bucket, loc); lastBucket = bucket; } else { *prevNextPtr = loc; @@ -519,7 +521,7 @@ void initializeV1RS(OperationContext* txn, invariant(size >= MmapV1RecordHeader::HeaderSize); if (grabBagIdx == 0) { - md->setDeletedListLegacyGrabBag(txn, loc); + md->setDeletedListLegacyGrabBag(opCtx, loc); } else { *prevNextPtr = loc; } @@ -535,10 +537,10 @@ void initializeV1RS(OperationContext* txn, } // Make sure we set everything up as requested. - assertStateV1RS(txn, records, drecs, legacyGrabBag, em, md); + assertStateV1RS(opCtx, records, drecs, legacyGrabBag, em, md); } -void assertStateV1RS(OperationContext* txn, +void assertStateV1RS(OperationContext* opCtx, const LocAndSize* records, const LocAndSize* drecs, const LocAndSize* legacyGrabBag, @@ -553,7 +555,7 @@ void assertStateV1RS(OperationContext* txn, int recIdx = 0; - DiskLoc extLoc = md->firstExtent(txn); + DiskLoc extLoc = md->firstExtent(opCtx); while (!extLoc.isNull()) { // for each Extent Extent* ext = em->getExtent(extLoc, true); int expectedPrevOfs = DiskLoc::NullOfs; @@ -579,7 +581,7 @@ void assertStateV1RS(OperationContext* txn, } if (ext->xnext.isNull()) { - ASSERT_EQUALS(md->lastExtent(txn), extLoc); + ASSERT_EQUALS(md->lastExtent(opCtx), extLoc); } extLoc = ext->xnext; @@ -602,7 +604,7 @@ void assertStateV1RS(OperationContext* txn, // the first drec in the capExtent. If the capExtent is the first Extent, // it should be Null. - if (md->capExtent() == md->firstExtent(txn)) { + if (md->capExtent() == md->firstExtent(opCtx)) { ASSERT_EQUALS(actualLoc, DiskLoc()); } else { ASSERT_NOT_EQUALS(actualLoc.a(), md->capExtent().a()); @@ -659,7 +661,7 @@ void assertStateV1RS(OperationContext* txn, } } catch (...) { // If a test fails, provide extra info to make debugging easier - printRecList(txn, em, md); + printRecList(opCtx, em, md); printDRecList(em, md); throw; } |