summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-08-20 15:41:08 -0400
committerEliot Horowitz <eliot@10gen.com>2009-08-20 15:41:08 -0400
commit20fc44edfbf8816c7d08f6ac3380d42706ca51bc (patch)
tree961413971b1a5aa0202fcb1ca5c59687ef5047cb
parentf0a26f673b19778ace2682ecf04b2d36dd9f8c9e (diff)
parentc0994c6b3a6b9cab0bcda1d09fb55fbfc9f13b4f (diff)
downloadmongo-20fc44edfbf8816c7d08f6ac3380d42706ca51bc.tar.gz
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r--db/db.cpp8
-rw-r--r--db/namespace.cpp27
-rw-r--r--db/namespace.h6
-rw-r--r--util/mmap_win.cpp2
4 files changed, 33 insertions, 10 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 3fdfdbb2625..efad0d2e41b 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -61,6 +61,7 @@ namespace mongo {
extern int opLogging;
extern long long oplogSize;
extern OpLog _oplog;
+ extern int lenForNewNsFiles;
extern int ctr;
extern int callDepth;
@@ -483,6 +484,7 @@ int main(int argc, char* argv[], char *envp[] )
("nohttpinterface", "disable http interface")
("noscripting", "disable scripting engine")
("noprealloc", "disable data file preallocation")
+ ("nssize", po::value<int>()->default_value(16), ".ns file size (in MB) for new databases")
("oplog", po::value<int>(), "0=off 1=W 2=R 3=both 7=W+some reads")
("sysinfo", "print some diagnostic system information")
#if defined(_WIN32)
@@ -693,6 +695,12 @@ int main(int argc, char* argv[], char *envp[] )
if (params.count("autoresync")) {
autoresync = true;
}
+ if( params.count("nssize") ) {
+ int x = params["nssize"].as<int>();
+ uassert("bad --nssize arg", x > 0 && x <= (0x7fffffff/1024/1024));
+ lenForNewNsFiles = x * 1024 * 1024;
+ assert(lenForNewNsFiles > 0);
+ }
if (params.count("oplogSize")) {
long x = params["oplogSize"].as<long>();
uassert("bad --oplogSize arg", x > 0);
diff --git a/db/namespace.cpp b/db/namespace.cpp
index b34e379f7b7..3e5cc497901 100644
--- a/db/namespace.cpp
+++ b/db/namespace.cpp
@@ -42,12 +42,14 @@ namespace mongo {
};
bool NamespaceIndex::exists() const {
- return !boost::filesystem::exists(path());
+ return !boost::filesystem::exists(path());
}
boost::filesystem::path NamespaceIndex::path() const {
return boost::filesystem::path( dir_ ) / ( database_ + ".ns" );
}
+
+ int lenForNewNsFiles = 16 * 1024 * 1024;
void NamespaceIndex::init() {
if ( ht )
@@ -61,14 +63,29 @@ namespace mongo {
i.dbDropped();
}
- long LEN = 16 * 1024 * 1024;
- string pathString = path().string();
- void *p = f.map(pathString.c_str(), LEN);
+ int len = -1;
+ boost::filesystem::path nsPath = path();
+ string pathString = nsPath.string();
+ void *p;
+ if( boost::filesystem::exists(nsPath) ) {
+ p = f.map(pathString.c_str());
+ len = f.length();
+ uassert( "bad .ns file length, cannot open database", len % (1024*1024) == 0 );
+ }
+ else {
+ // use lenForNewNsFiles, we are making a new database
+ massert( "bad lenForNewNsFiles", lenForNewNsFiles >= 1024*1024 );
+ long l = lenForNewNsFiles;
+ p = f.map(pathString.c_str(), l);
+ len = (int) l;
+ assert( len == lenForNewNsFiles );
+ }
+
if ( p == 0 ) {
problem() << "couldn't open file " << pathString << " terminating" << endl;
dbexit( EXIT_FS );
}
- ht = new HashTable<Namespace,NamespaceDetails>(p, LEN, "namespace index");
+ ht = new HashTable<Namespace,NamespaceDetails>(p, len, "namespace index");
}
void NamespaceDetails::addDeletedRec(DeletedRecord *d, DiskLoc dloc) {
diff --git a/db/namespace.h b/db/namespace.h
index 4470aa63f09..2ae5e3f0fc3 100644
--- a/db/namespace.h
+++ b/db/namespace.h
@@ -33,7 +33,7 @@ namespace mongo {
/* in the mongo source code, "client" means "database". */
- const int MaxClientLen = 256; // max str len for the db name
+ const int MaxClientLen = 256; // max str len for the db name, including null char
// "database.a.b.c" -> "database"
inline void nsToClient(const char *ns, char *database) {
@@ -554,10 +554,10 @@ namespace mongo {
}
return false;
}
-
+
bool allocated() const {
return ht != 0;
- }
+ }
private:
boost::filesystem::path path() const;
diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp
index da8a096de5e..7773438dfa0 100644
--- a/util/mmap_win.cpp
+++ b/util/mmap_win.cpp
@@ -77,8 +77,6 @@ namespace mongo {
out() << "CreateFile failed " << filename << endl;
return 0;
}
- if ( mapped > 500000000 )
- out() << "WARNING: too much mem mapped for win32" << endl;
mapped += length;