Skip to content

Commit

Permalink
fix case where its possible to creaet an invalid extent SERVER-1034
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Apr 21, 2010
1 parent 9945f76 commit 1561c0a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/pdfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1561c0a

Please sign in to comment.