Skip to content

Commit

Permalink
SERVER-13084: some work on DiskLoc::ext
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Apr 13, 2014
1 parent ef8a276 commit 12a2947
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/mongo/db/catalog/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "mongo/db/ops/delete.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/storage/data_file.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/storage_options.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/db/catalog/collection.h"
Expand Down
1 change: 1 addition & 0 deletions src/mongo/db/commands/parallel_collection_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/util/touch_pages.h"

Expand Down
1 change: 1 addition & 0 deletions src/mongo/db/commands/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/kill_current_op.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/util/timer.h"
#include "mongo/util/touch_pages.h"
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/exec/oplogstart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace mongo {

// Set up our extent hopping state. Get the start of the extent that we were collection
// scanning.
Extent* e = _curloc.rec()->myExtent(_curloc);
Extent* e = _curloc.rec()->myExtent(_curloc).ext();
if (!_nsd->capLooped() || (e->myLoc != _nsd->capExtent())) {
_curloc = e->firstRecord;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace mongo {

// static
DiskLoc OplogStart::prevExtentFirstLoc(const NamespaceDetails* nsd, const DiskLoc& rec ) {
Extent *e = rec.rec()->myExtent( rec );
Extent *e = rec.rec()->myExtent( rec ).ext();
if (nsd->capLooped() ) {
while( true ) {
// Advance e to preceding extent (looping to lastExtent if necessary).
Expand Down
2 changes: 2 additions & 0 deletions src/mongo/db/storage/extent_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ namespace mongo {

/**
* @param loc - has to be for a specific Record (not an Extent)
* TODO(ERH): remove this - only RecordStore can do this
*/
Extent* extentFor( const DiskLoc& loc ) const;

/**
* @param loc - has to be for a specific Record (not an Extent)
* TODO(ERH): remove this - only RecordStore can do this
*/
DiskLoc extentLocFor( const DiskLoc& loc ) const;

Expand Down
5 changes: 2 additions & 3 deletions src/mongo/db/storage/record.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#pragma once

#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/diskloc.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/db/storage/extent.h"

namespace mongo {

Expand Down Expand Up @@ -75,8 +75,7 @@ namespace mongo {
/* use this when a record is deleted. basically a union with next/prev fields */
DeletedRecord& asDeleted() { return *((DeletedRecord*) this); }

// TODO(ERH): remove
Extent* myExtent(const DiskLoc& myLoc) { return DiskLoc(myLoc.a(), extentOfs() ).ext(); }
DiskLoc myExtent(const DiskLoc& myLoc) const { return DiskLoc(myLoc.a(), extentOfs() ); }

struct NP {
int nextOfs;
Expand Down
1 change: 1 addition & 0 deletions src/mongo/db/structure/catalog/namespace_details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "mongo/db/ops/update.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/storage/durable_mapped_file.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/catalog/hashtab.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/startup_test.h"
Expand Down
25 changes: 15 additions & 10 deletions src/mongo/db/structure/record_store_v1_capped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,15 @@ namespace mongo {
memset(t->_reserved, 0, sizeof(t->_reserved));

// Reset all existing extents and recreate the deleted list.
for( DiskLoc ext = t->_firstExtent; !ext.isNull(); ext = ext.ext()->xnext ) {
DiskLoc prev = ext.ext()->xprev;
DiskLoc next = ext.ext()->xnext;
DiskLoc empty = ext.ext()->reuse( _ns, true );
ext.ext()->xprev.writing() = prev;
ext.ext()->xnext.writing() = next;
for( DiskLoc ext = t->_firstExtent;
!ext.isNull();
ext = _extentManager->getExtent(ext)->xnext ) {

DiskLoc prev = _extentManager->getExtent(ext)->xprev;
DiskLoc next = _extentManager->getExtent(ext)->xnext;
DiskLoc empty = _extentManager->getExtent(ext)->reuse( _ns, true );
_extentManager->getExtent(ext)->xprev.writing() = prev;
_extentManager->getExtent(ext)->xnext.writing() = next;
addDeletedRec( empty );
}

Expand Down Expand Up @@ -509,10 +512,12 @@ namespace mongo {
DiskLoc newCapExtent = _details->_capExtent;
do {
// Find the previous extent, looping if necessary.
newCapExtent = ( newCapExtent == _details->_firstExtent ) ? _details->_lastExtent : newCapExtent.ext()->xprev;
newCapExtent.ext()->assertOk();
newCapExtent = ( newCapExtent == _details->_firstExtent ) ?
_details->_lastExtent :
_extentManager->getExtent(newCapExtent)->xprev;
_extentManager->getExtent(newCapExtent)->assertOk();
}
while ( newCapExtent.ext()->firstRecord.isNull() );
while ( _extentManager->getExtent(newCapExtent)->firstRecord.isNull() );
_details->_capExtent.writing() = newCapExtent;

// Place all documents in the new capExtent on the fresh side
Expand All @@ -539,7 +544,7 @@ namespace mongo {
}

Extent* CappedRecordStoreV1::theCapExtent() const {
return _details->_capExtent.ext();
return _extentManager->getExtent(_details->_capExtent);
}

void CappedRecordStoreV1::addDeletedRec( const DiskLoc& dloc ) {
Expand Down
1 change: 1 addition & 0 deletions src/mongo/dbtests/namespacetests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "mongo/db/json.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/queryutil.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/record_store_v1_capped.h"
#include "mongo/db/structure/record_store_v1_simple.h"
#include "mongo/db/structure/catalog/namespace.h"
Expand Down
1 change: 1 addition & 0 deletions src/mongo/dbtests/pdfiletests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "mongo/db/ops/insert.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/storage/data_file.h"
#include "mongo/db/storage/extent.h"
#include "mongo/dbtests/dbtests.h"

namespace PdfileTests {
Expand Down
1 change: 1 addition & 0 deletions src/mongo/dbtests/query_stage_collscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/util/fail_point_service.h"
Expand Down
1 change: 1 addition & 0 deletions src/mongo/tools/dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "mongo/db/db.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/storage/extent.h"
#include "mongo/db/structure/catalog/namespace_details.h"
#include "mongo/tools/mongodump_options.h"
#include "mongo/tools/tool.h"
Expand Down

0 comments on commit 12a2947

Please sign in to comment.