DiskLoc MmapV1ExtentManager::_createExtent( OperationContext* txn, int size, bool enforceQuota ) { size = quantizeExtentSize( size ); if ( size > maxSize() ) size = maxSize(); verify( size < DataFile::maxSize() ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = _getOpenFile(i); invariant(f); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, i, f, size, enforceQuota ); } } _checkQuota( enforceQuota, numFiles() ); // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = _addAFile( txn, size, false ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, numFiles() - 1, f, size, enforceQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }
Extent* ExtentManager::createExtent(const char *ns, int size, bool newCapped, bool enforceQuota ) { size = quantizeExtentSize( size ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = getFile( i ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( i, f, ns, size, newCapped, enforceQuota ); } } // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = addAFile( size, false ); if ( f->getHeader()->unusedLength >= size || f->getHeader()->fileLength >= DataFile::maxSize() ) { return _createExtentInFile( numFiles() - 1, f, ns, size, newCapped, enforceQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }
DiskLoc MmapV1ExtentManager::_createExtent( TransactionExperiment* txn, int size, int maxFileNoForQuota ) { size = quantizeExtentSize( size ); if ( size > maxSize() ) size = maxSize(); verify( size < DataFile::maxSize() ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = getFile( txn, i ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, i, f, size, maxFileNoForQuota ); } } if ( maxFileNoForQuota > 0 && static_cast<int>( numFiles() ) >= maxFileNoForQuota && !cc().hasWrittenSinceCheckpoint() ) { _quotaExceeded(); } // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = _addAFile( txn, size, false ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, numFiles() - 1, f, size, maxFileNoForQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }
Extent* ExtentManager::createExtent(const char *ns, int size, bool newCapped, bool enforceQuota ) { size = quantizeExtentSize( size ); if ( size > Extent::maxSize() ) size = Extent::maxSize(); verify( size < DataFile::maxSize() ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = getFile( i ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( i, f, ns, size, newCapped, enforceQuota ); } } if ( enforceQuota && fileIndexExceedsQuota( ns, numFiles() ) && !cc().hasWrittenThisPass() ) { _quotaExceeded(); } // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = addAFile( size, false ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( numFiles() - 1, f, ns, size, newCapped, enforceQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }