summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/btree.cpp2
-rw-r--r--db/dur.cpp13
-rw-r--r--db/dur.h5
-rw-r--r--db/dur_journal.cpp2
-rw-r--r--db/mongommf.cpp33
-rw-r--r--db/mongommf.h10
-rw-r--r--db/namespace.cpp7
-rw-r--r--dbtests/mmaptests.cpp4
-rw-r--r--dbtests/perftests.cpp2
-rw-r--r--dbtests/threadedtests.cpp13
-rw-r--r--pch.h9
-rw-r--r--util/mmap.cpp4
-rw-r--r--util/mmap.h6
-rw-r--r--util/version.cpp3
14 files changed, 32 insertions, 81 deletions
diff --git a/db/btree.cpp b/db/btree.cpp
index ceb1d8562cf..784a335ed32 100644
--- a/db/btree.cpp
+++ b/db/btree.cpp
@@ -30,7 +30,7 @@
namespace mongo {
-#define VERIFYTHISLOC dassert( thisLoc.btree() == this || testIntent );
+#define VERIFYTHISLOC dassert( thisLoc.btree() == this );
/**
* give us a writable version of the btree bucket (declares write intent).
diff --git a/db/dur.cpp b/db/dur.cpp
index 2a3b7273579..9fdfda673c5 100644
--- a/db/dur.cpp
+++ b/db/dur.cpp
@@ -198,8 +198,6 @@ namespace mongo {
void* DurableImpl::writingPtr(void *x, unsigned len) {
void *p = x;
- if( testIntent )
- p = MongoMMF::switchToPrivateView(x);
declareWriteIntent(p, len);
return p;
}
@@ -207,20 +205,16 @@ namespace mongo {
/** declare intent to write
@param ofs offset within buf at which we will write
@param len the length at ofs we will write
- @return new buffer pointer. this is modified when testIntent is true.
+ @return new buffer pointer.
*/
void* DurableImpl::writingAtOffset(void *buf, unsigned ofs, unsigned len) {
char *p = (char *) buf;
- if( testIntent )
- p = (char *) MongoMMF::switchToPrivateView(buf);
declareWriteIntent(p+ofs, len);
return p;
}
void* DurableImpl::writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges ) {
char *p = (char *) buf;
- if( testIntent )
- p = (char *) MongoMMF::switchToPrivateView(buf);
for( vector< pair< long long, unsigned > >::const_iterator i = ranges.begin();
i != ranges.end(); ++i ) {
declareWriteIntent( p + i->first, i->second );
@@ -243,9 +237,6 @@ namespace mongo {
*/
#if 0
void DurableImpl::debugCheckLastDeclaredWrite() {
- if( testIntent )
- return;
-
static int n;
++n;
@@ -585,8 +576,6 @@ namespace mongo {
DurableInterface::enableDurability();
- if( testIntent )
- return;
journalMakeDir();
try {
recover();
diff --git a/db/dur.h b/db/dur.h
index b11e358b922..11a1fb0b188 100644
--- a/db/dur.h
+++ b/db/dur.h
@@ -136,11 +136,6 @@ namespace mongo {
*/
virtual void setNoJournal(void *dst, void *src, unsigned len) = 0;
- /* assert that we have not (at least so far) declared write intent for p */
- inline void assertReading(void *p) {
- dassert( !testIntent || MongoMMF::switchToPrivateView(p) != p );
- }
-
static DurableInterface& getDur() { return *_impl; }
private:
diff --git a/db/dur_journal.cpp b/db/dur_journal.cpp
index 9db06b40f4e..7ab767dbc18 100644
--- a/db/dur_journal.cpp
+++ b/db/dur_journal.cpp
@@ -165,8 +165,6 @@ namespace mongo {
/** at clean shutdown */
bool okToCleanUp = false; // failed recovery would set this to false
void journalCleanupAtShutdown() {
- if( testIntent )
- return;
if( !okToCleanUp )
return;
diff --git a/db/mongommf.cpp b/db/mongommf.cpp
index 17ea895ad43..f4c95f6ae83 100644
--- a/db/mongommf.cpp
+++ b/db/mongommf.cpp
@@ -32,15 +32,13 @@ using namespace mongoutils;
namespace mongo {
void MongoMMF::remapThePrivateView() {
- assert( cmdLine.dur && !testIntent );
+ assert( cmdLine.dur );
privateViews.remove(_view_private);
_view_private = remapPrivateView(_view_private);
privateViews.add(_view_private, this);
}
void* MongoMMF::getView() {
- if( testIntent )
- return _view_readonly;
return _view_private;
}
@@ -106,9 +104,8 @@ namespace mongo {
}
PointerToMMF privateViews;
- static PointerToMMF ourReadViews; /// _TESTINTENT (testIntent) build use only (other than existance)
- /*static*/ void* MongoMMF::switchToPrivateView(void *readonly_ptr) {
+ /* void* MongoMMF::switchToPrivateView(void *readonly_ptr) {
assert( cmdLine.dur );
assert( testIntent );
@@ -135,19 +132,19 @@ namespace mongo {
// did you call writing() with a pointer that isn't into a datafile?
log() << "dur error switchToPrivateView " << p << endl;
return p;
- }
+ }*/
/* switch to _view_write. normally, this is a bad idea since your changes will not
show up in _view_private if there have been changes there; thus the leading underscore
as a tad of a "warning". but useful when done with some care, such as during
initialization.
*/
- /*static*/ void* MongoMMF::_switchToWritableView(void *p) {
+ /* void* MongoMMF::_switchToWritableView(void *p) {
RARELY log() << "todo dur not done switchtowritable" << endl;
if( debug )
return switchToPrivateView(p);
return p;
- }
+ }*/
extern string dbpath;
@@ -175,7 +172,7 @@ namespace mongo {
setPath(fname);
bool preExisting = MemoryMappedFile::exists(fname.c_str());
_view_write = map(fname.c_str(), len, sequentialHint ? SEQUENTIAL : 0);
- if( cmdLine.dur && !testIntent && _view_write && !preExisting ) {
+ if( cmdLine.dur && _view_write && !preExisting ) {
getDur().createdFile(fname, len);
}
return finishOpening();
@@ -184,14 +181,7 @@ namespace mongo {
bool MongoMMF::finishOpening() {
if( _view_write ) {
if( cmdLine.dur ) {
- if( testIntent ) {
- _view_private = _view_write;
- _view_readonly = MemoryMappedFile::createReadOnlyMap();
- ourReadViews.add(_view_readonly, this);
- }
- else {
- _view_private = createPrivateMap();
- }
+ _view_private = createPrivateMap();
privateViews.add(_view_private, this); // note that testIntent builds use this, even though it points to view_write then...
}
else {
@@ -203,7 +193,7 @@ namespace mongo {
}
MongoMMF::MongoMMF() : _willNeedRemap(false) {
- _view_write = _view_private = _view_readonly = 0;
+ _view_write = _view_private = 0;
}
MongoMMF::~MongoMMF() {
@@ -216,17 +206,14 @@ namespace mongo {
/*virtual*/ void MongoMMF::close() {
{
- if( !testIntent && cmdLine.dur && _view_write/*actually was opened*/ ) {
+ if( cmdLine.dur && _view_write/*actually was opened*/ ) {
if( debug )
log() << "closingFileNotication:" << filename() << endl;
dur::closingFileNotification();
}
privateViews.remove(_view_private);
- if( debug ) {
- ourReadViews.remove(_view_readonly);
- }
}
- _view_write = _view_private = _view_readonly = 0;
+ _view_write = _view_private = 0;
MemoryMappedFile::close();
}
diff --git a/db/mongommf.h b/db/mongommf.h
index ec38ce015a2..05f5404cbbd 100644
--- a/db/mongommf.h
+++ b/db/mongommf.h
@@ -50,7 +50,6 @@ namespace mongo {
/* Get the "standard" view (which is the private one).
@return the private view.
- on _TESTINTENT, returns the readonly view
*/
void* getView();
@@ -59,13 +58,7 @@ namespace mongo {
as a tad of a "warning". but useful when done with some care, such as during
initialization.
*/
- static void* _switchToWritableView(void *private_ptr);
-
- /** for _TESTINTENT build.
- translates the read view pointer into a pointer to the corresponding
- place in the private view.
- */
- static void* switchToPrivateView(void *debug_readonly_ptr);
+ //static void* _switchToWritableView(void *private_ptr);
/** for a filename a/b/c.3
filePath() is "a/b/c"
@@ -93,7 +86,6 @@ namespace mongo {
void *_view_write;
void *_view_private;
- void *_view_readonly; // for _DEBUG build
bool _willNeedRemap;
RelativePath _p; // e.g. "somepath/dbname"
int _fileSuffixNo; // e.g. 3. -1="ns"
diff --git a/db/namespace.cpp b/db/namespace.cpp
index 20678770d89..a191c077c8c 100644
--- a/db/namespace.cpp
+++ b/db/namespace.cpp
@@ -133,12 +133,12 @@ namespace mongo {
if( backgroundIndexBuildInProgress || capped2.cc2_ptr ) {
assertInWriteLock();
- NamespaceDetails *d = (NamespaceDetails *) MongoMMF::_switchToWritableView(this);
if( backgroundIndexBuildInProgress ) {
log() << "backgroundIndexBuildInProgress was " << backgroundIndexBuildInProgress << " for " << k << ", indicating an abnormal db shutdown" << endl;
- d->backgroundIndexBuildInProgress = 0;
+ getDur().writingInt( backgroundIndexBuildInProgress ) = 0;
}
- d->capped2.cc2_ptr = 0;
+ if( capped2.cc2_ptr )
+ *getDur().writing(&capped2.cc2_ptr) = 0;
}
}
@@ -214,7 +214,6 @@ namespace mongo {
}
void NamespaceDetails::addDeletedRec(DeletedRecord *d, DiskLoc dloc) {
- getDur().assertReading(this);
BOOST_STATIC_ASSERT( sizeof(NamespaceDetails::Extra) <= sizeof(NamespaceDetails) );
{
diff --git a/dbtests/mmaptests.cpp b/dbtests/mmaptests.cpp
index 2773987d276..e8c25ec91e2 100644
--- a/dbtests/mmaptests.cpp
+++ b/dbtests/mmaptests.cpp
@@ -44,7 +44,7 @@ namespace MMapTests {
MongoMMF f;
unsigned long long len = 256 * 1024 * 1024;
assert( f.create(fn, len, /*sequential*/false) );
- if( !testIntent ) {
+ {
char *p = (char *) f.getView();
assert(p);
// write something to the private view as a test
@@ -74,7 +74,7 @@ namespace MMapTests {
for( int i = 0; i < N; i++ ) {
MongoMMF f;
assert( f.open(fn, i%4==1) );
- if( !testIntent ) {
+ {
char *p = (char *) f.getView();
assert(p);
strcpy(p, "zzz");
diff --git a/dbtests/perftests.cpp b/dbtests/perftests.cpp
index 337e6f2ab9d..182595c3055 100644
--- a/dbtests/perftests.cpp
+++ b/dbtests/perftests.cpp
@@ -293,7 +293,7 @@ namespace PerfTests {
MongoMMF f;
unsigned long long len = 1 * 1024 * 1024;
assert( f.create(fn, len, /*sequential*/rand()%2==0) );
- if( !testIntent ) {
+ {
char *p = (char *) f.getView();
assert(p);
// write something to the private view as a test
diff --git a/dbtests/threadedtests.cpp b/dbtests/threadedtests.cpp
index 72642c4619b..6015d8e3544 100644
--- a/dbtests/threadedtests.cpp
+++ b/dbtests/threadedtests.cpp
@@ -21,6 +21,7 @@
#include "../bson/util/atomic_int.h"
#include "../util/concurrency/mvar.h"
#include "../util/concurrency/thread_pool.h"
+#include "../util/timer.h"
#include <boost/thread.hpp>
#include <boost/bind.hpp>
@@ -58,8 +59,20 @@ namespace ThreadedTests {
};
class MongoMutexTest : public ThreadedTest<135> {
+#if defined(_DEBUG)
+ enum { N = 10000 };
+#else
enum { N = 80000 };
+#endif
MongoMutex *mm;
+ public:
+ void run() {
+ Timer t;
+ cout << "MongoMutexTest" << endl;
+ ThreadedTest<135>::run();
+ cout << "MongoMutexTest " << t.millis() << "ms" << endl;
+ }
+ private:
virtual void setup() {
mm = new MongoMutex("MongoMutexTest");
}
diff --git a/pch.h b/pch.h
index be48761500d..51bc2203049 100644
--- a/pch.h
+++ b/pch.h
@@ -95,15 +95,6 @@
namespace mongo {
-# if defined(_TESTINTENT)
- /** Use _TESTINTENT to test write intent declarations by using a read only view for non-declared operations.
- We don't do journalling when _TESTINTENT is enabled.
- */
- const bool testIntent = true;
-# else
- const bool testIntent = false;
-# endif
-
using namespace std;
using boost::shared_ptr;
diff --git a/util/mmap.cpp b/util/mmap.cpp
index 7b69e33cd58..ae840e8310d 100644
--- a/util/mmap.cpp
+++ b/util/mmap.cpp
@@ -178,8 +178,6 @@ namespace mongo {
ptf = this;
}
-#if defined(_DEBUG) && !defined(_TESTINTENT)
-
void MongoFile::markAllWritable() {
rwlock lk( mmmutex , false );
for ( set<MongoFile*>::iterator i = mmfiles.begin(); i != mmfiles.end(); i++ ) {
@@ -195,6 +193,4 @@ namespace mongo {
if (mmf) mmf->_unlock();
}
}
-#endif
-
} // namespace mongo
diff --git a/util/mmap.h b/util/mmap.h
index 32e86f3a218..c33fb35c393 100644
--- a/util/mmap.h
+++ b/util/mmap.h
@@ -93,12 +93,6 @@ namespace mongo {
static RWLock mmmutex;
};
-#if !defined(_DEBUG) || defined(_TESTINTENT)
- // no-ops in production
- inline void MongoFile::markAllWritable() {}
- inline void MongoFile::unmarkAllWritable() {}
-#endif
-
/** look up a MMF by filename. scoped mutex locking convention.
example:
MMFFinderByName finder;
diff --git a/util/version.cpp b/util/version.cpp
index 11ddc2823bb..f39e281bb21 100644
--- a/util/version.cpp
+++ b/util/version.cpp
@@ -61,9 +61,6 @@ namespace mongo {
void printSysInfo() {
log() << "sys info: " << sysInfo() << endl;
-#if defined(_TESTINTENT)
- log() << "_TESTINTENT defined - this mode is for qa purposes" << endl;
-#endif
}
//