summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-04-21 10:09:25 -0400
committerEliot Horowitz <eliot@10gen.com>2010-04-21 11:41:32 -0400
commit1561c0a3e2464320b5d810c8c70fd11db55f7c3b (patch)
tree43038dea4ff10ae9068e0e7357507175609a7dac /db
parent9945f76ea76baa5403785f67995f85208a9a122e (diff)
downloadmongo-1561c0a3e2464320b5d810c8c70fd11db55f7c3b.tar.gz
fix case where its possible to creaet an invalid extent SERVER-1034
Diffstat (limited to 'db')
-rw-r--r--db/pdfile.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index ab7212946f0..38842833a62 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -45,6 +45,8 @@ _ disallow system* manipulations from the database.
namespace mongo {
+ const int MaxExtentSize = 0x7ff00000;
+
map<string, unsigned> BackgroundOperation::dbsInProg;
set<string> BackgroundOperation::nsInProg;
@@ -357,7 +359,7 @@ namespace mongo {
Extent* MongoDataFile::createExtent(const char *ns, int approxSize, bool newCapped, int loops) {
massert( 10357 , "shutdown in progress", !goingAway );
- massert( 10358 , "bad new extent size", approxSize >= 0 && approxSize <= 0x7ff00000 );
+ massert( 10358 , "bad new extent size", approxSize >= 0 && approxSize <= MaxExtentSize );
massert( 10359 , "header==0 on new extent: 32 bit mmap space exceeded?", header ); // null if file open failed
int ExtentSize = approxSize <= header->unusedLength ? approxSize : header->unusedLength;
DiskLoc loc;
@@ -919,9 +921,12 @@ namespace mongo {
}
int followupExtentSize(int len, int lastExtentLen) {
+ assert( len < MaxExtentSize );
int x = initialExtentSize(len);
int y = (int) (lastExtentLen < 4000000 ? lastExtentLen * 4.0 : lastExtentLen * 1.2);
int sz = y > x ? y : x;
+ if ( sz < lastExtentLen || sz > MaxExtentSize )
+ sz = lastExtentLen;
sz = ((int)sz) & 0xffffff00;
assert( sz > len );
return sz;