0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-615 more precise extent skipping calculation

This commit is contained in:
Aaron 2010-03-22 13:57:59 -07:00
parent 97275707db
commit 4912b40106

View File

@ -1188,11 +1188,10 @@ namespace mongo {
string toNs = string( realDbName ) + "." + to;
NamespaceDetails *nsd = nsdetails( fromNs.c_str() );
massert( 10301 , "source collection " + fromNs + " does not exist", nsd );
long long excessSize = nsd->datasize - size * 2;
long long excessSize = nsd->datasize - size * 2; // datasize and extentSize can't be compared exactly, so add some padding to 'size'
DiskLoc extent = nsd->firstExtent;
for( ; excessSize > 0 && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
for( ; excessSize > extent.ext()->length && extent != nsd->lastExtent; extent = extent.ext()->xnext ) {
excessSize -= extent.ext()->length;
if ( excessSize > 0 )
log( 2 ) << "cloneCollectionAsCapped skipping extent of size " << extent.ext()->length << endl;
log( 6 ) << "excessSize: " << excessSize << endl;
}