summaryrefslogtreecommitdiff
path: root/src/mongo/db/structure/record_store.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-03-20 17:23:08 -0400
committerEliot Horowitz <eliot@10gen.com>2014-04-03 13:31:49 -0400
commit9ad381f8f93518a6564799aef0cce14c378157f7 (patch)
tree32b33e0b218978eca2da1d219b60eede9ea81f92 /src/mongo/db/structure/record_store.cpp
parent186d1545c6eba44e892d9a319a907de6fdf7cc16 (diff)
downloadmongo-9ad381f8f93518a6564799aef0cce14c378157f7.tar.gz
SERVER-13084: clean up ExtentManager layering
Diffstat (limited to 'src/mongo/db/structure/record_store.cpp')
-rw-r--r--src/mongo/db/structure/record_store.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/mongo/db/structure/record_store.cpp b/src/mongo/db/structure/record_store.cpp
index 482c2da6553..dbd0b285bd1 100644
--- a/src/mongo/db/structure/record_store.cpp
+++ b/src/mongo/db/structure/record_store.cpp
@@ -188,6 +188,38 @@ namespace mongo {
}
}
+ void RecordStoreV1Base::increaseStorageSize( int size, int quotaMax ) {
+ DiskLoc eloc = _extentManager->allocateExtent( _ns,
+ _details->isCapped(),
+ size,
+ quotaMax );
+
+ Extent *e = _extentManager->getExtent( eloc, false );
+
+ invariant( e );
+
+ DiskLoc emptyLoc = getDur().writing(e)->reuse( _ns, _details->isCapped() );
+
+ if ( _details->lastExtent().isNull() ) {
+ verify( _details->firstExtent().isNull() );
+ _details->setFirstExtent( eloc );
+ _details->setLastExtent( eloc );
+ getDur().writingDiskLoc( _details->capExtent() ) = eloc;
+ verify( e->xprev.isNull() );
+ verify( e->xnext.isNull() );
+ }
+ else {
+ verify( !_details->firstExtent().isNull() );
+ getDur().writingDiskLoc(e->xprev) = _details->lastExtent();
+ getDur().writingDiskLoc(_extentManager->getExtent(_details->lastExtent())->xnext) = eloc;
+ _details->setLastExtent( eloc );
+ }
+
+ _details->setLastExtentSize( e->length );
+
+ _details->addDeletedRec(emptyLoc.drec(), emptyLoc);
+ }
+
// -------------------------------
SimpleRecordStoreV1::SimpleRecordStoreV1( const StringData& ns,
@@ -207,10 +239,9 @@ namespace mongo {
LOG(1) << "allocating new extent";
- _extentManager->increaseStorageSize( _ns, _details,
- Extent::followupSize( lengthWithHeaders,
- _details->lastExtentSize()),
- quotaMax );
+ increaseStorageSize( Extent::followupSize( lengthWithHeaders,
+ _details->lastExtentSize()),
+ quotaMax );
loc = _details->alloc( NULL, _ns, lengthWithHeaders );
if ( !loc.isNull() ) {
@@ -225,10 +256,9 @@ namespace mongo {
for ( int z = 0; z < 10 && lengthWithHeaders > _details->lastExtentSize(); z++ ) {
log() << "try #" << z << endl;
- _extentManager->increaseStorageSize( _ns, _details,
- Extent::followupSize( lengthWithHeaders,
- _details->lastExtentSize()),
- quotaMax );
+ increaseStorageSize( Extent::followupSize( lengthWithHeaders,
+ _details->lastExtentSize()),
+ quotaMax );
loc = _details->alloc( NULL, _ns, lengthWithHeaders);
if ( ! loc.isNull() )