diff options
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp | 249 |
1 files changed, 127 insertions, 122 deletions
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp index d67fa341cb4..2c49cf8b5c8 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp @@ -139,7 +139,7 @@ RecordStoreV1Base::RecordStoreV1Base(StringData ns, RecordStoreV1Base::~RecordStoreV1Base() {} -int64_t RecordStoreV1Base::storageSize(OperationContext* txn, +int64_t RecordStoreV1Base::storageSize(OperationContext* opCtx, BSONObjBuilder* extraInfo, int level) const { BSONArrayBuilder extentInfo; @@ -147,7 +147,7 @@ int64_t RecordStoreV1Base::storageSize(OperationContext* txn, int64_t total = 0; int n = 0; - DiskLoc cur = _details->firstExtent(txn); + DiskLoc cur = _details->firstExtent(opCtx); while (!cur.isNull()) { Extent* e = _extentManager->getExtent(cur); @@ -170,11 +170,11 @@ int64_t RecordStoreV1Base::storageSize(OperationContext* txn, return total; } -RecordData RecordStoreV1Base::dataFor(OperationContext* txn, const RecordId& loc) const { +RecordData RecordStoreV1Base::dataFor(OperationContext* opCtx, const RecordId& loc) const { return recordFor(DiskLoc::fromRecordId(loc))->toRecordData(); } -bool RecordStoreV1Base::findRecord(OperationContext* txn, +bool RecordStoreV1Base::findRecord(OperationContext* opCtx, const RecordId& loc, RecordData* rd) const { // this is a bit odd, as the semantics of using the storage engine imply it _has_ to be. @@ -202,28 +202,29 @@ DeletedRecord* RecordStoreV1Base::drec(const DiskLoc& loc) const { return reinterpret_cast<DeletedRecord*>(recordFor(loc)); } -Extent* RecordStoreV1Base::_getExtent(OperationContext* txn, const DiskLoc& loc) const { +Extent* RecordStoreV1Base::_getExtent(OperationContext* opCtx, const DiskLoc& loc) const { return _extentManager->getExtent(loc); } -DiskLoc RecordStoreV1Base::_getExtentLocForRecord(OperationContext* txn, const DiskLoc& loc) const { +DiskLoc RecordStoreV1Base::_getExtentLocForRecord(OperationContext* opCtx, + const DiskLoc& loc) const { return _extentManager->extentLocForV1(loc); } -DiskLoc RecordStoreV1Base::getNextRecord(OperationContext* txn, const DiskLoc& loc) const { - DiskLoc next = getNextRecordInExtent(txn, loc); +DiskLoc RecordStoreV1Base::getNextRecord(OperationContext* opCtx, const DiskLoc& loc) const { + DiskLoc next = getNextRecordInExtent(opCtx, loc); if (!next.isNull()) { return next; } // now traverse extents - Extent* e = _getExtent(txn, _getExtentLocForRecord(txn, loc)); + Extent* e = _getExtent(opCtx, _getExtentLocForRecord(opCtx, loc)); while (1) { if (e->xnext.isNull()) return DiskLoc(); // end of collection - e = _getExtent(txn, e->xnext); + e = _getExtent(opCtx, e->xnext); if (!e->firstRecord.isNull()) break; // entire extent could be empty, keep looking @@ -231,19 +232,19 @@ DiskLoc RecordStoreV1Base::getNextRecord(OperationContext* txn, const DiskLoc& l return e->firstRecord; } -DiskLoc RecordStoreV1Base::getPrevRecord(OperationContext* txn, const DiskLoc& loc) const { - DiskLoc prev = getPrevRecordInExtent(txn, loc); +DiskLoc RecordStoreV1Base::getPrevRecord(OperationContext* opCtx, const DiskLoc& loc) const { + DiskLoc prev = getPrevRecordInExtent(opCtx, loc); if (!prev.isNull()) { return prev; } // now traverse extents - Extent* e = _getExtent(txn, _getExtentLocForRecord(txn, loc)); + Extent* e = _getExtent(opCtx, _getExtentLocForRecord(opCtx, loc)); while (1) { if (e->xprev.isNull()) return DiskLoc(); // end of collection - e = _getExtent(txn, e->xprev); + e = _getExtent(opCtx, e->xprev); if (!e->firstRecord.isNull()) break; // entire extent could be empty, keep looking @@ -251,7 +252,7 @@ DiskLoc RecordStoreV1Base::getPrevRecord(OperationContext* txn, const DiskLoc& l return e->lastRecord; } -DiskLoc RecordStoreV1Base::_findFirstSpot(OperationContext* txn, +DiskLoc RecordStoreV1Base::_findFirstSpot(OperationContext* opCtx, const DiskLoc& extDiskLoc, Extent* e) { DiskLoc emptyLoc = extDiskLoc; @@ -266,14 +267,15 @@ DiskLoc RecordStoreV1Base::_findFirstSpot(OperationContext* txn, ofs = newOfs; } - DeletedRecord* empty = txn->recoveryUnit()->writing(drec(emptyLoc)); + DeletedRecord* empty = opCtx->recoveryUnit()->writing(drec(emptyLoc)); empty->lengthWithHeaders() = delRecLength; empty->extentOfs() = e->myLoc.getOfs(); empty->nextDeleted().Null(); return emptyLoc; } -DiskLoc RecordStoreV1Base::getNextRecordInExtent(OperationContext* txn, const DiskLoc& loc) const { +DiskLoc RecordStoreV1Base::getNextRecordInExtent(OperationContext* opCtx, + const DiskLoc& loc) const { int nextOffset = recordFor(loc)->nextOfs(); if (nextOffset == DiskLoc::NullOfs) @@ -284,7 +286,8 @@ DiskLoc RecordStoreV1Base::getNextRecordInExtent(OperationContext* txn, const Di return result; } -DiskLoc RecordStoreV1Base::getPrevRecordInExtent(OperationContext* txn, const DiskLoc& loc) const { +DiskLoc RecordStoreV1Base::getPrevRecordInExtent(OperationContext* opCtx, + const DiskLoc& loc) const { int prevOffset = recordFor(loc)->prevOfs(); if (prevOffset == DiskLoc::NullOfs) @@ -295,7 +298,7 @@ DiskLoc RecordStoreV1Base::getPrevRecordInExtent(OperationContext* txn, const Di return result; } -Status RecordStoreV1Base::insertRecordsWithDocWriter(OperationContext* txn, +Status RecordStoreV1Base::insertRecordsWithDocWriter(OperationContext* opCtx, const DocWriter* const* docs, size_t nDocs, RecordId* idsOut) { @@ -312,19 +315,19 @@ Status RecordStoreV1Base::insertRecordsWithDocWriter(OperationContext* txn, ? quantizeAllocationSpace(lenWHdr) : lenWHdr; - StatusWith<DiskLoc> loc = allocRecord(txn, lenToAlloc, /*enforceQuota=*/false); + StatusWith<DiskLoc> loc = allocRecord(opCtx, lenToAlloc, /*enforceQuota=*/false); if (!loc.isOK()) return loc.getStatus(); MmapV1RecordHeader* r = recordFor(loc.getValue()); fassert(17319, r->lengthWithHeaders() >= lenWHdr); - r = reinterpret_cast<MmapV1RecordHeader*>(txn->recoveryUnit()->writingPtr(r, lenWHdr)); + r = reinterpret_cast<MmapV1RecordHeader*>(opCtx->recoveryUnit()->writingPtr(r, lenWHdr)); docs[i]->writeDocument(r->data()); - _addRecordToRecListInExtent(txn, r, loc.getValue()); + _addRecordToRecListInExtent(opCtx, r, loc.getValue()); - _details->incrementStats(txn, r->netLength(), 1); + _details->incrementStats(opCtx, r->netLength(), 1); if (idsOut) idsOut[i] = loc.getValue().toRecordId(); @@ -335,7 +338,7 @@ Status RecordStoreV1Base::insertRecordsWithDocWriter(OperationContext* txn, } -StatusWith<RecordId> RecordStoreV1Base::insertRecord(OperationContext* txn, +StatusWith<RecordId> RecordStoreV1Base::insertRecord(OperationContext* opCtx, const char* data, int len, bool enforceQuota) { @@ -347,10 +350,10 @@ StatusWith<RecordId> RecordStoreV1Base::insertRecord(OperationContext* txn, return StatusWith<RecordId>(ErrorCodes::InvalidLength, "record has to be <= 16.5MB"); } - return _insertRecord(txn, data, len, enforceQuota); + return _insertRecord(opCtx, data, len, enforceQuota); } -StatusWith<RecordId> RecordStoreV1Base::_insertRecord(OperationContext* txn, +StatusWith<RecordId> RecordStoreV1Base::_insertRecord(OperationContext* opCtx, const char* data, int len, bool enforceQuota) { @@ -358,7 +361,7 @@ StatusWith<RecordId> RecordStoreV1Base::_insertRecord(OperationContext* txn, const int lenToAlloc = shouldPadInserts() ? quantizeAllocationSpace(lenWHdr) : lenWHdr; fassert(17208, lenToAlloc >= lenWHdr); - StatusWith<DiskLoc> loc = allocRecord(txn, lenToAlloc, enforceQuota); + StatusWith<DiskLoc> loc = allocRecord(opCtx, lenToAlloc, enforceQuota); if (!loc.isOK()) return StatusWith<RecordId>(loc.getStatus()); @@ -366,17 +369,17 @@ StatusWith<RecordId> RecordStoreV1Base::_insertRecord(OperationContext* txn, fassert(17210, r->lengthWithHeaders() >= lenWHdr); // copy the data - r = reinterpret_cast<MmapV1RecordHeader*>(txn->recoveryUnit()->writingPtr(r, lenWHdr)); + r = reinterpret_cast<MmapV1RecordHeader*>(opCtx->recoveryUnit()->writingPtr(r, lenWHdr)); memcpy(r->data(), data, len); - _addRecordToRecListInExtent(txn, r, loc.getValue()); + _addRecordToRecListInExtent(opCtx, r, loc.getValue()); - _details->incrementStats(txn, r->netLength(), 1); + _details->incrementStats(opCtx, r->netLength(), 1); return StatusWith<RecordId>(loc.getValue().toRecordId()); } -Status RecordStoreV1Base::updateRecord(OperationContext* txn, +Status RecordStoreV1Base::updateRecord(OperationContext* opCtx, const RecordId& oldLocation, const char* data, int dataSize, @@ -386,13 +389,13 @@ Status RecordStoreV1Base::updateRecord(OperationContext* txn, if (oldRecord->netLength() >= dataSize) { // Make sure to notify other queries before we do an in-place update. if (notifier) { - Status callbackStatus = notifier->recordStoreGoingToUpdateInPlace(txn, oldLocation); + Status callbackStatus = notifier->recordStoreGoingToUpdateInPlace(opCtx, oldLocation); if (!callbackStatus.isOK()) return callbackStatus; } // we fit - memcpy(txn->recoveryUnit()->writingPtr(oldRecord->data(), dataSize), data, dataSize); + memcpy(opCtx->recoveryUnit()->writingPtr(oldRecord->data(), dataSize), data, dataSize); return Status::OK(); } @@ -407,7 +410,7 @@ bool RecordStoreV1Base::updateWithDamagesSupported() const { } StatusWith<RecordData> RecordStoreV1Base::updateWithDamages( - OperationContext* txn, + OperationContext* opCtx, const RecordId& loc, const RecordData& oldRec, const char* damageSource, @@ -420,14 +423,15 @@ StatusWith<RecordData> RecordStoreV1Base::updateWithDamages( const mutablebson::DamageVector::const_iterator end = damages.end(); for (; where != end; ++where) { const char* sourcePtr = damageSource + where->sourceOffset; - void* targetPtr = txn->recoveryUnit()->writingPtr(root + where->targetOffset, where->size); + void* targetPtr = + opCtx->recoveryUnit()->writingPtr(root + where->targetOffset, where->size); std::memcpy(targetPtr, sourcePtr, where->size); } return rec->toRecordData(); } -void RecordStoreV1Base::deleteRecord(OperationContext* txn, const RecordId& rid) { +void RecordStoreV1Base::deleteRecord(OperationContext* opCtx, const RecordId& rid) { const DiskLoc dl = DiskLoc::fromRecordId(rid); MmapV1RecordHeader* todelete = recordFor(dl); @@ -436,31 +440,31 @@ void RecordStoreV1Base::deleteRecord(OperationContext* txn, const RecordId& rid) /* remove ourself from the record next/prev chain */ { if (todelete->prevOfs() != DiskLoc::NullOfs) { - DiskLoc prev = getPrevRecordInExtent(txn, dl); + DiskLoc prev = getPrevRecordInExtent(opCtx, dl); MmapV1RecordHeader* prevRecord = recordFor(prev); - txn->recoveryUnit()->writingInt(prevRecord->nextOfs()) = todelete->nextOfs(); + opCtx->recoveryUnit()->writingInt(prevRecord->nextOfs()) = todelete->nextOfs(); } if (todelete->nextOfs() != DiskLoc::NullOfs) { - DiskLoc next = getNextRecord(txn, dl); + DiskLoc next = getNextRecord(opCtx, dl); MmapV1RecordHeader* nextRecord = recordFor(next); - txn->recoveryUnit()->writingInt(nextRecord->prevOfs()) = todelete->prevOfs(); + opCtx->recoveryUnit()->writingInt(nextRecord->prevOfs()) = todelete->prevOfs(); } } /* remove ourself from extent pointers */ { DiskLoc extentLoc = todelete->myExtentLoc(dl); - Extent* e = _getExtent(txn, extentLoc); + Extent* e = _getExtent(opCtx, extentLoc); if (e->firstRecord == dl) { - txn->recoveryUnit()->writing(&e->firstRecord); + opCtx->recoveryUnit()->writing(&e->firstRecord); if (todelete->nextOfs() == DiskLoc::NullOfs) e->firstRecord.Null(); else e->firstRecord.set(dl.a(), todelete->nextOfs()); } if (e->lastRecord == dl) { - txn->recoveryUnit()->writing(&e->lastRecord); + opCtx->recoveryUnit()->writing(&e->lastRecord); if (todelete->prevOfs() == DiskLoc::NullOfs) e->lastRecord.Null(); else @@ -470,7 +474,7 @@ void RecordStoreV1Base::deleteRecord(OperationContext* txn, const RecordId& rid) /* add to the free list */ { - _details->incrementStats(txn, -1 * todelete->netLength(), -1); + _details->incrementStats(opCtx, -1 * todelete->netLength(), -1); if (_isSystemIndexes) { /* temp: if in system.indexes, don't reuse, and zero out: we want to be @@ -478,76 +482,76 @@ void RecordStoreV1Base::deleteRecord(OperationContext* txn, const RecordId& rid) to this disk location. so an incorrectly done remove would cause a lot of problems. */ - memset(txn->recoveryUnit()->writingPtr(todelete, todelete->lengthWithHeaders()), + memset(opCtx->recoveryUnit()->writingPtr(todelete, todelete->lengthWithHeaders()), 0, todelete->lengthWithHeaders()); } else { // this is defensive so we can detect if we are still using a location // that was deleted - memset(txn->recoveryUnit()->writingPtr(todelete->data(), 4), 0xee, 4); - addDeletedRec(txn, dl); + memset(opCtx->recoveryUnit()->writingPtr(todelete->data(), 4), 0xee, 4); + addDeletedRec(opCtx, dl); } } } -std::unique_ptr<RecordCursor> RecordStoreV1Base::getCursorForRepair(OperationContext* txn) const { - return stdx::make_unique<RecordStoreV1RepairCursor>(txn, this); +std::unique_ptr<RecordCursor> RecordStoreV1Base::getCursorForRepair(OperationContext* opCtx) const { + return stdx::make_unique<RecordStoreV1RepairCursor>(opCtx, this); } -void RecordStoreV1Base::_addRecordToRecListInExtent(OperationContext* txn, +void RecordStoreV1Base::_addRecordToRecListInExtent(OperationContext* opCtx, MmapV1RecordHeader* r, DiskLoc loc) { dassert(recordFor(loc) == r); - DiskLoc extentLoc = _getExtentLocForRecord(txn, loc); - Extent* e = _getExtent(txn, extentLoc); + DiskLoc extentLoc = _getExtentLocForRecord(opCtx, loc); + Extent* e = _getExtent(opCtx, extentLoc); if (e->lastRecord.isNull()) { - *txn->recoveryUnit()->writing(&e->firstRecord) = loc; - *txn->recoveryUnit()->writing(&e->lastRecord) = loc; + *opCtx->recoveryUnit()->writing(&e->firstRecord) = loc; + *opCtx->recoveryUnit()->writing(&e->lastRecord) = loc; r->prevOfs() = r->nextOfs() = DiskLoc::NullOfs; } else { MmapV1RecordHeader* oldlast = recordFor(e->lastRecord); r->prevOfs() = e->lastRecord.getOfs(); r->nextOfs() = DiskLoc::NullOfs; - txn->recoveryUnit()->writingInt(oldlast->nextOfs()) = loc.getOfs(); - *txn->recoveryUnit()->writing(&e->lastRecord) = loc; + opCtx->recoveryUnit()->writingInt(oldlast->nextOfs()) = loc.getOfs(); + *opCtx->recoveryUnit()->writing(&e->lastRecord) = loc; } } -void RecordStoreV1Base::increaseStorageSize(OperationContext* txn, int size, bool enforceQuota) { - DiskLoc eloc = _extentManager->allocateExtent(txn, isCapped(), size, enforceQuota); +void RecordStoreV1Base::increaseStorageSize(OperationContext* opCtx, int size, bool enforceQuota) { + DiskLoc eloc = _extentManager->allocateExtent(opCtx, isCapped(), size, enforceQuota); Extent* e = _extentManager->getExtent(eloc); invariant(e); - *txn->recoveryUnit()->writing(&e->nsDiagnostic) = _ns; + *opCtx->recoveryUnit()->writing(&e->nsDiagnostic) = _ns; - txn->recoveryUnit()->writing(&e->xnext)->Null(); - txn->recoveryUnit()->writing(&e->xprev)->Null(); - txn->recoveryUnit()->writing(&e->firstRecord)->Null(); - txn->recoveryUnit()->writing(&e->lastRecord)->Null(); + opCtx->recoveryUnit()->writing(&e->xnext)->Null(); + opCtx->recoveryUnit()->writing(&e->xprev)->Null(); + opCtx->recoveryUnit()->writing(&e->firstRecord)->Null(); + opCtx->recoveryUnit()->writing(&e->lastRecord)->Null(); - DiskLoc emptyLoc = _findFirstSpot(txn, eloc, e); + DiskLoc emptyLoc = _findFirstSpot(opCtx, eloc, e); - if (_details->lastExtent(txn).isNull()) { - invariant(_details->firstExtent(txn).isNull()); - _details->setFirstExtent(txn, eloc); - _details->setLastExtent(txn, eloc); - _details->setCapExtent(txn, eloc); + if (_details->lastExtent(opCtx).isNull()) { + invariant(_details->firstExtent(opCtx).isNull()); + _details->setFirstExtent(opCtx, eloc); + _details->setLastExtent(opCtx, eloc); + _details->setCapExtent(opCtx, eloc); invariant(e->xprev.isNull()); invariant(e->xnext.isNull()); } else { - invariant(!_details->firstExtent(txn).isNull()); - *txn->recoveryUnit()->writing(&e->xprev) = _details->lastExtent(txn); - *txn->recoveryUnit()->writing( - &_extentManager->getExtent(_details->lastExtent(txn))->xnext) = eloc; - _details->setLastExtent(txn, eloc); + invariant(!_details->firstExtent(opCtx).isNull()); + *opCtx->recoveryUnit()->writing(&e->xprev) = _details->lastExtent(opCtx); + *opCtx->recoveryUnit()->writing( + &_extentManager->getExtent(_details->lastExtent(opCtx))->xnext) = eloc; + _details->setLastExtent(opCtx, eloc); } - _details->setLastExtentSize(txn, e->length); + _details->setLastExtentSize(opCtx, e->length); - addDeletedRec(txn, emptyLoc); + addDeletedRec(opCtx, emptyLoc); } -Status RecordStoreV1Base::validate(OperationContext* txn, +Status RecordStoreV1Base::validate(OperationContext* opCtx, ValidateCmdLevel level, ValidateAdaptor* adaptor, ValidateResults* results, @@ -568,22 +572,22 @@ Status RecordStoreV1Base::validate(OperationContext* txn, output->appendNumber("datasize", _details->dataSize()); output->appendNumber("nrecords", _details->numRecords()); - output->appendNumber("lastExtentSize", _details->lastExtentSize(txn)); + output->appendNumber("lastExtentSize", _details->lastExtentSize(opCtx)); - if (_details->firstExtent(txn).isNull()) + if (_details->firstExtent(opCtx).isNull()) output->append("firstExtent", "null"); else - output->append( - "firstExtent", - str::stream() << _details->firstExtent(txn).toString() << " ns:" - << _getExtent(txn, _details->firstExtent(txn))->nsDiagnostic.toString()); - if (_details->lastExtent(txn).isNull()) + output->append("firstExtent", + str::stream() << _details->firstExtent(opCtx).toString() << " ns:" + << _getExtent(opCtx, _details->firstExtent(opCtx)) + ->nsDiagnostic.toString()); + if (_details->lastExtent(opCtx).isNull()) output->append("lastExtent", "null"); else - output->append( - "lastExtent", - str::stream() << _details->lastExtent(txn).toString() << " ns:" - << _getExtent(txn, _details->lastExtent(txn))->nsDiagnostic.toString()); + output->append("lastExtent", + str::stream() << _details->lastExtent(opCtx).toString() << " ns:" + << _getExtent(opCtx, _details->lastExtent(opCtx)) + ->nsDiagnostic.toString()); // 22222222222222222222222222 { // validate extent basics @@ -591,14 +595,14 @@ Status RecordStoreV1Base::validate(OperationContext* txn, int extentCount = 0; DiskLoc extentDiskLoc; try { - if (!_details->firstExtent(txn).isNull()) { - _getExtent(txn, _details->firstExtent(txn))->assertOk(); - _getExtent(txn, _details->lastExtent(txn))->assertOk(); + if (!_details->firstExtent(opCtx).isNull()) { + _getExtent(opCtx, _details->firstExtent(opCtx))->assertOk(); + _getExtent(opCtx, _details->lastExtent(opCtx))->assertOk(); } - extentDiskLoc = _details->firstExtent(txn); + extentDiskLoc = _details->firstExtent(opCtx); while (!extentDiskLoc.isNull()) { - Extent* thisExtent = _getExtent(txn, extentDiskLoc); + Extent* thisExtent = _getExtent(opCtx, extentDiskLoc); if (level == kValidateFull) { extentData << thisExtent->dump(); } @@ -608,24 +612,24 @@ Status RecordStoreV1Base::validate(OperationContext* txn, DiskLoc nextDiskLoc = thisExtent->xnext; if (extentCount > 0 && !nextDiskLoc.isNull() && - _getExtent(txn, nextDiskLoc)->xprev != extentDiskLoc) { + _getExtent(opCtx, nextDiskLoc)->xprev != extentDiskLoc) { StringBuilder sb; - sb << "'xprev' pointer " << _getExtent(txn, nextDiskLoc)->xprev.toString() + sb << "'xprev' pointer " << _getExtent(opCtx, nextDiskLoc)->xprev.toString() << " in extent " << nextDiskLoc.toString() << " does not point to extent " << extentDiskLoc.toString(); results->errors.push_back(sb.str()); results->valid = false; } - if (nextDiskLoc.isNull() && extentDiskLoc != _details->lastExtent(txn)) { + if (nextDiskLoc.isNull() && extentDiskLoc != _details->lastExtent(opCtx)) { StringBuilder sb; - sb << "'lastExtent' pointer " << _details->lastExtent(txn).toString() + sb << "'lastExtent' pointer " << _details->lastExtent(opCtx).toString() << " does not point to last extent in list " << extentDiskLoc.toString(); results->errors.push_back(sb.str()); results->valid = false; } extentDiskLoc = nextDiskLoc; extentCount++; - txn->checkForInterrupt(); + opCtx->checkForInterrupt(); } } catch (const DBException& e) { StringBuilder sb; @@ -644,31 +648,31 @@ Status RecordStoreV1Base::validate(OperationContext* txn, // 333333333333333333333333333 bool testingLastExtent = false; try { - DiskLoc firstExtentLoc = _details->firstExtent(txn); + DiskLoc firstExtentLoc = _details->firstExtent(opCtx); if (firstExtentLoc.isNull()) { // this is ok } else { - output->append("firstExtentDetails", _getExtent(txn, firstExtentLoc)->dump()); - if (!_getExtent(txn, firstExtentLoc)->xprev.isNull()) { + output->append("firstExtentDetails", _getExtent(opCtx, firstExtentLoc)->dump()); + if (!_getExtent(opCtx, firstExtentLoc)->xprev.isNull()) { StringBuilder sb; sb << "'xprev' pointer in 'firstExtent' " - << _details->firstExtent(txn).toString() << " is " - << _getExtent(txn, firstExtentLoc)->xprev.toString() << ", should be null"; + << _details->firstExtent(opCtx).toString() << " is " + << _getExtent(opCtx, firstExtentLoc)->xprev.toString() << ", should be null"; results->errors.push_back(sb.str()); results->valid = false; } } testingLastExtent = true; - DiskLoc lastExtentLoc = _details->lastExtent(txn); + DiskLoc lastExtentLoc = _details->lastExtent(opCtx); if (lastExtentLoc.isNull()) { // this is ok } else { if (firstExtentLoc != lastExtentLoc) { - output->append("lastExtentDetails", _getExtent(txn, lastExtentLoc)->dump()); - if (!_getExtent(txn, lastExtentLoc)->xnext.isNull()) { + output->append("lastExtentDetails", _getExtent(opCtx, lastExtentLoc)->dump()); + if (!_getExtent(opCtx, lastExtentLoc)->xnext.isNull()) { StringBuilder sb; sb << "'xnext' pointer in 'lastExtent' " << lastExtentLoc.toString() - << " is " << _getExtent(txn, lastExtentLoc)->xnext.toString() + << " is " << _getExtent(opCtx, lastExtentLoc)->xnext.toString() << ", should be null"; results->errors.push_back(sb.str()); results->valid = false; @@ -696,7 +700,7 @@ Status RecordStoreV1Base::validate(OperationContext* txn, int outOfOrder = 0; DiskLoc dl_last; - auto cursor = getCursor(txn); + auto cursor = getCursor(opCtx); while (auto record = cursor->next()) { const auto dl = DiskLoc::fromRecordId(record->id); n++; @@ -800,7 +804,7 @@ Status RecordStoreV1Base::validate(OperationContext* txn, delSize += d->lengthWithHeaders(); loc = d->nextDeleted(); k++; - txn->checkForInterrupt(); + opCtx->checkForInterrupt(); } delBucketSizes << k; } catch (...) { @@ -829,10 +833,10 @@ Status RecordStoreV1Base::validate(OperationContext* txn, return Status::OK(); } -void RecordStoreV1Base::appendCustomStats(OperationContext* txn, +void RecordStoreV1Base::appendCustomStats(OperationContext* opCtx, BSONObjBuilder* result, double scale) const { - result->append("lastExtentSize", _details->lastExtentSize(txn) / scale); + result->append("lastExtentSize", _details->lastExtentSize(opCtx) / scale); result->append("paddingFactor", 1.0); // hard coded result->append("paddingFactorNote", "paddingFactor is unused and unmaintained in 3.0. It " @@ -841,7 +845,8 @@ void RecordStoreV1Base::appendCustomStats(OperationContext* txn, result->appendBool("capped", isCapped()); if (isCapped()) { result->appendNumber("max", _details->maxCappedDocs()); - result->appendNumber("maxSize", static_cast<long long>(storageSize(txn, NULL, 0) / scale)); + result->appendNumber("maxSize", + static_cast<long long>(storageSize(opCtx, NULL, 0) / scale)); } } @@ -853,13 +858,13 @@ struct touch_location { }; } -Status RecordStoreV1Base::touch(OperationContext* txn, BSONObjBuilder* output) const { +Status RecordStoreV1Base::touch(OperationContext* opCtx, BSONObjBuilder* output) const { Timer t; std::vector<touch_location> ranges; { - DiskLoc nextLoc = _details->firstExtent(txn); - Extent* ext = nextLoc.isNull() ? NULL : _getExtent(txn, nextLoc); + DiskLoc nextLoc = _details->firstExtent(opCtx); + Extent* ext = nextLoc.isNull() ? NULL : _getExtent(opCtx, nextLoc); while (ext) { touch_location tl; tl.root = reinterpret_cast<const char*>(ext); @@ -870,20 +875,20 @@ Status RecordStoreV1Base::touch(OperationContext* txn, BSONObjBuilder* output) c if (nextLoc.isNull()) ext = NULL; else - ext = _getExtent(txn, nextLoc); + ext = _getExtent(opCtx, nextLoc); } } std::string progress_msg = "touch " + ns() + " extents"; - stdx::unique_lock<Client> lk(*txn->getClient()); + stdx::unique_lock<Client> lk(*opCtx->getClient()); ProgressMeterHolder pm( - *txn->setMessage_inlock(progress_msg.c_str(), "Touch Progress", ranges.size())); + *opCtx->setMessage_inlock(progress_msg.c_str(), "Touch Progress", ranges.size())); lk.unlock(); for (std::vector<touch_location>::iterator it = ranges.begin(); it != ranges.end(); ++it) { touch_pages(it->root, it->length); pm.hit(); - txn->checkForInterrupt(); + opCtx->checkForInterrupt(); } pm.finished(); @@ -900,7 +905,7 @@ boost::optional<Record> RecordStoreV1Base::IntraExtentIterator::next() { return {}; auto out = _curr.toRecordId(); advance(); - return {{out, _rs->dataFor(_txn, out)}}; + return {{out, _rs->dataFor(_opCtx, out)}}; } void RecordStoreV1Base::IntraExtentIterator::advance() { @@ -912,13 +917,13 @@ void RecordStoreV1Base::IntraExtentIterator::advance() { _curr = (nextOfs == DiskLoc::NullOfs ? DiskLoc() : DiskLoc(_curr.a(), nextOfs)); } -void RecordStoreV1Base::IntraExtentIterator::invalidate(OperationContext* txn, +void RecordStoreV1Base::IntraExtentIterator::invalidate(OperationContext* opCtx, const RecordId& rid) { if (rid == _curr.toRecordId()) { const DiskLoc origLoc = _curr; // Undo the advance on rollback, as the deletion that forced it "never happened". - txn->recoveryUnit()->onRollback([this, origLoc]() { this->_curr = origLoc; }); + opCtx->recoveryUnit()->onRollback([this, origLoc]() { this->_curr = origLoc; }); advance(); } } |